byte[] value = (byte[]) val; for (int i = start; i < end; i++) { v.getMutator().setSafe(i, value, 0, value.length);
final int valueLength = cell.getValueLength(); final byte[] valueArray = cell.getValueArray(); v.getMutator().setSafe(rowCount, valueArray, valueOffset, valueLength);
@Override public int next() { final Stopwatch watch = Stopwatch.createStarted(); if (keyVector != null) { keyVector.clear(); keyVector.allocateNew(); } if (valueVector != null) { valueVector.clear(); valueVector.allocateNew(); } int recordCount = 0; int batchSize = 0; try { while (recordCount < PER_BATCH_RECORD_COUNT && batchSize < PER_BATCH_BYTES && reader.next(key, value)) { keyVector.getMutator().setSafe(recordCount, key.getBytes(), 0, key.getLength()); valueVector.getMutator().setSafe(recordCount, value.getBytes(), 0, value.getLength()); batchSize += (key.getLength() + value.getLength()); ++recordCount; } keyVector.getMutator().setValueCount(recordCount); valueVector.getMutator().setValueCount(recordCount); logger.debug("Read {} records in {} ms", recordCount, watch.elapsed(TimeUnit.MILLISECONDS)); return recordCount; } catch (IOException ioe) { close(); throw UserException.dataReadError(ioe).addContext("File Path", split.getPath().toString()).build(logger); } }
@Override protected void readField(long recordsToReadInThisPass) { this.bytebuf = pageReader.pageData; if (usingDictionary) { NullableVarBinaryVector.Mutator mutator = valueVec.getMutator(); Binary currDictValToWrite; for (int i = 0; i < recordsToReadInThisPass; i++) { currDictValToWrite = pageReader.dictionaryValueReader.readBytes(); ByteBuffer buf = currDictValToWrite.toByteBuffer(); mutator.setSafe(valuesReadInCurrentPass + i, buf, buf.position(), 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 = castedBaseVector.getBuffer().writerIndex(); castedBaseVector.getBuffer().setIndex(0, writerIndex + (int) readLength); } else { super.readField(recordsToReadInThisPass); // TODO - replace this with fixed binary type in drill // for 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); } } } }
public void write(NullableVarBinaryHolder h) { mutator.setSafe(idx(), h); vector.getMutator().setValueCount(idx()+1); }
public void writeNull() { mutator.setNull(idx()); vector.getMutator().setValueCount(idx() + 1); }
public void setSafe(int index, NullableVarBinaryHolder holder) { setType(index, MinorType.VARBINARY); getVarBinaryVector().getMutator().setSafe(index, holder); }
@Override public boolean setSafe(int index, DrillBuf value, int start, int length) { if (index >= nullableVarBinaryVector.getValueCapacity()) { return false; } if (usingDictionary) { ByteBuffer buf = currDictValToWrite.toByteBuffer(); mutator.setSafe(index, buf, buf.position(), currDictValToWrite.length()); } else { mutator.setSafe(index, 1, start, start + length, value); } return true; }
@Override public void setValueCount(int valueCount) { assert valueCount >= 0; fillEmpties(valueCount); values.getMutator().setValueCount(valueCount); bits.getMutator().setValueCount(valueCount); } /** Enables this wrapper container class to participate in bulk mutator logic */
@Override public void toNullable(ValueVector nullableVector) { NullableVarBinaryVector dest = (NullableVarBinaryVector) nullableVector; dest.getMutator().fromNotNullable(this); }
@Override public void exchange(ValueVector other) { NullableVarBinaryVector target = (NullableVarBinaryVector) other; bits.exchange(target.bits); values.exchange(target.values); mutator.exchange(other.getMutator()); }
public void write(VarBinaryHolder h) { mutator.setSafe(idx(), h); vector.getMutator().setValueCount(idx()+1); }
public void writeVarBinary(int start, int end, DrillBuf buffer) { mutator.setSafe(idx(), 1, start, end, buffer); vector.getMutator().setValueCount(idx() + 1); }
public void setSafe(int index, VarBinaryHolder value) { if (index > lastSet + 1) { fillEmpties(index); } bits.getMutator().setSafe(index, 1); values.getMutator().setSafe(index, value); setCount++; lastSet = index; }
public void setSafe(int index, int isSet, int startField, int endField, DrillBuf bufferField ) { if (index > lastSet + 1) { fillEmpties(index); } bits.getMutator().setSafe(index, isSet); values.getMutator().setSafe(index, startField, endField, bufferField); setCount++; lastSet = index; }
public void setSafe(int index, byte[] value, int start, int length) { if (index > lastSet + 1) { fillEmpties(index); } bits.getMutator().setSafe(index, 1); values.getMutator().setSafe(index, value, start, length); setCount++; lastSet = index; }
@Override public void generateTestData(int valueCount){ bits.getMutator().generateTestDataAlt(valueCount); values.getMutator().generateTestData(valueCount); lastSet = valueCount; setValueCount(valueCount); }
public void fromNotNullable(VarBinaryVector srce) { clear(); final int valueCount = srce.getAccessor().getValueCount(); // Create a new bits vector, all values non-null fillBitsVector(getBitsVector(), valueCount); // Swap the data portion getValuesVector().exchange(srce); lastSet = valueCount; setValueCount(valueCount); } }
public void setSafe(int index, ByteBuffer value, int start, int length) { if (index > lastSet + 1) { fillEmpties(index); } bits.getMutator().setSafe(index, 1); values.getMutator().setSafe(index, value, start, length); setCount++; lastSet = index; }