Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunjeet committed Sep 22, 2024
1 parent 1a01bb9 commit 5e61d8f
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<size;i++)
checksum.applyInt(getElementOrdinal(shardOrdinal, i));
checksum.applyInt(getElementOrdinal(startElement, endElement, i));

ordinal = ordinal + numShards;
} else {
Expand All @@ -71,9 +73,7 @@ protected void applyShardToChecksum(HollowChecksum checksum, BitSet populatedOrd
}
}

private int getElementOrdinal(int ordinal, int listIndex) {
long startElement = dataElements.getStartElement(ordinal);
long endElement = dataElements.getEndElement(ordinal);
int getElementOrdinal(long startElement, long endElement, int listIndex) {
long elementIndex = startElement + listIndex;
if(elementIndex >= endElement)
throw new ArrayIndexOutOfBoundsException("Array index out of bounds: " + listIndex + ", list size: " + (endElement - startElement));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -384,7 +383,6 @@ public void publishDirectlyAndRestore() {

}

// SNAP: TODO: add test for collections
@Test
public void continuesARestoredState() {
HollowProducer genesisProducer = createInMemoryProducerWithResharding();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/";
Expand Down

0 comments on commit 5e61d8f

Please sign in to comment.