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; }
if (read(start, buf, 0, size) != size) throw new EOFException(); readBlock = new DfsBlock(packKey, start, buf); blockCache.put(readBlock);
return new DfsBlock(key, pos, buf); } finally { if (rc != fileChannel) {
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(JGitText.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(DfsText.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; }
if (read(start, buf, 0, size) != size) throw new EOFException(); readBlock = new DfsBlock(packKey, start, buf); blockCache.put(readBlock);
DfsBlock v = new DfsBlock(key, pos, buf); return v; } finally {
return new DfsBlock(key, pos, buf); } finally { if (rc != fileChannel) {