/** * Compute the ObjectId for this tree * * @param ins a {@link org.eclipse.jgit.lib.ObjectInserter} object. * @return ObjectId for this tree */ public ObjectId computeId(ObjectInserter ins) { if (buf != null) return ins.idFor(OBJ_TREE, buf, 0, ptr); final long len = overflowBuffer.length(); try { return ins.idFor(OBJ_TREE, len, overflowBuffer.openInputStream()); } catch (IOException e) { // this should never happen throw new RuntimeException(e); } }
PackIndex writePackIndex(DfsPackDescription pack, byte[] packHash, List<PackedObjectInfo> list) throws IOException { pack.setIndexVersion(INDEX_VERSION); pack.setObjectCount(list.size()); // If there are less than 58,000 objects, the entire index fits in under // 2 MiB. Callers will probably need the index immediately, so buffer // the index in process and load from the buffer. PackIndex packIndex = null; try (TemporaryBuffer.Heap buf = maybeGetTemporaryBuffer(list); DfsOutputStream os = db.writeFile(pack, INDEX); CountingOutputStream cnt = new CountingOutputStream(os)) { if (buf != null) { index(buf, packHash, list); packIndex = PackIndex.read(buf.openInputStream()); buf.writeTo(cnt, null); } else { index(cnt, packHash, list); } pack.addFileExt(INDEX); pack.setBlockSize(INDEX, os.blockSize()); pack.setFileSize(INDEX, cnt.getCount()); } return packIndex; }
/** * Compute the ObjectId for this tree * * @param ins a {@link org.eclipse.jgit.lib.ObjectInserter} object. * @return ObjectId for this tree */ public ObjectId computeId(ObjectInserter ins) { if (buf != null) return ins.idFor(OBJ_TREE, buf, 0, ptr); final long len = overflowBuffer.length(); try { return ins.idFor(OBJ_TREE, len, overflowBuffer.openInputStream()); } catch (IOException e) { // this should never happen throw new RuntimeException(e); } }
PackIndex writePackIndex(DfsPackDescription pack, byte[] packHash, List<PackedObjectInfo> list) throws IOException { pack.setIndexVersion(INDEX_VERSION); pack.setObjectCount(list.size()); // If there are less than 58,000 objects, the entire index fits in under // 2 MiB. Callers will probably need the index immediately, so buffer // the index in process and load from the buffer. TemporaryBuffer.Heap buf = null; PackIndex packIndex = null; if (list.size() <= 58000) { buf = new TemporaryBuffer.Heap(2 << 20); index(buf, packHash, list); packIndex = PackIndex.read(buf.openInputStream()); } DfsOutputStream os = db.writeFile(pack, INDEX); try { CountingOutputStream cnt = new CountingOutputStream(os); if (buf != null) buf.writeTo(cnt, null); else index(cnt, packHash, list); pack.addFileExt(INDEX); pack.setFileSize(INDEX, cnt.getCount()); } finally { os.close(); } return packIndex; }
PackIndex writePackIndex(DfsPackDescription pack, byte[] packHash, List<PackedObjectInfo> list) throws IOException { pack.setIndexVersion(INDEX_VERSION); pack.setObjectCount(list.size()); // If there are less than 58,000 objects, the entire index fits in under // 2 MiB. Callers will probably need the index immediately, so buffer // the index in process and load from the buffer. PackIndex packIndex = null; try (TemporaryBuffer.Heap buf = maybeGetTemporaryBuffer(list); DfsOutputStream os = db.writeFile(pack, INDEX); CountingOutputStream cnt = new CountingOutputStream(os)) { if (buf != null) { index(buf, packHash, list); packIndex = PackIndex.read(buf.openInputStream()); buf.writeTo(cnt, null); } else { index(cnt, packHash, list); } pack.addFileExt(INDEX); pack.setBlockSize(INDEX, os.blockSize()); pack.setFileSize(INDEX, cnt.getCount()); } return packIndex; }
/** * Compute the ObjectId for this tree * * @param ins * @return ObjectId for this tree */ public ObjectId computeId(ObjectInserter ins) { if (buf != null) return ins.idFor(OBJ_TREE, buf, 0, ptr); final long len = overflowBuffer.length(); try { return ins.idFor(OBJ_TREE, len, overflowBuffer.openInputStream()); } catch (IOException e) { // this should never happen throw new RuntimeException(e); } }
/** * Insert this tree and obtain its ObjectId. * * @param ins * the inserter to store the tree. * @return computed ObjectId of the tree * @throws java.io.IOException * the tree could not be stored. */ public ObjectId insertTo(ObjectInserter ins) throws IOException { if (buf != null) return ins.insert(OBJ_TREE, buf, 0, ptr); final long len = overflowBuffer.length(); return ins.insert(OBJ_TREE, len, overflowBuffer.openInputStream()); }
/** * Insert this tree and obtain its ObjectId. * * @param ins * the inserter to store the tree. * @return computed ObjectId of the tree * @throws IOException * the tree could not be stored. */ public ObjectId insertTo(ObjectInserter ins) throws IOException { if (buf != null) return ins.insert(OBJ_TREE, buf, 0, ptr); final long len = overflowBuffer.length(); return ins.insert(OBJ_TREE, len, overflowBuffer.openInputStream()); }
/** * Insert this tree and obtain its ObjectId. * * @param ins * the inserter to store the tree. * @return computed ObjectId of the tree * @throws java.io.IOException * the tree could not be stored. */ public ObjectId insertTo(ObjectInserter ins) throws IOException { if (buf != null) return ins.insert(OBJ_TREE, buf, 0, ptr); final long len = overflowBuffer.length(); return ins.insert(OBJ_TREE, len, overflowBuffer.openInputStream()); }