rpuch commented on code in PR #3299:
URL: https://github.com/apache/ignite-3/pull/3299#discussion_r1504302657
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java:
##########
@@ -3814,4 +3845,22 @@ private HybridTimestamp
indexStartBuildingActivationTs(BuildIndexReplicaRequest
return hybridTimestamp(catalog.time());
}
+
+ private int schemaVersionByTs(HybridTimestamp ts) {
Review Comment:
```suggestion
private int tableVersionByTs(HybridTimestamp ts) {
```
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java:
##########
@@ -1308,7 +1338,8 @@ private CompletableFuture<Void> continueIndexScan(
Cursor<IndexRow> indexCursor,
int batchSize,
List<BinaryRow> result,
- Predicate<IndexRow> isUpperBoundAchieved
+ Predicate<IndexRow> isUpperBoundAchieved,
+ int schemaVersion
Review Comment:
```suggestion
int tableVersion
```
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java:
##########
@@ -1257,18 +1275,29 @@ private CompletableFuture<List<BinaryRow>>
scanSortedIndex(
flags
))).cursor();
+ int batchCount = request.batchSize();
+
var result = new ArrayList<BinaryRow>(batchCount);
- return continueReadOnlyIndexScan(schemaAwareIndexStorage, cursor,
timestamp, batchCount, result)
- .thenApply(ignore -> closeCursorIfBatchNotFull(result,
batchCount, cursorId));
+ HybridTimestamp readTimestamp = request.readTimestamp();
+
+ return continueReadOnlyIndexScan(
+ schemaAwareIndexStorage,
+ cursor,
+ readTimestamp,
+ batchCount,
+ result,
+ schemaVersionByTs(readTimestamp)
+ ).thenApply(ignore -> closeCursorIfBatchNotFull(result, batchCount,
cursorId));
}
private CompletableFuture<Void> continueReadOnlyIndexScan(
TableSchemaAwareIndexStorage schemaAwareIndexStorage,
Cursor<IndexRow> cursor,
- HybridTimestamp timestamp,
+ HybridTimestamp readTimestamp,
int batchSize,
- List<BinaryRow> result
+ List<BinaryRow> result,
+ int schemaVersion
Review Comment:
```suggestion
int tableVersion
```
##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java:
##########
@@ -3814,4 +3845,22 @@ private HybridTimestamp
indexStartBuildingActivationTs(BuildIndexReplicaRequest
return hybridTimestamp(catalog.time());
}
+
+ private int schemaVersionByTs(HybridTimestamp ts) {
+ int activeCatalogVersion =
catalogService.activeCatalogVersion(ts.longValue());
+
+ CatalogTableDescriptor table = catalogService.table(tableId(),
activeCatalogVersion);
+
+ assert table != null : "tableId=" + tableId() + ", catalogVersion=" +
activeCatalogVersion;
+
+ return table.tableVersion();
+ }
+
+ private static @Nullable BinaryRow binaryRow(@Nullable TimedBinaryRow
timedBinaryRow) {
+ return timedBinaryRow == null ? null : timedBinaryRow.binaryRow();
+ }
+
+ private @Nullable BinaryRow upgrage(@Nullable BinaryRow source, int
targetSchemaVersion) {
+ return source == null ? null : new BinaryRowUpgrader(schemaRegistry,
targetSchemaVersion).upgrade(source);
Review Comment:
I wonder if this creates too much garbage. For each table version, we only
need one upgrader, it can be cached.
--
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]