MCPcopy Index your code
hub / github.com/questdb/questdb / alloc

Method alloc

core/src/main/java/io/questdb/std/Rosti.java:34–56  ·  view source on GitHub ↗
(ColumnTypes types, long capacity)

Source from the content-addressed store, hash-verified

32public final class Rosti {
33
34 public static long alloc(ColumnTypes types, long capacity) {
35 // min capacity that works on all platforms is 16
36 assert capacity >= 16;
37
38 final int columnCount = types.getColumnCount();
39 final long mem = Unsafe.malloc(4L * columnCount, MemoryTag.NATIVE_ROSTI);
40 try {
41 long p = mem;
42 for (int i = 0; i < columnCount; i++) {
43 Unsafe.putInt(p, types.getColumnType(i));
44 p += Integer.BYTES;
45 }
46 // this is not an exact size of memory allocated for Rosti, but this is useful to
47 // track that we free these maps
48 long pRosti = alloc(mem, columnCount, Numbers.ceilPow2(capacity) - 1);
49 if (pRosti != 0) {
50 Unsafe.recordMemAlloc(getAllocMemory(pRosti), MemoryTag.NATIVE_ROSTI);
51 }
52 return pRosti;
53 } finally {
54 Unsafe.free(mem, 4L * columnCount, MemoryTag.NATIVE_ROSTI);
55 }
56 }
57
58 public static native void clear(long pRosti);
59

Callers 2

testPrintRostiMethod · 0.95
allocMethod · 0.95

Calls 8

mallocMethod · 0.95
putIntMethod · 0.95
ceilPow2Method · 0.95
recordMemAllocMethod · 0.95
getAllocMemoryMethod · 0.95
freeMethod · 0.95
getColumnCountMethod · 0.65
getColumnTypeMethod · 0.65

Tested by 1

testPrintRostiMethod · 0.76