AMashenkov commented on a change in pull request #132:
URL: https://github.com/apache/ignite-3/pull/132#discussion_r635023355



##########
File path: 
modules/schema/src/main/java/org/apache/ignite/internal/schema/configuration/SchemaDescriptorConverter.java
##########
@@ -0,0 +1,133 @@
+/*
+ * 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.configuration;
+
+import org.apache.ignite.internal.schema.Bitmask;
+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.NativeTypeSpec;
+import org.apache.ignite.internal.schema.NumericNativeType;
+import org.apache.ignite.internal.schema.SchemaDescriptor;
+
+import org.apache.ignite.internal.schema.VarlenNativeType;
+import org.apache.ignite.schema.ColumnType;
+import org.apache.ignite.schema.SchemaTable;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import static org.apache.ignite.internal.schema.NativeType.BYTE;
+import static org.apache.ignite.internal.schema.NativeType.DOUBLE;
+import static org.apache.ignite.internal.schema.NativeType.FLOAT;
+import static org.apache.ignite.internal.schema.NativeType.INTEGER;
+import static org.apache.ignite.internal.schema.NativeType.LONG;
+import static org.apache.ignite.internal.schema.NativeType.SHORT;
+import static org.apache.ignite.internal.schema.NativeType.UUID;
+
+/** Build SchemaDescriptor from SchemaTable internal configuration. */
+public class SchemaDescriptorConverter {
+    /**
+     * Convert ColumnType to NativeType.
+     *
+     * @param colType ColumnType.
+     * @return NativeType.
+     */
+    private static NativeType convert(ColumnType colType) {
+        assert colType != null;
+
+        ColumnType.ColumnTypeSpec type = colType.typeSpec();
+        switch (type) {
+            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)colType;
+                return new NumericNativeType(numType.precision(), 
numType.scale());
+
+            case UUID:
+                return UUID;
+
+            case BITMASK:
+                return new 
Bitmask(((ColumnType.VarLenColumnType)colType).length());
+
+            case STRING:
+                return new VarlenNativeType(NativeTypeSpec.STRING, 
((ColumnType.VarLenColumnType)colType).length());
+
+            case BLOB:
+                return new VarlenNativeType(NativeTypeSpec.BYTES, 
((ColumnType.VarLenColumnType)colType).length());
+
+                default:

Review comment:
       ```suggestion
               default:
   ```




-- 
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