rpuch commented on code in PR #1331:
URL: https://github.com/apache/ignite-3/pull/1331#discussion_r1020273283


##########
modules/transactions/src/main/java/org/apache/ignite/internal/tx/storage/state/rocksdb/TxStateRocksDbStorage.java:
##########
@@ -115,11 +118,13 @@ public TxStateRocksDbStorage(
         this.persistedTierReadOptions = persistedTierReadOptions;
         this.partitionId = partitionId;
         this.tableStorage = tableStorage;
-        this.lastAppliedIndexKey = 
ByteBuffer.allocate(Short.BYTES).order(ByteOrder.BIG_ENDIAN)
+        this.lastAppliedIndexAndTermKey = 
ByteBuffer.allocate(Short.BYTES).order(ByteOrder.BIG_ENDIAN)
                 .putShort((short) partitionId)
                 .array();
 
-        lastAppliedIndex = readLastAppliedIndex(readOptions);
+        byte[] indexAndTermBytes = readLastAppliedIndexAndTerm(readOptions);

Review Comment:
   In the partition storage, we store the metadata (including index and term) 
in a separate column family. Here, there was just one metadata originally (last 
applied index), so the author employed a hack: a special key was used to store 
the index in the same column family that hosts the data. Now we need to store 2 
pieces of metadata, so it becomes a bit ugly to increase the number of keys.
   
   I invented the following solutions:
   
   1. Add `meta` CF as it is done for MV data storage. This is a bit cumbersome.
   2. Construct metadata keys like this: `concat(partitionId, 0)` for index, 
`concat(partitionId, 1)` for term and then skip them when iterating over the 
keys in `scan()`. I implemented this first, but it causes a penalty of reading 
the key to analyze its length on each  iteration, and it's a bit cumbersome as 
well.
   3. Reuse the same (the only) metadata key to store index together with term. 
They are always updated together, so this looked like a natural solution, I 
chose this one.



-- 
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]

Reply via email to