/** * Copy a cell value from a particular index in source vector to a particular * position in this vector. * @param inIndex position to copy from in source vector * @param outIndex position to copy to in this vector * @param from source vector */ public void copyFrom(int inIndex, int outIndex, ListVector from) { FieldReader in = from.getReader(); in.setPosition(inIndex); FieldWriter out = getWriter(); out.setPosition(outIndex); ComplexCopier.copy(in, out); }
@Override public void set(ValueVector v, int index) { this.dataVector = ((ListVector)v).getDataVector(); if(obj != null){ UnionListWriter listWriter = ((ListVector)v).getWriter(); listWriter.setPosition(index); List<Integer> list = obj; listWriter.startList(); for (int i = 0; i < list.size(); i++) { listWriter.bigInt().writeBigInt(list.get(i)); } listWriter.endList(); } }
@Override public int next(int records) { if (position == values.size()) { return 0; // no more data available } UnionListWriter listWriter = list.getWriter(); int returned = Math.min(records, values.size() - position); container.allocateNew(); for (int i = 0; i < returned; i++) { int rowId = rowIds.get(position + i); id.setSafe(i, rowId); byte[] valueBytes = values.get(rowId).getBytes(); value.setSafe(i, valueBytes, 0, valueBytes.length); listWriter.setPosition(i); listWriter.startList(); List<Long> list = listValues.get(rowId); for (int j = 0; j < INNER_LIST_SIZE; j++) { listWriter.bigInt().writeBigInt(list.get(j)); } listWriter.endList(); } container.setAllCount(returned); position += returned; return returned; }
UnionListWriter l1IntsWriter = l1IntsVector.getWriter(); UnionListWriter l1StringsWriter = l1StringsVector.getWriter(); UnionListWriter l2IntsWriter = l2IntsVector.getWriter(); UnionListWriter l2StringsWriter = l2StringsVector.getWriter(); UnionListWriter l3IntsWriter = l3IntsVector.getWriter(); UnionListWriter l3StringsWriter = l3StringsVector.getWriter(); NullableStructWriter structWriter = structVector.getWriter();
@Test public void list() throws InterruptedException { try (BufferAllocator allocator = new RootAllocator(Integer.MAX_VALUE); ListVector inVector = new ListVector("input", allocator, null)) { UnionListWriter writer = inVector.getWriter(); writer.allocate(); writer.setPosition(0);