private int computeBlockBytes(int entryBytes, boolean restart) { return computeBlockBytes( entriesSumBytes + entryBytes, restartCnt + (restart ? 1 : 0)); }
int currentSize() { return computeBlockBytes(0, false); }
private BlockSizeTooSmallException blockSizeTooSmall(Entry entry) { // Compute size required to fit this entry by itself. int min = FILE_HEADER_LEN + computeBlockBytes(entry.sizeBytes(), 1); return new BlockSizeTooSmallException(min); }
private boolean tryAdd(Entry entry, boolean tryRestart) { byte[] key = entry.key; int prefixLen = 0; boolean restart = tryRestart && nextShouldBeRestart(); if (!restart) { Entry priorEntry = entries.get(entries.size() - 1); byte[] prior = priorEntry.key; prefixLen = commonPrefix(prior, prior.length, key); if (prefixLen <= 5 /* "refs/" */ && keyType == REF_BLOCK_TYPE) { // Force restart points at transitions between namespaces // such as "refs/heads/" to "refs/tags/". restart = true; prefixLen = 0; } else if (prefixLen == 0) { restart = true; } } entry.restart = restart; entry.prefixLen = prefixLen; int entryBytes = entry.sizeBytes(); if (computeBlockBytes(entryBytes, restart) > blockLimitBytes) { return false; } entriesSumBytes += entryBytes; entries.add(entry); if (restart) { restartCnt++; } return true; }
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; }
private int computeBlockBytes(int entryBytes, boolean restart) { return computeBlockBytes( entriesSumBytes + entryBytes, restartCnt + (restart ? 1 : 0)); }
int currentSize() { return computeBlockBytes(0, false); }
private BlockSizeTooSmallException blockSizeTooSmall(Entry entry) { // Compute size required to fit this entry by itself. int min = FILE_HEADER_LEN + computeBlockBytes(entry.sizeBytes(), 1); return new BlockSizeTooSmallException(min); }
private boolean tryAdd(Entry entry, boolean tryRestart) { byte[] key = entry.key; int prefixLen = 0; boolean restart = tryRestart && nextShouldBeRestart(); if (!restart) { Entry priorEntry = entries.get(entries.size() - 1); byte[] prior = priorEntry.key; prefixLen = commonPrefix(prior, prior.length, key); if (prefixLen <= 5 /* "refs/" */ && keyType == REF_BLOCK_TYPE) { // Force restart points at transitions between namespaces // such as "refs/heads/" to "refs/tags/". restart = true; prefixLen = 0; } else if (prefixLen == 0) { restart = true; } } entry.restart = restart; entry.prefixLen = prefixLen; int entryBytes = entry.sizeBytes(); if (computeBlockBytes(entryBytes, restart) > blockLimitBytes) { return false; } entriesSumBytes += entryBytes; entries.add(entry); if (restart) { restartCnt++; } return true; }
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; }