diff options
author | Joshua Watt <JPEWhacker@gmail.com> | 2024-02-18 15:59:48 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-02-19 11:58:12 +0000 |
commit | 3bd2c69e70853584beaaa5a4fd62589fa051d911 (patch) | |
tree | 3dc6469a1895cc7a31a58e4fc9dc43cef9a82cfb /bitbake/lib/hashserv/sqlite.py | |
parent | be909636c608d5ba24a41327c53d6a4ba3b70151 (diff) | |
download | poky-3bd2c69e70853584beaaa5a4fd62589fa051d911.tar.gz |
bitbake: hashserv: Add unihash-exists API
Adds API to check if the server is aware of the existence of a given
unihash. This can be used as an optimization for sstate where a client
can query the hash equivalence server to check if a unihash exists
before querying the sstate cache. If the hash server isn't aware of the
existence of a unihash, then there is very likely not a matching sstate
object, so this should be able to significantly cut down on the number
of negative hits on the sstate cache.
(Bitbake rev: cfe0ac071cfb998e4a1dd263f8860b140843361a)
Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/hashserv/sqlite.py')
-rw-r--r-- | bitbake/lib/hashserv/sqlite.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bitbake/lib/hashserv/sqlite.py b/bitbake/lib/hashserv/sqlite.py index 608490730d..da2e844a03 100644 --- a/bitbake/lib/hashserv/sqlite.py +++ b/bitbake/lib/hashserv/sqlite.py | |||
@@ -145,6 +145,9 @@ class DatabaseEngine(object): | |||
145 | "CREATE INDEX IF NOT EXISTS taskhash_lookup_v4 ON unihashes_v3 (method, taskhash)" | 145 | "CREATE INDEX IF NOT EXISTS taskhash_lookup_v4 ON unihashes_v3 (method, taskhash)" |
146 | ) | 146 | ) |
147 | cursor.execute( | 147 | cursor.execute( |
148 | "CREATE INDEX IF NOT EXISTS unihash_lookup_v1 ON unihashes_v3 (unihash)" | ||
149 | ) | ||
150 | cursor.execute( | ||
148 | "CREATE INDEX IF NOT EXISTS outhash_lookup_v3 ON outhashes_v2 (method, outhash)" | 151 | "CREATE INDEX IF NOT EXISTS outhash_lookup_v3 ON outhashes_v2 (method, outhash)" |
149 | ) | 152 | ) |
150 | cursor.execute("CREATE INDEX IF NOT EXISTS config_lookup ON config (name)") | 153 | cursor.execute("CREATE INDEX IF NOT EXISTS config_lookup ON config (name)") |
@@ -255,6 +258,19 @@ class Database(object): | |||
255 | ) | 258 | ) |
256 | return cursor.fetchone() | 259 | return cursor.fetchone() |
257 | 260 | ||
261 | async def unihash_exists(self, unihash): | ||
262 | with closing(self.db.cursor()) as cursor: | ||
263 | cursor.execute( | ||
264 | """ | ||
265 | SELECT * FROM unihashes_v3 WHERE unihash=:unihash | ||
266 | LIMIT 1 | ||
267 | """, | ||
268 | { | ||
269 | "unihash": unihash, | ||
270 | }, | ||
271 | ) | ||
272 | return cursor.fetchone() is not None | ||
273 | |||
258 | async def get_outhash(self, method, outhash): | 274 | async def get_outhash(self, method, outhash): |
259 | with closing(self.db.cursor()) as cursor: | 275 | with closing(self.db.cursor()) as cursor: |
260 | cursor.execute( | 276 | cursor.execute( |