jt2594838 commented on a change in pull request #466: [IOTDB-208] Bloom filter
URL: https://github.com/apache/incubator-iotdb/pull/466#discussion_r337375287
 
 

 ##########
 File path: 
tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/TsFileMetaData.java
 ##########
 @@ -247,9 +271,59 @@ public int serializeTo(OutputStream outputStream) throws 
IOException {
     byteLen += ReadWriteIOUtils.write(totalChunkNum, outputStream);
     byteLen += ReadWriteIOUtils.write(invalidChunkNum, outputStream);
 
+
+    return byteLen;
+  }
+
+  /**
+   * use the given outputStream to serialize bloom filter.
+   *
+   * @param outputStream -output stream to determine byte length
+   * @return -byte length
+   */
+  public int serializeBloomFilter(OutputStream outputStream, 
List<ChunkGroupMetaData> chunkGroupMetaDataList)
+      throws IOException {
+    int byteLen = 0;
+    BloomFilter filter = buildBloomFilter(chunkGroupMetaDataList);
+
+    byte[] bytes = filter.serialize();
+    byteLen += ReadWriteIOUtils.write(ByteBuffer.wrap(bytes), outputStream);
 
 Review comment:
   ```
   outputStream.write(bytes);
   byteLen += bytes.length;
   ```
    should be enough, there is no need to wrap with a ByteBuffer.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to