maedhroz commented on code in PR #2498:
URL: https://github.com/apache/cassandra/pull/2498#discussion_r1270157902
##########
src/java/org/apache/cassandra/index/sai/disk/v1/SkinnyRowAwarePrimaryKeyMap.java:
##########
@@ -109,89 +101,71 @@ public RowAwarePrimaryKeyMapFactory(IndexDescriptor
indexDescriptor, SSTableRead
public PrimaryKeyMap newPerSSTablePrimaryKeyMap() throws IOException
{
LongArray rowIdToToken = new
LongArray.DeferredLongArray(tokenReaderFactory::open);
- return new RowAwarePrimaryKeyMap(rowIdToToken,
- new
TriePrefixSearcher(primaryKeyTrieFile.instantiateRebufferer(null),
sortedTermsMeta.trieFilePointer),
- sortedTermsReader.openCursor(),
- partitioner,
- primaryKeyFactory,
- clusteringComparator);
+ return new SkinnyRowAwarePrimaryKeyMap(rowIdToToken,
+
sortedTermsReader.openCursor(),
+ partitioner,
+ primaryKeyFactory);
}
@Override
public void close()
{
- FileUtils.closeQuietly(Arrays.asList(tokensFile,
primaryKeyBlocksFile, primaryKeyBlockOffsetsFile, primaryKeyTrieFile));
+ FileUtils.closeQuietly(Arrays.asList(tokensFile,
primaryKeyBlocksFile, primaryKeyBlockOffsetsFile));
}
}
- private final LongArray rowIdToToken;
- private final TriePrefixSearcher triePrefixSearcher;
- private final SortedTermsReader.Cursor cursor;
- private final IPartitioner partitioner;
- private final PrimaryKey.Factory primaryKeyFactory;
- private final ClusteringComparator clusteringComparator;
- private final ByteBuffer tokenBuffer = ByteBuffer.allocate(Long.BYTES);
-
- private RowAwarePrimaryKeyMap(LongArray rowIdToToken,
- TriePrefixSearcher triePrefixSearcher,
- SortedTermsReader.Cursor cursor,
- IPartitioner partitioner,
- PrimaryKey.Factory primaryKeyFactory,
- ClusteringComparator clusteringComparator)
+ protected final LongArray tokenArray;
+ protected final SortedTermsReader.Cursor cursor;
+ protected final IPartitioner partitioner;
+ protected final PrimaryKey.Factory primaryKeyFactory;
+ protected final ByteBuffer tokenBuffer = ByteBuffer.allocate(Long.BYTES);
+
+ protected SkinnyRowAwarePrimaryKeyMap(LongArray tokenArray,
+ SortedTermsReader.Cursor cursor,
+ IPartitioner partitioner,
+ PrimaryKey.Factory primaryKeyFactory)
{
- this.rowIdToToken = rowIdToToken;
- this.triePrefixSearcher = triePrefixSearcher;
+ this.tokenArray = tokenArray;
this.cursor = cursor;
this.partitioner = partitioner;
this.primaryKeyFactory = primaryKeyFactory;
- this.clusteringComparator = clusteringComparator;
}
@Override
public PrimaryKey primaryKeyFromRowId(long sstableRowId)
{
- tokenBuffer.putLong(rowIdToToken.get(sstableRowId));
+ tokenBuffer.putLong(tokenArray.get(sstableRowId));
tokenBuffer.rewind();
return
primaryKeyFactory.createDeferred(partitioner.getTokenFactory().fromByteArray(tokenBuffer),
() -> supplier(sstableRowId));
}
@Override
public long rowIdFromPrimaryKey(PrimaryKey key)
{
- return
triePrefixSearcher.prefixSearch(key.asComparableBytes(ByteComparable.Version.OSS50));
+ return tokenArray.findTokenRowID(key.token().getLongValue());
Review Comment:
Just to refresh my memory, this never had to be exact, because it's only
used for skipping, right?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]