From e3e1743a85e8e3be9e1d9f970e938b73aabd1c57 Mon Sep 17 00:00:00 2001 From: Sunjeet Singh Date: Sat, 7 Sep 2024 07:01:49 -0700 Subject: [PATCH] Tests for set and map type state resharding --- ...llowListTypeDataElementsSplitJoinTest.java | 4 +- .../list/HollowListTypeReadStateTest.java | 4 +- ...llowListTypeDataElementsSplitJoinTest.java | 2 +- ...ollowMapTypeDataElementsSplitJoinTest.java | 32 ++++++++++--- ...ollowMapTypeDataElementsSplitJoinTest.java | 12 ++--- .../map/HollowMapTypeReadStateTest.java | 47 +++++++++++++++++++ ...ollowMapTypeDataElementsSplitJoinTest.java | 2 +- ...owObjectTypeDataElementsSplitJoinTest.java | 2 +- ...ollowSetTypeDataElementsSplitJoinTest.java | 11 +++++ .../set/HollowSetTypeReadStateTest.java | 47 +++++++++++++++++++ 10 files changed, 141 insertions(+), 22 deletions(-) create mode 100644 hollow/src/test/java/com/netflix/hollow/core/read/engine/map/HollowMapTypeReadStateTest.java create mode 100644 hollow/src/test/java/com/netflix/hollow/core/read/engine/set/HollowSetTypeReadStateTest.java diff --git a/hollow/src/test/java/com/netflix/hollow/core/read/engine/list/HollowListTypeDataElementsSplitJoinTest.java b/hollow/src/test/java/com/netflix/hollow/core/read/engine/list/HollowListTypeDataElementsSplitJoinTest.java index 610e95915..424c801dd 100644 --- a/hollow/src/test/java/com/netflix/hollow/core/read/engine/list/HollowListTypeDataElementsSplitJoinTest.java +++ b/hollow/src/test/java/com/netflix/hollow/core/read/engine/list/HollowListTypeDataElementsSplitJoinTest.java @@ -19,7 +19,7 @@ public void testSplitThenJoin() throws IOException { int maxNumListRecords = 100; // 1->2->1, 1->4->1, ... - for (int numRecords=0;numRecords new IllegalArgumentException("Array is empty")); - // populate write state with that many ordinals - super.populateWriteStateEngine(numKeyValueOrdinals); + if (maps.length > 0) { + int numKeyValueOrdinals = 1 + Arrays.stream(maps) + .flatMap(Arrays::stream) + .flatMapToInt(Arrays::stream) + .max() + .orElseThrow(() -> new IllegalArgumentException("Array is empty")); + // populate write state with that many ordinals + super.populateWriteStateEngine(numKeyValueOrdinals); + } for(int[][] map : maps) { HollowMapWriteRecord rec = new HollowMapWriteRecord(); for (int[] entry : map) { @@ -65,6 +68,21 @@ protected HollowMapTypeReadState populateTypeStateWith(int[][][] maps) throws IO return (HollowMapTypeReadState) readStateEngine.getTypeState("TestMap"); } + protected int[][][] generateListContents(int numRecords) { + int[][][] maps = new int[numRecords][][]; + Random random = new Random(); + int maxEntries = 10; + for (int i=0;i2->1, 1->4->1, ... - for (int listRecord=0;listRecord