public void populate(final int count){ for (int i = 0; i < count; i++) { if(value != null) { ((VarBinaryVector) vector).setSafe(i, value, 0, value.length); } } vector.setValueCount(count); }
private void setOutputRowCount(int count) { for (ValueVector vv : familyVectorMap.values()) { vv.setValueCount(count); } if (rowKeyVector != null) { rowKeyVector.setValueCount(count); } }
private static void writeVarBinaryData(VarBinaryVector vector, int valueCount) { Charset utf8Charset = Charset.forName("UTF-8"); final byte[] even = "AAAAA1".getBytes(utf8Charset); final byte[] odd = "BBBBBBBBB2".getBytes(utf8Charset); for (int i = 0; i < valueCount; i++) { if (i % 2 == 0) { vector.setSafe(i, even); } else { vector.setSafe(i, odd); } } vector.setValueCount(valueCount); }
/** * Create an ndarray vector that stores structs * of {@link INDArray} * based on the {@link org.apache.arrow.flatbuf.Tensor} * format * @param allocator the allocator to use * @param name the name of the vector * @param length the number of vectors to store * @return */ public static VarBinaryVector ndarrayVectorOf(BufferAllocator allocator,String name,int length) { VarBinaryVector ret = new VarBinaryVector(name,allocator); ret.allocateNewSafe(); ret.setValueCount(length); return ret; }
public void writeNull() { vector.setNull(idx()); vector.setValueCount(idx()+1); } }
public void write(NullableVarBinaryHolder h) { vector.setSafe(idx(), h); vector.setValueCount(idx()+1); }
public void write(VarBinaryHolder h) { vector.setSafe(idx(), h); vector.setValueCount(idx()+1); }
public void writeVarBinary(int start, int end, ArrowBuf buffer) { vector.setSafe(idx(), 1, start, end, buffer); vector.setValueCount(idx()+1); }
@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 < numRowsPerBatch && batchSize < numBytesPerBatch && reader.next(key, value)) { keyVector.setSafe(recordCount, key.getBytes(), 0, key.getLength()); valueVector.setSafe(recordCount, value.getBytes(), 0, value.getLength()); batchSize += (key.getLength() + value.getLength()); ++recordCount; } keyVector.setValueCount(recordCount); valueVector.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); } }
static void populate(VarBinaryVector vector, byte[][] values){ vector.allocateNew(); Random r = new Random(); for(int i =0; i < values.length; i++){ byte[] val = values[i]; if(val != null){ vector.setSafe(i, val, 0, val.length); } else { // add noise. this confirms that after pivot, noise is gone. byte[] bytes = new byte[r.nextInt(15)]; r.nextBytes(bytes); vector.setSafe(i, bytes, 0, bytes.length); vector.setNull(i); } } vector.setValueCount(values.length); }
private static VectorContainer buildBinaryGlobalDictionary(List<Dictionary> dictionaries, VectorContainer existingDict, ColumnDescriptor columnDescriptor, BufferAllocator bufferAllocator) { final Field field = new Field(SchemaPath.getCompoundPath(columnDescriptor.getPath()).getAsUnescapedPath(), true, new ArrowType.Binary(), null); final VectorContainer input = new VectorContainer(bufferAllocator); final VarBinaryVector binaryVector = input.addOrGet(field); binaryVector.allocateNew(); final SortedSet<Binary> values = new TreeSet<>(); for (Dictionary dictionary : dictionaries) { for (int i = 0; i <= dictionary.getMaxId(); ++i) { values.add(dictionary.decodeToBinary(i)); } } if (existingDict != null) { final VarBinaryVector existingDictValues = existingDict.getValueAccessorById(VarBinaryVector.class, 0).getValueVector(); for (int i = 0; i < existingDict.getRecordCount(); ++i) { values.add(Binary.fromConstantByteArray(existingDictValues.get(i))); } } final Iterator<Binary> iter = values.iterator(); int recordCount = 0; while (iter.hasNext()) { final byte[] data = iter.next().getBytes(); binaryVector.setSafe(recordCount++, data, 0, data.length); } binaryVector.setValueCount(recordCount); input.setRecordCount(recordCount); input.buildSchema(BatchSchema.SelectionVectorMode.NONE); return input; }
final VarBinaryVector dictionary = dictionaries.get(fieldName).getValueAccessorById(VarBinaryVector.class, 0).getValueVector(); decodeBinary(input, output, dictionary); output.setValueCount(recordsConsumedCurrentBatch);
binVector.setSafe(3, "THREE".getBytes(), 0, "TWO".getBytes().length); intVector.setValueCount(4); binVector.setValueCount(4);
binaryVector.setSafe(3, "def".getBytes(UTF8), 0, 3); binaryVector.setSafe(4, "efg".getBytes(UTF8), 0, 3); binaryVector.setValueCount(5); dict2.setRecordCount(5); dict2.buildSchema(BatchSchema.SelectionVectorMode.NONE);