private int findNextBatchRecord(ByteSequence bs, RandomAccessFile reader) throws IOException { final ByteSequence header = new ByteSequence(BATCH_CONTROL_RECORD_HEADER); int pos = 0; while (true) { pos = bs.indexOf(header, 0); if (pos >= 0) { bs.setOffset(bs.offset + pos); return pos; } else { // need to load the next data chunck in.. if (bs.length != bs.data.length) { // If we had a short read then we were at EOF return -1; } bs.setOffset(bs.length - BATCH_CONTROL_RECORD_HEADER.length); bs.reset(); bs.setLength(bs.length + reader.read(bs.data, bs.length, bs.data.length - BATCH_CONTROL_RECORD_HEADER.length)); } } }
private int findNextBatchRecord(ByteSequence bs, RandomAccessFile reader) throws IOException { final ByteSequence header = new ByteSequence(BATCH_CONTROL_RECORD_HEADER); int pos = 0; while (true) { pos = bs.indexOf(header, 0); if (pos >= 0) { bs.setOffset(bs.offset + pos); return pos; } else { // need to load the next data chunck in.. if (bs.length != bs.data.length) { // If we had a short read then we were at EOF return -1; } bs.setOffset(bs.length - BATCH_CONTROL_RECORD_HEADER.length); bs.reset(); bs.setLength(bs.length + reader.read(bs.data, bs.length, bs.data.length - BATCH_CONTROL_RECORD_HEADER.length)); } } }
private int findNextBatchRecord(ByteSequence bs, RandomAccessFile reader) throws IOException { final ByteSequence header = new ByteSequence(BATCH_CONTROL_RECORD_HEADER); int pos = 0; while (true) { pos = bs.indexOf(header, 0); if (pos >= 0) { bs.setOffset(bs.offset + pos); return pos; } else { // need to load the next data chunck in.. if (bs.length != bs.data.length) { // If we had a short read then we were at EOF return -1; } bs.setOffset(bs.length - BATCH_CONTROL_RECORD_HEADER.length); bs.reset(); bs.setLength(bs.length + reader.read(bs.data, bs.length, bs.data.length - BATCH_CONTROL_RECORD_HEADER.length)); } } }
private int findNextBatchRecord(ByteSequence bs, RandomAccessFile reader) throws IOException { final ByteSequence header = new ByteSequence(BATCH_CONTROL_RECORD_HEADER); int pos = 0; while (true) { pos = bs.indexOf(header, 0); if (pos >= 0) { bs.setOffset(bs.offset + pos); return pos; } else { // need to load the next data chunck in.. if (bs.length != bs.data.length) { // If we had a short read then we were at EOF return -1; } bs.setOffset(bs.length - BATCH_CONTROL_RECORD_HEADER.length); bs.reset(); bs.setLength(bs.length + reader.read(bs.data, bs.length, bs.data.length - BATCH_CONTROL_RECORD_HEADER.length)); } } }