-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
solver: add sqlcachestorage as an alternative to the bolt db
This creates an sql cache storage that stores the cache key index in an sqlite3 database instead of in bolt. At the moment, this is just functional in the bare minimum as a way to test the feasibility of this method. There are ways to configure the sqlite database for more efficient transactions. This can be used as an alternative storage for bolt db and is potentially usable as a distributed cache key storage for another implementation in the future. Signed-off-by: Jonathan A. Sternberg <[email protected]>
- Loading branch information
1 parent
5c66a49
commit 1286ed3
Showing
68 changed files
with
277,523 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
debug = true | ||
|
||
[grpc] | ||
debugAddress = "0.0.0.0:6060" | ||
debugAddress = "0.0.0.0:6060" | ||
|
||
[cache] | ||
index-format = "sqlite" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package sqlcachestorage | ||
|
||
const ( | ||
createResultsTableSQL = ` | ||
CREATE TABLE IF NOT EXISTS results ( | ||
id text NOT NULL, | ||
created_at timestamp, | ||
worker_ref_id text NOT NULL | ||
); | ||
` | ||
|
||
createResultsIndexSQL = ` | ||
CREATE INDEX IF NOT EXISTS results_index | ||
ON results (id); | ||
` | ||
|
||
createResultsByRefIndexSQL = ` | ||
CREATE INDEX IF NOT EXISTS results_by_ref_index | ||
ON results (worker_ref_id); | ||
` | ||
|
||
createLinksTableSQL = ` | ||
CREATE TABLE IF NOT EXISTS links ( | ||
source_result_id text NOT NULL, | ||
vertex_input integer DEFAULT 0, | ||
vertex_output integer DEFAULT 0, | ||
vertex_digest text NOT NULL, | ||
vertex_selector text DEFAULT '', | ||
target_result_id text NOT NULL, | ||
UNIQUE (source_result_id, vertex_input, vertex_output, vertex_digest, vertex_selector, target_result_id) | ||
); | ||
` | ||
|
||
createUnreferencedLinksTriggerSQL = ` | ||
CREATE TRIGGER IF NOT EXISTS unreferenced_links_sql AFTER DELETE ON results | ||
BEGIN | ||
DELETE FROM links WHERE source_result_id = old.id OR target_result_id = old.id; | ||
END | ||
` | ||
|
||
createLinksIndexSQL = ` | ||
CREATE INDEX IF NOT EXISTS links_index | ||
ON links (source_result_id, vertex_input, vertex_output, vertex_digest, vertex_selector, target_result_id); | ||
` | ||
|
||
createBacklinksIndexSQL = ` | ||
CREATE INDEX IF NOT EXISTS backlinks_index | ||
ON links (target_result_id); | ||
` | ||
|
||
existsSQL = ` | ||
SELECT 1 FROM results WHERE id = ? LIMIT 1; | ||
` | ||
|
||
walkSQL = ` | ||
SELECT id FROM results; | ||
` | ||
|
||
walkResultsSQL = ` | ||
SELECT worker_ref_id, created_at FROM results WHERE id = ?; | ||
` | ||
|
||
loadSQL = ` | ||
SELECT worker_ref_id, created_at FROM results | ||
WHERE id = ? AND worker_ref_id = ? | ||
LIMIT 1; | ||
` | ||
|
||
addResultSQL = ` | ||
INSERT INTO results (id, created_at, worker_ref_id) | ||
VALUES(?, ?, ?); | ||
` | ||
|
||
deleteResultByRefIDSQL = ` | ||
DELETE FROM results WHERE worker_ref_id = ?; | ||
` | ||
|
||
walkIDsByResultSQL = ` | ||
SELECT DISTINCT id FROM results WHERE worker_ref_id = ?; | ||
` | ||
|
||
addLinkSQL = ` | ||
INSERT INTO links (source_result_id, vertex_input, vertex_output, vertex_digest, vertex_selector, target_result_id) | ||
VALUES (?, ?, ?, ?, ?, ?); | ||
` | ||
|
||
walkLinksSQL = ` | ||
SELECT target_result_id FROM links | ||
WHERE source_result_id = ? AND vertex_input = ? AND vertex_output = ? AND vertex_digest = ? AND vertex_selector = ?; | ||
` | ||
|
||
hasLinkSQL = ` | ||
SELECT 1 FROM links | ||
WHERE source_result_id = ? | ||
AND vertex_input = ? | ||
AND vertex_output = ? | ||
AND vertex_digest = ? | ||
AND vertex_selector = ? | ||
AND target_result_id = ? | ||
LIMIT 1; | ||
` | ||
|
||
walkBacklinksSQL = ` | ||
SELECT source_result_id, vertex_input, vertex_output, vertex_digest, vertex_selector FROM links WHERE target_result_id = ?; | ||
` | ||
) | ||
|
||
var createSQL = []string{ | ||
createResultsTableSQL, | ||
createResultsIndexSQL, | ||
createResultsByRefIndexSQL, | ||
createLinksTableSQL, | ||
createUnreferencedLinksTriggerSQL, | ||
createLinksIndexSQL, | ||
createBacklinksIndexSQL, | ||
} |
Oops, something went wrong.