You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/05/12 13:09:28 UTC

[GitHub] [ignite-3] tledkov-gridgain opened a new pull request #123: IGNITE-14692 Validate tuple for STRICT schema

tledkov-gridgain opened a new pull request #123:
URL: https://github.com/apache/ignite-3/pull/123


   


-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r635079496



##########
File path: modules/table/src/main/java/org/apache/ignite/internal/table/InvalidSchemaException.java
##########
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.table;
+
+import org.apache.ignite.lang.IgniteException;
+
+/**
+ * Invalid tuple invocation exception is thrown when tuple doesn't match the table schema.
+ */
+public class InvalidSchemaException extends IgniteException {

Review comment:
       Will the name ''SchemaMismatchException" more suitable?




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r635988680



##########
File path: modules/table/src/integrationTest/java/org/apache/ignite/distributed/ITDistributedTableTest.java
##########
@@ -97,11 +97,15 @@
     private ClusterService client;
 
     /** Schema. */
-    public static SchemaDescriptor SCHEMA = new SchemaDescriptor(1, new Column[] {
-        new Column("key", NativeType.LONG, false)
-    }, new Column[] {
-        new Column("value", NativeType.LONG, false)
-    });
+    public static SchemaDescriptor SCHEMA = new SchemaDescriptor(UUID.randomUUID(),
+        1,
+        new Column[] {
+            new Column("key", NativeTypes.LONG, false)
+        },
+        new Column[] {
+            new Column("value", NativeTypes.LONG, false)
+        }
+    );

Review comment:
       ```suggestion
       public static SchemaDescriptor SCHEMA = new SchemaDescriptor(UUID.randomUUID(),
           1,
           new Column[] {new Column("key", NativeTypes.LONG, false)},
           new Column[] {new Column("value", NativeTypes.LONG, false)}
       );
   ```




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r635072507



##########
File path: modules/schema/src/test/java/org/apache/ignite/internal/schema/RowTest.java
##########
@@ -68,8 +68,8 @@ public void testFixedSizes() {
             new Column("keyFloatCol", FLOAT, true),
             new Column("keyDoubleCol", DOUBLE, true),
             new Column("keyUuidCol", UUID, true),
-            new Column("keyBitmask1Col", Bitmask.of(4), true),
-            new Column("keyBitmask2Col", Bitmask.of(22), true)
+            new Column("keyBitmask1Col", BitmaskNativeType.of(4), true),

Review comment:
       Let's introduce NativeTypes.bitmaskOf(int) 




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] tledkov-gridgain commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
tledkov-gridgain commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r634110533



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/NativeType.java
##########
@@ -104,6 +100,107 @@ public NativeTypeSpec spec() {
         return typeSpec;
     }
 
+    /**
+     * Return the native type for specified object.
+     *
+     * @return {@code null} for {@code null} value. Otherwise returns NativeType according to the value's type.
+     */
+    public static NativeType fromObject(Object val) {
+        NativeTypeSpec spec = NativeTypeSpec.fromObject(val);
+
+        if (spec == null)
+            return null;
+
+        switch (spec) {
+            case BYTE:
+                return BYTE;
+
+            case SHORT:
+                return SHORT;
+
+            case INTEGER:
+                return INTEGER;
+
+            case LONG:
+                return LONG;
+
+            case FLOAT:
+                return FLOAT;
+
+            case DOUBLE:
+                return DOUBLE;
+
+            case UUID:
+                return UUID;
+
+            case STRING:
+                return new VarlenNativeType(NativeTypeSpec.STRING, ((CharSequence)val).length());

Review comment:
       I guess it is OK. Because he second argument of the VarlenNativeType constructor is `length`. `sizeInBytres` is set to zero for VarlenNativeType.




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r635982581



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/Column.java
##########
@@ -132,6 +172,35 @@ public boolean nullable() {
         return name.compareTo(o.name);
     }
 
+    /**
+     * Validate the object by column's constraint.
+     */
+    public void validate(Object val) {
+        if (val == null && !nullable) {
+            throw new IllegalArgumentException("Failed to set column (null was passed, but column is not nullable): " +
+                "[col=" + this + ']');
+        }
+
+        NativeType objType = NativeType.fromObject(val);
+
+        if (objType != null && type.mismatch(objType)) {
+            throw new InvalidTypeException("Column's type mismatch [" +
+                "column=" + this +
+                ", expectedType=" + type +
+                ", actualType=" + objType +
+                ", val=" + val + ']');
+        }
+    }
+
+    /**
+     * Copy column with new schema index.
+     *
+     * @param schemaIndex new schema index.

Review comment:
       ```suggestion
        * @param schemaIndex Column index in the schema.
        * @return Column.
   ```




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r634138585



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/NativeType.java
##########
@@ -104,6 +101,115 @@ public NativeTypeSpec spec() {
         return typeSpec;
     }
 
+    /**
+     * Return the native type for specified object.
+     *
+     * @return {@code null} for {@code null} value. Otherwise returns NativeType according to the value's type.
+     */
+    public static NativeType fromObject(Object val) {
+        NativeTypeSpec spec = NativeTypeSpec.fromObject(val);
+
+        if (spec == null)
+            return null;
+
+        switch (spec) {
+            case BYTE:
+                return BYTE;
+
+            case SHORT:
+                return SHORT;
+
+            case INTEGER:
+                return INTEGER;
+
+            case LONG:
+                return LONG;
+
+            case FLOAT:
+                return FLOAT;
+
+            case DOUBLE:
+                return DOUBLE;
+
+            case UUID:
+                return UUID;
+
+            case STRING:
+                return new VarlenNativeType(NativeTypeSpec.STRING, ((CharSequence)val).length());
+
+            case BYTES:
+                return new VarlenNativeType(NativeTypeSpec.BYTES, ((byte[])val).length);
+
+            case BITMASK:
+                return BitmaskNativeType.of(((BitSet)val).length());
+
+            default:
+                assert false : "Unexpected type: " + spec;
+                return null;

Review comment:
       ```suggestion
                   assert false : "Unexpected type: " + spec;
                   
                   return null;
   ```




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r633447084



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/NativeType.java
##########
@@ -104,6 +100,107 @@ public NativeTypeSpec spec() {
         return typeSpec;
     }
 
+    /**
+     * Return the native type for specified object.
+     *
+     * @return {@code null} for {@code null} value. Otherwise returns NativeType according to the value's type.
+     */
+    public static NativeType fromObject(Object val) {
+        NativeTypeSpec spec = NativeTypeSpec.fromObject(val);
+
+        if (spec == null)
+            return null;
+
+        switch (spec) {
+            case BYTE:
+                return BYTE;
+
+            case SHORT:
+                return SHORT;
+
+            case INTEGER:
+                return INTEGER;
+
+            case LONG:
+                return LONG;
+
+            case FLOAT:
+                return FLOAT;
+
+            case DOUBLE:
+                return DOUBLE;
+
+            case UUID:
+                return UUID;
+
+            case STRING:
+                return new VarlenNativeType(NativeTypeSpec.STRING, ((CharSequence)val).length());

Review comment:
       ((CharSequence)val).length() return size in chars, but not bytes.

##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/Columns.java
##########
@@ -309,6 +310,34 @@ public int columnIndex(String colName) {
         throw new NoSuchElementException("No field '" + colName + "' defined");
     }
 
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        Columns columns = (Columns)o;
+
+        return firstVarlenColIdx == columns.firstVarlenColIdx
+            && nullMapSize == columns.nullMapSize
+            && Arrays.equals(cols, columns.cols)
+            && Arrays.equals(foldingTbl, columns.foldingTbl)
+            && Arrays.equals(foldingMask, columns.foldingMask);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int result = Objects.hash(firstVarlenColIdx, nullMapSize);
+
+        result = 31 * result + Arrays.hashCode(cols);
+        result = 31 * result + Arrays.hashCode(foldingTbl);
+        result = 31 * result + Arrays.hashCode(foldingMask);

Review comment:
       ```suggestion
           int result =  Arrays.hashCode(cols);
   ```

##########
File path: modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
##########
@@ -243,9 +247,9 @@ public void testFixedNullableKeyFixedNullableValue() {
     @Test
     public void testFixedNullableKeyVarlenNullableValue() {
         Column[] keyCols = new Column[] {new Column("keyIntCol", INTEGER, true)};
-        Column[] valCols = new Column[] {new Column("valStrCol", STRING, true)};
+        Column[] valCols = new Column[] {new Column("valStrCol", NativeType.of(ColumnType.string()), true)};

Review comment:
       ```suggestion
           Column[] valCols = new Column[] {new Column("valStrCol", VarlenNativeType.STRING, true)};
   ```

##########
File path: modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
##########
@@ -328,10 +332,10 @@ public void testFixedNullableKeyVarlenValue() {
 
     @Test
     public void testVarlenKeyFixedNullableValue() {
-        Column[] keyCols = new Column[] {new Column("keyStrCol", STRING, false)};
+        Column[] keyCols = new Column[] {new Column("keyStrCol", NativeType.of(ColumnType.string()), false)};

Review comment:
       ```suggestion
           Column[] keyCols = new Column[] {new Column("keyStrCol", VarlenNativeType.STRING, false)};
   ```

##########
File path: modules/api/src/main/java/org/apache/ignite/table/ColumnNotFoundException.java
##########
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.table;
+
+import org.apache.ignite.lang.IgniteException;
+
+/**
+ * Invalid tuple invocation exception is thrown when tuple doesn't match the table schema.
+ */
+public class ColumnNotFoundException extends IgniteException {

Review comment:
       Should ColumnNotFoundException extends InvalidSchemaException instead?

##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/Columns.java
##########
@@ -309,6 +310,34 @@ public int columnIndex(String colName) {
         throw new NoSuchElementException("No field '" + colName + "' defined");
     }
 
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        Columns columns = (Columns)o;
+
+        return firstVarlenColIdx == columns.firstVarlenColIdx
+            && nullMapSize == columns.nullMapSize
+            && Arrays.equals(cols, columns.cols)
+            && Arrays.equals(foldingTbl, columns.foldingTbl)
+            && Arrays.equals(foldingMask, columns.foldingMask);

Review comment:
       ```suggestion
           return Arrays.equals(cols, columns.cols);
   ```

##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/VarlenNativeType.java
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.schema;
+
+/**
+ * Types with various length (STRING, BYTES).
+ */
+public class VarlenNativeType extends NativeType {
+    /**
+     *
+     */

Review comment:
       ```suggestion
       /** */
   ```

##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/VarlenNativeType.java
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.schema;
+
+/**
+ * Types with various length (STRING, BYTES).
+ */
+public class VarlenNativeType extends NativeType {
+    /**
+     *
+     */
+    public static final NativeType STRING = new org.apache.ignite.internal.schema.VarlenNativeType(NativeTypeSpec.STRING, 0);
+
+    /**
+     *
+     */

Review comment:
       ```suggestion
       /** */
   ```

##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/NativeType.java
##########
@@ -104,6 +100,107 @@ public NativeTypeSpec spec() {
         return typeSpec;
     }
 
+    /**
+     * Return the native type for specified object.
+     *
+     * @return {@code null} for {@code null} value. Otherwise returns NativeType according to the value's type.
+     */
+    public static NativeType fromObject(Object val) {
+        NativeTypeSpec spec = NativeTypeSpec.fromObject(val);
+
+        if (spec == null)
+            return null;
+
+        switch (spec) {
+            case BYTE:
+                return BYTE;
+
+            case SHORT:
+                return SHORT;
+
+            case INTEGER:
+                return INTEGER;
+
+            case LONG:
+                return LONG;
+
+            case FLOAT:
+                return FLOAT;
+
+            case DOUBLE:
+                return DOUBLE;
+
+            case UUID:
+                return UUID;
+
+            case STRING:
+                return new VarlenNativeType(NativeTypeSpec.STRING, ((CharSequence)val).length());
+
+            case BYTES:
+                return new VarlenNativeType(NativeTypeSpec.BYTES, ((byte[])val).length);
+
+            case BITMASK:
+                return BitmaskNativeType.of(((BitSet)val).length());
+
+            default:
+                assert false : "Unexpected type: " + spec;
+                return null;
+        }
+    }
+
+    /** */
+    public static NativeType of(ColumnType type) {
+        switch (type.typeSpec()) {
+            case INT8:
+                return BYTE;
+
+            case INT16:
+                return SHORT;
+
+            case INT32:
+                return INTEGER;
+
+            case INT64:
+                return LONG;
+
+            case UINT8:
+            case UINT16:
+            case UINT32:
+            case UINT64:
+                throw new UnsupportedOperationException("Unsigned types are not supported yet.");
+
+            case FLOAT:
+                return FLOAT;
+
+            case DOUBLE:
+                return DOUBLE;
+
+            case DECIMAL:
+                ColumnType.NumericColumnType numType = (ColumnType.NumericColumnType)type;
+                return new NumericNativeType(numType.precision(), numType.scale());
+
+            case UUID:
+                return UUID;
+
+            case BITMASK:
+                return new BitmaskNativeType(((ColumnType.VarLenColumnType)type).length());
+
+            case STRING:
+                return new VarlenNativeType(NativeTypeSpec.STRING, ((ColumnType.VarLenColumnType)type).length());
+
+            case BLOB:
+                return new VarlenNativeType(NativeTypeSpec.BYTES, ((ColumnType.VarLenColumnType)type).length());
+
+            default:
+                throw new InvalidTypeException("Unexpected type " + type);
+        }
+    }
+
+    /** */
+    public boolean mismatch(NativeType type) {

Review comment:
       ```suggestion
       public boolean mismatch(@NotNull NativeType type) {
           assert type != null;
   ```

##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/RowAssembler.java
##########
@@ -301,7 +302,7 @@ public void appendUuid(UUID uuid) {
      * @param val Column value.
      */
     public void appendString(String val) {
-        checkType(NativeType.STRING);
+        checkType(NativeType.of(ColumnType.stringOf(10)));

Review comment:
       Why ColumnType.stringOf(10) ?

##########
File path: modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
##########
@@ -132,9 +136,9 @@ public void testFixedKeyVarlenNullableValue() {
     @Test
     public void testFixedKeyVarlenValue() {
         Column[] keyCols = new Column[] {new Column("keyShortCol", SHORT, false)};
-        Column[] valCols = new Column[] {new Column("valStrCol", STRING, false)};
+        Column[] valCols = new Column[] {new Column("valStrCol", NativeType.of(ColumnType.string()), false)};

Review comment:
       ```suggestion
           Column[] valCols = new Column[] {new Column("valStrCol", VarlenNativeType.STRING, false)};
   ```

##########
File path: modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
##########
@@ -98,9 +102,9 @@ public void testFixedKeyFixedValue() {
     @Test
     public void testFixedKeyVarlenNullableValue() {
         Column[] keyCols = new Column[] {new Column("keyShortCol", SHORT, false)};
-        Column[] valCols = new Column[] {new Column("valStrCol", STRING, true)};
+        Column[] valCols = new Column[] {new Column("valStrCol", NativeType.of(ColumnType.string()), true)};

Review comment:
       ```suggestion
           Column[] valCols = new Column[] {new Column("valStrCol", VarlenNativeType.STRING, true)};
   ```

##########
File path: modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
##########
@@ -364,10 +368,10 @@ public void testVarlenKeyFixedNullableValue() {
 
     @Test
     public void testVarlenKeyFixedValue() {
-        Column[] keyCols = new Column[] {new Column("keyStrCol", STRING, false)};
+        Column[] keyCols = new Column[] {new Column("keyStrCol", NativeType.of(ColumnType.string()), false)};

Review comment:
       ```suggestion
           Column[] keyCols = new Column[] {new Column("keyStrCol", VarlenNativeType.STRING, false)};
   ```

##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/Columns.java
##########
@@ -309,6 +310,34 @@ public int columnIndex(String colName) {
         throw new NoSuchElementException("No field '" + colName + "' defined");
     }
 
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        Columns columns = (Columns)o;
+
+        return firstVarlenColIdx == columns.firstVarlenColIdx
+            && nullMapSize == columns.nullMapSize
+            && Arrays.equals(cols, columns.cols)
+            && Arrays.equals(foldingTbl, columns.foldingTbl)
+            && Arrays.equals(foldingMask, columns.foldingMask);

Review comment:
       Fields that are calculated from Columns can be omited as they hold cached values for performance reasons.
   

##########
File path: modules/table/src/test/java/org/apache/ignite/internal/table/StrictSchemaOperationsTest.java
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.table;
+
+import org.apache.ignite.internal.schema.Column;
+import org.apache.ignite.internal.schema.InvalidTypeException;
+import org.apache.ignite.internal.schema.NativeType;
+import org.apache.ignite.internal.schema.SchemaDescriptor;
+import org.apache.ignite.internal.table.impl.DummyInternalTableImpl;
+import org.apache.ignite.internal.table.impl.DummySchemaManagerImpl;
+import org.apache.ignite.schema.ColumnType;
+import org.apache.ignite.table.ColumnNotFoundException;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+/**
+ * Check data by strict schema.
+ * <p>
+ */
+public class StrictSchemaOperationsTest {

Review comment:
       Let's add positive test cases.
   Let's add positive test for string of 3 chars with high surrogates (a string which doesn't fit 3 bytes).

##########
File path: modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
##########
@@ -391,10 +395,10 @@ public void testVarlenKeyFixedValue() {
 
     @Test
     public void testVarlenKeyVarlenNullableValue() {
-        Column[] keyCols = new Column[] {new Column("keyStrCol", STRING, false)};
+        Column[] keyCols = new Column[] {new Column("keyStrCol", NativeType.of(ColumnType.string()), false)};

Review comment:
       ```suggestion
           Column[] keyCols = new Column[] {new Column("keyStrCol", VarlenNativeType.STRING, false)};
   ```

##########
File path: modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
##########
@@ -295,9 +299,9 @@ public void testFixedNullableKeyVarlenNullableValue() {
     @Test
     public void testFixedNullableKeyVarlenValue() {
         Column[] keyCols = new Column[] {new Column("keyByteCol", BYTE, true)};
-        Column[] valCols = new Column[] {new Column("valStrCol", STRING, false)};
+        Column[] valCols = new Column[] {new Column("valStrCol", NativeType.of(ColumnType.string()), false)};

Review comment:
       ```suggestion
           Column[] valCols = new Column[] {new Column("valStrCol", VarlenNativeType.STRING, false)};
   ```




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r635981846



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/Column.java
##########
@@ -26,6 +28,9 @@
  * flag is not taken into account when columns are compared.
  */
 public class Column implements Comparable<Column> {
+    /** Default return NULL. */

Review comment:
       ```suggestion
       /** {@code Null} value supplier. */
   ```




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r635983537



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/NumericNativeType.java
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.schema;
+
+import java.util.Objects;
+import org.apache.ignite.internal.tostring.S;
+
+/**
+ * Numeric column type.
+ */
+public class NumericNativeType extends NativeType {
+    /** Precision. */
+    private final int precision;
+
+    /** Scale. */
+    private final int scale;
+
+    /** Constructor. */
+    NumericNativeType(int precision, int scale) {
+        super(NativeTypeSpec.DECIMAL);
+
+        this.precision = precision;
+        this.scale = scale;
+    }
+
+    /**
+     * @return Precision.
+     */
+    public int precision() {
+        return precision;
+    }
+
+    /**
+     * @return Scale.
+     */
+    public int scale() {
+        return scale;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean mismatch(NativeType type) {
+        return super.mismatch(type)
+            || precision < ((NumericNativeType)type).precision
+            || scale < ((NumericNativeType)type).scale;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        if (!super.equals(o))
+            return false;
+
+        NumericNativeType type = (NumericNativeType)o;
+
+        return precision == type.precision &&
+            scale == type.scale;
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        return Objects.hash(super.hashCode(), precision, scale);
+    }
+
+

Review comment:
       ```suggestion
   
   ```




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r635075882



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/NumericNativeType.java
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.schema;
+
+import java.util.Objects;
+import org.apache.ignite.internal.tostring.S;
+
+/**
+ * Numeric column type.
+ */
+public class NumericNativeType extends NativeType {
+    /** Precision. */
+    private final int precision;
+
+    /** Scale. */
+    private final int scale;
+
+    /** Constructor. */
+    NumericNativeType(int precision, int scale) {
+        super(NativeTypeSpec.DECIMAL);
+
+        this.precision = precision;
+        this.scale = scale;
+    }
+
+    /**
+     * @return Precision.
+     */
+    public int precision() {
+        return precision;
+    }
+
+    /**
+     * @return Scale.
+     */
+    public int scale() {
+        return scale;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean mismatch(NativeType type) {
+        return super.mismatch(type)
+            || precision < ((org.apache.ignite.internal.schema.NumericNativeType)type).precision
+            || scale < ((org.apache.ignite.internal.schema.NumericNativeType)type).scale;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        if (!super.equals(o))
+            return false;
+
+        org.apache.ignite.internal.schema.NumericNativeType type = (org.apache.ignite.internal.schema.NumericNativeType)o;

Review comment:
       Let's use simple class name.




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r635076506



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/NumericNativeType.java
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.schema;
+
+import java.util.Objects;
+import org.apache.ignite.internal.tostring.S;
+
+/**
+ * Numeric column type.
+ */
+public class NumericNativeType extends NativeType {
+    /** Precision. */
+    private final int precision;
+
+    /** Scale. */
+    private final int scale;
+
+    /** Constructor. */
+    NumericNativeType(int precision, int scale) {
+        super(NativeTypeSpec.DECIMAL);
+
+        this.precision = precision;
+        this.scale = scale;
+    }
+
+    /**
+     * @return Precision.
+     */
+    public int precision() {
+        return precision;
+    }
+
+    /**
+     * @return Scale.
+     */
+    public int scale() {
+        return scale;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean mismatch(NativeType type) {
+        return super.mismatch(type)
+            || precision < ((org.apache.ignite.internal.schema.NumericNativeType)type).precision
+            || scale < ((org.apache.ignite.internal.schema.NumericNativeType)type).scale;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        if (!super.equals(o))
+            return false;
+
+        org.apache.ignite.internal.schema.NumericNativeType type = (org.apache.ignite.internal.schema.NumericNativeType)o;

Review comment:
       ```suggestion
           NumericNativeType type = (NumericNativeType)o;
   ```




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r635986463



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/VarlenNativeType.java
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.schema;
+
+import org.apache.ignite.internal.tostring.S;
+
+/**
+ * Types with various length (STRING, BYTES).

Review comment:
       ```suggestion
    * Variable-length native type.
   ```




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r635076243



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/NumericNativeType.java
##########
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.schema;
+
+import java.util.Objects;
+import org.apache.ignite.internal.tostring.S;
+
+/**
+ * Numeric column type.
+ */
+public class NumericNativeType extends NativeType {
+    /** Precision. */
+    private final int precision;
+
+    /** Scale. */
+    private final int scale;
+
+    /** Constructor. */
+    NumericNativeType(int precision, int scale) {
+        super(NativeTypeSpec.DECIMAL);
+
+        this.precision = precision;
+        this.scale = scale;
+    }
+
+    /**
+     * @return Precision.
+     */
+    public int precision() {
+        return precision;
+    }
+
+    /**
+     * @return Scale.
+     */
+    public int scale() {
+        return scale;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean mismatch(NativeType type) {
+        return super.mismatch(type)
+            || precision < ((org.apache.ignite.internal.schema.NumericNativeType)type).precision
+            || scale < ((org.apache.ignite.internal.schema.NumericNativeType)type).scale;

Review comment:
       ```suggestion
               || precision < ((NumericNativeType)type).precision
               || scale < ((NumericNativeType)type).scale;
   ```




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r635077480



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/VarlenNativeType.java
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.schema;
+
+import org.apache.ignite.internal.tostring.S;
+
+/**
+ * Types with various length (STRING, BYTES).
+ */
+public class VarlenNativeType extends NativeType {
+    /** Length of the type. */
+    private final int len;
+
+    /**
+     * @param typeSpec Type spec.
+     * @param len Type length.
+     */
+    protected VarlenNativeType(NativeTypeSpec typeSpec, int len) {
+        super(typeSpec);
+
+        this.len = len;
+    }
+
+    /** {@inheritDoc} */
+    @Override public boolean mismatch(NativeType type) {
+        return super.mismatch(type) || len < ((org.apache.ignite.internal.schema.VarlenNativeType)type).len;

Review comment:
       ```suggestion
           return super.mismatch(type) || len < ((VarlenNativeType)type).len;
   ```




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r633447084



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/NativeType.java
##########
@@ -104,6 +100,107 @@ public NativeTypeSpec spec() {
         return typeSpec;
     }
 
+    /**
+     * Return the native type for specified object.
+     *
+     * @return {@code null} for {@code null} value. Otherwise returns NativeType according to the value's type.
+     */
+    public static NativeType fromObject(Object val) {
+        NativeTypeSpec spec = NativeTypeSpec.fromObject(val);
+
+        if (spec == null)
+            return null;
+
+        switch (spec) {
+            case BYTE:
+                return BYTE;
+
+            case SHORT:
+                return SHORT;
+
+            case INTEGER:
+                return INTEGER;
+
+            case LONG:
+                return LONG;
+
+            case FLOAT:
+                return FLOAT;
+
+            case DOUBLE:
+                return DOUBLE;
+
+            case UUID:
+                return UUID;
+
+            case STRING:
+                return new VarlenNativeType(NativeTypeSpec.STRING, ((CharSequence)val).length());

Review comment:
       ((CharSequence)val).length() return size in chars, but not bytes.

##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/Columns.java
##########
@@ -309,6 +310,34 @@ public int columnIndex(String colName) {
         throw new NoSuchElementException("No field '" + colName + "' defined");
     }
 
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        Columns columns = (Columns)o;
+
+        return firstVarlenColIdx == columns.firstVarlenColIdx
+            && nullMapSize == columns.nullMapSize
+            && Arrays.equals(cols, columns.cols)
+            && Arrays.equals(foldingTbl, columns.foldingTbl)
+            && Arrays.equals(foldingMask, columns.foldingMask);
+    }
+
+    /** {@inheritDoc} */
+    @Override public int hashCode() {
+        int result = Objects.hash(firstVarlenColIdx, nullMapSize);
+
+        result = 31 * result + Arrays.hashCode(cols);
+        result = 31 * result + Arrays.hashCode(foldingTbl);
+        result = 31 * result + Arrays.hashCode(foldingMask);

Review comment:
       ```suggestion
           int result =  Arrays.hashCode(cols);
   ```

##########
File path: modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
##########
@@ -243,9 +247,9 @@ public void testFixedNullableKeyFixedNullableValue() {
     @Test
     public void testFixedNullableKeyVarlenNullableValue() {
         Column[] keyCols = new Column[] {new Column("keyIntCol", INTEGER, true)};
-        Column[] valCols = new Column[] {new Column("valStrCol", STRING, true)};
+        Column[] valCols = new Column[] {new Column("valStrCol", NativeType.of(ColumnType.string()), true)};

Review comment:
       ```suggestion
           Column[] valCols = new Column[] {new Column("valStrCol", VarlenNativeType.STRING, true)};
   ```

##########
File path: modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
##########
@@ -328,10 +332,10 @@ public void testFixedNullableKeyVarlenValue() {
 
     @Test
     public void testVarlenKeyFixedNullableValue() {
-        Column[] keyCols = new Column[] {new Column("keyStrCol", STRING, false)};
+        Column[] keyCols = new Column[] {new Column("keyStrCol", NativeType.of(ColumnType.string()), false)};

Review comment:
       ```suggestion
           Column[] keyCols = new Column[] {new Column("keyStrCol", VarlenNativeType.STRING, false)};
   ```

##########
File path: modules/api/src/main/java/org/apache/ignite/table/ColumnNotFoundException.java
##########
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.table;
+
+import org.apache.ignite.lang.IgniteException;
+
+/**
+ * Invalid tuple invocation exception is thrown when tuple doesn't match the table schema.
+ */
+public class ColumnNotFoundException extends IgniteException {

Review comment:
       Should ColumnNotFoundException extends InvalidSchemaException instead?

##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/Columns.java
##########
@@ -309,6 +310,34 @@ public int columnIndex(String colName) {
         throw new NoSuchElementException("No field '" + colName + "' defined");
     }
 
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        Columns columns = (Columns)o;
+
+        return firstVarlenColIdx == columns.firstVarlenColIdx
+            && nullMapSize == columns.nullMapSize
+            && Arrays.equals(cols, columns.cols)
+            && Arrays.equals(foldingTbl, columns.foldingTbl)
+            && Arrays.equals(foldingMask, columns.foldingMask);

Review comment:
       ```suggestion
           return Arrays.equals(cols, columns.cols);
   ```

##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/VarlenNativeType.java
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.schema;
+
+/**
+ * Types with various length (STRING, BYTES).
+ */
+public class VarlenNativeType extends NativeType {
+    /**
+     *
+     */

Review comment:
       ```suggestion
       /** */
   ```

##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/VarlenNativeType.java
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.schema;
+
+/**
+ * Types with various length (STRING, BYTES).
+ */
+public class VarlenNativeType extends NativeType {
+    /**
+     *
+     */
+    public static final NativeType STRING = new org.apache.ignite.internal.schema.VarlenNativeType(NativeTypeSpec.STRING, 0);
+
+    /**
+     *
+     */

Review comment:
       ```suggestion
       /** */
   ```

##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/NativeType.java
##########
@@ -104,6 +100,107 @@ public NativeTypeSpec spec() {
         return typeSpec;
     }
 
+    /**
+     * Return the native type for specified object.
+     *
+     * @return {@code null} for {@code null} value. Otherwise returns NativeType according to the value's type.
+     */
+    public static NativeType fromObject(Object val) {
+        NativeTypeSpec spec = NativeTypeSpec.fromObject(val);
+
+        if (spec == null)
+            return null;
+
+        switch (spec) {
+            case BYTE:
+                return BYTE;
+
+            case SHORT:
+                return SHORT;
+
+            case INTEGER:
+                return INTEGER;
+
+            case LONG:
+                return LONG;
+
+            case FLOAT:
+                return FLOAT;
+
+            case DOUBLE:
+                return DOUBLE;
+
+            case UUID:
+                return UUID;
+
+            case STRING:
+                return new VarlenNativeType(NativeTypeSpec.STRING, ((CharSequence)val).length());
+
+            case BYTES:
+                return new VarlenNativeType(NativeTypeSpec.BYTES, ((byte[])val).length);
+
+            case BITMASK:
+                return BitmaskNativeType.of(((BitSet)val).length());
+
+            default:
+                assert false : "Unexpected type: " + spec;
+                return null;
+        }
+    }
+
+    /** */
+    public static NativeType of(ColumnType type) {
+        switch (type.typeSpec()) {
+            case INT8:
+                return BYTE;
+
+            case INT16:
+                return SHORT;
+
+            case INT32:
+                return INTEGER;
+
+            case INT64:
+                return LONG;
+
+            case UINT8:
+            case UINT16:
+            case UINT32:
+            case UINT64:
+                throw new UnsupportedOperationException("Unsigned types are not supported yet.");
+
+            case FLOAT:
+                return FLOAT;
+
+            case DOUBLE:
+                return DOUBLE;
+
+            case DECIMAL:
+                ColumnType.NumericColumnType numType = (ColumnType.NumericColumnType)type;
+                return new NumericNativeType(numType.precision(), numType.scale());
+
+            case UUID:
+                return UUID;
+
+            case BITMASK:
+                return new BitmaskNativeType(((ColumnType.VarLenColumnType)type).length());
+
+            case STRING:
+                return new VarlenNativeType(NativeTypeSpec.STRING, ((ColumnType.VarLenColumnType)type).length());
+
+            case BLOB:
+                return new VarlenNativeType(NativeTypeSpec.BYTES, ((ColumnType.VarLenColumnType)type).length());
+
+            default:
+                throw new InvalidTypeException("Unexpected type " + type);
+        }
+    }
+
+    /** */
+    public boolean mismatch(NativeType type) {

Review comment:
       ```suggestion
       public boolean mismatch(@NotNull NativeType type) {
           assert type != null;
   ```

##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/RowAssembler.java
##########
@@ -301,7 +302,7 @@ public void appendUuid(UUID uuid) {
      * @param val Column value.
      */
     public void appendString(String val) {
-        checkType(NativeType.STRING);
+        checkType(NativeType.of(ColumnType.stringOf(10)));

Review comment:
       Why ColumnType.stringOf(10) ?

##########
File path: modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
##########
@@ -132,9 +136,9 @@ public void testFixedKeyVarlenNullableValue() {
     @Test
     public void testFixedKeyVarlenValue() {
         Column[] keyCols = new Column[] {new Column("keyShortCol", SHORT, false)};
-        Column[] valCols = new Column[] {new Column("valStrCol", STRING, false)};
+        Column[] valCols = new Column[] {new Column("valStrCol", NativeType.of(ColumnType.string()), false)};

Review comment:
       ```suggestion
           Column[] valCols = new Column[] {new Column("valStrCol", VarlenNativeType.STRING, false)};
   ```

##########
File path: modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
##########
@@ -98,9 +102,9 @@ public void testFixedKeyFixedValue() {
     @Test
     public void testFixedKeyVarlenNullableValue() {
         Column[] keyCols = new Column[] {new Column("keyShortCol", SHORT, false)};
-        Column[] valCols = new Column[] {new Column("valStrCol", STRING, true)};
+        Column[] valCols = new Column[] {new Column("valStrCol", NativeType.of(ColumnType.string()), true)};

Review comment:
       ```suggestion
           Column[] valCols = new Column[] {new Column("valStrCol", VarlenNativeType.STRING, true)};
   ```

##########
File path: modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
##########
@@ -364,10 +368,10 @@ public void testVarlenKeyFixedNullableValue() {
 
     @Test
     public void testVarlenKeyFixedValue() {
-        Column[] keyCols = new Column[] {new Column("keyStrCol", STRING, false)};
+        Column[] keyCols = new Column[] {new Column("keyStrCol", NativeType.of(ColumnType.string()), false)};

Review comment:
       ```suggestion
           Column[] keyCols = new Column[] {new Column("keyStrCol", VarlenNativeType.STRING, false)};
   ```

##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/Columns.java
##########
@@ -309,6 +310,34 @@ public int columnIndex(String colName) {
         throw new NoSuchElementException("No field '" + colName + "' defined");
     }
 
+    /** {@inheritDoc} */
+    @Override public boolean equals(Object o) {
+        if (this == o)
+            return true;
+
+        if (o == null || getClass() != o.getClass())
+            return false;
+
+        Columns columns = (Columns)o;
+
+        return firstVarlenColIdx == columns.firstVarlenColIdx
+            && nullMapSize == columns.nullMapSize
+            && Arrays.equals(cols, columns.cols)
+            && Arrays.equals(foldingTbl, columns.foldingTbl)
+            && Arrays.equals(foldingMask, columns.foldingMask);

Review comment:
       Fields that are calculated from Columns can be omited as they hold cached values for performance reasons.
   

##########
File path: modules/table/src/test/java/org/apache/ignite/internal/table/StrictSchemaOperationsTest.java
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.table;
+
+import org.apache.ignite.internal.schema.Column;
+import org.apache.ignite.internal.schema.InvalidTypeException;
+import org.apache.ignite.internal.schema.NativeType;
+import org.apache.ignite.internal.schema.SchemaDescriptor;
+import org.apache.ignite.internal.table.impl.DummyInternalTableImpl;
+import org.apache.ignite.internal.table.impl.DummySchemaManagerImpl;
+import org.apache.ignite.schema.ColumnType;
+import org.apache.ignite.table.ColumnNotFoundException;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+/**
+ * Check data by strict schema.
+ * <p>
+ */
+public class StrictSchemaOperationsTest {

Review comment:
       Let's add positive test cases.
   Let's add positive test for string of 3 chars with high surrogates (a string which doesn't fit 3 bytes).

##########
File path: modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
##########
@@ -391,10 +395,10 @@ public void testVarlenKeyFixedValue() {
 
     @Test
     public void testVarlenKeyVarlenNullableValue() {
-        Column[] keyCols = new Column[] {new Column("keyStrCol", STRING, false)};
+        Column[] keyCols = new Column[] {new Column("keyStrCol", NativeType.of(ColumnType.string()), false)};

Review comment:
       ```suggestion
           Column[] keyCols = new Column[] {new Column("keyStrCol", VarlenNativeType.STRING, false)};
   ```

##########
File path: modules/schema/src/test/java/org/apache/ignite/internal/schema/RowAssemblerTest.java
##########
@@ -295,9 +299,9 @@ public void testFixedNullableKeyVarlenNullableValue() {
     @Test
     public void testFixedNullableKeyVarlenValue() {
         Column[] keyCols = new Column[] {new Column("keyByteCol", BYTE, true)};
-        Column[] valCols = new Column[] {new Column("valStrCol", STRING, false)};
+        Column[] valCols = new Column[] {new Column("valStrCol", NativeType.of(ColumnType.string()), false)};

Review comment:
       ```suggestion
           Column[] valCols = new Column[] {new Column("valStrCol", VarlenNativeType.STRING, false)};
   ```




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r635078759



##########
File path: modules/table/src/main/java/org/apache/ignite/internal/table/ColumnNotFoundException.java
##########
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.table;
+
+import org.apache.ignite.lang.IgniteException;
+
+/**
+ * Invalid tuple invocation exception is thrown when tuple doesn't match the table schema.
+ */
+public class ColumnNotFoundException extends IgniteException {

Review comment:
       ```suggestion
   public class ColumnNotFoundException extends InvalidSchemaException {
   ```




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] ygerzhedovich commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
ygerzhedovich commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r631866673



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/Row.java
##########
@@ -228,6 +229,11 @@ public Double doubleValueBoxed(int col) throws InvalidTypeException {
         return off < 0 ? null : readDouble(offset(off));
     }
 
+    public BigDecimal decimalValue(int idx) {
+        // TODO: decimal support

Review comment:
       ```suggestion
           // TODO: IGNITE-13668 decimal support
   ```




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r635073365



##########
File path: modules/table/src/test/java/org/apache/ignite/internal/table/StrictSchemaOperationsTest.java
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.table;
+
+import org.apache.ignite.internal.schema.Column;
+import org.apache.ignite.internal.schema.InvalidTypeException;
+import org.apache.ignite.internal.schema.NativeType;
+import org.apache.ignite.internal.schema.NativeTypes;
+import org.apache.ignite.internal.schema.SchemaDescriptor;
+import org.apache.ignite.internal.table.impl.DummyInternalTableImpl;
+import org.apache.ignite.internal.table.impl.DummySchemaManagerImpl;
+import org.apache.ignite.schema.ColumnType;
+import org.apache.ignite.table.Table;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+/**
+ * Check data by strict schema.
+ * <p>

Review comment:
       ```suggestion
   ```




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r635071298



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/NativeTypes.java
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.schema;
+
+/**
+ * A thin wrapper over {@link NativeTypeSpec} to instantiate parameterized constrained types.
+ */
+public class NativeTypes {
+    /** */
+    public static final NativeType BYTE = new NativeType(NativeTypeSpec.BYTE, 1);
+
+    /** */
+    public static final NativeType SHORT = new NativeType(NativeTypeSpec.SHORT, 2);
+
+    /** */
+    public static final NativeType INTEGER = new NativeType(NativeTypeSpec.INTEGER, 4);
+
+    /** */
+    public static final NativeType LONG = new NativeType(NativeTypeSpec.LONG, 8);
+
+    /** */
+    public static final NativeType FLOAT = new NativeType(NativeTypeSpec.FLOAT, 4);
+
+    /** */
+    public static final NativeType DOUBLE = new NativeType(NativeTypeSpec.DOUBLE, 8);
+
+    /** */
+    public static final NativeType UUID = new NativeType(NativeTypeSpec.UUID, 16);
+
+    /** */
+    public static final NativeType STRING = new org.apache.ignite.internal.schema.VarlenNativeType(NativeTypeSpec.STRING, Integer.MAX_VALUE);

Review comment:
       Add import.




-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] tledkov-gridgain merged pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
tledkov-gridgain merged pull request #123:
URL: https://github.com/apache/ignite-3/pull/123


   


-- 
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:
users@infra.apache.org



[GitHub] [ignite-3] AMashenkov commented on a change in pull request #123: IGNITE-14692 Validate tuple for STRICT schema

Posted by GitBox <gi...@apache.org>.
AMashenkov commented on a change in pull request #123:
URL: https://github.com/apache/ignite-3/pull/123#discussion_r634138282



##########
File path: modules/schema/src/main/java/org/apache/ignite/internal/schema/NativeType.java
##########
@@ -104,6 +101,115 @@ public NativeTypeSpec spec() {
         return typeSpec;
     }
 
+    /**
+     * Return the native type for specified object.
+     *
+     * @return {@code null} for {@code null} value. Otherwise returns NativeType according to the value's type.
+     */
+    public static NativeType fromObject(Object val) {
+        NativeTypeSpec spec = NativeTypeSpec.fromObject(val);
+
+        if (spec == null)
+            return null;
+
+        switch (spec) {
+            case BYTE:
+                return BYTE;
+
+            case SHORT:
+                return SHORT;
+
+            case INTEGER:
+                return INTEGER;
+
+            case LONG:
+                return LONG;
+
+            case FLOAT:
+                return FLOAT;
+
+            case DOUBLE:
+                return DOUBLE;
+
+            case UUID:
+                return UUID;
+
+            case STRING:
+                return new VarlenNativeType(NativeTypeSpec.STRING, ((CharSequence)val).length());
+
+            case BYTES:
+                return new VarlenNativeType(NativeTypeSpec.BYTES, ((byte[])val).length);
+
+            case BITMASK:
+                return BitmaskNativeType.of(((BitSet)val).length());
+
+            default:
+                assert false : "Unexpected type: " + spec;
+                return null;
+        }
+    }
+
+    /** */
+    public static NativeType of(ColumnType type) {

Review comment:
       ```suggestion
       public static NativeType from(ColumnType type) {
   ```




-- 
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:
users@infra.apache.org