Skip to content

Commit

Permalink
Replaced Tuplator with equivalent TupleGenerator from ms-util (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnhatch authored Feb 2, 2024
1 parent f70043f commit b476b24
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 262 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import gov.hhs.aspr.ms.gcm.plugins.people.support.PersonId;
import gov.hhs.aspr.ms.gcm.plugins.stochastics.datamanagers.StochasticsDataManager;
import gov.hhs.aspr.ms.gcm.plugins.stochastics.support.RandomNumberGeneratorId;
import util.combinatorics.TupleGenerator;
import util.errors.ContractException;

/**
Expand Down Expand Up @@ -186,7 +187,7 @@ public void removeLabel(final Object label) {
}

private class PartialKeyIterator implements KeyIterator {
private final Tuplator tuplator;
private final TupleGenerator tupleGenerator;
private int index;
private final Key baseKey;
private Key nextKey;
Expand All @@ -211,25 +212,25 @@ public PartialKeyIterator(final Key partialKey) {
}
}

final Tuplator.Builder builder = Tuplator.builder();
final TupleGenerator.Builder builder = TupleGenerator.builder();
for (int i = 0; i < dimensionCount; i++) {
final int labelIndex = keyIndexes[i];
final LabelManager labelManager = labelManagers[labelIndex];
builder.addDimension(labelManager.getLabelCount());
}
tuplator = builder.build();
tupleGenerator = builder.build();

// baseKey = new Key(partialKey);
baseKey = partialKey;
calculateNextKey();
}

private void calculateNextKey() {
if (index >= tuplator.size()) {
if (index >= tupleGenerator.size()) {
nextKey = null;
} else {
while (index < tuplator.size()) {
tuplator.fillTuple(index++, tuple);
while (index < tupleGenerator.size()) {
tupleGenerator.fillTuple(index++, tuple);
for (int j = 0; j < dimensionCount; j++) {
final LabelManager labelManager = labelManagers[keyIndexes[j]];
// unsafe mutation calculate next key
Expand Down Expand Up @@ -261,7 +262,7 @@ public Key next() {

@Override
public int size() {
return tuplator.size();
return tupleGenerator.size();
}

}
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit b476b24

Please sign in to comment.