use of com.intellij.util.indexing.containers.IdSet in project intellij-community by JetBrains.
the class ValueContainerImpl method saveTo.
@Override
public void saveTo(DataOutput out, DataExternalizer<Value> externalizer) throws IOException {
DataInputOutputUtil.writeINT(out, size());
for (final InvertedIndexValueIterator<Value> valueIterator = getValueIterator(); valueIterator.hasNext(); ) {
final Value value = valueIterator.next();
externalizer.save(out, value);
Object fileSetObject = valueIterator.getFileSetObject();
if (fileSetObject instanceof Integer) {
// most common 90% case during index building
DataInputOutputUtil.writeINT(out, (Integer) fileSetObject);
} else {
// serialize positive file ids with delta encoding
ChangeBufferingList originalInput = (ChangeBufferingList) fileSetObject;
IntIdsIterator intIterator = originalInput.sortedIntIterator();
if (DebugAssertions.DEBUG)
DebugAssertions.assertTrue(intIterator.hasAscendingOrder());
if (intIterator.size() == 1) {
DataInputOutputUtil.writeINT(out, intIterator.next());
} else {
DataInputOutputUtil.writeINT(out, -intIterator.size());
IdSet checkSet = originalInput.getCheckSet();
if (checkSet != null && checkSet.size() != intIterator.size()) {
// debug code
int a = 1;
assert false;
}
int prev = 0;
while (intIterator.hasNext()) {
int fileId = intIterator.next();
if (checkSet != null && !checkSet.contains(fileId)) {
// debug code
int a = 1;
assert false;
}
DataInputOutputUtil.writeINT(out, fileId - prev);
prev = fileId;
}
}
}
}
}
Aggregations