~vkolesnikov/pbxt/pbxt-15-operator-new

« back to all changes in this revision

Viewing changes to src/index_xt.cc

  • Committer: Paul McCullagh
  • Date: 2010-01-22 14:28:24 UTC
  • mfrom: (824.1.3 1.1-trunk)
  • Revision ID: paul.mccullagh@primebase.org-20100122142824-op8l5myhwttjdv54
Merged 1.1 trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
3669
3669
        return FALSE;
3670
3670
}
3671
3671
 
3672
 
static void idx_set_index_selectivity(XTThreadPtr self, XTOpenTablePtr ot, XTIndexPtr ind)
 
3672
static void idx_set_index_selectivity(XTOpenTablePtr ot, XTIndexPtr ind, XTThreadPtr thread)
3673
3673
{
3674
3674
        static const xtRecordID MAX_RECORDS = 100;
3675
3675
 
3720
3720
                                last_rec = ot->ot_curr_rec_id;
3721
3721
 
3722
3722
                                key_len = ot->ot_ind_state.i_item_size - XT_RECORD_REF_SIZE;
3723
 
                                xt_ind_unlock_handle(ot->ot_ind_rhandle);
 
3723
                                xt_ind_lock_handle(ot->ot_ind_rhandle);
3724
3724
                                memcpy(key_buf, ot->ot_ind_rhandle->ih_branch->tb_data + ot->ot_ind_state.i_item_offset, key_len);
3725
3725
                                xt_ind_unlock_handle(ot->ot_ind_rhandle);
3726
3726
                        }
3762
3762
                last_iter_rec = last_rec;
3763
3763
 
3764
3764
                if (ot->ot_ind_rhandle) {
3765
 
                        xt_ind_release_handle(ot->ot_ind_rhandle, FALSE, self);
 
3765
                        xt_ind_release_handle(ot->ot_ind_rhandle, FALSE, thread);
3766
3766
                        ot->ot_ind_rhandle = NULL;
3767
3767
                }
3768
3768
        }
3783
3783
        return;
3784
3784
 
3785
3785
        failed_1:
3786
 
        xt_ind_release_handle(ot->ot_ind_rhandle, FALSE, self);
3787
 
        ot->ot_ind_rhandle = NULL;
 
3786
        if (ot->ot_ind_rhandle) {
 
3787
                xt_ind_release_handle(ot->ot_ind_rhandle, FALSE, thread);
 
3788
                ot->ot_ind_rhandle = NULL;
 
3789
        }
3788
3790
 
3789
3791
        failed:
3790
3792
        xt_tab_disable_index(ot->ot_table, XT_INDEX_CORRUPTED);
3792
3794
        return;
3793
3795
}
3794
3796
 
3795
 
xtPublic void xt_ind_set_index_selectivity(XTThreadPtr self, XTOpenTablePtr ot)
 
3797
xtPublic void xt_ind_set_index_selectivity(XTOpenTablePtr ot, XTThreadPtr thread)
3796
3798
{
3797
3799
        XTTableHPtr             tab = ot->ot_table;
3798
3800
        XTIndexPtr              *ind;
3799
3801
        u_int                   i;
 
3802
        time_t                  now;
3800
3803
 
3801
 
        if (!tab->tab_dic.dic_disable_index) {
3802
 
                for (i=0, ind=tab->tab_dic.dic_keys; i<tab->tab_dic.dic_key_count; i++, ind++)
3803
 
                        idx_set_index_selectivity(self, ot, *ind);
 
3804
        now = time(NULL);
 
3805
        xt_lock_mutex_ns(&tab->tab_ind_stat_lock);
 
3806
        if (tab->tab_ind_stat_calc_time < now) {
 
3807
                if (!tab->tab_dic.dic_disable_index) {
 
3808
                        for (i=0, ind=tab->tab_dic.dic_keys; i<tab->tab_dic.dic_key_count; i++, ind++)
 
3809
                                idx_set_index_selectivity(ot, *ind, thread);
 
3810
                }
 
3811
                tab->tab_ind_stat_calc_time = time(NULL);
3804
3812
        }
 
3813
        xt_unlock_mutex_ns(&tab->tab_ind_stat_lock);
3805
3814
}
3806
3815
 
3807
3816
/*