gortiz commented on code in PR #13303: URL: https://github.com/apache/pinot/pull/13303#discussion_r1738725334
########## pinot-common/src/test/java/org/apache/pinot/common/datablock/ZeroCopyDataBlockSerdeTest.java: ########## @@ -0,0 +1,96 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.common.datablock; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; +import java.util.Collections; +import java.util.Random; +import org.apache.pinot.segment.spi.memory.PinotByteBuffer; +import org.apache.pinot.segment.spi.memory.PinotDataBuffer; +import org.testng.annotations.AfterSuite; +import org.testng.annotations.BeforeSuite; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import static org.testng.Assert.*; + + +public class ZeroCopyDataBlockSerdeTest { + + private DataBlockSerde _originalSerde = null; + + @BeforeSuite + public void setUp() { + _originalSerde = DataBlockUtils.getSerde(DataBlockSerde.Version.V1_V2); + DataBlockUtils.setSerde(DataBlockSerde.Version.V1_V2, new ZeroCopyDataBlockSerde()); + } + + @AfterSuite + public void tearDown() { + if (_originalSerde != null) { + DataBlockUtils.setSerde(DataBlockSerde.Version.V1_V2, _originalSerde); + } + } + + @DataProvider(name = "blocks") + public Object[][] blocks() { + + Random r = new Random(); + byte[] bytes1 = new byte[128]; + r.nextBytes(bytes1); + byte[] bytes2 = new byte[128]; + r.nextBytes(bytes2); + + return new Object[][] { + {"empty error", MetadataBlock.newError(Collections.emptyMap())}, + {"error with single message", MetadataBlock.newError(ImmutableMap.<Integer, String>builder() + .put(123, "error") + .build())}, + {"error with two messages", MetadataBlock.newError(ImmutableMap.<Integer, String>builder() + .put(123, "error") + .put(1234, "another error") + .build())}, + {"eos empty", MetadataBlock.newEos()}, + {"eos with empty stat", new MetadataBlock(Collections.singletonList(PinotDataBuffer.empty()))}, + {"eos with several empty stats", + new MetadataBlock(Lists.newArrayList(PinotDataBuffer.empty(), PinotDataBuffer.empty()))}, + {"eos with one not empty stat", new MetadataBlock(Lists.newArrayList(PinotByteBuffer.wrap(bytes1)))}, + {"eos with two not empty stat", + new MetadataBlock(Lists.newArrayList(PinotByteBuffer.wrap(bytes1), PinotByteBuffer.wrap(bytes2)))} + }; + } + + @Test(dataProvider = "blocks") + void testSerde(String desc, DataBlock block) { Review Comment: It would be great, but it is not easy to create actual row and column blocks here given DataBlockBuilder is in `pinot-core`. I remember I tried to move it to `pinot-common` but I guess I didn't commit the change because there was some issue (maybe some other dependency in `pinot-core`) Instead we are testing these serde properties in `DataBlockSerdeTest`. That is not great, but it is easier to implement right now. > including some edge cases like null dictionary, null data schema etc.? I don't think these are valid cases for row/column blocks -- 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: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org