<T> Ref<T> putRef(DfsStreamKey key, long size, T v) { return put(key, 0, (int) Math.min(size, Integer.MAX_VALUE), v); }
void put(DfsBlock v) { put(v.stream, v.start, v.size(), v); }
private DfsBlock flushBlock() throws IOException { if (isEmptyPack) throw new IOException(DfsText.get().willNotStoreEmptyPack); out.write(currBuf, 0, currEnd); byte[] buf; if (currEnd == currBuf.length) { buf = currBuf; } else { buf = new byte[currEnd]; System.arraycopy(currBuf, 0, buf, 0, currEnd); } DfsBlock v = new DfsBlock(packKey, currPos, buf); readBlock = v; blockCache.put(v); return v; }
private void flushBlock() throws IOException { out.write(currBuf, 0, currPtr); byte[] buf; if (currPtr == currBuf.length) buf = currBuf; else buf = copyOf(currBuf, 0, currPtr); cache.put(new DfsBlock(packKey, currPos, buf)); currPos += currPtr; currPtr = 0; currBuf = null; }
private DfsBlock getOrLoadBlock(long pos) throws IOException { long s = toBlockStart(pos); DfsBlock b = cache.get(packKey, s); if (b != null) return b; byte[] d = new byte[blockSize]; for (int p = 0; p < blockSize;) { int n = out.read(s + p, ByteBuffer.wrap(d, p, blockSize - p)); if (n <= 0) throw new EOFException(JGitText.get().unexpectedEofInPack); p += n; } b = new DfsBlock(packKey, s, d); cache.put(b); return b; }
throw new EOFException(); readBlock = new DfsBlock(packKey, start, buf); blockCache.put(readBlock);
<T> Ref<T> putRef(DfsStreamKey key, long size, T v) { return put(key, 0, (int) Math.min(size, Integer.MAX_VALUE), v); }
void setPackIndex(PackIndex idx) { long objCnt = idx.getObjectCount(); int recSize = Constants.OBJECT_ID_LENGTH + 8; int sz = (int) Math.min(objCnt * recSize, Integer.MAX_VALUE); index = cache.put(key, POS_INDEX, sz, idx); }
void put(DfsBlock v) { put(v.stream, v.start, v.size(), v); }
void put(DfsBlock v) { put(v.pack, v.start, v.size(), v); }
private DfsBlock flushBlock() throws IOException { if (isEmptyPack) throw new IOException(DfsText.get().willNotStoreEmptyPack); out.write(currBuf, 0, currEnd); byte[] buf; if (currEnd == currBuf.length) { buf = currBuf; } else { buf = new byte[currEnd]; System.arraycopy(currBuf, 0, buf, 0, currEnd); } DfsBlock v = new DfsBlock(packKey, currPos, buf); readBlock = v; blockCache.put(v); return v; }
private DfsBlock flushBlock() throws IOException { if (isEmptyPack) throw new IOException(DfsText.get().willNotStoreEmptyPack); out.write(currBuf, 0, currEnd); byte[] buf; if (currEnd == currBuf.length) { buf = currBuf; } else { buf = new byte[currEnd]; System.arraycopy(currBuf, 0, buf, 0, currEnd); } DfsBlock v = new DfsBlock(packKey, currPos, buf); readBlock = v; blockCache.put(v); return v; }
private void flushBlock() throws IOException { out.write(currBuf, 0, currPtr); byte[] buf; if (currPtr == currBuf.length) buf = currBuf; else buf = copyOf(currBuf, 0, currPtr); cache.put(new DfsBlock(packKey, currPos, buf)); currPos += currPtr; currPtr = 0; currBuf = null; }
private void flushBlock() throws IOException { out.write(currBuf, 0, currPtr); byte[] buf; if (currPtr == currBuf.length) buf = currBuf; else buf = copyOf(currBuf, 0, currPtr); cache.put(new DfsBlock(packKey, currPos, buf)); currPos += currPtr; currPtr = 0; currBuf = null; }
private DfsBlock getOrLoadBlock(long pos) throws IOException { long s = toBlockStart(pos); DfsBlock b = cache.get(packKey, s); if (b != null) return b; byte[] d = new byte[blockSize]; for (int p = 0; p < blockSize;) { int n = out.read(s + p, ByteBuffer.wrap(d, p, blockSize - p)); if (n <= 0) throw new EOFException(DfsText.get().unexpectedEofInPack); p += n; } b = new DfsBlock(packKey, s, d); cache.put(b); return b; }
private DfsBlock getOrLoadBlock(long pos) throws IOException { long s = toBlockStart(pos); DfsBlock b = cache.get(packKey, s); if (b != null) return b; byte[] d = new byte[blockSize]; for (int p = 0; p < blockSize;) { int n = out.read(s + p, ByteBuffer.wrap(d, p, blockSize - p)); if (n <= 0) throw new EOFException(JGitText.get().unexpectedEofInPack); p += n; } b = new DfsBlock(packKey, s, d); cache.put(b); return b; }
@Override protected int readDatabase(byte[] dst, int pos, int cnt) throws IOException { if (cnt == 0) return 0; if (currPos <= readPos) { // Requested read is still buffered. Copy direct from buffer. int p = (int) (readPos - currPos); int n = Math.min(cnt, currEnd - p); if (n == 0) throw new EOFException(); System.arraycopy(currBuf, p, dst, pos, n); readPos += n; return n; } if (readBlock == null || !readBlock.contains(packKey, readPos)) { long start = toBlockStart(readPos); readBlock = blockCache.get(packKey, start); if (readBlock == null) { int size = (int) Math.min(blockSize, packEnd - start); byte[] buf = new byte[size]; if (read(start, buf, 0, size) != size) throw new EOFException(); readBlock = new DfsBlock(packKey, start, buf); blockCache.put(readBlock); } } int n = readBlock.copy(readPos, dst, pos, cnt); readPos += n; return n; }
throw new EOFException(); readBlock = new DfsBlock(packKey, start, buf); blockCache.put(readBlock);
PackReverseIndex getReverseIdx(DfsReader ctx) throws IOException { DfsBlockCache.Ref<PackReverseIndex> revref = reverseIndex; if (revref != null) { PackReverseIndex revidx = revref.get(); if (revidx != null) return revidx; } synchronized (initLock) { revref = reverseIndex; if (revref != null) { PackReverseIndex revidx = revref.get(); if (revidx != null) return revidx; } PackIndex idx = idx(ctx); PackReverseIndex revidx = new PackReverseIndex(idx); int sz = (int) Math.min( idx.getObjectCount() * 8, Integer.MAX_VALUE); reverseIndex = cache.put(key, POS_REVERSE_INDEX, sz, revidx); return revidx; } }
bitmapIndex = cache.put(key, POS_BITMAP_INDEX, (int) Math.min(size, Integer.MAX_VALUE), idx); return idx;