in Java/core/src/main/java/com/amazon/randomcutforest/state/store/PointStoreMapper.java [91:136]
public PointStoreState toState(PointStore model) {
model.compact();
PointStoreState state = new PointStoreState();
state.setVersion(Version.V3_0);
state.setCompressed(compressionEnabled);
state.setDimensions(model.getDimensions());
state.setCapacity(model.getCapacity());
state.setShingleSize(model.getShingleSize());
state.setDirectLocationMap(false);
state.setInternalShinglingEnabled(model.isInternalShinglingEnabled());
state.setLastTimeStamp(model.getNextSequenceIndex());
if (model.isInternalShinglingEnabled()) {
state.setInternalShingle(toDoubleArray(model.getInternalShingle()));
state.setRotationEnabled(model.isInternalRotationEnabled());
}
state.setDynamicResizingEnabled(true);
if (state.isDynamicResizingEnabled()) {
state.setCurrentStoreCapacity(model.getCurrentStoreCapacity());
state.setIndexCapacity(model.getIndexCapacity());
}
state.setStartOfFreeSegment(model.getStartOfFreeSegment());
state.setPrecision(Precision.FLOAT_32.name());
int[] refcount = model.getRefCount();
int[] tempList = model.getLocationList();
int[] locationList = new int[model.getIndexCapacity()];
int[] duplicateRefs = new int[2 * model.getIndexCapacity()];
int size = 0;
int duplicateSize = 0;
for (int i = 0; i < refcount.length; i++) {
if (refcount[i] > 0) {
locationList[size] = tempList[i];
++size;
if (refcount[i] > numberOfTrees) {
duplicateRefs[duplicateSize] = i;
duplicateRefs[duplicateSize + 1] = refcount[i] - numberOfTrees;
refcount[i] = numberOfTrees;
duplicateSize += 2;
}
}
}
state.setRefCount(ArrayPacking.pack(refcount, refcount.length, state.isCompressed()));
state.setDuplicateRefs(ArrayPacking.pack(duplicateRefs, duplicateSize, state.isCompressed()));
state.setLocationList(ArrayPacking.pack(locationList, size, state.isCompressed()));
state.setPointData(ArrayPacking.pack(model.getStore(), model.getStartOfFreeSegment()));
return state;
}