From 34d9a21e014a3e0cc3a76ca9ea80355fe4411e28 Mon Sep 17 00:00:00 2001 From: Sunjeet Singh Date: Mon, 9 Oct 2023 07:53:54 -0700 Subject: [PATCH] Restore private modifier, cleanup, more test --- .../object/HollowObjectTypeDataElements.java | 4 ++-- .../HollowObjectTypeDataElementsJoinerTest.java | 15 +++++++++++++-- ...llowObjectTypeDataElementsSplitJoinTest.java | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/hollow/src/main/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeDataElements.java b/hollow/src/main/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeDataElements.java index 09ae537b80..a28c629df4 100644 --- a/hollow/src/main/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeDataElements.java +++ b/hollow/src/main/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeDataElements.java @@ -52,8 +52,8 @@ public class HollowObjectTypeDataElements { final long nullValueForField[]; int bitsPerRecord; - int bitsPerUnfilteredField[]; - boolean unfilteredFieldIsIncluded[]; + private int bitsPerUnfilteredField[]; + private boolean unfilteredFieldIsIncluded[]; final ArraySegmentRecycler memoryRecycler; final MemoryMode memoryMode; diff --git a/hollow/src/test/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeDataElementsJoinerTest.java b/hollow/src/test/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeDataElementsJoinerTest.java index 81d0c8d8f3..8c4868480a 100644 --- a/hollow/src/test/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeDataElementsJoinerTest.java +++ b/hollow/src/test/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeDataElementsJoinerTest.java @@ -2,20 +2,31 @@ import static org.junit.Assert.assertEquals; +import com.netflix.hollow.core.write.HollowObjectTypeWriteState; import java.io.IOException; import org.junit.Assert; import org.junit.Test; public class HollowObjectTypeDataElementsJoinerTest extends AbstractHollowObjectTypeDataElementsSplitJoinTest { + @Override + protected void initializeTypeStates() { + writeStateEngine.setTargetMaxTypeShardSize(16); + writeStateEngine.addTypeState(new HollowObjectTypeWriteState(schema)); + } + @Test public void testJoin() throws IOException { HollowObjectTypeDataElementsJoiner joiner = new HollowObjectTypeDataElementsJoiner(); - HollowObjectTypeReadState typeReadState = populateTypeStateWith(5); + HollowObjectTypeReadState typeReadState = populateTypeStateWith(1); assertEquals(1, typeReadState.numShards()); + + HollowObjectTypeReadState typeReadStateSharded = populateTypeStateWith(5); assertDataUnchanged(5); + assertEquals(8, typeReadStateSharded.numShards()); + + HollowObjectTypeDataElements joinedDataElements = joiner.join(typeReadStateSharded.currentDataElements()); - HollowObjectTypeDataElements joinedDataElements = joiner.join(typeReadState.currentDataElements()); typeReadState.setCurrentData(joinedDataElements); assertDataUnchanged(5); diff --git a/hollow/src/test/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeDataElementsSplitJoinTest.java b/hollow/src/test/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeDataElementsSplitJoinTest.java index d87b389ab6..3e2cf99f87 100644 --- a/hollow/src/test/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeDataElementsSplitJoinTest.java +++ b/hollow/src/test/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeDataElementsSplitJoinTest.java @@ -66,6 +66,23 @@ public void testSplitThenJoinWithFilter() throws IOException { } } + @Test + public void testSplitThenJoinWithEmptyJoin() throws IOException { + HollowObjectTypeDataElementsSplitter splitter = new HollowObjectTypeDataElementsSplitter(); + + HollowObjectTypeReadState typeReadState = populateTypeStateWith(1); + assertEquals(1, typeReadState.numShards()); + + HollowObjectTypeDataElements[] splitBy4 = splitter.split(typeReadState.currentDataElements()[0], 4); + assertEquals(-1, splitBy4[1].maxOrdinal); + assertEquals(-1, splitBy4[3].maxOrdinal); + + HollowObjectTypeDataElementsJoiner joiner = new HollowObjectTypeDataElementsJoiner(); + HollowObjectTypeDataElements joined = joiner.join(new HollowObjectTypeDataElements[]{splitBy4[1], splitBy4[3]}); + + assertEquals(-1, joined.maxOrdinal); + } + // manually invoked // @Test public void testSplittingAndJoiningWithSnapshotBlob() throws Exception {