use of org.apache.drill.shaded.guava.com.google.common.base.Stopwatch in project drill by apache.
the class AsyncPageReader method decompressPageV1.
/**
* Reads a compressed v1 data page or a dictionary page, both of which are compressed
* in their entirety.
* @return decompressed Parquet page data
* @throws IOException
*/
protected DrillBuf decompressPageV1(ReadStatus readStatus) throws IOException {
Stopwatch timer = Stopwatch.createUnstarted();
PageHeader pageHeader = readStatus.getPageHeader();
int inputSize = pageHeader.getCompressed_page_size();
int outputSize = pageHeader.getUncompressed_page_size();
// TODO: does reporting this number have the same meaning in an async context?
long start = dataReader.getPos();
long timeToRead;
DrillBuf inputPageData = readStatus.getPageData();
DrillBuf outputPageData = this.allocator.buffer(outputSize);
try {
timer.start();
CompressionCodecName codecName = columnChunkMetaData.getCodec();
CompressionCodecFactory.BytesInputDecompressor decomp = codecFactory.getDecompressor(codecName);
ByteBuffer input = inputPageData.nioBuffer(0, inputSize);
ByteBuffer output = outputPageData.nioBuffer(0, outputSize);
decomp.decompress(input, inputSize, output, outputSize);
outputPageData.writerIndex(outputSize);
timeToRead = timer.elapsed(TimeUnit.NANOSECONDS);
if (logger.isTraceEnabled()) {
logger.trace("Col: {} readPos: {} Uncompressed_size: {} pageData: {}", columnChunkMetaData.toString(), // TODO: see comment on earlier call to getPos()
dataReader.getPos(), outputSize, ByteBufUtil.hexDump(outputPageData));
}
this.updateStats(pageHeader, "Decompress", start, timeToRead, inputSize, outputSize);
} finally {
readStatus.setPageData(null);
if (inputPageData != null) {
inputPageData.release();
}
}
return outputPageData;
}
use of org.apache.drill.shaded.guava.com.google.common.base.Stopwatch in project drill by apache.
the class ParquetRecordReader method next.
/**
* Read the next record batch from the file using the reader and read state
* created previously.
*/
@Override
public int next() {
readState.resetBatch();
Stopwatch timer = Stopwatch.createStarted();
try {
return batchReader.readBatch();
} catch (Exception e) {
throw handleAndRaise("\nHadoop path: " + hadoopPath.toUri().getPath() + "\nTotal records read: " + readState.recordsRead() + "\nRow group index: " + rowGroupIndex + "\nRecords to read: " + numRecordsToRead, e);
} finally {
parquetReaderStats.timeProcess.addAndGet(timer.elapsed(TimeUnit.NANOSECONDS));
}
}
use of org.apache.drill.shaded.guava.com.google.common.base.Stopwatch in project drill by apache.
the class VarLenBinaryReader method readFields.
/**
* Reads as many variable length values as possible.
*
* @param recordsToReadInThisPass - the number of records recommended for reading form the reader
* @return - the number of fixed length fields that will fit in the batch
*/
public long readFields(long recordsToReadInThisPass) throws IOException {
// write the first 0 offset
for (VarLengthColumn<?> columnReader : columns) {
columnReader.reset();
}
Stopwatch timer = Stopwatch.createStarted();
// Ensure we do not read more than batch record count
recordsToReadInThisPass = Math.min(recordsToReadInThisPass, batchSizer.getCurrentRecordsPerBatch());
long recordsReadInCurrentPass = 0;
if (!useBulkReader) {
recordsReadInCurrentPass = determineSizesSerial(recordsToReadInThisPass);
if (useAsyncTasks) {
readRecordsParallel(recordsReadInCurrentPass);
} else {
readRecordsSerial(recordsReadInCurrentPass);
}
} else {
recordsReadInCurrentPass = readRecordsInBulk((int) recordsToReadInThisPass);
}
// Publish this information
parentReader.getReadState().setValuesReadInCurrentPass((int) recordsReadInCurrentPass);
// Update the stats
parentReader.parquetReaderStats.timeVarColumnRead.addAndGet(timer.elapsed(TimeUnit.NANOSECONDS));
return recordsReadInCurrentPass;
}
use of org.apache.drill.shaded.guava.com.google.common.base.Stopwatch in project drill by apache.
the class BatchReader method readAllFixedFields.
protected void readAllFixedFields(long recordsToRead) throws Exception {
Stopwatch timer = Stopwatch.createStarted();
if (readState.useAsyncColReader()) {
readAllFixedFieldsParallel(recordsToRead);
} else {
readAllFixedFieldsSerial(recordsToRead);
}
readState.parquetReaderStats().timeFixedColumnRead.addAndGet(timer.elapsed(TimeUnit.NANOSECONDS));
}
use of org.apache.drill.shaded.guava.com.google.common.base.Stopwatch in project drill by apache.
the class BlockMapBuilder method buildEndpointMap.
/**
* Builds a mapping of Drillbit endpoints to hostnames
*/
private static ImmutableMap<String, DrillbitEndpoint> buildEndpointMap(Collection<DrillbitEndpoint> endpoints) {
Stopwatch watch = Stopwatch.createStarted();
HashMap<String, DrillbitEndpoint> endpointMap = Maps.newHashMap();
for (DrillbitEndpoint d : endpoints) {
String hostName = d.getAddress();
endpointMap.put(hostName, d);
}
watch.stop();
logger.debug("Took {} ms to build endpoint map", watch.elapsed(TimeUnit.MILLISECONDS));
return ImmutableMap.copyOf(endpointMap);
}
Aggregations