public BasicRecordFile(File file, Serializer<E> serializer) throws IOException { this.file = file; this.serializer = serializer; buffer = new MMapBuffer(file, FileChannel.MapMode.READ_ONLY, ByteOrder.BIG_ENDIAN); memory = buffer.memory(); }
public DynamicMMapBufferDataOutputStream(final File file, final ByteOrder byteOrder) throws IOException { this.file = file; this.byteOrder = byteOrder; buffer = new MMapBuffer(file, 0, 4096, FileChannel.MapMode.READ_WRITE, byteOrder); memory = buffer.memory(); }
public BasicRecordFile(File file, Serializer<E> serializer) throws IOException { this.file = file; this.serializer = serializer; buffer = new MMapBuffer(file, FileChannel.MapMode.READ_ONLY, ByteOrder.BIG_ENDIAN); memory = buffer.memory(); }
public DynamicMMapBufferDataOutputStream(final File file, final ByteOrder byteOrder, long offset) throws IOException { this.file = file; this.byteOrder = byteOrder; buffer = new MMapBuffer(file, 0, Math.max(4096, file.length()), FileChannel.MapMode.READ_WRITE, byteOrder); memory = buffer.memory(); currentAddress = offset; }
public MMapShortArrayIntValueLookup(MMapBuffer buffer, int length) { this.buffer = buffer; this.shortArray = buffer.memory().shortArray(0, length); }
public MMapIntArrayIntValueLookup(MMapBuffer buffer, int length) { this.buffer = buffer; this.intArray = buffer.memory().intArray(0, length); }
public DirectMemory memory() { return buffer.memory().slice(0, currentAddress); }
public void mincore(long position, long length, DirectMemory direct) { if (position+length > memory().length()) { throw new IndexOutOfBoundsException(); } final long ap = address+position; final long a = ap/PAGE_SIZE*PAGE_SIZE; final long l = length+(ap-a); if ((l+PAGE_SIZE-1)/PAGE_SIZE > direct.length()) throw new IndexOutOfBoundsException(); NativeMemoryUtils.mincore(a, l, direct); }
public static @Nullable byte[] getMetadata(File file) throws IOException { final long length = file.length(); final MMapBuffer buffer = new MMapBuffer(file, 0, length, FileChannel.MapMode.READ_ONLY, ByteOrder.BIG_ENDIAN); final DirectMemory memory = buffer.memory(); final int metadataLength = memory.getInt(length - 12); if (metadataLength == Integer.MAX_VALUE) return null; final byte[] metadata = new byte[metadataLength]; memory.getBytes(length-12-metadataLength, metadata); return metadata; }
public static @Nullable byte[] getMetadata(File file) throws IOException { final long length = file.length(); final MMapBuffer buffer = new MMapBuffer(file, 0, length, FileChannel.MapMode.READ_ONLY, ByteOrder.BIG_ENDIAN); final DirectMemory memory = buffer.memory(); final int metadataLength = memory.getInt(length - 12); if (metadataLength == Integer.MAX_VALUE) return null; final byte[] metadata = new byte[metadataLength]; memory.getBytes(length-12-metadataLength, metadata); return metadata; }
public MMapFastBitSet(File file, int size, FileChannel.MapMode mapMode) throws IOException { this.size = size; this.arraySize = (size + 64) >> 6; this.bufferLength = arraySize * 8; this.buffer = new MMapBuffer(file, 0, bufferLength, mapMode, ByteOrder.LITTLE_ENDIAN); this.bits = buffer.memory().longArray(0, arraySize); }
public void writeChar(final int v) throws IOException { try { memory.putChar(currentAddress, (char)v); currentAddress+=2; } catch (IndexOutOfBoundsException e) { toClose.add(buffer); buffer = new MMapBuffer(file, 0, memory.length() * 2, FileChannel.MapMode.READ_WRITE, byteOrder); memory = buffer.memory(); writeChar(v); } }
public void writeLong(final long v) throws IOException { try { memory.putLong(currentAddress, v); currentAddress+=8; } catch (IndexOutOfBoundsException e) { toClose.add(buffer); buffer = new MMapBuffer(file, 0, memory.length() * 2, FileChannel.MapMode.READ_WRITE, byteOrder); memory = buffer.memory(); writeLong(v); } }
public void writeDouble(final double v) throws IOException { try { memory.putDouble(currentAddress, v); currentAddress+=8; } catch (IndexOutOfBoundsException e) { toClose.add(buffer); buffer = new MMapBuffer(file, 0, memory.length() * 2, FileChannel.MapMode.READ_WRITE, byteOrder); memory = buffer.memory(); writeDouble(v); } }
public void writeBoolean(final boolean v) throws IOException { try { memory.putByte(currentAddress, (byte)(v ? 1 : 0)); currentAddress++; } catch (IndexOutOfBoundsException e) { toClose.add(buffer); buffer = new MMapBuffer(file, 0, memory.length() * 2, FileChannel.MapMode.READ_WRITE, byteOrder); memory = buffer.memory(); writeBoolean(v); } }
public void writeFloat(final float v) throws IOException { try { memory.putFloat(currentAddress, v); currentAddress+=4; } catch (IndexOutOfBoundsException e) { toClose.add(buffer); buffer = new MMapBuffer(file, 0, memory.length() * 2, FileChannel.MapMode.READ_WRITE, byteOrder); memory = buffer.memory(); writeFloat(v); } }
public void writeShort(final int v) throws IOException { try { memory.putShort(currentAddress, (short)v); currentAddress+=2; } catch (IndexOutOfBoundsException e) { toClose.add(buffer); buffer = new MMapBuffer(file, 0, memory.length() * 2, FileChannel.MapMode.READ_WRITE, byteOrder); memory = buffer.memory(); writeShort(v); } }
public void writeInt(final int v) throws IOException { try { memory.putInt(currentAddress, v); currentAddress+=4; } catch (IndexOutOfBoundsException e) { toClose.add(buffer); buffer = new MMapBuffer(file, 0, memory.length() * 2, FileChannel.MapMode.READ_WRITE, byteOrder); memory = buffer.memory(); writeInt(v); } }
public void writeByte(final int v) throws IOException { try { memory.putByte(currentAddress, (byte)v); currentAddress++; } catch (IndexOutOfBoundsException e) { toClose.add(buffer); buffer = new MMapBuffer(file, 0, memory.length() * 2, FileChannel.MapMode.READ_WRITE, byteOrder); memory = buffer.memory(); writeByte(v); } }
private void internalReset(SimpleTermIterator term) throws IOException { final String filename = term.getFilename(); if (!filename.equals(currentFileOpen)) { if (file != null) file.close(); file = mapCache.copyOrOpen(filename); memory = file.get().memory(); currentFileOpen = filename; } buffer.reset(memory.getAddress()+term.getOffset(), term.docFreq()); lastDoc = 0; }