@Override public void readFully(final byte[] b, final int off, final int len) throws IOException { memory.getBytes(position, b, off, len); position+=len; }
public void set(final long index, final DoubleArray doubles, final long start, final long length) { doubles.buffer.getBytes(index*TYPE_SIZE, this.buffer, start*TYPE_SIZE, length*TYPE_SIZE); }
public void set(final long index, final IntArray ints, final long start, final long length) { ints.buffer.getBytes(index*TYPE_SIZE, this.buffer, start*TYPE_SIZE, length*TYPE_SIZE); }
public void set(final long index, final ByteArray bytes, final long start, final long length) { bytes.buffer.getBytes(index, this.buffer, start, length); }
public void set(final long index, final LongArray longs, final long start, final long length) { longs.buffer.getBytes(index*TYPE_SIZE, this.buffer, start*TYPE_SIZE, length*TYPE_SIZE); }
public void set(final long index, final FloatArray floats, final long start, final long length) { floats.buffer.getBytes(index*TYPE_SIZE, this.buffer, start*TYPE_SIZE, length*TYPE_SIZE); }
public void set(final long index, final CharArray chars, final long start, final long length) { chars.buffer.getBytes(index*TYPE_SIZE, this.buffer, start*TYPE_SIZE, length*TYPE_SIZE); }
public void set(final long index, final ShortArray shorts, final long start, final long length) { shorts.buffer.getBytes(index*TYPE_SIZE, this.buffer, start*TYPE_SIZE, length*TYPE_SIZE); }
public void get(final long index, final byte[] bytes, final int start, final int length) { buffer.getBytes(index, bytes, start, length); }
@Override public int read(byte[] b, int off, int len) throws IOException { //min of int and long is guaranteed to be int final int read = (int)Math.min(len, length()-position); if (read == 0) return -1; memory.getBytes(position, b, off, read); position+=read; return read; }
private void syncPage(int index) throws IOException { final PageTableEntry pte = pageTable[index]; final long address = (long)index << PAGE_BITS; synchronized (pte) { if (pte.dirty) { if (log.isDebugEnabled()) log.debug("synchronizing page in file " + file.getPath() + " at address " + address); final int pageLength = (int)Math.min(PAGE_SIZE, length-address); synchronized (raf) { pte.memory.getBytes(0, pageBuffer, 0, pageLength); raf.seek(address); raf.write(pageBuffer, 0, pageLength); } pte.dirty = false; } } }
@Override public void putBytes(long l, Memory source, long start, long length) { checkBounds(l, length); source.getBytes(start, data, (int)(offset+l), (int)length); }
@Override public int read(ByteBuffer dst) throws IOException { if (memory.length()-position <= 0) return -1; final int length = (int)Math.min(dst.remaining(), memory.length()-position); dst.limit(length); memory.getBytes(position, dst); position+=length; return length; }
@Override public void putBytes(long l, Memory source, long start, long length) { if (source.isDirect()) { putBytes(l, (DirectMemory) source, start, length); } else { source.getBytes(start, this, l, length); } }
public String getString(final int docId) { final int address = docIdToAddress.getInt(docId << 2); final int firstByte = stringValues.getByte(address)&0xFF; final int length; final int valOffset; if (firstByte == 0xFF) { length = stringValues.getInt(address+1); valOffset = address+5; } else { length = firstByte; valOffset = address+1; } final byte[] bytes = new byte[length]; stringValues.getBytes(valOffset, bytes); return new String(bytes, Charsets.UTF_8); }