SammyVimes commented on code in PR #1127:
URL: https://github.com/apache/ignite-3/pull/1127#discussion_r982735362
##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/BinaryTuplePrefix.java:
##########
@@ -54,6 +57,28 @@ public BinaryTuplePrefix(BinaryTupleSchema schema,
ByteBuffer buffer) {
this.schema = schema;
}
+ /**
+ * Creates a prefix that contains all columns from the provided {@link
BinaryTuple}.
+ *
+ * @param tuple Tuple to create a prefix from.
+ * @return Prefix, equivalent to the tuple.
+ */
+ public static BinaryTuplePrefix fromBinaryTuple(BinaryTuple tuple) {
+ ByteBuffer tupleBuffer = tuple.byteBuffer();
+
+ ByteBuffer prefixBuffer = ByteBuffer.allocate(tupleBuffer.remaining()
+ Integer.BYTES)
+ .order(ByteOrder.LITTLE_ENDIAN)
Review Comment:
Can you extract byte order to some constant? If it's not too much of a hassle
##########
modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/index/RocksDbSortedIndexStorage.java:
##########
@@ -178,35 +198,36 @@ private IndexRow decodeRow(ByteBuffer bytes) {
var tuple = new BinaryTuple(descriptor.binaryTupleSchema(),
binaryTupleSlice(bytes));
+ return new IndexRowImpl(tuple, decodeRowId(bytes));
+ }
+
+ private RowId decodeRowId(ByteBuffer bytes) {
// RowId UUID is located at the last 16 bytes of the key
long mostSignificantBits = bytes.getLong(bytes.limit() - Long.BYTES *
2);
long leastSignificantBits = bytes.getLong(bytes.limit() - Long.BYTES);
- var rowId = new RowId(partitionStorage.partitionId(),
mostSignificantBits, leastSignificantBits);
-
- return new IndexRowImpl(tuple, rowId);
+ return new RowId(partitionStorage.partitionId(), mostSignificantBits,
leastSignificantBits);
}
private byte[] rocksPrefix(BinaryTuplePrefix prefix) {
- return rocksPrefix(prefix, 0).array();
- }
+ ByteBuffer bytes = prefix.byteBuffer();
- private ByteBuffer rocksPrefix(InternalTuple prefix, int extraLength) {
- ByteBuffer keyBytes = prefix.byteBuffer();
-
- return ByteBuffer.allocate(Short.BYTES + keyBytes.remaining() +
extraLength)
+ return ByteBuffer.allocate(Short.BYTES + bytes.remaining())
.order(ByteOrder.BIG_ENDIAN)
.putShort((short) partitionStorage.partitionId())
- .put(keyBytes);
+ .put(bytes)
+ .array();
}
private byte[] rocksKey(IndexRow row) {
- RowId rowId = row.rowId();
+ ByteBuffer bytes = row.indexColumns().byteBuffer();
- // We don't store the Partition ID as it is already a part of the key.
- return rocksPrefix(row.indexColumns(), 2 * Long.BYTES)
- .putLong(rowId.mostSignificantBits())
- .putLong(rowId.leastSignificantBits())
+ return ByteBuffer.allocate(Short.BYTES + bytes.remaining() +
ROW_ID_SIZE)
+ .order(ByteOrder.BIG_ENDIAN)
Review Comment:
Let's extract byte order to a constant
##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/AbstractPageMemoryTableStorage.java:
##########
@@ -141,14 +147,44 @@ public CompletableFuture<Void> destroyPartition(int
partitionId) throws StorageE
return CompletableFuture.completedFuture(null);
}
+ @Override
+ public IndexStorage getOrCreateIndex(int partitionId, UUID indexId) {
Review Comment:
I wonder if this method can be default, because it looks the same as in
rocksdb table storage
--
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]