You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by ht...@apache.org on 2026/07/23 06:23:27 UTC
(asterixdb) branch master updated: [ASTERIXDB-3702][STO] Drop redundant leaf-page-id array in sample cursors
This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git
The following commit(s) were added to refs/heads/master by this push:
new b1b18faf07 [ASTERIXDB-3702][STO] Drop redundant leaf-page-id array in sample cursors
b1b18faf07 is described below
commit b1b18faf07bae918231dbbbd560d73391021f14d
Author: Ritik Raj <ra...@gmail.com>
AuthorDate: Wed Jul 15 14:29:00 2026 +0530
[ASTERIXDB-3702][STO] Drop redundant leaf-page-id array in sample cursors
The batched random draws already pack (pageId << 32 | drawIndex)
into the sorted long[] key, so the parallel drawPageIds[] int array
was redundant: the page id is just the high 32 bits of the sort
key. Derive it there and remove the array from both the row and
column sample cursors, saving a leafDrawBatchSize-int allocation
and one scattered gather per draw.
Behavior is unchanged - the resolved (pageId, drawIndex) is
identical.
Co-Authored-By: Claude Opus 4.8 (1M context) <no...@anthropic.com>
Change-Id: Id676af0729fe5f61d69a935ff46d0323f635dff9
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21432
Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Ian Maxon <im...@apache.org>
Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
Reviewed-by: Ritik Raj <ri...@couchbase.com>
---
.../storage/am/btree/impls/DiskBTreeSampleCursor.java | 13 ++++++-------
.../btree/column/impls/btree/ColumnBtreeSampleCursor.java | 10 +++++-----
2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/DiskBTreeSampleCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/DiskBTreeSampleCursor.java
index ad964e4572..ab7c34478d 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/DiskBTreeSampleCursor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/impls/DiskBTreeSampleCursor.java
@@ -99,7 +99,6 @@ public final class DiskBTreeSampleCursor extends EnforcedIndexCursor implements
// object comparator dispatch of the previous List<LeafDraw> approach while
// still grouping draws by pageId for pin reuse. A single reusable LeafDraw
// view is repointed per draw to preserve the existing call shape.
- private final int[] drawPageIds;
private final double[] drawAcceptanceSamples;
private final int[] drawTupleStartSeeds;
// Packed sort key: (pageId << 32) | originalDrawIndex. Sorting by the full
@@ -165,7 +164,6 @@ public final class DiskBTreeSampleCursor extends EnforcedIndexCursor implements
this.leafDrawBatchSize = (int) Math.max(leafDrawBatchSize, componentSampleCardinality);
// Pre-allocate flat SoA draw buffers once to avoid churn during refills.
- this.drawPageIds = new int[this.leafDrawBatchSize];
this.drawAcceptanceSamples = new double[this.leafDrawBatchSize];
this.drawTupleStartSeeds = new int[this.leafDrawBatchSize];
this.drawSortKeys = new long[this.leafDrawBatchSize];
@@ -258,10 +256,12 @@ public final class DiskBTreeSampleCursor extends EnforcedIndexCursor implements
return null;
}
}
- // Resolve the next draw in sorted (pageId-ascending) order. The low 32
- // bits of the sort key index back into the unsorted SoA side arrays.
- int drawIndex = (int) drawSortKeys[pendingLeafDrawIndex++];
- leafDrawView.pageId = drawPageIds[drawIndex];
+ // Resolve the next draw in sorted (pageId-ascending) order. The sort key packs
+ // (pageId << 32 | drawIndex): the high 32 bits ARE the pageId (no separate array), the low 32
+ // bits index back into the unsorted SoA side arrays.
+ long sortKey = drawSortKeys[pendingLeafDrawIndex++];
+ int drawIndex = (int) sortKey;
+ leafDrawView.pageId = (int) (sortKey >>> 32);
leafDrawView.acceptanceSample = drawAcceptanceSamples[drawIndex];
leafDrawView.tupleStartSeed = drawTupleStartSeeds[drawIndex];
return leafDrawView;
@@ -275,7 +275,6 @@ public final class DiskBTreeSampleCursor extends EnforcedIndexCursor implements
for (int i = 0; i < leafDrawBatchSize; i++) {
int randomLeafIndex = randomNumGen.nextInt(leafPageIds.size());
int targetPageId = leafPageIds.get(randomLeafIndex);
- drawPageIds[i] = targetPageId;
drawAcceptanceSamples[i] = randomNumGen.nextDouble();
drawTupleStartSeeds[i] = randomNumGen.nextInt();
// Pack (pageId, drawIndex): pageIds are non-negative leaf page IDs,
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree-column/src/main/java/org/apache/hyracks/storage/am/lsm/btree/column/impls/btree/ColumnBtreeSampleCursor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree-column/src/main/java/org/apache/hyracks/storage/am/lsm/btree/column/impls/btree/ColumnBtreeSampleCursor.java
index e7e6368061..a12388209c 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree-column/src/main/java/org/apache/hyracks/storage/am/lsm/btree/column/impls/btree/ColumnBtreeSampleCursor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-btree-column/src/main/java/org/apache/hyracks/storage/am/lsm/btree/column/impls/btree/ColumnBtreeSampleCursor.java
@@ -108,7 +108,6 @@ public class ColumnBtreeSampleCursor extends EnforcedIndexCursor implements ITre
// Phase 1 batched I/O draws stored as flat parallel primitive arrays (SoA).
// Sorted via a packed long[] key ((pageId << 32) | drawIndex) so page0 pins
// proceed in ascending pageId order without boxed-object comparator overhead.
- private final int[] drawPageIds;
private final double[] drawAcceptanceSamples;
private final int[] drawTupleStartSeeds;
private final long[] drawSortKeys;
@@ -182,7 +181,6 @@ public class ColumnBtreeSampleCursor extends EnforcedIndexCursor implements ITre
this.traceTimingEnabled = LOGGER.isTraceEnabled();
this.leafDrawBatchSize = (int) Math.max(leafDrawBatchSize, componentSampleCardinality);
- this.drawPageIds = new int[this.leafDrawBatchSize];
this.drawAcceptanceSamples = new double[this.leafDrawBatchSize];
this.drawTupleStartSeeds = new int[this.leafDrawBatchSize];
this.drawSortKeys = new long[this.leafDrawBatchSize];
@@ -286,8 +284,11 @@ public class ColumnBtreeSampleCursor extends EnforcedIndexCursor implements ITre
return null;
}
}
- int drawIndex = (int) drawSortKeys[pendingLeafDrawIndex++];
- leafDrawView.pageId = drawPageIds[drawIndex];
+ // Sort key packs (pageId << 32 | drawIndex): high 32 bits ARE the pageId (no separate array),
+ // low 32 bits index back into the unsorted SoA side arrays.
+ long sortKey = drawSortKeys[pendingLeafDrawIndex++];
+ int drawIndex = (int) sortKey;
+ leafDrawView.pageId = (int) (sortKey >>> 32);
leafDrawView.acceptanceSample = drawAcceptanceSamples[drawIndex];
leafDrawView.tupleStartSeed = drawTupleStartSeeds[drawIndex];
return leafDrawView;
@@ -301,7 +302,6 @@ public class ColumnBtreeSampleCursor extends EnforcedIndexCursor implements ITre
for (int i = 0; i < leafDrawBatchSize; i++) {
int randomLeafIndex = randomNumGen.nextInt(leafPageIds.length);
int targetPageId = leafPageIds[randomLeafIndex];
- drawPageIds[i] = targetPageId;
drawAcceptanceSamples[i] = randomNumGen.nextDouble();
drawTupleStartSeeds[i] = randomNumGen.nextInt();
drawSortKeys[i] = (((long) targetPageId) << 32) | (i & 0xffffffffL);