From a6b90b7ec5c238692dc323e25ef927e4433edb1d Mon Sep 17 00:00:00 2001 From: Gal Paikin Date: Mon, 30 Nov 2020 15:57:06 +0100 Subject: Add getsRefsByPrefixWithSkips (excluding prefixes) to ReftableDatabase We sometimes want to get all the refs except specific prefixes, similarly to getRefsByPrefix that gets all the refs of a specific prefix. We now create a new method that gets all refs matching a prefix except a set of specific prefixes. One use-case is for Gerrit to be able to get all the refs except refs/changes; in Gerrit we often have lots of refs/changes, but very little other refs. Currently, to get all the refs except refs/changes we need to get all the refs and then filter the refs/changes, which is very inefficient. With this method, we can simply skip the unneeded prefix so that we don't have to go over all the elements. RefDirectory still uses the inefficient implementation, since there isn't a simple way to use Refcursor to achieve the efficient implementation (as done in ReftableDatabase). Signed-off-by: Gal Paikin Change-Id: I8c5db581acdeb6698e3d3a2abde8da32f70c854c --- .../jgit/http/test/RefsUnreadableInMemoryRepository.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'org.eclipse.jgit.http.test/src') diff --git a/org.eclipse.jgit.http.test/src/org/eclipse/jgit/http/test/RefsUnreadableInMemoryRepository.java b/org.eclipse.jgit.http.test/src/org/eclipse/jgit/http/test/RefsUnreadableInMemoryRepository.java index 80cbe8738c..4167b038e1 100644 --- a/org.eclipse.jgit.http.test/src/org/eclipse/jgit/http/test/RefsUnreadableInMemoryRepository.java +++ b/org.eclipse.jgit.http.test/src/org/eclipse/jgit/http/test/RefsUnreadableInMemoryRepository.java @@ -83,6 +83,17 @@ class RefsUnreadableInMemoryRepository extends InMemoryRepository { return super.getRefsByPrefix(prefix); } + /** {@inheritDoc} */ + @Override + public List getRefsByPrefixWithExclusions(String include, Set excludes) + throws IOException { + if (failing) { + throw new IOException("disk failed, no refs found"); + } + + return super.getRefsByPrefixWithExclusions(include, excludes); + } + /** {@inheritDoc} */ @Override public Set getTipsWithSha1(ObjectId id) throws IOException { -- cgit v1.2.3