diff --git a/hollow/src/main/java/com/netflix/hollow/core/read/engine/HollowTypeReshardingStrategy.java b/hollow/src/main/java/com/netflix/hollow/core/read/engine/HollowTypeReshardingStrategy.java index 3ed09434b..f76fbe5cf 100644 --- a/hollow/src/main/java/com/netflix/hollow/core/read/engine/HollowTypeReshardingStrategy.java +++ b/hollow/src/main/java/com/netflix/hollow/core/read/engine/HollowTypeReshardingStrategy.java @@ -171,7 +171,6 @@ public HollowTypeReadStateShard[] expandWithOriginalDataElements(ShardsHolder sh } } return newShards; - // return shardsHolder.getClass().getConstructor(HollowTypeReadStateShard[].class).newInstance((Object) newShards); } public HollowTypeReadStateShard[] splitDataElementsForOneShard(HollowTypeReadState typeState, int currentIndex, int prevNumShards, int shardingFactor) { diff --git a/hollow/src/main/java/com/netflix/hollow/core/read/engine/list/HollowListTypeReadState.java b/hollow/src/main/java/com/netflix/hollow/core/read/engine/list/HollowListTypeReadState.java index 0d1a83e69..7d41dd47d 100644 --- a/hollow/src/main/java/com/netflix/hollow/core/read/engine/list/HollowListTypeReadState.java +++ b/hollow/src/main/java/com/netflix/hollow/core/read/engine/list/HollowListTypeReadState.java @@ -201,11 +201,7 @@ public int getElementOrdinal(int ordinal, int listIndex) { endElement = shard.dataElements.getEndElement(shardOrdinal); } while(readWasUnsafe(shardsHolder, ordinal, shard)); - long elementIndex = startElement + listIndex; - if(elementIndex >= endElement) - throw new ArrayIndexOutOfBoundsException("Array index out of bounds: " + listIndex + ", list size: " + (endElement - startElement)); - - elementOrdinal = (int)shard.dataElements.elementData.getElementValue(elementIndex * shard.dataElements.bitsPerElement, shard.dataElements.bitsPerElement); + elementOrdinal = shard.getElementOrdinal(startElement, endElement, listIndex); } while(readWasUnsafe(shardsHolder, ordinal, shard)); return elementOrdinal; @@ -284,8 +280,7 @@ HollowListTypeDataElements[] currentDataElements() { @Override protected void applyToChecksum(HollowChecksum checksum, HollowSchema withSchema) { - final HollowListTypeShardsHolder shardsHolder = this.shardsVolatile; - final HollowListTypeReadStateShard[] shards = shardsHolder.shards; + final HollowListTypeReadStateShard[] shards = this.shardsVolatile.shards; if(!getSchema().equals(withSchema)) throw new IllegalArgumentException("HollowListTypeReadState cannot calculate checksum with unequal schemas: " + getSchema().getName()); diff --git a/hollow/src/main/java/com/netflix/hollow/core/read/engine/list/HollowListTypeReadStateShard.java b/hollow/src/main/java/com/netflix/hollow/core/read/engine/list/HollowListTypeReadStateShard.java index e86adb579..207b77660 100644 --- a/hollow/src/main/java/com/netflix/hollow/core/read/engine/list/HollowListTypeReadStateShard.java +++ b/hollow/src/main/java/com/netflix/hollow/core/read/engine/list/HollowListTypeReadStateShard.java @@ -22,7 +22,7 @@ import com.netflix.hollow.tools.checksum.HollowChecksum; import java.util.BitSet; -public class HollowListTypeReadStateShard implements HollowTypeReadStateShard { +class HollowListTypeReadStateShard implements HollowTypeReadStateShard { final HollowListTypeDataElements dataElements; final int shardOrdinalShift; @@ -58,8 +58,10 @@ protected void applyShardToChecksum(HollowChecksum checksum, BitSet populatedOrd int size = size(shardOrdinal); checksum.applyInt(ordinal); + long startElement = dataElements.getStartElement(shardOrdinal); + long endElement = dataElements.getEndElement(shardOrdinal); for(int i=0;i= endElement) throw new ArrayIndexOutOfBoundsException("Array index out of bounds: " + listIndex + ", list size: " + (endElement - startElement)); diff --git a/hollow/src/main/java/com/netflix/hollow/core/read/engine/map/HollowMapTypeReadState.java b/hollow/src/main/java/com/netflix/hollow/core/read/engine/map/HollowMapTypeReadState.java index c21bdd585..74435c036 100644 --- a/hollow/src/main/java/com/netflix/hollow/core/read/engine/map/HollowMapTypeReadState.java +++ b/hollow/src/main/java/com/netflix/hollow/core/read/engine/map/HollowMapTypeReadState.java @@ -36,7 +36,6 @@ import com.netflix.hollow.core.read.engine.HollowTypeDataElements; import com.netflix.hollow.core.read.engine.HollowTypeReadState; import com.netflix.hollow.core.read.engine.HollowTypeReadStateShard; -import com.netflix.hollow.core.read.engine.HollowTypeReshardingStrategy; import com.netflix.hollow.core.read.engine.PopulatedOrdinalListener; import com.netflix.hollow.core.read.engine.SetMapKeyHasher; import com.netflix.hollow.core.read.engine.ShardsHolder; @@ -59,14 +58,12 @@ */ public class HollowMapTypeReadState extends HollowTypeReadState implements HollowMapTypeDataAccess { private static final Logger LOG = Logger.getLogger(HollowMapTypeReadState.class.getName()); - private static final HollowTypeReshardingStrategy RESHARDING_STRATEGY = new HollowMapTypeReshardingStrategy(); private final HollowMapSampler sampler; - private volatile HollowPrimaryKeyValueDeriver keyDeriver; - private int maxOrdinal; + private volatile HollowPrimaryKeyValueDeriver keyDeriver; volatile HollowMapTypeShardsHolder shardsVolatile; @Override @@ -487,7 +484,6 @@ public HollowPrimaryKeyValueDeriver getKeyDeriver() { } public void buildKeyDeriver() { - HollowMapTypeReadStateShard[] shards = this.shardsVolatile.shards; if(getSchema().getHashKey() != null) { try { this.keyDeriver = new HollowPrimaryKeyValueDeriver(getSchema().getHashKey(), getStateEngine()); diff --git a/hollow/src/main/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeReadStateShard.java b/hollow/src/main/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeReadStateShard.java index c267e91b5..fe3745f45 100644 --- a/hollow/src/main/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeReadStateShard.java +++ b/hollow/src/main/java/com/netflix/hollow/core/read/engine/object/HollowObjectTypeReadStateShard.java @@ -31,7 +31,7 @@ import java.util.Collections; import java.util.List; -public class HollowObjectTypeReadStateShard implements HollowTypeReadStateShard { +class HollowObjectTypeReadStateShard implements HollowTypeReadStateShard { private final HollowObjectSchema schema; final HollowObjectTypeDataElements dataElements; diff --git a/hollow/src/main/java/com/netflix/hollow/core/read/engine/set/HollowSetTypeReadState.java b/hollow/src/main/java/com/netflix/hollow/core/read/engine/set/HollowSetTypeReadState.java index 32e93e838..2db730233 100644 --- a/hollow/src/main/java/com/netflix/hollow/core/read/engine/set/HollowSetTypeReadState.java +++ b/hollow/src/main/java/com/netflix/hollow/core/read/engine/set/HollowSetTypeReadState.java @@ -28,7 +28,6 @@ import com.netflix.hollow.core.memory.HollowUnsafeHandle; import com.netflix.hollow.core.memory.MemoryMode; import com.netflix.hollow.core.memory.encoding.GapEncodedVariableLengthIntegerReader; -import com.netflix.hollow.core.memory.encoding.HashCodes; import com.netflix.hollow.core.memory.encoding.VarInt; import com.netflix.hollow.core.memory.pool.ArraySegmentRecycler; import com.netflix.hollow.core.read.HollowBlobInput; @@ -62,7 +61,6 @@ public class HollowSetTypeReadState extends HollowCollectionTypeReadState implem private static final Logger LOG = Logger.getLogger(HollowSetTypeReadState.class.getName()); private final HollowSetSampler sampler; - private int maxOrdinal; @@ -429,7 +427,6 @@ public HollowPrimaryKeyValueDeriver getKeyDeriver() { } public void buildKeyDeriver() { - final HollowSetTypeReadStateShard[] shards = this.shardsVolatile.shards; if(getSchema().getHashKey() != null) { try { this.keyDeriver = new HollowPrimaryKeyValueDeriver(getSchema().getHashKey(), getStateEngine()); diff --git a/hollow/src/test/java/com/netflix/hollow/api/producer/HollowIncrementalProducerTest.java b/hollow/src/test/java/com/netflix/hollow/api/producer/HollowIncrementalProducerTest.java index 51c761fd2..cf9e2c7fa 100644 --- a/hollow/src/test/java/com/netflix/hollow/api/producer/HollowIncrementalProducerTest.java +++ b/hollow/src/test/java/com/netflix/hollow/api/producer/HollowIncrementalProducerTest.java @@ -38,6 +38,7 @@ import com.netflix.hollow.core.write.objectmapper.RecordPrimaryKey; import com.netflix.hollow.core.write.objectmapper.flatrecords.FakeHollowSchemaIdentifierMapper; import com.netflix.hollow.core.write.objectmapper.flatrecords.FlatRecordWriter; +import com.netflix.hollow.test.InMemoryBlobStore; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -47,8 +48,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.TimeUnit; - -import com.netflix.hollow.test.InMemoryBlobStore; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; @@ -384,7 +383,6 @@ public void publishDirectlyAndRestore() { } - // SNAP: TODO: add test for collections @Test public void continuesARestoredState() { HollowProducer genesisProducer = createInMemoryProducerWithResharding(); diff --git a/hollow/src/test/java/com/netflix/hollow/core/read/engine/VMSHollowTypeReshardingStrategyTest.java b/hollow/src/test/java/com/netflix/hollow/core/read/engine/VMSHollowTypeReshardingStrategyTest.java index 34f452a56..8a9d72163 100644 --- a/hollow/src/test/java/com/netflix/hollow/core/read/engine/VMSHollowTypeReshardingStrategyTest.java +++ b/hollow/src/test/java/com/netflix/hollow/core/read/engine/VMSHollowTypeReshardingStrategyTest.java @@ -10,7 +10,7 @@ public class VMSHollowTypeReshardingStrategyTest { - @Test + // @Test public void testSplittingAndJoiningWithSnapshotBlob() throws Exception { String blobPath = "/Users/ssingh/workspace/blob-cache/vms-daintree/prod/"; // null; // dir where snapshot blob exists for e.g. "/tmp/";