use of jetbrains.exodus.core.dataStructures.hash.ObjectProcedureThrows in project xodus by JetBrains.
the class FileSystemBlobVaultOld method flushBlobs.
@Override
public void flushBlobs(@Nullable final LongHashMap<InputStream> blobStreams, @Nullable final LongHashMap<File> blobFiles, @Nullable final LongSet deferredBlobsToDelete, @NotNull final Transaction txn) throws Exception {
if (blobStreams != null) {
blobStreams.forEachEntry((ObjectProcedureThrows<Map.Entry<Long, InputStream>, Exception>) object -> {
final InputStream stream = object.getValue();
stream.reset();
setContent(object.getKey(), stream);
return true;
});
}
// if there were blob files then move them
if (blobFiles != null) {
blobFiles.forEachEntry((ObjectProcedureThrows<Map.Entry<Long, File>, Exception>) object -> {
setContent(object.getKey(), object.getValue());
return true;
});
}
// if there are deferred blobs to delete then defer their deletion
if (deferredBlobsToDelete != null) {
final LongArrayList copy = new LongArrayList(deferredBlobsToDelete.size());
final LongIterator it = deferredBlobsToDelete.iterator();
while (it.hasNext()) {
copy.add(it.nextLong());
}
final Environment environment = txn.getEnvironment();
environment.executeTransactionSafeTask(() -> DeferredIO.getJobProcessor().queueIn(new Job() {
@Override
protected void execute() {
final long[] blobHandles = copy.getInstantArray();
for (int i = 0; i < copy.size(); ++i) {
delete(blobHandles[i]);
}
}
@Override
public String getName() {
return "Delete obsolete blob files";
}
@Override
public String getGroup() {
return environment.getLocation();
}
}, environment.getEnvironmentConfig().getGcFilesDeletionDelay()));
}
}
Aggregations