private void positionBufferForOffset(ByteBuffer buffer, int offset) throws IOException { if (useMemoryMappedBuffer) { buffer.position(offset); return; } // Check to see if requested offset is already loaded; ensure that record header is in the // buffer if (currentOffset <= offset && currentOffset + buffer.limit() >= offset + 8) { buffer.position(toBufferOffset(offset)); } else { if (!randomAccessEnabled) { throw new UnsupportedOperationException("Random Access not enabled"); } FileChannel fc = (FileChannel) this.channel; fc.position(offset); currentOffset = offset; buffer.position(0); buffer.limit(buffer.capacity()); fill(buffer, fc); buffer.flip(); } }
throws IOException { buffer.position(this.toBufferOffset(record.end)); buffer.order(ByteOrder.BIG_ENDIAN);
private int getNextOffset() throws IOException { if(currentShape >= 0) { return this.toBufferOffset(shxReader.getOffsetInBytes(currentShape)); } else { return this.toBufferOffset(record.end); } }
/** * If there exists another record. Currently checks the stream for the * presence of 8 more bytes, the length of a record. If this is true and the * record indicates the next logical record number (if checkRecord == true), * there exists more records. * * @param checkRecno * If true then record number is checked * @throws IOException * @return True if has next record, false otherwise. */ private boolean hasNext(boolean checkRecno) throws IOException { // mark current position int position = buffer.position(); // ensure the proper position, regardless of read or handler behavior buffer.position(this.toBufferOffset(record.end)); // no more data left if (buffer.remaining() < 8) return false; // looks good boolean hasNext = true; if (checkRecno) { // record headers in big endian buffer.order(ByteOrder.BIG_ENDIAN); hasNext = buffer.getInt() == record.number + 1; } // reset things to as they were buffer.position(position); return hasNext; }
private void positionBufferForOffset(ByteBuffer buffer, int offset) throws IOException { if (useMemoryMappedBuffer) { buffer.position(offset); return; } // Check to see if requested offset is already loaded; ensure that record header is in the buffer if (currentOffset <= offset && currentOffset + buffer.limit() >= offset + 8) { buffer.position(toBufferOffset(offset)); } else { if (!randomAccessEnabled) { throw new UnsupportedOperationException("Random Access not enabled"); } FileChannel fc = (FileChannel) this.channel; fc.position(offset); currentOffset = offset; buffer.position(0); buffer.limit(buffer.capacity()); fill(buffer, fc); buffer.flip(); } }
throws IOException { buffer.position(this.toBufferOffset(record.end)); buffer.order(ByteOrder.BIG_ENDIAN);
throws IOException { buffer.position(this.toBufferOffset(record.end)); buffer.order(ByteOrder.BIG_ENDIAN);
throws IOException { buffer.position(this.toBufferOffset(record.end)); buffer.order(ByteOrder.BIG_ENDIAN);
buffer.position(this.toBufferOffset(offset)); } else { FileChannel fc = (FileChannel) this.channel;
buffer.position(this.toBufferOffset(offset)); } else { FileChannel fc = (FileChannel) this.channel;
buffer.position(this.toBufferOffset(record.end));