From b3dd29599e94d18b0a2674391fedac051e166040 Mon Sep 17 00:00:00 2001 From: Sunjeet Singh Date: Wed, 11 Oct 2023 07:44:38 -0700 Subject: [PATCH] Cleanup of object read state --- .../object/HollowObjectTypeReadState.java | 17 +- .../HollowObjectTypeReadStateShard.java | 6 +- .../write/HollowObjectTypeWriteState.java | 2 + ...ollowObjectTypeDataElementsJoinerTest.java | 150 +++++++++--------- 4 files changed, 88 insertions(+), 87 deletions(-) diff --git a/hollow/src/main/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeReadState.java b/hollow/src/main/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeReadState.java index c2786e76a0..b0316e0a71 100644 --- a/hollow/src/main/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeReadState.java +++ b/hollow/src/main/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeReadState.java @@ -45,8 +45,8 @@ public class HollowObjectTypeReadState extends HollowTypeReadState implements Ho private final HollowObjectSchema unfilteredSchema; private final HollowObjectSampler sampler; - public static class ShardsHolder { // SNAP: TODO: remove - public final HollowObjectTypeReadStateShard shards[]; // SNAP: TODO: remove + static class ShardsHolder { + final HollowObjectTypeReadStateShard shards[]; final int shardNumberMask; private ShardsHolder(HollowSchema schema, int numShards) { @@ -71,7 +71,7 @@ private ShardsHolder(HollowSchema schema, HollowObjectTypeDataElements[] dataEle } } - volatile ShardsHolder shardsVolatile; // SNAP: TODO: remove + volatile ShardsHolder shardsVolatile; private int maxOrdinal; @@ -189,7 +189,7 @@ static int shardingFactor(int oldNumShards, int newNumShards) { * * @param newNumShards The desired number of shards */ - public void reshard(int newNumShards) { // TODO: package private + void reshard(int newNumShards) { int prevNumShards = shardsVolatile.shards.length; int shardingFactor = shardingFactor(prevNumShards, newNumShards); HollowObjectTypeDataElements[] newDataElements; @@ -558,17 +558,16 @@ HollowObjectTypeDataElements[] currentDataElements() { @Override protected void applyToChecksum(HollowChecksum checksum, HollowSchema withSchema) { - final HollowObjectTypeReadStateShard[] shards = this.shardsVolatile.shards; + final ShardsHolder shardsHolder = this.shardsVolatile; + final HollowObjectTypeReadStateShard[] shards = shardsHolder.shards; + int shardNumberMask = shardsHolder.shardNumberMask; if(!(withSchema instanceof HollowObjectSchema)) throw new IllegalArgumentException("HollowObjectTypeReadState can only calculate checksum with a HollowObjectSchema: " + getSchema().getName()); BitSet populatedOrdinals = getPopulatedOrdinals(); for(int i=0;i> shardOrdinalShift; checksum.applyInt(ordinal); for(int i=0;i {