public PointerReadableByteBufferFile(long maxBufferSegmentSize, File file, boolean writeable) throws IOException { this.maxBufferSegmentSize = Math.min(UIO.chunkLength(UIO.chunkPower(maxBufferSegmentSize, 0)), MAX_BUFFER_SEGMENT_SIZE); this.file = file; this.writeable = writeable; // test power of 2 if ((this.maxBufferSegmentSize & (this.maxBufferSegmentSize - 1)) == 0) { this.fShift = Long.numberOfTrailingZeros(this.maxBufferSegmentSize); this.fseekMask = this.maxBufferSegmentSize - 1; } else { throw new IllegalArgumentException("It's hard to ensure powers of 2"); } this.length = file.length(); long position = this.length; int filerIndex = (int) (position >> fShift); long filerSeek = position & fseekMask; int newLength = filerIndex + 1; ByteBuffer[] newFilers = new ByteBuffer[newLength]; for (int n = 0; n < newLength; n++) { if (n < newLength - 1) { newFilers[n] = allocate(n, maxBufferSegmentSize); } else { newFilers[n] = allocate(n, filerSeek); } } bbs = newFilers; }
private ReadOnlyIndex moveIntoPlace(String rawhideName, File commitingIndexFile, File commitedIndexFile, IndexRangeId indexRangeId) throws Exception { FileUtils.forceMkdir(commitedIndexFile.getParentFile()); Files.move(commitingIndexFile.toPath(), commitedIndexFile.toPath(), StandardCopyOption.ATOMIC_MOVE); ReadOnlyFile readOnlyFile = new ReadOnlyFile(commitedIndexFile); ReadOnlyIndex reopenedIndex = new ReadOnlyIndex(labFiles, destroy, indexRangeId, readOnlyFile, rawhide, leapsCache); if (fsyncFileRenames) { reopenedIndex.fsync(); // Sorry // TODO Files.fsync index when java 9 supports it. } LOG.inc("movedIntoPlace"); LOG.inc("movedIntoPlace>" + rawhideName); int histo = (int) Math.pow(2, UIO.chunkPower(readOnlyFile.length(), 0)); LOG.inc("movedIntoPlace>" + histo); LOG.inc("movedIntoPlace>" + rawhideName + ">" + histo); return reopenedIndex; }
int twoPower = 63 - UIO.chunkPower(hashIndexMaxCapacity, 1); int twoPower = 63 - UIO.chunkPower(hashIndexMaxCapacity, 1);
long length = f.length(); int chunkPower = UIO.chunkPower(length + 1, 0); byte hashIndexLongPrecision = (byte) Math.min((chunkPower / 8) + 1, 8); int twoPower = UIO.chunkPower(hashIndexMaxCapacity, 1); hashIndexMaxCapacity = (1L << twoPower); long hashIndexSizeInBytes = hashIndexMaxCapacity * hashIndexLongPrecision;
int power = UIO.chunkPower(indexAlignedAddress + length, MIN_POWER); byte[] bytes = new byte[1 << power]; if (m.slabs[index] != null) {
long length = f.length(); int chunkPower = UIO.chunkPower(length + 1, 0); byte hashIndexLongPrecision = (byte) Math.min((chunkPower / 8) + 1, 8); long maxReinsertionsBeforeExtinction = (long) (count * 0.01d); int twoPower = -1; if (fib) { twoPower = UIO.chunkPower(hashIndexMaxCapacity, 1); hashIndexMaxCapacity = (1L << twoPower); twoPower = 63 - twoPower;