This is an automated email from the ASF dual-hosted git repository.
jooger pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new a5c0973bf4 IGNITE-21891: fixing an issue for tuples when key columns
are after value ones
a5c0973bf4 is described below
commit a5c0973bf499f01352dc20438601e1ffca0d5b99
Author: Max Zhuravkov <[email protected]>
AuthorDate: Sat Mar 30 16:56:03 2024 +0200
IGNITE-21891: fixing an issue for tuples when key columns are after value
ones
---
.../client/ItCustomKeyColumnOrderEmbeddedTest.java | 16 ------
.../internal/table/AbstractRowTupleAdapter.java | 66 +++++++++++-----------
.../ignite/internal/table/RecordViewImpl.java | 17 ++++--
3 files changed, 45 insertions(+), 54 deletions(-)
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItCustomKeyColumnOrderEmbeddedTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItCustomKeyColumnOrderEmbeddedTest.java
index 53420218a1..3f7bc29139 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItCustomKeyColumnOrderEmbeddedTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItCustomKeyColumnOrderEmbeddedTest.java
@@ -18,8 +18,6 @@
package org.apache.ignite.internal.runner.app.client;
import org.apache.ignite.Ignite;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
/**
* Tests custom key column order table operations with embedded API.
@@ -29,18 +27,4 @@ public class ItCustomKeyColumnOrderEmbeddedTest extends
ItCustomKeyColumnOrderCl
protected Ignite ignite() {
return server();
}
-
- @Override
- @Test
- @Disabled("https://issues.apache.org/jira/browse/IGNITE-21891")
- void testRecordView() {
- super.testRecordView();
- }
-
- @Override
- @Test
- @Disabled("https://issues.apache.org/jira/browse/IGNITE-21891")
- void testKeyValueBinaryView() {
- super.testKeyValueBinaryView();
- }
}
diff --git
a/modules/table/src/main/java/org/apache/ignite/internal/table/AbstractRowTupleAdapter.java
b/modules/table/src/main/java/org/apache/ignite/internal/table/AbstractRowTupleAdapter.java
index 24e62d5a5d..644d74b7a7 100644
---
a/modules/table/src/main/java/org/apache/ignite/internal/table/AbstractRowTupleAdapter.java
+++
b/modules/table/src/main/java/org/apache/ignite/internal/table/AbstractRowTupleAdapter.java
@@ -22,6 +22,7 @@ import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.BitSet;
+import java.util.List;
import java.util.Objects;
import java.util.UUID;
import org.apache.ignite.internal.schema.Column;
@@ -79,11 +80,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
return -1;
}
- if (row.keyOnly()) {
- return col.positionInKey();
- }
-
- return col.positionInRow();
+ return correctIndex(col);
}
/** {@inheritDoc} */
@@ -93,7 +90,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
Column col =
row.schema().column(IgniteNameUtils.parseSimpleName(columnName));
- return col == null ? defaultValue : (T) row.value(col.positionInRow());
+ return col == null ? defaultValue : (T) row.value(correctIndex(col));
}
/** {@inheritDoc} */
@@ -101,14 +98,14 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public <T> T value(String columnName) {
Column col = rowColumnByName(columnName);
- return (T) row.value(col.positionInRow());
+ return (T) row.value(correctIndex(col));
}
@Override
public <T> T value(int columnIndex) {
Column col = rowColumnByIndex(columnIndex);
- return (T) row.value(col.positionInRow());
+ return (T) row.value(correctIndex(col));
}
/** {@inheritDoc} */
@@ -116,7 +113,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public boolean booleanValue(String columnName) {
Column col = rowColumnByName(columnName);
- return row.booleanValue(col.positionInRow());
+ return row.booleanValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -124,7 +121,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public boolean booleanValue(int columnIndex) {
Column col = rowColumnByIndex(columnIndex);
- return row.booleanValue(col.positionInRow());
+ return row.booleanValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -180,7 +177,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public long longValue(String columnName) {
Column col = rowColumnByName(columnName);
- return row.longValue(col.positionInRow());
+ return row.longValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -188,7 +185,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public long longValue(int columnIndex) {
Column col = rowColumnByIndex(columnIndex);
- return row.longValue(col.positionInRow());
+ return row.longValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -196,7 +193,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public float floatValue(String columnName) {
Column col = rowColumnByName(columnName);
- return row.floatValue(col.positionInRow());
+ return row.floatValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -204,7 +201,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public float floatValue(int columnIndex) {
Column col = rowColumnByIndex(columnIndex);
- return row.floatValue(col.positionInRow());
+ return row.floatValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -212,7 +209,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public double doubleValue(String columnName) {
Column col = rowColumnByName(columnName);
- return row.doubleValue(col.positionInRow());
+ return row.doubleValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -220,7 +217,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public double doubleValue(int columnIndex) {
Column col = rowColumnByIndex(columnIndex);
- return row.doubleValue(col.positionInRow());
+ return row.doubleValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -228,7 +225,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public String stringValue(String columnName) {
Column col = rowColumnByName(columnName);
- return row.stringValue(col.positionInRow());
+ return row.stringValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -236,7 +233,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public String stringValue(int columnIndex) {
Column col = rowColumnByIndex(columnIndex);
- return row.stringValue(col.positionInRow());
+ return row.stringValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -244,7 +241,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public UUID uuidValue(String columnName) {
Column col = rowColumnByName(columnName);
- return row.uuidValue(col.positionInRow());
+ return row.uuidValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -252,7 +249,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public UUID uuidValue(int columnIndex) {
Column col = rowColumnByIndex(columnIndex);
- return row.uuidValue(col.positionInRow());
+ return row.uuidValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -260,7 +257,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public BitSet bitmaskValue(String columnName) {
Column col = rowColumnByName(columnName);
- return row.bitmaskValue(col.positionInRow());
+ return row.bitmaskValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -268,7 +265,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public BitSet bitmaskValue(int columnIndex) {
Column col = rowColumnByIndex(columnIndex);
- return row.bitmaskValue(col.positionInRow());
+ return row.bitmaskValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -276,7 +273,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public LocalDate dateValue(String columnName) {
Column col = rowColumnByName(columnName);
- return row.dateValue(col.positionInRow());
+ return row.dateValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -284,7 +281,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public LocalDate dateValue(int columnIndex) {
Column col = rowColumnByIndex(columnIndex);
- return row.dateValue(col.positionInRow());
+ return row.dateValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -292,7 +289,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public LocalTime timeValue(String columnName) {
Column col = rowColumnByName(columnName);
- return row.timeValue(col.positionInRow());
+ return row.timeValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -300,7 +297,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public LocalTime timeValue(int columnIndex) {
Column col = rowColumnByIndex(columnIndex);
- return row.timeValue(col.positionInRow());
+ return row.timeValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -308,7 +305,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public LocalDateTime datetimeValue(String columnName) {
Column col = rowColumnByName(columnName);
- return row.dateTimeValue(col.positionInRow());
+ return row.dateTimeValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -316,7 +313,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public LocalDateTime datetimeValue(int columnIndex) {
Column col = rowColumnByIndex(columnIndex);
- return row.dateTimeValue(col.positionInRow());
+ return row.dateTimeValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -324,7 +321,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public Instant timestampValue(String columnName) {
Column col = rowColumnByName(columnName);
- return row.timestampValue(col.positionInRow());
+ return row.timestampValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -332,7 +329,7 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
public Instant timestampValue(int columnIndex) {
Column col = rowColumnByIndex(columnIndex);
- return row.timestampValue(col.positionInRow());
+ return row.timestampValue(correctIndex(col));
}
/** {@inheritDoc} */
@@ -380,9 +377,14 @@ public abstract class AbstractRowTupleAdapter implements
Tuple, SchemaAware {
* @return Column.
*/
protected Column rowColumnByIndex(int columnIndex) {
- Objects.checkIndex(columnIndex, row.schema().length());
+ List<Column> columns = row.keyOnly() ? row.schema().keyColumns() :
row.schema().columns();
- return row.schema().column(columnIndex);
+ Objects.checkIndex(columnIndex, columns.size());
+
+ return columns.get(columnIndex);
}
+ private int correctIndex(Column col) {
+ return row.keyOnly() ? col.positionInKey() : col.positionInRow();
+ }
}
diff --git
a/modules/table/src/main/java/org/apache/ignite/internal/table/RecordViewImpl.java
b/modules/table/src/main/java/org/apache/ignite/internal/table/RecordViewImpl.java
index eb31be616b..ce8c65b883 100644
---
a/modules/table/src/main/java/org/apache/ignite/internal/table/RecordViewImpl.java
+++
b/modules/table/src/main/java/org/apache/ignite/internal/table/RecordViewImpl.java
@@ -121,7 +121,7 @@ public class RecordViewImpl<R> extends AbstractTableView<R>
implements RecordVie
return doOperation(tx, (schemaVersion) -> {
return tbl.getAll(marshalKeys(keyRecs, schemaVersion),
(InternalTransaction) tx)
- .thenApply(binaryRows -> unmarshal(binaryRows,
schemaVersion, true));
+ .thenApply(binaryRows -> unmarshal(binaryRows, false,
schemaVersion, true));
});
}
@@ -227,7 +227,8 @@ public class RecordViewImpl<R> extends AbstractTableView<R>
implements RecordVie
return doOperation(tx, (schemaVersion) -> {
Collection<BinaryRowEx> rows = marshal(recs, schemaVersion);
- return tbl.insertAll(rows, (InternalTransaction)
tx).thenApply(binaryRows -> unmarshal(binaryRows, schemaVersion, false));
+ return tbl.insertAll(rows, (InternalTransaction) tx)
+ .thenApply(binaryRows -> unmarshal(binaryRows, false,
schemaVersion, false));
});
}
@@ -355,7 +356,7 @@ public class RecordViewImpl<R> extends AbstractTableView<R>
implements RecordVie
return doOperation(tx, (schemaVersion) -> {
Collection<BinaryRowEx> rows = marshalKeys(keyRecs, schemaVersion);
- return tbl.deleteAll(rows, (InternalTransaction)
tx).thenApply(binaryRows -> unmarshal(binaryRows, schemaVersion, false));
+ return tbl.deleteAll(rows, (InternalTransaction)
tx).thenApply(binaryRows -> unmarshal(binaryRows, true, schemaVersion, false));
});
}
@@ -374,7 +375,7 @@ public class RecordViewImpl<R> extends AbstractTableView<R>
implements RecordVie
Collection<BinaryRowEx> rows = marshal(recs, schemaVersion);
return tbl.deleteAllExact(rows, (InternalTransaction) tx)
- .thenApply(binaryRows -> unmarshal(binaryRows,
schemaVersion, false));
+ .thenApply(binaryRows -> unmarshal(binaryRows, true,
schemaVersion, false));
});
}
@@ -530,10 +531,11 @@ public class RecordViewImpl<R> extends
AbstractTableView<R> implements RecordVie
*
* @param rows Row collection.
* @param addNull {@code true} if {@code null} is added for missing rows.
+ * @param keyOnly If rows are key-only.
* @param targetSchemaVersion Schema version that should be used.
* @return Records collection.
*/
- private List<R> unmarshal(Collection<BinaryRow> rows, int
targetSchemaVersion, boolean addNull) {
+ private List<R> unmarshal(Collection<BinaryRow> rows, boolean keyOnly, int
targetSchemaVersion, boolean addNull) {
if (rows.isEmpty()) {
return Collections.emptyList();
}
@@ -542,8 +544,11 @@ public class RecordViewImpl<R> extends
AbstractTableView<R> implements RecordVie
RecordMarshaller<R> marsh = marshaller(targetSchemaVersion);
var recs = new ArrayList<R>(rows.size());
+ List<Row> resolvedRows = keyOnly
+ ? rowConverter.resolveKeys(rows, targetSchemaVersion)
+ : rowConverter.resolveRows(rows, targetSchemaVersion);
- for (Row row : rowConverter.resolveRows(rows,
targetSchemaVersion)) {
+ for (Row row : resolvedRows) {
if (row != null) {
recs.add(marsh.unmarshal(row));
} else if (addNull) {