private static void consumeField(int fieldIdx, TypeExtractor typeExtractor, Pipe output, byte[] data, int offset, int length) { TypeExtractor.resetFieldSum(typeExtractor); TypeExtractor.appendContent(typeExtractor, data, offset, offset+length); //NOTE: in this case fieldIdx is not used however it holds the column number starting with zero // System.err.println("xxxxx "+new String(data,offset,length)); writeMetaMessage(typeExtractor, data, offset, length, output); //TODO: As an alternate implementation we can // * Open a message of type X in beginningOfLine() ByteBuffer.addMessageIDx(x) // * For every call including zero lookup the type and use they ByteBuffer.add XXX // * change endOfData to use RingBuffer.publishEOF(ring); // * publish in the endOfLine() method. //TODO: The best approach would be to have these code generated from the template file - see JavaPoet See YF // using the high level API to write would allow us to write the fields in any order that they arrive. // WAIT: may not need code generation. If we pass in array of strings that represent the fields in order // Then on startup convert those strings to an array of LOCs // then on parse use fieldIdx to look up the LOC and type to do the "right thing" // the switch would be a conditional that could be removed by code generation.... but only if needed. }
private static void consumeField(int fieldIdx, TypeExtractor typeExtractor, Pipe output, byte[] data, int offset1, int length1, int offset2, int length2) { TypeExtractor.resetFieldSum(typeExtractor); assert(length1>=0) : "bad length "+length1; TypeExtractor.appendContent(typeExtractor, data, offset1, offset1+length1); assert(length2>=0) : "bad length "+length2; TypeExtractor.appendContent(typeExtractor, data, offset2, offset2+length2); //NOTE: in this case fieldIdx is not used however it holds the column number starting with zero writeMetaMessage(typeExtractor, data, offset1, length1, offset2, length2, output); }