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/18 07:20:07 UTC

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

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