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:
[email protected]


Reply via email to