Skip to content

Commit

Permalink
most tests fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunjeet committed Jan 21, 2025
1 parent 7b9dcb8 commit 6e0a4a2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class HollowListTypeWriteState extends HollowTypeWriteState {
private ByteDataArray deltaAddedOrdinals[];
private ByteDataArray deltaRemovedOrdinals[];

protected int maxOrdinal;

public HollowListTypeWriteState(HollowListSchema schema) {
this(schema, -1);
}
Expand All @@ -70,7 +72,9 @@ public void prepareForWrite() {
}

private void gatherStatistics() {
gatherShardingStats();
maxOrdinal = ordinalMap.maxOrdinal();

gatherShardingStats(maxOrdinal);

int maxElementOrdinal = 0;

Expand Down Expand Up @@ -147,7 +151,6 @@ protected int typeStateNumShards(int maxOrdinal) {
@Override
public void calculateSnapshot() {
maxOrdinal = ordinalMap.maxOrdinal();

listPointerArray = new FixedLengthElementArray[numShards];
elementArray = new FixedLengthElementArray[numShards];

Expand Down Expand Up @@ -250,7 +253,6 @@ public void writeReverseDelta(DataOutputStream dos) throws IOException {

private void calculateDelta(ThreadSafeBitSet fromCyclePopulated, ThreadSafeBitSet toCyclePopulated) {
maxOrdinal = ordinalMap.maxOrdinal();

numListsInDelta = new int[numShards];
numElementsInDelta = new long[numShards];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public class HollowMapTypeWriteState extends HollowTypeWriteState {
private ByteDataArray deltaAddedOrdinals[];
private ByteDataArray deltaRemovedOrdinals[];

protected int maxOrdinal;


public HollowMapTypeWriteState(HollowMapSchema schema) {
this(schema, -1);
}
Expand All @@ -77,7 +80,9 @@ public void prepareForWrite() {
}

private void gatherStatistics() {
gatherShardingStats();
maxOrdinal = ordinalMap.maxOrdinal();

gatherShardingStats(maxOrdinal);

int maxKeyOrdinal = 0;
int maxValueOrdinal = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class HollowObjectTypeWriteState extends HollowTypeWriteState {
private ByteDataArray deltaAddedOrdinals[];
private ByteDataArray deltaRemovedOrdinals[];

protected int maxOrdinal;

public HollowObjectTypeWriteState(HollowObjectSchema schema) {
this(schema, -1);
}
Expand Down Expand Up @@ -75,15 +77,15 @@ public void prepareForWrite() {

fieldStats = new FieldStatistics(getSchema());

int maxOrdinal = ordinalMap.maxOrdinal();
maxOrdinal = ordinalMap.maxOrdinal();

for(int i=0;i<=maxOrdinal;i++) {
discoverObjectFieldStatisticsForRecord(fieldStats, i);
}

fieldStats.completeCalculations();

gatherShardingStats();
gatherShardingStats(maxOrdinal);
}

@Override
Expand Down Expand Up @@ -170,6 +172,7 @@ public void prepareForNextCycle() {
@Override
public void calculateSnapshot() {
maxOrdinal = ordinalMap.maxOrdinal();

int numBitsPerRecord = fieldStats.getNumBitsPerRecord();

fixedLengthLongArray = new FixedLengthElementArray[numShards];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class HollowSetTypeWriteState extends HollowTypeWriteState {
private ByteDataArray deltaAddedOrdinals[];
private ByteDataArray deltaRemovedOrdinals[];

protected int maxOrdinal;

public HollowSetTypeWriteState(HollowSetSchema schema) {
this(schema, -1);
}
Expand All @@ -75,7 +77,9 @@ public void prepareForWrite() {
}

private void gatherStatistics() {
gatherShardingStats();
maxOrdinal = ordinalMap.maxOrdinal();

gatherShardingStats(maxOrdinal);

int maxElementOrdinal = 0;
int maxSetSize = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ public abstract class HollowTypeWriteState {

private boolean isNumShardsPinned; // if numShards is pinned using numShards annotation in data model

protected int maxOrdinal;
protected int maxShardOrdinal[];
protected int revMaxShardOrdinal[];

public HollowTypeWriteState(HollowSchema schema, int numShards) {
this(schema, numShards, false);
}
Expand Down Expand Up @@ -396,7 +392,7 @@ public HollowWriteStateEngine getStateEngine() {
return stateEngine;
}

protected int[] calcMaxShardOrdinal(int maxOrdinal, int numShards) {
protected static int[] calcMaxShardOrdinal(int maxOrdinal, int numShards) {
int[] maxShardOrdinal = new int[numShards];
int minRecordLocationsPerShard = (maxOrdinal + 1) / numShards;
for(int i=0;i<numShards;i++)
Expand All @@ -415,8 +411,11 @@ public boolean allowTypeResharding() {
return stateEngine.allowTypeResharding();
}

protected void gatherShardingStats() {
int maxOrdinal = ordinalMap.maxOrdinal();
protected int maxShardOrdinal[];
protected int revMaxShardOrdinal[];


protected void gatherShardingStats(int maxOrdinal) {
if(numShards == -1) {
numShards = typeStateNumShards(maxOrdinal);
revNumShards = numShards;
Expand Down

0 comments on commit 6e0a4a2

Please sign in to comment.