Java Code Examples for org.apache.arrow.vector.VarCharVector#allocateNew()
The following examples show how to use
org.apache.arrow.vector.VarCharVector#allocateNew() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestVarBinaryPivot.java From dremio-oss with Apache License 2.0 | 6 votes |
static void populate(VarCharVector 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); }
Example 2
Source File: TestSplitAndTransfer.java From dremio-oss with Apache License 2.0 | 5 votes |
@Test public void test() throws Exception { final VarCharVector varCharVector = new VarCharVector("field", allocator); varCharVector.allocateNew(10000, 1000); final int valueCount = 500; final String[] compareArray = new String[valueCount]; for (int i = 0; i < valueCount; i += 3) { final String s = String.format("%010d", i); varCharVector.set(i, s.getBytes()); compareArray[i] = s; } varCharVector.setValueCount(valueCount); final TransferPair tp = varCharVector.getTransferPair(allocator); final VarCharVector newVarCharVector = (VarCharVector) tp.getTo(); final int[][] startLengths = {{0, 201}, {201, 200}, {401, 99}}; for (final int[] startLength : startLengths) { final int start = startLength[0]; final int length = startLength[1]; tp.splitAndTransfer(start, length); newVarCharVector.setValueCount(length); for (int i = 0; i < length; i++) { final boolean expectedSet = ((start + i) % 3) == 0; if (expectedSet) { final byte[] expectedValue = compareArray[start + i].getBytes(); assertFalse(newVarCharVector.isNull(i)); assertArrayEquals(expectedValue, newVarCharVector.get(i)); } else { assertTrue(newVarCharVector.isNull(i)); } } newVarCharVector.clear(); } varCharVector.close(); allocator.close(); }
Example 3
Source File: TestBoundedPivots.java From dremio-oss with Apache License 2.0 | 5 votes |
static String[] populateVarCharValues(VarCharVector vector, int size){ vector.allocateNew(); String values[] = new String[size]; for(int i =0; i < values.length; i++){ if (RAND.nextBoolean()) { values[i] = RandomStringUtils.randomAlphanumeric(RAND.nextInt(25)); vector.setSafe(i, values[i].getBytes(Charsets.UTF_8)); } } vector.setValueCount(values.length); return values; }
Example 4
Source File: TestBoundedPivots.java From dremio-oss with Apache License 2.0 | 5 votes |
static String[] populateVarCharValuesWithoutNull(VarCharVector vector, int size){ vector.allocateNew(); String values[] = new String[size]; for(int i =0; i < values.length; i++){ values[i] = RandomStringUtils.randomAlphanumeric(RAND.nextInt(25)); vector.setSafe(i, values[i].getBytes(Charsets.UTF_8)); } vector.setValueCount(values.length); return values; }
Example 5
Source File: TestArrowFileReader.java From dremio-oss with Apache License 2.0 | 5 votes |
/** Helper method which creates a test varchar vector */ private static VarCharVector testVarCharVector(BufferAllocator allocator) { 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; }
Example 6
Source File: TestData.java From dremio-oss with Apache License 2.0 | 5 votes |
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); }
Example 7
Source File: ArrowStringMemoryAllocator.java From yosegi with Apache License 2.0 | 4 votes |
public ArrowStringMemoryAllocator( final VarCharVector vector , final int rowCount ) { vector.allocateNew(); this.vector = vector; }
Example 8
Source File: ArrowStringMemoryAllocator.java From multiple-dimension-spread with Apache License 2.0 | 4 votes |
public ArrowStringMemoryAllocator( final VarCharVector vector , final int rowCount ){ vector.allocateNew(); this.vector = vector; }