use of io.airlift.units.DataSize in project presto by prestodb.
the class TestRcFileReaderManual method readValues.
private static List<Integer> readValues(Slice data, int offset, int length) throws IOException {
if (offset < 0) {
// adjust length to new offset
length += offset;
offset = 0;
}
if (offset + length > data.length()) {
length = data.length() - offset;
}
RcFileReader reader = new RcFileReader(new SliceRcFileDataSource(data), new BinaryRcFileEncoding(), ImmutableMap.of(0, SMALLINT), new BogusRcFileCodecFactory(), offset, length, new DataSize(1, MEGABYTE));
ImmutableList.Builder<Integer> values = ImmutableList.builder();
while (reader.advance() >= 0) {
Block block = reader.readBlock(0);
for (int position = 0; position < block.getPositionCount(); position++) {
values.add((int) SMALLINT.getLong(block, position));
}
}
return values.build();
}
use of io.airlift.units.DataSize in project airpal by airbnb.
the class Execution method createNoOpQueryStats.
public static QueryStats createNoOpQueryStats() {
DateTime now = DateTime.now();
io.airlift.units.Duration zeroDuration = new io.airlift.units.Duration(0, TimeUnit.SECONDS);
DataSize zeroData = new DataSize(0, DataSize.Unit.BYTE);
return new QueryStats(now, null, now, now, zeroDuration, zeroDuration, zeroDuration, zeroDuration, zeroDuration, zeroDuration, 0, 0, 0, 0, 0, 0, 0, 0.0, zeroData, zeroData, zeroDuration, zeroDuration, zeroDuration, zeroDuration, false, ImmutableSet.of(), zeroData, 0, zeroData, 0, zeroData, 0);
}
use of io.airlift.units.DataSize in project presto by prestodb.
the class Top100Benchmark method createOperatorFactories.
@Override
protected List<? extends OperatorFactory> createOperatorFactories() {
OperatorFactory tableScanOperator = createTableScanOperator(0, new PlanNodeId("test"), "orders", "totalprice");
TopNOperatorFactory topNOperator = new TopNOperatorFactory(1, new PlanNodeId("test"), tableScanOperator.getTypes(), 100, ImmutableList.of(0), ImmutableList.of(ASC_NULLS_LAST), false, new DataSize(16, MEGABYTE));
return ImmutableList.of(tableScanOperator, topNOperator);
}
use of io.airlift.units.DataSize in project presto by prestodb.
the class MemoryLocalQueryRunner method execute.
public void execute(@Language("SQL") String query) {
Session session = testSessionBuilder().setSystemProperty("optimizer.optimize-hash-generation", "true").build();
ExecutorService executor = localQueryRunner.getExecutor();
MemoryPool memoryPool = new MemoryPool(new MemoryPoolId("test"), new DataSize(1, GIGABYTE));
MemoryPool systemMemoryPool = new MemoryPool(new MemoryPoolId("testSystem"), new DataSize(1, GIGABYTE));
TaskContext taskContext = new QueryContext(new QueryId("test"), new DataSize(256, MEGABYTE), memoryPool, systemMemoryPool, executor).addTaskContext(new TaskStateMachine(new TaskId("query", 0, 0), executor), session, false, false);
// Use NullOutputFactory to avoid coping out results to avoid affecting benchmark results
List<Driver> drivers = localQueryRunner.createDrivers(query, new NullOutputOperator.NullOutputFactory(), taskContext);
boolean done = false;
while (!done) {
boolean processed = false;
for (Driver driver : drivers) {
if (!driver.isFinished()) {
driver.process();
processed = true;
}
}
done = !processed;
}
}
use of io.airlift.units.DataSize in project presto by prestodb.
the class FormatUtils method formatDataRate.
public static String formatDataRate(DataSize dataSize, Duration duration, boolean longForm) {
double rate = dataSize.toBytes() / duration.getValue(SECONDS);
if (Double.isNaN(rate) || Double.isInfinite(rate)) {
rate = 0;
}
String rateString = formatDataSize(new DataSize(rate, BYTE), false);
if (longForm) {
if (!rateString.endsWith("B")) {
rateString += "B";
}
rateString += "/s";
}
return rateString;
}
Aggregations