use of jetbrains.exodus.core.dataStructures.hash.ObjectProcedure in project xodus by JetBrains.
the class Memory method dump.
public void dump(@NotNull final File location) {
location.mkdirs();
final ObjectProcedure<Map.Entry<Long, Block>> saver = new ObjectProcedure<Map.Entry<Long, Block>>() {
@Override
public boolean execute(Map.Entry<Long, Block> object) {
try {
final File dest = new File(location, LogUtil.getLogFilename(object.getKey()));
final RandomAccessFile output = new RandomAccessFile(dest, "rw");
final Block block = object.getValue();
output.write(block.getData(), 0, block.getSize());
output.close();
// output.getChannel().force(false);
} catch (IOException e) {
throw new ExodusException(e);
}
return true;
}
};
synchronized (data) {
data.forEachEntry(saver);
removedBlocks.forEachEntry(saver);
}
}
use of jetbrains.exodus.core.dataStructures.hash.ObjectProcedure in project xodus by JetBrains.
the class PersistentHashSetTest method forEachKeyTest.
@SuppressWarnings({ "OverlyLongMethod" })
@Test
public void forEachKeyTest() {
Random random = new Random(8234890);
PersistentHashSet.MutablePersistentHashSet<Integer> tree = new PersistentHashSet<Integer>().beginWrite();
int[] p = genPermutation(random);
HashSet<Integer> added = new HashSet<>();
for (int i = 0; i < ENTRIES_TO_ADD; i++) {
int size = tree.size();
Assert.assertEquals(i, size);
if ((size & 1023) == 0 || size < 100) {
final Collection<Integer> actual = new HashSet<>(size);
ObjectProcedure<Integer> proc = new ObjectProcedure<Integer>() {
@Override
public boolean execute(Integer object) {
Assert.assertFalse(actual.contains(object));
actual.add(object);
return true;
}
};
tree.forEachKey(proc);
Assert.assertEquals(size, actual.size());
for (Integer key : added) {
Assert.assertTrue(actual.contains(key));
}
}
tree.add(p[i]);
added.add(p[i]);
}
}
Aggregations