@Test public void convertTextDataToLines() throws Exception { String data = "Qué será será\n" + "Whatever will be will be\n" + "We are going\n" + "to Wembeley!\n"; byte[] dataBytes = data.getBytes(); String[] dataLines = new String[]{ "Qué será será\n", "Whatever will be will be\n", "We are going\n", "to Wembeley!\n"}; OneField field = new OneField(DataType.BYTEA.getOID(), dataBytes); List<OneField> fields = new ArrayList<>(); fields.add(field); RequestContext context = new RequestContext(); addColumn(context, 0, DataType.TEXT, "col0"); context.setStatsMaxFragments(100); context.setStatsSampleRatio(1f); BridgeOutputBuilder builder = makeBuilder(context); LinkedList<Writable> outputQueue = builder.makeOutput(fields); assertEquals(4, outputQueue.size()); for (int i = 0; i < dataLines.length; ++i) { Writable line = outputQueue.get(i); compareBufferWritable(line, dataLines[i]); } assertNull(builder.getPartialLine()); }
void convertTextDataToLines(byte[] val) { int len = val.length; int start = 0; int end = 0; byte[] line; BufferWritable writable; while (start < len) { end = ArrayUtils.indexOf(val, DELIM, start); if (end == ArrayUtils.INDEX_NOT_FOUND) { end = len; isPartialLine = true; } else { end++; isPartialLine = false; } line = Arrays.copyOfRange(val, start, end); if (partialLine != null) { ((BufferWritable) partialLine).append(line); writable = (BufferWritable) partialLine; partialLine = null; } else { writable = new BufferWritable(line); } if (isPartialLine) { partialLine = writable; } else { outputList.add(writable); } start = end; } }
BridgeOutputBuilder { void convertTextDataToLines(byte[] val) { int len = val.length; int start = 0; int end = 0; byte[] line; BufferWritable writable; while (start < len) { end = ArrayUtils.indexOf(val, DELIM, start); if (end == ArrayUtils.INDEX_NOT_FOUND) { end = len; isPartialLine = true; } else { end++; isPartialLine = false; } line = Arrays.copyOfRange(val, start, end); if (partialLine != null) { ((BufferWritable) partialLine).append(line); writable = (BufferWritable) partialLine; partialLine = null; } else { writable = new BufferWritable(line); } if (isPartialLine) { partialLine = writable; } else { outputList.add(writable); } start = end; } } }
BridgeOutputBuilder { void convertTextDataToLines(byte[] val) { int len = val.length; int start = 0; int end = 0; byte[] line; BufferWritable writable; while (start < len) { end = ArrayUtils.indexOf(val, DELIM, start); if (end == ArrayUtils.INDEX_NOT_FOUND) { end = len; isPartialLine = true; } else { end++; isPartialLine = false; } line = Arrays.copyOfRange(val, start, end); if (partialLine != null) { ((BufferWritable) partialLine).append(line); writable = (BufferWritable) partialLine; partialLine = null; } else { writable = new BufferWritable(line); } if (isPartialLine) { partialLine = writable; } else { outputList.add(writable); } start = end; } } BridgeOutputBuilder(RequestContext context); }
BridgeOutputBuilder { void convertTextDataToLines(byte[] val) { int len = val.length; int start = 0; int end = 0; byte[] line; BufferWritable writable; while (start < len) { end = ArrayUtils.indexOf(val, DELIM, start); if (end == ArrayUtils.INDEX_NOT_FOUND) { end = len; isPartialLine = true; } else { end++; isPartialLine = false; } line = Arrays.copyOfRange(val, start, end); if (partialLine != null) { ((BufferWritable) partialLine).append(line); writable = (BufferWritable) partialLine; partialLine = null; } else { writable = new BufferWritable(line); } if (isPartialLine) { partialLine = writable; } else { outputList.add(writable); } start = end; } } BridgeOutputBuilder(RequestContext context); Writable getErrorOutput(Exception ex); LinkedList<Writable> makeOutput(List<OneField> recFields); LinkedList<Writable> makeVectorizedOutput(List<List<OneField>> recordsBatch); Writable getPartialLine(); }
BridgeOutputBuilder { void convertTextDataToLines(byte[] val) { int len = val.length; int start = 0; int end = 0; byte[] line; BufferWritable writable; while (start < len) { end = ArrayUtils.indexOf(val, DELIM, start); if (end == ArrayUtils.INDEX_NOT_FOUND) { end = len; isPartialLine = true; } else { end++; isPartialLine = false; } line = Arrays.copyOfRange(val, start, end); if (partialLine != null) { ((BufferWritable) partialLine).append(line); writable = (BufferWritable) partialLine; partialLine = null; } else { writable = new BufferWritable(line); } if (isPartialLine) { partialLine = writable; } else { outputList.add(writable); } start = end; } } BridgeOutputBuilder(RequestContext context); Writable getErrorOutput(Exception ex); LinkedList<Writable> makeOutput(List<OneField> recFields); LinkedList<Writable> makeVectorizedOutput(List<List<OneField>> recordsBatch); Writable getPartialLine();  }