@Override public Text readText() { return getReaderForIndex(idx()).readText(); }
@Override public void writeVar16Char(FieldReader reader) throws IOException { if (reader.isSet()) { writeVar16Char(reader.readText().toString()); } else { writeVar16charNull(); } }
@Override public void writeVarChar(FieldReader reader) throws IOException { if (reader.isSet()) { writeVarChar(reader.readText().toString()); } else { writeVarcharNull(); } }
public void writeVarChar(FieldReader reader, JsonOutputContext context) throws IOException { if (reader.isSet()) { // NB: For UnionReader(s), reader.isSet() checks if the reader has a type set, not if the data itself is null final Text text = reader.readText(); if (text != null) { String value = text.toString(); if (value.length() > context.getRemaining()) { // Truncate the string if the space is limited value = value.substring(0, context.getRemaining()); context.setTruncated(); } writeVarChar(value); context.used(value.length()); return; } } // Either the type or the value is not set writeNull(context); }
break; case VARCHAR: output.write(String.valueOf(nestedReader.readText()).getBytes()); break; case VARBINARY:
/** Helper method to get the values in given range in colVarChar vector used in this test class. */ private static List<String> getVarCharValues(VectorContainer container, int start, int end) { FieldReader reader = container.getValueAccessorById(VarCharVector.class, 1).getValueVector().getReader(); List<String> values = Lists.newArrayList(); for(int i=start; i<end; i++) { reader.setPosition(i); if (reader.isSet()) { final Text val = reader.readText(); values.add(val == null ? null : val.toString()); } else { values.add(null); } } return values; }
break; case VARCHAR: Text text = from.readText(); workBuf = workBuf.reallocIfNeeded(text.getLength()); workBuf.setBytes(0, text.getBytes());