SammyVimes commented on code in PR #1121:
URL: https://github.com/apache/ignite-3/pull/1121#discussion_r979807821
##########
modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvPartitionStorageTest.java:
##########
@@ -984,6 +986,94 @@ void testReadingTombstoneIfPreviousCommitNotExists() {
assertNull(res.newestCommitTimestamp());
}
+ @Test
+ void testScanVersions() throws Exception {
+ RowId rowId = new RowId(PARTITION_ID, 100, 0);
+
+ // Populate storage with several versions for the same row id.
+ List<TestValue> values = new ArrayList<>(List.of(value, value2));
+
+ for (TestValue value : values) {
+ storage.runConsistently(() -> {
+ storage.addWrite(rowId, binaryRow(key, value),
newTransactionId(), UUID.randomUUID(), PARTITION_ID);
Review Comment:
You can use addWrite() instead of storage.addWrite
##########
modules/core/src/main/java/org/apache/ignite/internal/util/Cursor.java:
##########
@@ -33,6 +34,10 @@ default Iterator<T> iterator() {
return this;
}
+ static <T> Cursor<T> empty() {
+ return fromIterator(Collections.emptyIterator());
Review Comment:
Could be just one static object
##########
modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbMvPartitionStorage.java:
##########
@@ -648,6 +649,37 @@ private static boolean matches(RowId rowId, ByteBuffer
keyByf) {
return rowId.mostSignificantBits() == keyByf.getLong() &&
rowId.leastSignificantBits() == keyByf.getLong();
}
+ @Override
+ public Cursor<BinaryRow> scanVersions(RowId rowId) throws StorageException
{
+ ByteBuffer keyBuf = prepareHeapKeyBuf(rowId);
+
+ byte[] lowerBound = copyOf(keyBuf.array(), ROW_PREFIX_SIZE);
+
+ incrementRowId(keyBuf);
+
+ Slice upperBound = new Slice(copyOf(keyBuf.array(), ROW_PREFIX_SIZE));
+
+ var options = new
ReadOptions().setIterateUpperBound(upperBound).setTotalOrderSeek(true);
+
+ RocksIterator it = db.newIterator(cf, options);
+
+ it.seek(lowerBound);
+
+ return new RocksIteratorAdapter<>(it) {
+ @Override
+ protected BinaryRow decodeEntry(byte[] key, byte[] value) {
+ return wrapValueIntoBinaryRow(value, key.length ==
ROW_PREFIX_SIZE);
+ }
+
+ @Override
+ public void close() throws Exception {
+ super.close();
+
+ IgniteUtils.closeAll(it, options, upperBound);
Review Comment:
Because it checks whether pointer still exists.
--
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]