Merge lp:~vkolesnikov/pbxt/pbxt-index-selectivity-backscan into lp:pbxt

Proposed by Vladimir Kolesnikov
Status: Merged
Merged at revision: not available
Proposed branch: lp:~vkolesnikov/pbxt/pbxt-index-selectivity-backscan
Merge into: lp:pbxt
Diff against target: None lines
To merge this branch: bzr merge lp:~vkolesnikov/pbxt/pbxt-index-selectivity-backscan
Reviewer Review Type Date Requested Status
PBXT Core Pending
Review via email: mp+4234@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Vladimir Kolesnikov (vkolesnikov) wrote :

Added backscan overlapping check, fixed a small bug

Revision history for this message
Paul McCullagh (paul-mccullagh) wrote :

I think you set NAX_RECORDS = 7 for testing purposes.

On Mar 6, 2009, at 2:25 PM, Vladimir Kolesnikov wrote:

> Vladimir Kolesnikov has proposed merging lp:~vkolesnikov/pbxt/pbxt-
> index-selectivity-backscan into lp:pbxt.
>
> Requested reviews:
> PBXT Core (pbxt-core)
>
> Added backscan overlapping check, fixed a small bug
> --
> https://code.launchpad.net/~vkolesnikov/pbxt/pbxt-index-selectivity-
> backscan/+merge/4234
> Your team PBXT Core is subscribed to branch lp:pbxt.
> === modified file 'src/index_xt.cc'
> --- src/index_xt.cc 2009-02-27 10:44:53 +0000
> +++ src/index_xt.cc 2009-03-06 13:22:25 +0000
> @@ -2659,6 +2659,8 @@
>
> static void idx_set_index_selectivity(XTThreadPtr self
> __attribute__((unused)), XTOpenTablePtr ot, XTIndexPtr ind)
> {
> + static const int NAX_RECORDS = 7;
> +
> XTIdxSearchKeyRec search_key;
> XTIndexSegPtr key_seg;
> u_int select_count[2] = {0, 0};
> @@ -2669,6 +2671,9 @@
> u_int curr_len;
> u_int diff;
> u_int j, i;
> + /* these 2 vars are used to check the overlapping if we have < 200
> records */
> + int last_rec = 0; /* last record accounted in this iteration */
> + int last_iter_rec = 0; /* last record accounted in the
> previous iteration */
>
> xtBool (* xt_idx_iterator[2])(
> register struct XTOpenTable *ot, register struct XTIndex *ind,
> register XTIdxSearchKeyPtr search_key) = {
> @@ -2697,9 +2702,10 @@
> goto failed;
>
> /* Initialize the buffer with the first index valid index entry: */
> - while (!select_count && ot->ot_curr_rec_id) {
> + while (!select_count[j] && ot->ot_curr_rec_id != last_iter_rec) {
> if (ot->ot_curr_row_id) {
> select_count[j]++;
> + last_rec = ot->ot_curr_rec_id;
>
> key_len = ot->ot_ind_state.i_item_size - XT_RECORD_REF_SIZE;
> xt_ind_unlock_handle(ot->ot_ind_rhandle);
> @@ -2710,11 +2716,12 @@
> goto failed_1;
> }
>
> - while (select_count[j] < 100 && ot->ot_curr_rec_id) {
> + while (select_count[j] < NAX_RECORDS && ot->ot_curr_rec_id !=
> last_iter_rec) {
> /* Check if the index entry is committed: */
> if (ot->ot_curr_row_id) {
> xt_ind_lock_handle(ot->ot_ind_rhandle);
> select_count[j]++;
> + last_rec = ot->ot_curr_rec_id;
>
> next_key_len = ot->ot_ind_state.i_item_size - XT_RECORD_REF_SIZE;
> next_key_buf = ot->ot_ind_rhandle->ih_branch->tb_data + ot-
> >ot_ind_state.i_item_offset;
> @@ -2740,6 +2747,8 @@
> goto failed_1;
> }
>
> + last_iter_rec = last_rec;
> +
> if (ot->ot_ind_rhandle) {
> xt_ind_release_handle(ot->ot_ind_rhandle, FALSE, self);
> ot->ot_ind_rhandle = NULL;
>

--
Paul McCullagh
PrimeBase Technologies
www.primebase.org
www.blobstreaming.org
pbxt.blogspot.com

577. By Vladimir Kolesnikov

fixed a typo

Revision history for this message
Vladimir Kolesnikov (vkolesnikov) wrote :

sorry, pushed fix

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/index_xt.cc'
2--- src/index_xt.cc 2009-02-27 10:44:53 +0000
3+++ src/index_xt.cc 2009-03-06 13:22:25 +0000
4@@ -2659,6 +2659,8 @@
5
6 static void idx_set_index_selectivity(XTThreadPtr self __attribute__((unused)), XTOpenTablePtr ot, XTIndexPtr ind)
7 {
8+ static const int NAX_RECORDS = 7;
9+
10 XTIdxSearchKeyRec search_key;
11 XTIndexSegPtr key_seg;
12 u_int select_count[2] = {0, 0};
13@@ -2669,6 +2671,9 @@
14 u_int curr_len;
15 u_int diff;
16 u_int j, i;
17+ /* these 2 vars are used to check the overlapping if we have < 200 records */
18+ int last_rec = 0; /* last record accounted in this iteration */
19+ int last_iter_rec = 0; /* last record accounted in the previous iteration */
20
21 xtBool (* xt_idx_iterator[2])(
22 register struct XTOpenTable *ot, register struct XTIndex *ind, register XTIdxSearchKeyPtr search_key) = {
23@@ -2697,9 +2702,10 @@
24 goto failed;
25
26 /* Initialize the buffer with the first index valid index entry: */
27- while (!select_count && ot->ot_curr_rec_id) {
28+ while (!select_count[j] && ot->ot_curr_rec_id != last_iter_rec) {
29 if (ot->ot_curr_row_id) {
30 select_count[j]++;
31+ last_rec = ot->ot_curr_rec_id;
32
33 key_len = ot->ot_ind_state.i_item_size - XT_RECORD_REF_SIZE;
34 xt_ind_unlock_handle(ot->ot_ind_rhandle);
35@@ -2710,11 +2716,12 @@
36 goto failed_1;
37 }
38
39- while (select_count[j] < 100 && ot->ot_curr_rec_id) {
40+ while (select_count[j] < NAX_RECORDS && ot->ot_curr_rec_id != last_iter_rec) {
41 /* Check if the index entry is committed: */
42 if (ot->ot_curr_row_id) {
43 xt_ind_lock_handle(ot->ot_ind_rhandle);
44 select_count[j]++;
45+ last_rec = ot->ot_curr_rec_id;
46
47 next_key_len = ot->ot_ind_state.i_item_size - XT_RECORD_REF_SIZE;
48 next_key_buf = ot->ot_ind_rhandle->ih_branch->tb_data + ot->ot_ind_state.i_item_offset;
49@@ -2740,6 +2747,8 @@
50 goto failed_1;
51 }
52
53+ last_iter_rec = last_rec;
54+
55 if (ot->ot_ind_rhandle) {
56 xt_ind_release_handle(ot->ot_ind_rhandle, FALSE, self);
57 ot->ot_ind_rhandle = NULL;

Subscribers

People subscribed via source and target branches