You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "xtern (via GitHub)" <gi...@apache.org> on 2024/05/27 10:27:08 UTC

[PR] IGNITE-22061 [ignite-3]

xtern opened a new pull request, #3819:
URL: https://github.com/apache/ignite-3/pull/3819

   https://issues.apache.org/jira/browse/IGNITE-22061


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-22061 Use compact representation of BigDecimal to improve values size estimation [ignite-3]

Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #3819:
URL: https://github.com/apache/ignite-3/pull/3819#discussion_r1618849730


##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/MarshallerUtil.java:
##########
@@ -69,6 +70,23 @@ public static int getValueSize(Object val, NativeType type) throws InvalidTypeEx
         }
     }
 
+    /**
+     * Converts the passed value to a more compact form, if possible.
+     *
+     * @param value Field value.
+     * @param type Mapped type.
+     * @return Value in a more compact form, or the original value if it cannot be compacted.
+     */
+    public static Object shrinkValue(Object value, NativeType type) {

Review Comment:
   ```suggestion
       public static <T> T shrinkValue(T value, NativeType 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.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-22061 Use compact representation of BigDecimal to improve values size estimation [ignite-3]

Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #3819:
URL: https://github.com/apache/ignite-3/pull/3819#discussion_r1618847754


##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/reflection/ObjectStatistics.java:
##########
@@ -23,35 +23,81 @@
 import org.apache.ignite.internal.marshaller.Marshaller;
 import org.apache.ignite.internal.schema.Column;
 import org.apache.ignite.internal.schema.SchemaDescriptor;
+import org.apache.ignite.internal.schema.marshaller.MarshallerUtil;
 import org.apache.ignite.internal.schema.row.RowAssembler;
 import org.apache.ignite.internal.type.NativeType;
 import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.TestOnly;
 
 /**
  * Object statistic.
  */
 class ObjectStatistics {
-    /** Cached zero statistics. */
-    private static final ObjectStatistics ZERO_STATISTICS = new ObjectStatistics(-1);
-
     /** Estimated total size of the object. */
     private final int estimatedValueSize;
 
+    private final Object[] values;
+
     /** Constructor. */
-    private ObjectStatistics(int estimatedValueSize) {
+    private ObjectStatistics(Object[] values, int estimatedValueSize) {
+        this.values = values;
         this.estimatedValueSize = estimatedValueSize;
     }
 
-    private int getEstimatedValueSize() {
+    int estimatedValueSize() {
         return estimatedValueSize;
     }
 
+    @TestOnly
+    <T> T value(int index) {
+        return (T) values[index];
+    }
+
+    static MarshallerRowBuilder createRowBuilder(SchemaDescriptor schema, Marshaller keyMarsh, Object key) {

Review Comment:
   Expression like `ObjectStatistics.createRowBuilder(...)` looks weird. 
   
   Let's move factory methods to MarshallerRowBuilder class or MarshallerUtil.



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-22061 Use compact representation of BigDecimal to improve values size estimation [ignite-3]

Posted by "AMashenkov (via GitHub)" <gi...@apache.org>.
AMashenkov commented on code in PR #3819:
URL: https://github.com/apache/ignite-3/pull/3819#discussion_r1618854140


##########
modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshallerImpl.java:
##########
@@ -187,15 +188,18 @@ private void gatherStatistics(
             }
 
             col.validate(val);
-            targetTuple.values.put(col.name(), val);
 
             if (val != null) {
+                val = MarshallerUtil.shrinkValue(val, col.type());

Review Comment:
   Does ti make sense for fix-length types (true == colType.spec().fixedLength()) ? 



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-22061 Use compact representation of BigDecimal to improve values size estimation [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern closed pull request #3819: IGNITE-22061 Use compact representation of BigDecimal to improve values size estimation
URL: https://github.com/apache/ignite-3/pull/3819


-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-22061 Use compact representation of BigDecimal to improve values size estimation [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #3819:
URL: https://github.com/apache/ignite-3/pull/3819#discussion_r1618962536


##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/reflection/ObjectStatistics.java:
##########
@@ -23,35 +23,81 @@
 import org.apache.ignite.internal.marshaller.Marshaller;
 import org.apache.ignite.internal.schema.Column;
 import org.apache.ignite.internal.schema.SchemaDescriptor;
+import org.apache.ignite.internal.schema.marshaller.MarshallerUtil;
 import org.apache.ignite.internal.schema.row.RowAssembler;
 import org.apache.ignite.internal.type.NativeType;
 import org.jetbrains.annotations.Nullable;
+import org.jetbrains.annotations.TestOnly;
 
 /**
  * Object statistic.
  */
 class ObjectStatistics {
-    /** Cached zero statistics. */
-    private static final ObjectStatistics ZERO_STATISTICS = new ObjectStatistics(-1);
-
     /** Estimated total size of the object. */
     private final int estimatedValueSize;
 
+    private final Object[] values;
+
     /** Constructor. */
-    private ObjectStatistics(int estimatedValueSize) {
+    private ObjectStatistics(Object[] values, int estimatedValueSize) {
+        this.values = values;
         this.estimatedValueSize = estimatedValueSize;
     }
 
-    private int getEstimatedValueSize() {
+    int estimatedValueSize() {
         return estimatedValueSize;
     }
 
+    @TestOnly
+    <T> T value(int index) {
+        return (T) values[index];
+    }
+
+    static MarshallerRowBuilder createRowBuilder(SchemaDescriptor schema, Marshaller keyMarsh, Object key) {

Review Comment:
   Moved to `MarshallerRowBuilder`, thanks.



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-22061 Use compact representation of BigDecimal to improve values size estimation [ignite-3]

Posted by "xtern (via GitHub)" <gi...@apache.org>.
xtern commented on code in PR #3819:
URL: https://github.com/apache/ignite-3/pull/3819#discussion_r1618961825


##########
modules/table/src/main/java/org/apache/ignite/internal/schema/marshaller/TupleMarshallerImpl.java:
##########
@@ -187,15 +188,18 @@ private void gatherStatistics(
             }
 
             col.validate(val);
-            targetTuple.values.put(col.name(), val);
 
             if (val != null) {
+                val = MarshallerUtil.shrinkValue(val, col.type());

Review Comment:
   Done, thanks



##########
modules/schema/src/main/java/org/apache/ignite/internal/schema/marshaller/MarshallerUtil.java:
##########
@@ -69,6 +70,23 @@ public static int getValueSize(Object val, NativeType type) throws InvalidTypeEx
         }
     }
 
+    /**
+     * Converts the passed value to a more compact form, if possible.
+     *
+     * @param value Field value.
+     * @param type Mapped type.
+     * @return Value in a more compact form, or the original value if it cannot be compacted.
+     */
+    public static Object shrinkValue(Object value, NativeType type) {

Review Comment:
   Done, thanks



-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org