use of org.apache.cassandra.utils.concurrent.OpOrder in project cassandra by apache.
the class CellSpecTest method data.
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() {
TableMetadata table = TableMetadata.builder("testing", "testing").addPartitionKeyColumn("pk", BytesType.instance).build();
byte[] rawBytes = { 0, 1, 2, 3, 4, 5, 6 };
ByteBuffer bbBytes = ByteBuffer.wrap(rawBytes);
NativePool pool = new NativePool(1024, 1024, 1, () -> ImmediateFuture.success(true));
NativeAllocator allocator = pool.newAllocator(null);
OpOrder order = new OpOrder();
List<Cell<?>> tests = new ArrayList<>();
BiConsumer<ColumnMetadata, CellPath> fn = (column, path) -> {
tests.add(new ArrayCell(column, 1234, 1, 1, rawBytes, path));
tests.add(new BufferCell(column, 1234, 1, 1, bbBytes, path));
tests.add(new NativeCell(allocator, order.getCurrent(), column, 1234, 1, 1, bbBytes, path));
};
// simple
fn.accept(ColumnMetadata.regularColumn(table, bytes("simple"), BytesType.instance), null);
// complex
// seems NativeCell does not allow CellPath.TOP, or CellPath.BOTTOM
fn.accept(ColumnMetadata.regularColumn(table, bytes("complex"), ListType.getInstance(BytesType.instance, true)), CellPath.create(bytes(UUIDGen.getTimeUUID())));
return tests.stream().map(a -> new Object[] { a.getClass().getSimpleName() + ":" + (a.path() == null ? "simple" : "complex"), a }).collect(Collectors.toList());
}
use of org.apache.cassandra.utils.concurrent.OpOrder in project cassandra by apache.
the class Memtable method estimateRowOverhead.
private static int estimateRowOverhead(final int count) {
// calculate row overhead
try (final OpOrder.Group group = new OpOrder().start()) {
int rowOverhead;
MemtableAllocator allocator = MEMORY_POOL.newAllocator(null);
ConcurrentNavigableMap<PartitionPosition, Object> partitions = new ConcurrentSkipListMap<>();
final Object val = new Object();
for (int i = 0; i < count; i++) partitions.put(allocator.clone(new BufferDecoratedKey(new LongToken(i), ByteBufferUtil.EMPTY_BYTE_BUFFER), group), val);
double avgSize = ObjectSizes.measureDeep(partitions) / (double) count;
rowOverhead = (int) ((avgSize - Math.floor(avgSize)) < 0.05 ? Math.floor(avgSize) : Math.ceil(avgSize));
rowOverhead -= ObjectSizes.measureDeep(new LongToken(0));
rowOverhead += AtomicBTreePartition.EMPTY_SIZE;
rowOverhead += AbstractBTreePartition.HOLDER_UNSHARED_HEAP_SIZE;
allocator.setDiscarding();
allocator.setDiscarded();
return rowOverhead;
}
}
use of org.apache.cassandra.utils.concurrent.OpOrder in project cassandra by apache.
the class ClusteringHeapSizeTest method data.
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() {
byte[] rawBytes = { 0, 1, 2, 3, 4, 5, 6 };
NativePool pool = new NativePool(1024, 1024, 1, () -> ImmediateFuture.success(true));
OpOrder order = new OpOrder();
ArrayClustering array = ArrayClustering.make(rawBytes);
BufferClustering buffer = BufferClustering.make(ByteBuffer.wrap(rawBytes));
return Arrays.asList(new Object[][] { { array }, { buffer }, { new NativeClustering(pool.newAllocator(null), order.getCurrent(), array) } });
}
use of org.apache.cassandra.utils.concurrent.OpOrder in project cassandra by apache.
the class NativeAllocatorTest method setUp.
@Before
public void setUp() {
exec = Executors.newScheduledThreadPool(2);
order = new OpOrder();
group = order.start();
canClean = new CountDownLatch(1);
isClean = new CountDownLatch(1);
allocatorRef = new AtomicReference<>();
barrier = new AtomicReference<>();
pool = new NativePool(1, 100, 0.75f, () -> {
try {
canClean.await();
} catch (InterruptedException e) {
throw new AssertionError();
}
if (isClean.getCount() > 0) {
allocatorRef.get().offHeap().released(80);
isClean.countDown();
}
return ImmediateFuture.success(true);
});
allocator = new NativeAllocator(pool);
allocatorRef.set(allocator);
markBlocking = () -> {
barrier.set(order.newBarrier());
barrier.get().issue();
barrier.get().markBlocking();
};
}
Aggregations