From: Joshua Watt <jpewhacker@gmail.com>
To: bitbake-devel@lists.openembedded.org
Cc: Joshua Watt <JPEWhacker@gmail.com>
Subject: [bitbake-devel][PATCH 3/5] hashserv: Extend get_outhash API to optionally include unihash
Date: Fri, 6 Oct 2023 09:36:43 -0600 [thread overview]
Message-ID: <20231006153645.1609760-4-JPEWhacker@gmail.com> (raw)
In-Reply-To: <20231006153645.1609760-1-JPEWhacker@gmail.com>
Extends the get_outhash API with a flag indicating whether to include
the unihash in the output. This is means that the query doesn't require
the unihash entry to be present to return a result
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
---
bitbake/lib/hashserv/client.py | 4 +--
bitbake/lib/hashserv/server.py | 45 ++++++++++++++++++++++------------
2 files changed, 32 insertions(+), 17 deletions(-)
diff --git a/bitbake/lib/hashserv/client.py b/bitbake/lib/hashserv/client.py
index 7446e4c9f67..eeafeabda05 100644
--- a/bitbake/lib/hashserv/client.py
+++ b/bitbake/lib/hashserv/client.py
@@ -83,10 +83,10 @@ class AsyncClient(bb.asyncrpc.AsyncClient):
{"get": {"taskhash": taskhash, "method": method, "all": all_properties}}
)
- async def get_outhash(self, method, outhash, taskhash):
+ async def get_outhash(self, method, outhash, taskhash, with_unihash=True):
await self._set_mode(self.MODE_NORMAL)
return await self.send_message(
- {"get-outhash": {"outhash": outhash, "taskhash": taskhash, "method": method}}
+ {"get-outhash": {"outhash": outhash, "taskhash": taskhash, "method": method, "with_unihash": with_unihash}}
)
async def get_stats(self):
diff --git a/bitbake/lib/hashserv/server.py b/bitbake/lib/hashserv/server.py
index daf1ffacbb9..d52e1d46df5 100644
--- a/bitbake/lib/hashserv/server.py
+++ b/bitbake/lib/hashserv/server.py
@@ -270,27 +270,42 @@ class ServerClient(bb.asyncrpc.AsyncServerConnection):
method = request['method']
outhash = request['outhash']
taskhash = request['taskhash']
+ with_unihash = request.get("with_unihash", True)
with closing(self.db.cursor()) as cursor:
- d = await self.get_outhash(cursor, method, outhash, taskhash)
+ d = await self.get_outhash(cursor, method, outhash, taskhash, with_unihash)
self.write_message(d)
- async def get_outhash(self, cursor, method, outhash, taskhash):
+ async def get_outhash(self, cursor, method, outhash, taskhash, with_unihash=True):
d = None
- cursor.execute(
- '''
- SELECT *, unihashes_v2.unihash AS unihash FROM outhashes_v2
- INNER JOIN unihashes_v2 ON unihashes_v2.method=outhashes_v2.method AND unihashes_v2.taskhash=outhashes_v2.taskhash
- WHERE outhashes_v2.method=:method AND outhashes_v2.outhash=:outhash
- ORDER BY outhashes_v2.created ASC
- LIMIT 1
- ''',
- {
- 'method': method,
- 'outhash': outhash,
- }
- )
+ if with_unihash:
+ cursor.execute(
+ '''
+ SELECT *, unihashes_v2.unihash AS unihash FROM outhashes_v2
+ INNER JOIN unihashes_v2 ON unihashes_v2.method=outhashes_v2.method AND unihashes_v2.taskhash=outhashes_v2.taskhash
+ WHERE outhashes_v2.method=:method AND outhashes_v2.outhash=:outhash
+ ORDER BY outhashes_v2.created ASC
+ LIMIT 1
+ ''',
+ {
+ 'method': method,
+ 'outhash': outhash,
+ }
+ )
+ else:
+ cursor.execute(
+ """
+ SELECT * FROM outhashes_v2
+ WHERE outhashes_v2.method=:method AND outhashes_v2.outhash=:outhash
+ ORDER BY outhashes_v2.created ASC
+ LIMIT 1
+ """,
+ {
+ 'method': method,
+ 'outhash': outhash,
+ }
+ )
row = cursor.fetchone()
if row is not None:
--
2.34.1
next prev parent reply other threads:[~2023-10-06 15:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-06 15:36 [bitbake-devel][PATCH 0/5] Add cleanup commands for hash equivalence Joshua Watt
2023-10-06 15:36 ` [bitbake-devel][PATCH 1/5] hashserv: Add remove API Joshua Watt
2023-10-06 15:36 ` [bitbake-devel][PATCH 2/5] bitbake-hashclient: Add remove subcommand Joshua Watt
2023-10-06 15:36 ` Joshua Watt [this message]
2023-10-06 15:36 ` [bitbake-devel][PATCH 4/5] hashserv: Add API to clean unused entries Joshua Watt
2023-10-06 15:36 ` [bitbake-devel][PATCH 5/5] bitbake-hashclient: Add clean-unused subcommand Joshua Watt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231006153645.1609760-4-JPEWhacker@gmail.com \
--to=jpewhacker@gmail.com \
--cc=bitbake-devel@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.