JingsongLi commented on a change in pull request #7913: 
[FLINK-11837][table-runtime-blink] Improve internal data format
URL: https://github.com/apache/flink/pull/7913#discussion_r263359288
 
 

 ##########
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/dataformat/BinaryString.java
 ##########
 @@ -54,21 +62,56 @@ public static BinaryString fromBytes(byte[] bytes) {
                                new MemorySegment[] 
{MemorySegmentFactory.wrap(bytes)}, 0, bytes.length);
        }
 
-       public static BinaryString fromBytes(byte[] bytes, int offset, int 
numBytes) {
-               return new BinaryString(
-                               new MemorySegment[] 
{MemorySegmentFactory.wrap(bytes)}, offset, numBytes);
+       @Override
+       public boolean equals(Object o) {
+               if (o != null && o instanceof BinaryString) {
+                       BinaryString other = (BinaryString) o;
+                       if (javaObject != null && other.javaObject != null) {
+                               return javaObject.equals(other.javaObject);
+                       }
+
+                       ensureMaterialized();
+                       other.ensureMaterialized();
+                       return binaryEquals(other);
+               } else {
+                       return false;
+               }
+       }
+
+       @Override
+       public int hashCode() {
+               ensureMaterialized();
+               return super.hashCode();
        }
 
        @Override
        public String toString() {
-               byte[] bytes = BinaryStringUtil.allocateReuseBytes(sizeInBytes);
-               SegmentsUtil.copyToBytes(segments, offset, bytes, 0, 
sizeInBytes);
-               return new String(bytes, 0, sizeInBytes);
+               if (javaObject == null) {
+                       byte[] bytes = 
SegmentsUtil.allocateReuseBytes(sizeInBytes);
+                       SegmentsUtil.copyToBytes(segments, offset, bytes, 0, 
sizeInBytes);
+                       javaObject = new String(bytes, 0, sizeInBytes);
+               }
+               return javaObject;
+       }
+
+       public void ensureMaterialized() {
 
 Review comment:
   Their ensureMaterialized method parameters are different. For example, 
BinaryGeneric needs a TypeSerializer to generate bytes data correctly.

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


With regards,
Apache Git Services

Reply via email to