use of com.cinchapi.lib.offheap.memory.OffHeapMemory in project concourse by cinchapi.
the class ChunkTest method testShiftExisting.
@SuppressWarnings("unchecked")
@Test
public void testShiftExisting() {
int count = TestData.getScaleCount();
for (int i = 0; i < count; ++i) {
chunk.insert(getLocator(), getKey(), getValue(), Time.now(), Action.ADD);
}
Iterator<Revision<L, K, V>> expected = ((Iterable<Revision<L, K, V>>) Reflection.get("revisions", chunk)).iterator();
OffHeapMemory memory = OffHeapMemory.allocateDirect(count * 3 * Write.MINIMUM_SIZE);
chunk.shift(memory);
Iterator<Revision<L, K, V>> actual = chunk.iterator();
while (expected.hasNext()) {
Revision<L, K, V> a = expected.next();
Revision<L, K, V> b = actual.next();
Assert.assertEquals(a, b);
}
}
use of com.cinchapi.lib.offheap.memory.OffHeapMemory in project concourse by cinchapi.
the class Segment method createOffHeap.
/**
* Return a {@link Segment} where each of its {@link Chunk Chunks} is
* {@link Chunk#shift(OffHeapMemory) shifted} to {@link OffHeapMemory}.
*
* @param expectedInsertions
* @return the {@link Segment}
*/
public static Segment createOffHeap(int expectedInsertions) {
Segment segment = create(expectedInsertions);
long capacity = expectedInsertions * Write.MINIMUM_SIZE * 3;
for (Chunk<? extends Byteable, ? extends Byteable, ? extends Byteable> chunk : Array.containing(segment.table, segment.index, segment.corpus)) {
// NOTE: Using DirectMemory because UnsafeMemory causes a segfault
// on CircleCI, so it isn't reliable yet. In the future, the kind of
// OffHeapMemory to use may be configurable based on tuning.
OffHeapMemory memory = OffHeapMemory.allocateDirect(capacity);
chunk.shift(memory);
}
return segment;
}
use of com.cinchapi.lib.offheap.memory.OffHeapMemory in project concourse by cinchapi.
the class CorpusChunkTest method testShiftExisting.
@SuppressWarnings("unchecked")
@Test
@Override
public void testShiftExisting() {
int count = TestData.getScaleCount();
CorpusChunk corpus = (CorpusChunk) chunk;
for (int i = 0; i < count; ++i) {
corpus.insert(Text.wrap(TestData.getString()), Value.wrap(Convert.javaToThrift(TestData.getString())), Identifier.of(Time.now()), Time.now(), Action.ADD);
}
Iterator<Revision<Text, Text, Position>> expected = ((Iterable<Revision<Text, Text, Position>>) Reflection.get("revisions", chunk)).iterator();
OffHeapMemory memory = OffHeapMemory.allocateDirect(count * 3 * Write.MINIMUM_SIZE);
chunk.shift(memory);
Iterator<Revision<Text, Text, Position>> actual = chunk.iterator();
while (expected.hasNext()) {
Revision<Text, Text, Position> a = expected.next();
Revision<Text, Text, Position> b = actual.next();
Assert.assertEquals(a, b);
}
}
Aggregations