@Override public FieldVector getNewVector( String name, FieldType fieldType, BufferAllocator allocator, CallBack schemaChangeCallback) { return new VarCharVector(name, fieldType, allocator); }
public TransferImpl(String ref, BufferAllocator allocator) { to = new VarCharVector(ref, field.getFieldType(), allocator); }
/** * * @param allocator * @param name * @param length the length of the vector * @return */ public static VarCharVector stringVectorOf(BufferAllocator allocator,String name,int length) { VarCharVector float4Vector = new VarCharVector(name,allocator); float4Vector.allocateNew(); float4Vector.setValueCount(length); return float4Vector; }
/** * * @param allocator * @param name * @param data * @return */ public static VarCharVector vectorFor(BufferAllocator allocator,String name,String[] data) { VarCharVector float4Vector = new VarCharVector(name,allocator); float4Vector.allocateNew(); for(int i = 0; i < data.length; i++) { float4Vector.setSafe(i,data[i].getBytes()); } float4Vector.setValueCount(data.length); return float4Vector; }
/** Helper method which creates a test varchar vector */ private static VarCharVector testVarCharVector() { VarCharVector colVarCharV = new VarCharVector("colVarChar", ALLOCATOR); colVarCharV.allocateNew(500, 5); for(int i=0; i<TEST_VARCHAR_VALUES.size(); i++) { if (TEST_VARCHAR_VALUES.get(i) == null) { colVarCharV.setNull(i); } else { colVarCharV.set(i, TEST_VARCHAR_VALUES.get(i).getBytes()); } } return colVarCharV; }
private static Pair<VarCharVector, ResultVerifier> testVarCharVector(final int startIndexInCurrentOutput, final int startIndexInJob) { VarCharVector colVarCharV = new VarCharVector("colVarChar", allocator); colVarCharV.allocateNew(500, 5); colVarCharV.set(0, "value1".getBytes()); colVarCharV.set(1, "long long long long long long long long long long long long long long long long value".getBytes() ); colVarCharV.set(2, "long long long long value".getBytes()); colVarCharV.setNull(3); colVarCharV.set(4, "l".getBytes()); ResultVerifier verifier = new ResultVerifier() { @Override public void verify(DataPOJO output) { int index = startIndexInCurrentOutput; int uIndex = startIndexInJob; assertEquals("value1", output.extractValue("colVarChar", index)); assertNull(output.extractUrl("colVarChar", index++)); uIndex++; assertEquals("long long long long long long ", output.extractValue("colVarChar", index)); assertEquals(cellUrl(uIndex++, "colVarChar"), output.extractUrl("colVarChar", index++)); assertEquals("long long long long value", output.extractValue("colVarChar", index)); assertNull(output.extractUrl("colVarChar", index++)); assertNull(output.extractValue("colVarChar", index)); assertNull(output.extractUrl("colVarChar", index++)); assertEquals("l", output.extractValue("colVarChar", index)); assertNull(output.extractUrl("colVarChar", index++)); } }; return Pair.of(colVarCharV, verifier); }
final int count = 1024; try( VarCharVector in = new VarCharVector("in", allocator); VarCharVector out = new VarCharVector("out", allocator); ){
@Test public void varcharRoundtrip() throws Exception { final int count = 1024; try ( VarCharVector in = new VarCharVector("in", allocator); VarCharVector out = new VarCharVector("out", allocator); ) { in.allocateNew(count * 8, count); for (int i = 0; i < count; i++) { if (i % 5 == 0) { byte[] data = ("hello-" + i).getBytes(Charsets.UTF_8); in.setSafe(i, data, 0, data.length); } } in.setValueCount(count); final PivotDef pivot = PivotBuilder.getBlockDefinition(new FieldVectorPair(in, out)); try ( final FixedBlockVector fbv = new FixedBlockVector(allocator, pivot.getBlockWidth()); final VariableBlockVector vbv = new VariableBlockVector(allocator, pivot.getVariableCount()); ) { fbv.ensureAvailableBlocks(count); Pivots.pivot(pivot, count, fbv, vbv); ValueVector[] ins = new ValueVector[]{in}; ValueVector[] outs = new ValueVector[]{out}; unpivotHelper(pivot, fbv, vbv, ins, outs, 0, count); unpivotHelper(pivot, fbv, vbv, ins, outs, 0, 100); unpivotHelper(pivot, fbv, vbv, ins, outs, 100, 924); } } }
BigIntVector col3 = new BigIntVector("col3", allocator); TimeMilliVector col4 = new TimeMilliVector("col4", allocator); VarCharVector col5 = new VarCharVector("col5", allocator); VarCharVector col6 = new VarCharVector("col6", allocator); BitVector col7 = new BitVector("col7", allocator); ){
@Test public void test() throws Exception { final VarCharVector varCharVector = new VarCharVector("field", allocator); varCharVector.allocateNew(10000, 1000);
@Test public void testLoadValueVector() throws Exception { final ValueVector fixedV = new IntVector("ints", allocator); final ValueVector varlenV = new VarCharVector("chars", allocator); final ValueVector nullableVarlenV = new VarCharVector("chars", allocator);
VarCharVector col1 = new VarCharVector("col1", allocator); TestVarBinaryPivot.populate(col1, col1arr); c.add(col1); VarCharVector col2 = new VarCharVector("col2", allocator); TestVarBinaryPivot.populate(col2, col2arr); c.add(col2);
return new VarBinaryVector(field.getName(), allocator); case VARCHAR: return new VarCharVector(field.getName(), allocator); case BIT: return new BitVector(field.getName(), allocator);
final VectorContainer c = new VectorContainer();) { VarCharVector col1 = new VarCharVector("col1", allocator); TestVarBinaryPivot.populate(col1, col1Arr); c.add(col1); VarCharVector col2 = new VarCharVector("col2", allocator); TestVarBinaryPivot.populate(col2, col2Arr); c.add(col2);
new VarCharVector("colVarChar", ALLOCATOR), testEmptyListVector(), testEmptyUnionVector());
final VectorContainer c = new VectorContainer();) { VarCharVector col1 = new VarCharVector("col1", allocator); c.add(col1); VarCharVector col2 = new VarCharVector("col2", allocator); c.add(col2); IntVector col3 = new IntVector("col3", allocator);
VarCharVector col1 = new VarCharVector("col1", allocator); TestVarBinaryPivot.populate(col1, col1arr); c.add(col1); VarCharVector col2 = new VarCharVector("col2", allocator); TestVarBinaryPivot.populate(col2, col2arr); c.add(col2);
final VectorContainer c = new VectorContainer();) { VarCharVector col1 = new VarCharVector("col1", allocator); TestVarBinaryPivot.populate(col1, col1arr); c.add(col1); VarCharVector col2 = new VarCharVector("col2", allocator); TestVarBinaryPivot.populate(col2, col2arr); c.add(col2);
try(IntVector col1 = new IntVector("col1", allocator); BigIntVector col2 = new BigIntVector("col2", allocator); VarCharVector col3 = new VarCharVector("col3", allocator);){
try(IntVector col1 = new IntVector("col1", allocator); BigIntVector col2 = new BigIntVector("col2", allocator); VarCharVector col3 = new VarCharVector("col3", allocator);){