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 Page readPage(Page page) throws IOException { // Read the page data pageFile.readPage(page.getPageId(), chunk.getData()); chunk.setOffset(0); chunk.setLength(pageFile.getPageSize()); DataByteArrayInputStream in = new DataByteArrayInputStream(chunk); page.read(in); chunk.setOffset(Page.PAGE_HEADER_SIZE); if (page.getType() == Page.PAGE_END_TYPE) { chunk.setLength((int)(page.getNext())); } if (page.getType() == Page.PAGE_FREE_TYPE) { throw new EOFException("Chunk stream does not exist, page: " + page.getPageId() + " is marked free"); } return page; }
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 Page readPage(Page page) throws IOException { // Read the page data pageFile.readPage(page.getPageId(), chunk.getData()); chunk.setOffset(0); chunk.setLength(pageFile.getPageSize()); DataByteArrayInputStream in = new DataByteArrayInputStream(chunk); page.read(in); chunk.setOffset(Page.PAGE_HEADER_SIZE); if (page.getType() == Page.PAGE_END_TYPE) { chunk.setLength((int)(page.getNext())); } if (page.getType() == Page.PAGE_FREE_TYPE) { throw new EOFException("Chunk stream does not exist, page: " + page.getPageId() + " is marked free"); } return page; }
private Page readPage(Page page) throws IOException { // Read the page data pageFile.readPage(page.getPageId(), chunk.getData()); chunk.setOffset(0); chunk.setLength(pageFile.getPageSize()); DataByteArrayInputStream in = new DataByteArrayInputStream(chunk); page.read(in); chunk.setOffset(Page.PAGE_HEADER_SIZE); if (page.getType() == Page.PAGE_END_TYPE) { chunk.setLength((int)(page.getNext())); } if (page.getType() == Page.PAGE_FREE_TYPE) { throw new EOFException("Chunk stream does not exist, page: " + page.getPageId() + " is marked free"); } return page; }
private Page readPage(Page page) throws IOException { // Read the page data pageFile.readPage(page.getPageId(), chunk.getData()); chunk.setOffset(0); chunk.setLength(pageFile.getPageSize()); DataByteArrayInputStream in = new DataByteArrayInputStream(chunk); page.read(in); chunk.setOffset(Page.PAGE_HEADER_SIZE); if (page.getType() == Page.PAGE_END_TYPE) { chunk.setLength((int)(page.getNext())); } if (page.getType() == Page.PAGE_FREE_TYPE) { throw new EOFException("Chunk stream does not exist, page: " + page.getPageId() + " is marked free"); } return page; }