]> source.dussan.org Git - jgit.git/commitdiff
reftable: add maxUpdateIndex to Reftable 70/149170/9
authorHan-Wen Nienhuys <hanwen@google.com>
Sun, 8 Sep 2019 16:02:05 +0000 (18:02 +0200)
committerHan-Wen Nienhuys <hanwen@google.com>
Thu, 19 Sep 2019 16:32:20 +0000 (18:32 +0200)
This makes maxUpdateIndex() available in MergedReftable, so we can
know generically at which index to create the next reftable in a
stack.

Change-Id: Ia2314bc57c8b5dd7e69d5e61096fdce1d35abd11
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/MergedReftable.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/Reftable.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/reftable/ReftableReader.java

index c740bf2c377191684574de144f8922bd90ff2437..f5d612f3e1b7c94fd953ddcacd22f2243ff6af1a 100644 (file)
@@ -91,6 +91,15 @@ public class MergedReftable extends Reftable {
                }
        }
 
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public long maxUpdateIndex() throws IOException {
+               return tables.length > 0 ? tables[tables.length - 1].maxUpdateIndex()
+                               : 0;
+       }
+
        /** {@inheritDoc} */
        @Override
        public RefCursor allRefs() throws IOException {
index cb02628e8d38b64c87003f73419ae967c02b7282..f5685c6ca76c0e9cb06efcbb1f4114c722346f1d 100644 (file)
@@ -98,6 +98,19 @@ public abstract class Reftable implements AutoCloseable {
                includeDeletes = deletes;
        }
 
+
+       /**
+        * Get the maximum update index for log entries that appear in this
+        * reftable.
+        *
+        * @return the maximum update index for log entries that appear in this
+        *         reftable. This should be 1 higher than the prior reftable's
+        *         {@code maxUpdateIndex} if this table is used in a stack.
+        * @throws java.io.IOException
+        *             file cannot be read.
+        */
+       public abstract long maxUpdateIndex() throws IOException;
+
        /**
         * Seek to the first reference, to iterate in order.
         *
index 02c2f5bba834529541079224e7324853e6bc024f..75e98958f450632be18cc5cad0a7ebbdfc61886f 100644 (file)
@@ -146,15 +146,9 @@ public class ReftableReader extends Reftable {
        }
 
        /**
-        * Get the maximum update index for log entries that appear in this
-        * reftable.
-        *
-        * @return the maximum update index for log entries that appear in this
-        *         reftable. This should be 1 higher than the prior reftable's
-        *         {@code maxUpdateIndex} if this table is used in a stack.
-        * @throws java.io.IOException
-        *             file cannot be read.
+        * {@inheritDoc}
         */
+       @Override
        public long maxUpdateIndex() throws IOException {
                if (blockSize == -1) {
                        readFileHeader();