ascherbakoff commented on a change in pull request #73:
URL: https://github.com/apache/ignite-3/pull/73#discussion_r610670298
##########
File path:
modules/table/src/main/java/org/apache/ignite/internal/table/RecordViewImpl.java
##########
@@ -78,7 +97,7 @@ public RecordViewImpl(TableStorage tbl, RecordMapper<R>
mapper) {
}
/** {@inheritDoc} */
- @Override public @NotNull IgniteFuture<Collection<R>>
getAllAsync(Collection<R> keyRecs) {
+ @Override public @NotNull CompletableFuture<Collection<R>>
getAllAsync(Collection<R> keyRecs) {
Review comment:
Why null is returned but the annotation specifies notnull ?
##########
File path:
modules/schema/src/main/java/org/apache/ignite/internal/schema/Row.java
##########
@@ -17,167 +17,217 @@
package org.apache.ignite.internal.schema;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
import java.util.BitSet;
import java.util.UUID;
/**
+ * Schema-aware row.
+ *
* The class contains non-generic methods to read boxed and unboxed primitives
based on the schema column types.
* Any type conversions and coercions should be implemented outside the row by
the key-value or query runtime.
* When a non-boxed primitive is read from a null column value, it is
converted to the primitive type default value.
*/
-public abstract class Row {
- /** */
- public static final int SCHEMA_VERSION_OFFSET = 0;
-
- /** */
- public static final int FLAGS_FIELD_OFFSET = SCHEMA_VERSION_OFFSET + 2;
-
- /** */
- public static final int KEY_HASH_FIELD_OFFSET = FLAGS_FIELD_OFFSET + 2;
-
- /** */
- public static final int KEY_CHUNK_OFFSET = KEY_HASH_FIELD_OFFSET + 4;
-
- /** */
- public static final int TOTAL_LEN_FIELD_SIZE = 4;
-
- /** */
- public static final int VARLEN_TABLE_SIZE_FIELD_SIZE = 2;
-
- /** */
- public static final int VARLEN_COLUMN_OFFSET_FIELD_SIZE = 2;
+public class Row implements BinaryRow {
+ /** Schema descriptor. */
+ private final SchemaDescriptor schema;
- /** */
- public static final class RowFlags {
- /** Tombstone flag. */
- public static final int TOMBSTONE = 1;
+ /** Binary row. */
+ private final BinaryRow row;
- /** Null-value flag. */
- public static final int NULL_VALUE = 1 << 1;
+ /**
+ * Constructor.
+ *
+ * @param schema Schema.
+ * @param row Binary row representation.
+ */
+ public Row(SchemaDescriptor schema, BinaryRow row) {
+ assert row.schemaVersion() == schema.version();
- /** Stub. */
- private RowFlags() {
- }
+ this.row = row;
+ this.schema = schema;
}
- /** Schema descriptor for which this row was created. */
- private final SchemaDescriptor schema;
-
/**
- * @param schema Schema instance.
+ * @return Row schema.
*/
- protected Row(SchemaDescriptor schema) {
- this.schema = schema;
+ public SchemaDescriptor rowSchema() {
+ return schema;
}
/**
* @return {@code True} if row has non-null value, {@code false} otherwise.
*/
- public boolean hasValue() {
- short flags = readShort(FLAGS_FIELD_OFFSET);
-
- return (flags & (RowFlags.NULL_VALUE | RowFlags.TOMBSTONE)) == 0;
+ @Override public boolean hasValue() {
+ return row.hasValue();
}
/**
+ * Reads value for specified column.
+ *
+ * @param col Column index.
+ * @return Column value.
+ * @throws InvalidTypeException If actual column type does not match the
requested column type.
*/
- public byte byteValue(int col) {
+ public byte byteValue(int col) throws InvalidTypeException {
long off = findColumn(col, NativeTypeSpec.BYTE);
return off < 0 ? 0 : readByte(offset(off));
}
/**
+ * Reads value for specified column.
+ *
+ * @param col Column index.
+ * @return Column value.
+ * @throws InvalidTypeException If actual column type does not match the
requested column type.
*/
- public Byte byteValueBoxed(int col) {
+ public Byte byteValueBoxed(int col) throws InvalidTypeException {
long off = findColumn(col, NativeTypeSpec.BYTE);
return off < 0 ? null : readByte(offset(off));
}
/**
+ * Reads value for specified column.
+ *
+ * @param col Column index.
+ * @return Column value.
+ * @throws InvalidTypeException If actual column type does not match the
requested column type.
*/
- public short shortValue(int col) {
+ public short shortValue(int col) throws InvalidTypeException {
long off = findColumn(col, NativeTypeSpec.SHORT);
return off < 0 ? 0 : readShort(offset(off));
}
/**
+ * Reads value for specified column.
+ *
+ * @param col Column index.
+ * @return Column value.
+ * @throws InvalidTypeException If actual column type does not match the
requested column type.
*/
- public Short shortValueBoxed(int col) {
+ public Short shortValueBoxed(int col) throws InvalidTypeException {
Review comment:
What is the point in having *Boxed methods ?
Boxed value will be created by autoboxing:
Short val = shortValue(0);
##########
File path:
modules/table/src/main/java/org/apache/ignite/internal/table/KVViewImpl.java
##########
@@ -222,7 +235,42 @@ public KVViewImpl(TableStorage tbl, KeyMapper<K>
keyMapper, ValueMapper<V> value
/**
* @return Marshaller.
*/
- private Marshaller marshaller() {
+ private KVSerializer<K, V> marshaller() {
return null; // table.schemaManager().marshaller();
}
+
+ /**
+ * @param row Binary row.
+ * @return Schema-aware row.
+ */
+ private Row wrap(BinaryRow row) {
+ if (row == null)
+ return null;
+
+ final SchemaDescriptor rowSchema =
schemaMgr.schema(row.schemaVersion()); // Get a schema for row.
+
+ return new Row(rowSchema, row);
+ }
+
+ /**
+ * Waits for operation completion.
+ *
+ * @param fut Future to wait to.
+ * @return Future result.
+ */
+ private <T> T sync(CompletableFuture<T> fut) {
Review comment:
This method has occured 4 times. Can the copy paste be removed ?
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]