vladErmakov07 commented on a change in pull request #243:
URL: https://github.com/apache/ignite-3/pull/243#discussion_r681816561



##########
File path: 
modules/schema/src/main/java/org/apache/ignite/internal/schema/row/Row.java
##########
@@ -233,8 +235,55 @@ public Double doubleValueBoxed(int col) throws 
InvalidTypeException {
      * @throws InvalidTypeException If actual column type does not match the 
requested column type.
      */
     public BigDecimal decimalValue(int col) throws InvalidTypeException {
-        // TODO: IGNITE-13668 decimal support
-        return null;
+        long offLen = findColumn(col, NativeTypeSpec.DECIMAL);
+
+        if (offLen < 0)
+            return offLen == -1 ? null : 
(BigDecimal)rowSchema().column(col).defaultValue();
+
+        int off = offset(offLen);
+        int len = length(offLen);
+
+        DecimalNativeType type = (DecimalNativeType)schema.column(col).type();
+
+        int shift;
+        int scale;
+
+        if (type.scale() == 0) {
+            shift = 0;
+            scale = 0;
+        } else if (type.scale() < Byte.MAX_VALUE) {
+            shift = 1;
+            scale = readByte(off);
+        } else if (type.scale() < Short.MAX_VALUE) {
+            shift = 2;
+            scale = readShort(off);
+        } else {
+            shift = 4;
+            scale = readInteger(off);
+        }

Review comment:
       Since the values will be cast to user-defined scale, I decided not to 
store the original scale at all.

##########
File path: 
modules/schema/src/test/java/org/apache/ignite/internal/schema/RowTest.java
##########
@@ -421,6 +433,26 @@ else if (type == NativeTypeSpec.STRING) {
                         nonNullVarLenValSize += 
RowAssembler.utf8EncodedLength((CharSequence)vals[i]);
                     }
                 }
+                else if (type == NativeTypeSpec.NUMBER) {
+                    if (schema.isKeyColumn(i)) {
+                        nonNullVarLenKeyCols++;
+                        nonNullVarLenKeySize += 
NumericTypeUtils.sizeInBytes((BigInteger)vals[i]);

Review comment:
       Done




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to