use of herddb.storage.IndexStatus in project herddb by diennea.
the class MemoryHashIndexManager method checkpoint.
@Override
public List<PostCheckpointAction> checkpoint(LogSequenceNumber sequenceNumber, boolean pin) throws DataStorageManagerException {
if (createdInTransaction > 0) {
LOGGER.log(Level.INFO, "checkpoint for index " + index.name + " skipped, this index is created on transaction " + createdInTransaction + " which is not committed");
return Collections.emptyList();
}
List<PostCheckpointAction> result = new ArrayList<>();
LOGGER.log(Level.INFO, "flush index {0}", new Object[] { index.name });
long pageId = newPageId.getAndIncrement();
Holder<Long> count = new Holder<>();
dataStorageManager.writeIndexPage(tableSpaceUUID, index.uuid, pageId, (out) -> {
long entries = 0;
// version
out.writeVLong(1);
// flags for future implementations
out.writeVLong(0);
out.writeVInt(data.size());
for (Map.Entry<Bytes, List<Bytes>> entry : data.entrySet()) {
out.writeArray(entry.getKey());
List<Bytes> entrydata = entry.getValue();
out.writeVInt(entrydata.size());
for (Bytes v : entrydata) {
out.writeArray(v);
++entries;
}
}
count.value = entries;
});
IndexStatus indexStatus = new IndexStatus(index.name, sequenceNumber, newPageId.get(), Collections.singleton(pageId), null);
result.addAll(dataStorageManager.indexCheckpoint(tableSpaceUUID, index.uuid, indexStatus, pin));
LOGGER.log(Level.INFO, "checkpoint index {0} finished: logpos {1}, {2} entries, page {3}", new Object[] { index.name, sequenceNumber, Long.toString(count.value), Long.toString(pageId) });
return result;
}
Aggregations