use of org.apache.drill.exec.memory.RootAllocator in project drill by apache.
the class TestBsonRecordReader method setUp.
@Before
public void setUp() {
allocator = new RootAllocator(Long.MAX_VALUE);
TestOutputMutator mutator = new TestOutputMutator(allocator);
writer = new VectorContainerWriter(mutator);
bufferManager = new BufferManagerImpl(allocator);
bsonReader = new BsonRecordReader(bufferManager.getManagedBuffer(1024), false, false);
}
use of org.apache.drill.exec.memory.RootAllocator in project drill by apache.
the class VariableLengthVectorTest method testSettingSameValueCount.
/**
* If the vector contains 1000 records, setting a value count of 1000 should work.
*/
@Test
public void testSettingSameValueCount() {
try (RootAllocator allocator = new RootAllocator(10_000_000)) {
MaterializedField field = MaterializedField.create("stringCol", Types.required(TypeProtos.MinorType.VARCHAR));
@SuppressWarnings("resource") VarCharVector vector = new VarCharVector(field, allocator);
vector.allocateNew();
try {
int size = 1000;
VarCharVector.Mutator mutator = vector.getMutator();
VarCharVector.Accessor accessor = vector.getAccessor();
setSafeIndexStrings("", 0, size, mutator);
mutator.setValueCount(size);
Assert.assertEquals(size, accessor.getValueCount());
checkIndexStrings("", 0, size, accessor);
} finally {
vector.clear();
}
}
}
use of org.apache.drill.exec.memory.RootAllocator in project drill by axbaretto.
the class AbstractGenericCopierTest method testAppendRecords.
@Test
public void testAppendRecords() throws SchemaChangeException {
try (RootAllocator allocator = new RootAllocator(10_000_000)) {
final BatchSchema batchSchema = createTestSchema(BatchSchema.SelectionVectorMode.NONE);
final RowSet srcRowSet = createSrcRowSet(allocator);
final RowSet destRowSet = new RowSetBuilder(allocator, batchSchema).build();
final VectorContainer destContainer = destRowSet.container();
final Copier copier = createCopier();
final RowSet expectedRowSet = createExpectedRowset(allocator);
copier.setup(new RowSetBatch(srcRowSet), destContainer);
copier.appendRecord(0);
copier.appendRecords(1, 2);
try {
new RowSetComparison(expectedRowSet).verify(destRowSet);
} finally {
srcRowSet.clear();
if (srcRowSet instanceof RowSet.HyperRowSet) {
((RowSet.HyperRowSet) srcRowSet).getSv4().clear();
}
destRowSet.clear();
expectedRowSet.clear();
}
}
}
use of org.apache.drill.exec.memory.RootAllocator in project drill by axbaretto.
the class VariableLengthVectorTest method testTrunicateVectorSetValueCount.
/**
* Test truncating data. If you have 10000 records, reduce the vector to 1000 records.
*/
@Test
public void testTrunicateVectorSetValueCount() {
try (RootAllocator allocator = new RootAllocator(10_000_000)) {
final MaterializedField field = MaterializedField.create("stringCol", Types.required(TypeProtos.MinorType.VARCHAR));
final VarCharVector vector = new VarCharVector(field, allocator);
vector.allocateNew();
try {
final int size = 1000;
final int fluffSize = 10000;
final VarCharVector.Mutator mutator = vector.getMutator();
final VarCharVector.Accessor accessor = vector.getAccessor();
setSafeIndexStrings("", 0, size, mutator);
setSafeIndexStrings("first cut ", size, fluffSize, mutator);
mutator.setValueCount(fluffSize);
Assert.assertEquals(fluffSize, accessor.getValueCount());
checkIndexStrings("", 0, size, accessor);
} finally {
vector.clear();
}
}
}
use of org.apache.drill.exec.memory.RootAllocator in project drill by apache.
the class ExampleTest method secondTest.
/**
* <p>
* Example that uses the fixture builder to build a cluster fixture. Lets
* you set configuration (boot-time) options, session options, system options
* and more.
* </p>
* <p>
* You can write test files to the {@link BaseDirTestWatcher#getRootDir()} and query them in the test.
* </p>
* <p>
* Also shows how to display the plan JSON and just run a query silently,
* getting just the row count, batch count and run time.
* </p>
* @throws Exception if anything goes wrong
*/
@Test
public void secondTest() throws Exception {
try (RootAllocator allocator = new RootAllocator(100_000_000)) {
final File tableFile = dirTestWatcher.getRootDir().toPath().resolve("employee.json").toFile();
final TupleMetadata schema = new SchemaBuilder().add("id", Types.required(TypeProtos.MinorType.VARCHAR)).add("name", Types.required(TypeProtos.MinorType.VARCHAR)).buildSchema();
final RowSet rowSet = new RowSetBuilder(allocator, schema).addRow("1", "kiwi").addRow("2", "watermelon").build();
new JsonFileBuilder(rowSet).build(tableFile);
rowSet.clear();
ClusterFixtureBuilder builder = ClusterFixture.builder(dirTestWatcher).configProperty(ExecConstants.SLICE_TARGET, 10);
try (ClusterFixture cluster = builder.build();
ClientFixture client = cluster.clientFixture()) {
String sql = "SELECT * FROM `dfs`.`test/employee.json`";
logger.info(client.queryBuilder().sql(sql).explainJson());
QuerySummary results = client.queryBuilder().sql(sql).run();
logger.info(String.format("Read %d rows", results.recordCount()));
// Usually we want to test something. Here, just test that we got
// the 2 records.
assertEquals(2, results.recordCount());
}
}
}
Aggregations