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
=== 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 @@
26592659
2660static void idx_set_index_selectivity(XTThreadPtr self __attribute__((unused)), XTOpenTablePtr ot, XTIndexPtr ind)2660static void idx_set_index_selectivity(XTThreadPtr self __attribute__((unused)), XTOpenTablePtr ot, XTIndexPtr ind)
2661{2661{
2662 static const int NAX_RECORDS = 7;
2663
2662 XTIdxSearchKeyRec search_key;2664 XTIdxSearchKeyRec search_key;
2663 XTIndexSegPtr key_seg;2665 XTIndexSegPtr key_seg;
2664 u_int select_count[2] = {0, 0};2666 u_int select_count[2] = {0, 0};
@@ -2669,6 +2671,9 @@
2669 u_int curr_len;2671 u_int curr_len;
2670 u_int diff;2672 u_int diff;
2671 u_int j, i;2673 u_int j, i;
2674 /* these 2 vars are used to check the overlapping if we have < 200 records */
2675 int last_rec = 0; /* last record accounted in this iteration */
2676 int last_iter_rec = 0; /* last record accounted in the previous iteration */
26722677
2673 xtBool (* xt_idx_iterator[2])(2678 xtBool (* xt_idx_iterator[2])(
2674 register struct XTOpenTable *ot, register struct XTIndex *ind, register XTIdxSearchKeyPtr search_key) = {2679 register struct XTOpenTable *ot, register struct XTIndex *ind, register XTIdxSearchKeyPtr search_key) = {
@@ -2697,9 +2702,10 @@
2697 goto failed;2702 goto failed;
26982703
2699 /* Initialize the buffer with the first index valid index entry: */2704 /* Initialize the buffer with the first index valid index entry: */
2700 while (!select_count && ot->ot_curr_rec_id) {2705 while (!select_count[j] && ot->ot_curr_rec_id != last_iter_rec) {
2701 if (ot->ot_curr_row_id) {2706 if (ot->ot_curr_row_id) {
2702 select_count[j]++;2707 select_count[j]++;
2708 last_rec = ot->ot_curr_rec_id;
27032709
2704 key_len = ot->ot_ind_state.i_item_size - XT_RECORD_REF_SIZE;2710 key_len = ot->ot_ind_state.i_item_size - XT_RECORD_REF_SIZE;
2705 xt_ind_unlock_handle(ot->ot_ind_rhandle);2711 xt_ind_unlock_handle(ot->ot_ind_rhandle);
@@ -2710,11 +2716,12 @@
2710 goto failed_1;2716 goto failed_1;
2711 }2717 }
27122718
2713 while (select_count[j] < 100 && ot->ot_curr_rec_id) {2719 while (select_count[j] < NAX_RECORDS && ot->ot_curr_rec_id != last_iter_rec) {
2714 /* Check if the index entry is committed: */2720 /* Check if the index entry is committed: */
2715 if (ot->ot_curr_row_id) {2721 if (ot->ot_curr_row_id) {
2716 xt_ind_lock_handle(ot->ot_ind_rhandle);2722 xt_ind_lock_handle(ot->ot_ind_rhandle);
2717 select_count[j]++;2723 select_count[j]++;
2724 last_rec = ot->ot_curr_rec_id;
27182725
2719 next_key_len = ot->ot_ind_state.i_item_size - XT_RECORD_REF_SIZE;2726 next_key_len = ot->ot_ind_state.i_item_size - XT_RECORD_REF_SIZE;
2720 next_key_buf = ot->ot_ind_rhandle->ih_branch->tb_data + ot->ot_ind_state.i_item_offset;2727 next_key_buf = ot->ot_ind_rhandle->ih_branch->tb_data + ot->ot_ind_state.i_item_offset;
@@ -2740,6 +2747,8 @@
2740 goto failed_1;2747 goto failed_1;
2741 }2748 }
27422749
2750 last_iter_rec = last_rec;
2751
2743 if (ot->ot_ind_rhandle) {2752 if (ot->ot_ind_rhandle) {
2744 xt_ind_release_handle(ot->ot_ind_rhandle, FALSE, self);2753 xt_ind_release_handle(ot->ot_ind_rhandle, FALSE, self);
2745 ot->ot_ind_rhandle = NULL;2754 ot->ot_ind_rhandle = NULL;

Subscribers

People subscribed via source and target branches