You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ro...@apache.org on 2023/05/30 19:44:29 UTC

[pinot] branch master updated: [multistage][bugfix] fix array type empty issue (#10810)

This is an automated email from the ASF dual-hosted git repository.

rongr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new bbf5c14179 [multistage][bugfix] fix array type empty issue (#10810)
bbf5c14179 is described below

commit bbf5c141791f38cdafad484ce9a91d3f47e1588b
Author: Rong Rong <ro...@apache.org>
AuthorDate: Tue May 30 12:44:22 2023 -0700

    [multistage][bugfix] fix array type empty issue (#10810)
    
    * fix array type empty issue on data block.
    * fix metadata block check
    
    ---------
    
    Co-authored-by: Rong Rong <ro...@startree.ai>
---
 .../main/java/org/apache/pinot/common/datablock/BaseDataBlock.java | 7 ++-----
 .../main/java/org/apache/pinot/common/datablock/MetadataBlock.java | 2 +-
 .../java/org/apache/pinot/core/common/datablock/DataBlockTest.java | 7 ++-----
 3 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/pinot-common/src/main/java/org/apache/pinot/common/datablock/BaseDataBlock.java b/pinot-common/src/main/java/org/apache/pinot/common/datablock/BaseDataBlock.java
index 40940f0585..e1cc459e29 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/datablock/BaseDataBlock.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/datablock/BaseDataBlock.java
@@ -186,15 +186,12 @@ public abstract class BaseDataBlock implements DataBlock {
     }
 
     // Read variable size data.
+    _variableSizeDataBytes = new byte[variableSizeDataLength];
     if (variableSizeDataLength != 0) {
-      _variableSizeDataBytes = new byte[variableSizeDataLength];
       byteBuffer.position(variableSizeDataStart);
       byteBuffer.get(_variableSizeDataBytes);
-      _variableSizeData = ByteBuffer.wrap(_variableSizeDataBytes);
-    } else {
-      _variableSizeDataBytes = null;
-      _variableSizeData = null;
     }
+    _variableSizeData = ByteBuffer.wrap(_variableSizeDataBytes);
 
     // Read metadata.
     int metadataLength = byteBuffer.getInt();
diff --git a/pinot-common/src/main/java/org/apache/pinot/common/datablock/MetadataBlock.java b/pinot-common/src/main/java/org/apache/pinot/common/datablock/MetadataBlock.java
index 42852f3539..2e19258d6c 100644
--- a/pinot-common/src/main/java/org/apache/pinot/common/datablock/MetadataBlock.java
+++ b/pinot-common/src/main/java/org/apache/pinot/common/datablock/MetadataBlock.java
@@ -130,7 +130,7 @@ public class MetadataBlock extends BaseDataBlock {
   public MetadataBlock(ByteBuffer byteBuffer)
       throws IOException {
     super(byteBuffer);
-    if (_variableSizeDataBytes != null) {
+    if (_variableSizeDataBytes != null && _variableSizeDataBytes.length > 0) {
       _contents = JSON.readValue(_variableSizeDataBytes, Contents.class);
     } else {
       _contents = new Contents();
diff --git a/pinot-core/src/test/java/org/apache/pinot/core/common/datablock/DataBlockTest.java b/pinot-core/src/test/java/org/apache/pinot/core/common/datablock/DataBlockTest.java
index 593fd62a69..600e8b8ce8 100644
--- a/pinot-core/src/test/java/org/apache/pinot/core/common/datablock/DataBlockTest.java
+++ b/pinot-core/src/test/java/org/apache/pinot/core/common/datablock/DataBlockTest.java
@@ -135,10 +135,7 @@ public class DataBlockTest {
         new DataSchema.ColumnDataType[]{DataSchema.ColumnDataType.INT_ARRAY});
 
     DataBlock dataBlock = DataBlockBuilder.buildFromRows(rows, dataSchema);
-    try {
-      DataBlockUtils.getDataBlock(ByteBuffer.wrap(dataBlock.toBytes())).getIntArray(0, 0);
-    } catch (Exception e) {
-      Assert.assertTrue(e.toString().contains("java.lang.NullPointerException"));
-    }
+    int[] intArray = DataBlockUtils.getDataBlock(ByteBuffer.wrap(dataBlock.toBytes())).getIntArray(0, 0);
+    Assert.assertEquals(intArray.length, 0);
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org