Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHan-Wen Nienhuys2019-08-19 05:25:58 -0400
committerHan-Wen Nienhuys2019-08-19 05:25:58 -0400
commitca3b4b608340218e15d45479c424794e95bfb316 (patch)
tree4d5f7946212fa25dea9d28b61c12d0874545cf1e
parentca9107d166ec2a06e8c16b73d05064ba28c049da (diff)
downloadjgit-ca3b4b608340218e15d45479c424794e95bfb316.tar.gz
jgit-ca3b4b608340218e15d45479c424794e95bfb316.tar.xz
jgit-ca3b4b608340218e15d45479c424794e95bfb316.zip
reftable: add some more comments
Change-Id: I95208f7a05919b5019895cf41ae378c97da6e680 Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java8
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java14
2 files changed, 18 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java
index 44529bfff2..f9e184c99e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/BlockReader.java
@@ -84,7 +84,11 @@ import org.eclipse.jgit.util.LongList;
import org.eclipse.jgit.util.NB;
import org.eclipse.jgit.util.RawParseUtils;
-/** Reads a single block for {@link ReftableReader}. */
+/**
+ * Reads a single block for {@link ReftableReader}. Instances are tied to a
+ * specific block in the file so are not reused for other blocks. Instances hold
+ * an offset into the block.
+ */
class BlockReader {
private byte blockType;
private long endPosition;
@@ -141,6 +145,8 @@ class BlockReader {
return RawParseUtils.decode(UTF_8, nameBuf, 0, len);
}
+ // Matches the key against a name or a prefix. For reflogs, only the
+ // refname is matched, and the updateIndex suffix is ignored.
boolean match(byte[] match, boolean matchIsPrefix) {
int len = nameLen;
if (blockType == LOG_BLOCK_TYPE) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java
index 226e675e41..4f0ff2d1d1 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java
@@ -256,8 +256,8 @@ public class ReftableReader extends Reftable {
return block;
}
if (blockType == LOG_BLOCK_TYPE) {
- // No index. Log blocks are irregularly sized, so we can't do binary search
- // between blocks. Scan over blocks instead.
+ // No index. Log blocks are irregularly sized, so we can't do binary
+ // search between blocks. Scan over blocks instead.
BlockReader block = readBlock(startPos, endPos);
for (;;) {
@@ -555,12 +555,20 @@ public class ReftableReader extends Reftable {
private class LogCursorImpl extends LogCursor {
private final long scanEnd;
private final byte[] match;
-
+
private String refName;
private long updateIndex;
private ReflogEntry entry;
BlockReader block;
+ /**
+ * Scans logs from this table until scanEnd position.
+ *
+ * @param scanEnd
+ * end of the log data in the reftable.
+ * @param match
+ * if non-null, limits the scan to precisely that refname.
+ */
LogCursorImpl(long scanEnd, byte[] match) {
this.scanEnd = scanEnd;
this.match = match;

Back to the top