Skip to content

Commit

Permalink
0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
seddonm1 committed Jun 27, 2023
1 parent 02b3bb8 commit c6c1a23
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This is an experimental binding using the [s3s](https://crates.io/crates/s3s) cr

## Why

This crate was built to test the feasiblity of using SQLite as an alternative to formats like [TFRecord](https://www.tensorflow.org/tutorials/load_data/tfrecord) for storing a large number of machine learning training data with an accessible API. Although `tfrecord` and SQLite share a similar few-large-storage-files architecture - making backups and data movement efficient/easy - having both a SQLite interface and [Amazon S3](https://aws.amazon.com/s3/)/`http` API makes access to the contained data easier with tooling that likely already exists on your machine.
This crate was built to test the feasiblity of using SQLite as an alternative to formats like [TFRecord](https://www.tensorflow.org/tutorials/load_data/tfrecord) for storing a large number of machine learning training data with an accessible API. Although `TFRecord` and SQLite share a similar few-large-storage-files architecture - making backups and data movement efficient/easy - having both a SQLite interface and [Amazon S3](https://aws.amazon.com/s3/)/`http` API makes access to the contained data easier with tooling that likely already exists on your machine.

This concept is backed by benchmarks from SQLite showing that it can be [faster than filesytems](https://www.sqlite.org/fasterthanfs.html) for certain data access patterns.

Expand All @@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS data (
metadata TEXT,
last_modified TEXT NOT NULL,
md5 TEXT
) STRICT, WITHOUT ROWID;
) STRICT;
```

### Multipart Uploads
Expand All @@ -40,7 +40,7 @@ CREATE TABLE IF NOT EXISTS multipart_upload (
key TEXT NOT NULL,
last_modified TEXT NOT NULL,
access_key TEXT
) STRICT, WITHOUT ROWID;
) STRICT;

CREATE TABLE IF NOT EXISTS multipart_upload_part (
upload_id BLOB NOT NULL,
Expand Down Expand Up @@ -71,7 +71,7 @@ cargo install --path .
## Run

```bash
s3ite . --access-key AKIAIOSFODNN7EXAMPLE --secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
s3ite . --host 0.0.0.0 --port 8014 --access-key AKIAIOSFODNN7EXAMPLE --secret-key wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
```

## Docker
Expand Down
12 changes: 9 additions & 3 deletions src/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ impl Sqlite {
.interact(|connection| {
connection.execute_batch(
"
PRAGMA journal_mode=WAL;
PRAGMA foreign_keys=true;
PRAGMA analysis_limit=1000;
PRAGMA optimize;
Expand Down Expand Up @@ -141,7 +142,12 @@ impl Sqlite {
let connection = pool.get().await.unwrap();
connection
.interact(|connection| {
connection.execute_batch("PRAGMA foreign_keys=true;")?;
connection.execute_batch(
"
PRAGMA journal_mode=WAL;
PRAGMA foreign_keys=true;
",
)?;

let transaction = connection.transaction()?;
Self::try_create_tables(&transaction)?;
Expand All @@ -165,7 +171,7 @@ impl Sqlite {
metadata TEXT,
last_modified TEXT NOT NULL,
md5 TEXT
) STRICT, WITHOUT ROWID;",
) STRICT;",
(),
)?;
transaction.execute(
Expand All @@ -175,7 +181,7 @@ impl Sqlite {
key TEXT NOT NULL,
last_modified TEXT NOT NULL,
access_key TEXT
) STRICT, WITHOUT ROWID;",
) STRICT;",
(),
)?;
transaction.execute(
Expand Down

0 comments on commit c6c1a23

Please sign in to comment.