use of jetbrains.exodus.core.dataStructures.hash.LongIterator in project xodus by JetBrains.
the class Log method getFirstLoggableOfType.
/**
* Returns the first loggable in the log of specified type.
*
* @param type type of loggable.
* @return loggable or null if it doesn't exists.
*/
@Nullable
public Loggable getFirstLoggableOfType(final int type) {
final LogTip logTip = getTip();
final LongIterator files = logTip.logFileSet.getFilesFrom(0);
final long approvedHighAddress = logTip.approvedHighAddress;
while (files.hasNext()) {
final long fileAddress = files.nextLong();
final Iterator<RandomAccessLoggable> it = getLoggableIterator(fileAddress);
while (it.hasNext()) {
final Loggable loggable = it.next();
if (loggable == null || loggable.getAddress() >= fileAddress + fileLengthBound) {
break;
}
if (loggable.getType() == type) {
return loggable;
}
if (loggable.getAddress() + loggable.length() == approvedHighAddress) {
break;
}
}
}
return null;
}
use of jetbrains.exodus.core.dataStructures.hash.LongIterator in project xodus by JetBrains.
the class UpdatableEntityIdSortedSetCachedInstanceIterable method getOrCreateIdCollection.
@NotNull
private OrderedEntityIdCollection getOrCreateIdCollection() {
OrderedEntityIdCollection collection = this.idCollection;
if (collection == null) {
PersistentLongSet.ImmutableSet currentSet = localIds.beginRead();
final long[] result = new long[currentSet.size()];
final LongIterator it = currentSet.longIterator();
int i = 0;
while (it.hasNext()) {
result[i++] = it.next();
}
collection = EntityIdArrayCachedInstanceIterableFactory.makeIdCollection(entityTypeId, result);
this.idCollection = collection;
}
return collection;
}
use of jetbrains.exodus.core.dataStructures.hash.LongIterator 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(new ObjectProcedureThrows<Map.Entry<Long, InputStream>, Exception>() {
@Override
public boolean execute(final Map.Entry<Long, InputStream> object) throws Exception {
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(new ObjectProcedureThrows<Map.Entry<Long, File>, Exception>() {
@Override
public boolean execute(final Map.Entry<Long, File> object) throws Exception {
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(new Runnable() {
@Override
public void run() {
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());
}
});
}
}
use of jetbrains.exodus.core.dataStructures.hash.LongIterator in project xodus by JetBrains.
the class JMHPersistentLongSetIterationBenchmark method iterateBitTree.
@Benchmark
@Warmup(iterations = 6, time = 1)
@Measurement(iterations = 8, time = 1)
@Fork(5)
public long iterateBitTree() {
LongIterator iterator = bitTreeSet.beginRead().longIterator();
long result = 0;
while (iterator.hasNext()) {
result += iterator.nextLong();
}
return result;
}
use of jetbrains.exodus.core.dataStructures.hash.LongIterator in project xodus by JetBrains.
the class JMHPersistentLongSetIterationBenchmark method iterate23Tree.
@Benchmark
@Warmup(iterations = 6, time = 1)
@Measurement(iterations = 8, time = 1)
@Fork(5)
public long iterate23Tree() {
LongIterator iterator = treeSet.beginRead().longIterator();
long result = 0;
while (iterator.hasNext()) {
result += iterator.nextLong();
}
return result;
}
Aggregations