/** * @param repo * @param chunk * @return the key */ public static ChunkKey create(RepositoryKey repo, ObjectId chunk) { return new ChunkKey(repo.asInt(), chunk); }
public void remove(ChunkKey key, WriteBuffer buffer) throws DhtException { table.deleteRow(key.asBytes()); } }
@Override public String toString() { return "chunk:" + asString(); } }
static ChunkKey getNextFragment(ChunkMeta meta, ChunkKey chunkKey) { int cnt = meta.getFragmentCount(); for (int i = 0; i < cnt - 1; i++) { ChunkKey key = ChunkKey.fromString(meta.getFragment(i)); if (chunkKey.equals(key)) return ChunkKey.fromString(meta.getFragment(i + 1)); } return null; }
private void push(List<String> list) { List<ChunkKey> keys = new ArrayList<ChunkKey>(list.size()); for (String keyString : list) keys.add(ChunkKey.fromString(keyString)); push(keys); }
private static void checkCycle(Delta delta, ChunkKey key, int ofs) throws DeltaChainCycleException { for (; delta != null; delta = delta.next) { if (delta.deltaPos == ofs && delta.deltaChunk.equals(key)) throw DeltaChainCycleException.INSTANCE; } }
/** * @param key * @return the key */ public static ChunkKey fromBytes(byte[] key) { return fromBytes(key, 0, key.length); }
private void addChunkList(CachedPackInfo.Builder info, MessageDigest version, List<ChunkKey> list) { if (list == null) return; long bytesTotal = info.getBytesTotal(); long objectsTotal = info.getObjectsTotal(); long objectsDelta = info.getObjectsDelta(); byte[] buf = new byte[Constants.OBJECT_ID_LENGTH]; for (ChunkKey key : list) { ChunkInfo chunkInfo = infoByKey.get(key); GitStore.ChunkInfo c = chunkInfo.getData(); int len = c.getChunkSize() - ChunkFormatter.TRAILER_SIZE; bytesTotal += len; objectsTotal += c.getObjectCounts().getTotal(); objectsDelta += c.getObjectCounts().getOfsDelta(); objectsDelta += c.getObjectCounts().getRefDelta(); info.getChunkListBuilder().addChunkKey( chunkInfo.getChunkKey().asString()); chunkInfo.getChunkKey().getChunkHash().copyRawTo(buf, 0); version.update(buf); } info.setBytesTotal(bytesTotal); info.setObjectsTotal(objectsTotal); info.setObjectsDelta(objectsDelta); }
@SuppressWarnings("boxing") private boolean isValid() { Boolean v = valid; if (v == null) { MessageDigest m = newMessageDigest(); m.update(dataBuf, dataPtr, dataLen); v = key.getChunkHash().compareTo(m.digest(), 0) == 0; valid = v; } return v.booleanValue(); }
int findOffset(RepositoryKey repo, AnyObjectId objId) { if (key.getRepositoryId() == repo.asInt() && index != null) return index.findOffset(objId); return -1; }
/** @return the repository that contains the chunk. */ public RepositoryKey getRepositoryKey() { return chunkKey.getRepositoryKey(); }
private void push(List<String> list) { List<ChunkKey> keys = new ArrayList<ChunkKey>(list.size()); for (String keyString : list) keys.add(ChunkKey.fromString(keyString)); push(keys); }
static ChunkKey getNextFragment(ChunkMeta meta, ChunkKey chunkKey) { int cnt = meta.getFragmentCount(); for (int i = 0; i < cnt - 1; i++) { ChunkKey key = ChunkKey.fromString(meta.getFragment(i)); if (chunkKey.equals(key)) return ChunkKey.fromString(meta.getFragment(i + 1)); } return null; }
private static void checkCycle(Delta delta, ChunkKey key, int ofs) throws DeltaChainCycleException { for (; delta != null; delta = delta.next) { if (delta.deltaPos == ofs && delta.deltaChunk.equals(key)) throw DeltaChainCycleException.INSTANCE; } }
/** * @param key * @return the key */ public static ChunkKey fromBytes(byte[] key) { return fromBytes(key, 0, key.length); }
private void addChunkList(CachedPackInfo.Builder info, MessageDigest version, List<ChunkKey> list) { if (list == null) return; long bytesTotal = info.getBytesTotal(); long objectsTotal = info.getObjectsTotal(); long objectsDelta = info.getObjectsDelta(); byte[] buf = new byte[Constants.OBJECT_ID_LENGTH]; for (ChunkKey key : list) { ChunkInfo chunkInfo = infoByKey.get(key); GitStore.ChunkInfo c = chunkInfo.getData(); int len = c.getChunkSize() - ChunkFormatter.TRAILER_SIZE; bytesTotal += len; objectsTotal += c.getObjectCounts().getTotal(); objectsDelta += c.getObjectCounts().getOfsDelta(); objectsDelta += c.getObjectCounts().getRefDelta(); info.getChunkListBuilder().addChunkKey( chunkInfo.getChunkKey().asString()); chunkInfo.getChunkKey().getChunkHash().copyRawTo(buf, 0); version.update(buf); } info.setBytesTotal(bytesTotal); info.setObjectsTotal(objectsTotal); info.setObjectsDelta(objectsDelta); }