@Override public void addBinary(Binary value) { holder.buffer = buf = buf.reallocIfNeeded(value.length()); buf.setBytes(0, value.toByteBuffer()); holder.start = 0; holder.end = value.length(); writer.write(holder); }
// this method is called by its superclass during a read loop @Override protected void readField(long recordsToReadInThisPass) { recordsReadInThisIteration = Math.min( pageReader.currentPageCount - pageReader.valuesRead, recordsToReadInThisPass - valuesReadInCurrentPass); readLengthInBits = recordsReadInThisIteration * dataTypeLengthInBits; readLength = (int) Math.ceil(readLengthInBits / 8.0); if (usingDictionary) { VarBinaryVector.Mutator mutator = valueVec.getMutator(); Binary currDictValToWrite = null; for (int i = 0; i < recordsReadInThisIteration; i++) { currDictValToWrite = pageReader.dictionaryValueReader.readBytes(); mutator.setSafe( valuesReadInCurrentPass + i, currDictValToWrite.toByteBuffer(), 0, currDictValToWrite.length()); } // Set the write Index. The next page that gets read might be a page that does not use // dictionary encoding // and we will go into the else condition below. The readField method of the parent class // requires the // writer index to be set correctly. int writerIndex = valueVec.getBuffer().writerIndex(); valueVec.getBuffer().setIndex(0, writerIndex + (int) readLength); } else { super.readField(recordsToReadInThisPass); } // TODO - replace this with fixed binary type in drill // now we need to write the lengths of each value int byteLength = dataTypeLengthInBits / 8; for (int i = 0; i < recordsToReadInThisPass; i++) { valueVec.getMutator().setValueLengthSafe(valuesReadInCurrentPass + i, byteLength); } }
@Override public void addBinary(Binary value) { holder.buffer.setBytes(0, value.toByteBuffer()); writer.write(holder); }