use of io.netty.buffer.DrillBuf in project drill by axbaretto.
the class HttpdLogRecord method writeString.
private void writeString(final VarCharWriter writer, final String value) {
final byte[] stringBytes = value.getBytes(Charsets.UTF_8);
final DrillBuf stringBuffer = buf(stringBytes.length);
stringBuffer.clear();
stringBuffer.writeBytes(stringBytes);
writer.writeVarChar(0, stringBytes.length, stringBuffer);
}
use of io.netty.buffer.DrillBuf in project drill by axbaretto.
the class AsyncPageReader method decompress.
private DrillBuf decompress(PageHeader pageHeader, DrillBuf compressedData) {
DrillBuf pageDataBuf = null;
Stopwatch timer = Stopwatch.createUnstarted();
long timeToRead;
int compressedSize = pageHeader.getCompressed_page_size();
int uncompressedSize = pageHeader.getUncompressed_page_size();
pageDataBuf = allocateTemporaryBuffer(uncompressedSize);
try {
timer.start();
CompressionCodecName codecName = parentColumnReader.columnChunkMetaData.getCodec();
ByteBuffer input = compressedData.nioBuffer(0, compressedSize);
ByteBuffer output = pageDataBuf.nioBuffer(0, uncompressedSize);
DecompressionHelper decompressionHelper = new DecompressionHelper(codecName);
decompressionHelper.decompress(input, compressedSize, output, uncompressedSize);
pageDataBuf.writerIndex(uncompressedSize);
timeToRead = timer.elapsed(TimeUnit.NANOSECONDS);
this.updateStats(pageHeader, "Decompress", 0, timeToRead, compressedSize, uncompressedSize);
} catch (IOException e) {
handleAndThrowException(e, "Error decompressing data.");
}
return pageDataBuf;
}
use of io.netty.buffer.DrillBuf in project drill by axbaretto.
the class AsyncPageReader method readDictionaryPageData.
// Read and decode the dictionary data
private void readDictionaryPageData(final ReadStatus readStatus, final ColumnReader<?> parentStatus) throws UserException {
try {
pageHeader = readStatus.getPageHeader();
int uncompressedSize = pageHeader.getUncompressed_page_size();
final DrillBuf dictionaryData = getDecompressedPageData(readStatus);
Stopwatch timer = Stopwatch.createStarted();
allocatedDictionaryBuffers.add(dictionaryData);
DictionaryPage page = new DictionaryPage(asBytesInput(dictionaryData, 0, uncompressedSize), pageHeader.uncompressed_page_size, pageHeader.dictionary_page_header.num_values, valueOf(pageHeader.dictionary_page_header.encoding.name()));
this.dictionary = page.getEncoding().initDictionary(parentStatus.columnDescriptor, page);
long timeToDecode = timer.elapsed(TimeUnit.NANOSECONDS);
stats.timeDictPageDecode.addAndGet(timeToDecode);
} catch (Exception e) {
handleAndThrowException(e, "Error decoding dictionary page.");
}
}
use of io.netty.buffer.DrillBuf in project drill by axbaretto.
the class AsyncPageReader method getDecompressedPageData.
private DrillBuf getDecompressedPageData(ReadStatus readStatus) {
DrillBuf data;
boolean isDictionary = false;
synchronized (this) {
data = readStatus.getPageData();
readStatus.setPageData(null);
isDictionary = readStatus.isDictionaryPage;
}
if (parentColumnReader.columnChunkMetaData.getCodec() != CompressionCodecName.UNCOMPRESSED) {
DrillBuf compressedData = data;
data = decompress(readStatus.getPageHeader(), compressedData);
synchronized (this) {
readStatus.setPageData(null);
}
compressedData.release();
} else {
if (isDictionary) {
stats.totalDictPageReadBytes.addAndGet(readStatus.bytesRead);
} else {
stats.totalDataPageReadBytes.addAndGet(readStatus.bytesRead);
}
}
return data;
}
use of io.netty.buffer.DrillBuf in project drill by axbaretto.
the class PageReader method readDictionaryPage.
private void readDictionaryPage(final PageHeader pageHeader, final ColumnReader<?> parentStatus) throws IOException {
int compressedSize = pageHeader.getCompressed_page_size();
int uncompressedSize = pageHeader.getUncompressed_page_size();
final DrillBuf dictionaryData = readPage(pageHeader, compressedSize, uncompressedSize);
allocatedDictionaryBuffers.add(dictionaryData);
DictionaryPage page = new DictionaryPage(asBytesInput(dictionaryData, 0, uncompressedSize), pageHeader.uncompressed_page_size, pageHeader.dictionary_page_header.num_values, valueOf(pageHeader.dictionary_page_header.encoding.name()));
this.dictionary = page.getEncoding().initDictionary(parentStatus.columnDescriptor, page);
}
Aggregations