@Override public boolean endField() { fieldOpen = false; if(collect) { assert currentVector != null; currentVector.setSafe(recordCount, fieldBytes, 0, currentDataPointer); } if (currentDataPointer > 0) { this.rowHasData = true; } return currentFieldIndex < maxField; }
private static void writeVarCharData(VarCharVector 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); } }
@Override public void setSafeValue(ObjectInspector oi, Object hiveFieldValue, ValueVector outputVV, int outputIndex) { final Text value = ((StringObjectInspector)oi).getPrimitiveWritableObject(hiveFieldValue); final byte[] valueBytes = value.getBytes(); final int len = value.getLength(); ((VarCharVector) outputVV).setSafe(outputIndex, valueBytes, 0, len); } }
public void populate(final int count){ for (int i = 0; i < count; i++) { if(value != null) { ((VarCharVector) vector).setSafe(i, value, 0, value.length); } } vector.setValueCount(count); }
@Override public boolean setSafe(int index, ArrowBuf value, int start, int length) { if (index >= vector.getValueCapacity()) { return false; } if (usingDictionary) { ByteBuffer buf = currDictValToWrite.toByteBuffer(); vector.setSafe(index, buf, buf.position(), currDictValToWrite.length()); } else { vector.setSafe(index, 1, start, start + length, value); } return true; }
@Override public void setSafeValue(ObjectInspector oi, Object hiveFieldValue, ValueVector outputVV, int outputIndex) { final Text value = ((HiveVarcharObjectInspector)oi).getPrimitiveWritableObject(hiveFieldValue).getTextValue(); final byte[] valueBytes = value.getBytes(); final int valueLen = value.getLength(); ((VarCharVector) outputVV).setSafe(outputIndex, valueBytes, 0, valueLen); } }
@Override public void setSafeValue(ObjectInspector oi, Object hiveFieldValue, ValueVector outputVV, int outputIndex) { final Text value = ((HiveCharObjectInspector)oi).getPrimitiveWritableObject(hiveFieldValue).getStrippedValue(); final byte[] valueBytes = value.getBytes(); final int valueLen = value.getLength(); ((VarCharVector) outputVV).setSafe(outputIndex, valueBytes, 0, valueLen); } }
protected void set(int index, VarCharVector v, String value){ byte[] bytesValue = value.getBytes(Charsets.UTF_8); v.setSafe(index, bytesValue, 0, bytesValue.length); }
@Override public boolean setSafe(int index, ArrowBuf bytebuf, int start, int length) { if (index >= varCharVector.getValueCapacity()) { return false; } if (usingDictionary) { currDictValToWrite = pageReader.dictionaryValueReader.readBytes(); ByteBuffer buf = currDictValToWrite.toByteBuffer(); varCharVector.setSafe(index, buf, buf.position(), currDictValToWrite.length()); } else { varCharVector.setSafe(index, 1, start, start + length, bytebuf); } return true; }
/** * Same as {@link #set(int, NullableVarCharHolder)} except that it handles the * case where index and length of new element are beyond the existing * capacity of the vector. * * @param index position of the element to set. * @param text Text object with data */ public void setSafe(int index, Text text) { setSafe(index, text.getBytes(), 0, text.getLength()); }
public void writeString(String s, int outboundIndex) throws IllegalArgumentException, IllegalAccessException { if (s == null) { return; } else { h.isSet = 1; byte[] bytes = s.getBytes(Charsets.UTF_8); ensureLength(bytes.length); data.clear(); data.writeBytes(bytes); h.buffer = data; h.start = 0; h.end = bytes.length; vector.setSafe(outboundIndex, h); } }
public void writeVarChar(int start, int end, ArrowBuf buffer) { vector.setSafe(idx(), 1, start, end, buffer); vector.setValueCount(idx()+1); }
public void writeVarChar(Text value) { vector.setSafe(idx(), value); vector.setValueCount(idx()+1); }
public void write(VarCharHolder h) { vector.setSafe(idx(), h); vector.setValueCount(idx()+1); }
public void write(NullableVarCharHolder h) { vector.setSafe(idx(), h); vector.setValueCount(idx()+1); }
@Override protected void generateRecord(long globalRecordIndex, int outputIndex) { regionKey.setSafe(outputIndex, globalRecordIndex); byte[] nameVal = regions.getValue((int) globalRecordIndex).getBytes(Charsets.UTF_8); name.setSafe(outputIndex, nameVal, 0, nameVal.length); // comment byte[] commentVal = commentRandom.nextValue().getBytes(Charsets.UTF_8); comment.setSafe(outputIndex, commentVal, 0, commentVal.length); }
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; }
@Override public void set(ValueVector v, int index) { if(obj != null){ byte[] bytes = obj.getBytes(); ((VarCharVector) v).setSafe(index, bytes, 0, obj.getLength()); } }
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; }
@Override protected void generateRecord(long globalRecordIndex, int outputIndex) { nationKey.setSafe(outputIndex, globalRecordIndex); byte[] nameVal = nations.getValue((int) globalRecordIndex).getBytes(Charsets.UTF_8); name.setSafe(outputIndex, nameVal, 0, nameVal.length); regionKey.setSafe(outputIndex, nations.getWeight((int) globalRecordIndex)); // comment byte[] commentVal = commentRandom.nextValue().getBytes(Charsets.UTF_8); comment.setSafe(outputIndex, commentVal, 0, commentVal.length); }