public MMapLongArrayIntValueLookup(MMapBuffer buffer, int length) { this.buffer = buffer; this.longArray = buffer.memory().longArray(0, length); }
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 static <T> MMapGOV4Function<T> readFrom(final String path) throws IOException, NoSuchFieldException, IllegalAccessException, ClassNotFoundException { final GOV4Function<T> gov4Function; try (final InputStream file = new FileInputStream(Files.buildPath(path, "GOV4Function.bin")); final ObjectInput input = new ObjectInputStream(file)) { gov4Function = (GOV4Function<T>)(input.readObject()); } final Field widthField = gov4Function.getClass().getDeclaredField("width"); widthField.setAccessible(true); final int width = (Integer) widthField.get(gov4Function); final MMapBuffer buffer = new MMapBuffer(new File(Files.buildPath(path, "signatures.bin")), FileChannel.MapMode.READ_ONLY, ByteOrder.LITTLE_ENDIAN); final MMapLongBigList signaturesData = new MMapLongBigList(buffer.memory().longArray(0, buffer.memory().length() / 8), width); final Field dataField = gov4Function.getClass().getDeclaredField("data"); dataField.setAccessible(true); dataField.set(gov4Function, signaturesData); return new MMapGOV4Function<>(gov4Function, buffer, width); }
public static MMapBuffer cacheLongFieldToFile(UnsortedIntTermDocIterator iterator, int numDocs, File file) throws IOException { final int[] docIdBuf = new int[BUFFER_SIZE]; final int length = numDocs * 8; final MMapBuffer buffer = new MMapBuffer(file, 0L, length, FileChannel.MapMode.READ_WRITE, ByteOrder.LITTLE_ENDIAN); final LongArray longArray = buffer.memory().longArray(0, numDocs); try { while (iterator.nextTerm()) { final long term = iterator.term(); while (true) { final int n = iterator.nextDocs(docIdBuf); for (int i = 0; i < n; ++i) { longArray.set(docIdBuf[i], term); } if (n < docIdBuf.length) { break; } } } buffer.sync(0, length); } catch (RuntimeException e) { Closeables2.closeQuietly(buffer, LOG); throw e; } catch (IOException e) { Closeables2.closeQuietly(buffer, LOG); throw e; } return buffer; }