private void writeObjBlocks() throws IOException { List<RefList> sorted = sortById(obj2ref); obj2ref = null; objIdLen = shortestUniqueAbbreviation(sorted); out.padBetweenBlocksToNextBlock(); objs = new Section(OBJ_BLOCK_TYPE); objs.entryCnt = sorted.size(); for (RefList l : sorted) { objs.write(new ObjEntry(objIdLen, l, l.blockPos)); } objs.finishSectionMaybeWriteIndex(); }
boolean tryAdd(Entry entry) { if (entry instanceof ObjEntry && computeBlockBytes(entry.sizeBytes(), 1) > blockLimitBytes) { // If the ObjEntry has so many ref block pointers that its // encoding overflows any block, reconfigure it to tell readers to // instead scan all refs for this ObjectId. That significantly // shrinks the entry to a very small size, which may now fit into // this block. ((ObjEntry) entry).markScanRequired(); } if (tryAdd(entry, true)) { return true; } else if (nextShouldBeRestart()) { // It was time for another restart, but the entry doesn't fit // with its complete key, as the block is nearly full. Try to // force it to fit with prefix compression rather than waste // the tail of the block with padding. return tryAdd(entry, false); } return false; }
ObjEntry(int idLen, ObjectId id, LongList blockPos) { super(key(idLen, id)); this.blockPos = blockPos; }
private void writeObjBlocks() throws IOException { List<RefList> sorted = sortById(obj2ref); obj2ref = null; objIdLen = shortestUniqueAbbreviation(sorted); out.padBetweenBlocksToNextBlock(); objs = new Section(OBJ_BLOCK_TYPE); objs.entryCnt = sorted.size(); for (RefList l : sorted) { objs.write(new ObjEntry(objIdLen, l, l.blockPos)); } objs.finishSectionMaybeWriteIndex(); }
boolean tryAdd(Entry entry) { if (entry instanceof ObjEntry && computeBlockBytes(entry.sizeBytes(), 1) > blockLimitBytes) { // If the ObjEntry has so many ref block pointers that its // encoding overflows any block, reconfigure it to tell readers to // instead scan all refs for this ObjectId. That significantly // shrinks the entry to a very small size, which may now fit into // this block. ((ObjEntry) entry).markScanRequired(); } if (tryAdd(entry, true)) { return true; } else if (nextShouldBeRestart()) { // It was time for another restart, but the entry doesn't fit // with its complete key, as the block is nearly full. Try to // force it to fit with prefix compression rather than waste // the tail of the block with padding. return tryAdd(entry, false); } return false; }
ObjEntry(int idLen, ObjectId id, LongList blockPos) { super(key(idLen, id)); this.blockPos = blockPos; }