Skip to content

Commit

Permalink
feat: use in-memory storage by default (#859)
Browse files Browse the repository at this point in the history
To keep consistent with sqlite and duckdb:

```sh
risinglight # use in-memory storage
risinglight test.db # use disk storage
```

---------

Signed-off-by: Runji Wang <[email protected]>
  • Loading branch information
wangrunji0408 authored Dec 3, 2024
1 parent b11a14f commit fe6ff85
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,12 @@ jobs:
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ env.CACHE_KEY_SUFFIX }}
- name: Generate TPC-H 1GB dataset
run: |
rm -rf risinglight.db
make tpch
run: make tpch
- name: Build RisingLight (in release mode)
run: |
cargo build --release
run: cargo build --release
- name: Run TPC-H Test
run: |
./target/release/risinglight -f tests/sql/tpch/create.sql
./target/release/risinglight -f tests/sql/tpch/import.sql
./target/release/risinglight -f tests/sql/tpch-full/_tpch_full.slt
rm -rf tpch.db
./target/release/risinglight tpch.db -f tests/sql/tpch/create.sql
./target/release/risinglight tpch.db -f tests/sql/tpch/import.sql
./target/release/risinglight tpch.db -f tests/sql/tpch-full/_tpch_full.slt
20 changes: 7 additions & 13 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@ use tracing_subscriber::prelude::*;
#[derive(Parser, Debug)]
#[clap(author, version, about, long_about = None)]
struct Args {
/// Where to store the database files
#[clap()]
storage_path: Option<String>,
/// The name of an RisingLight database.
/// A new database is created if the file does not previously exist.
#[clap(default_value = ":memory:")]
filename: String,

/// File to execute. Can be either a SQL `sql` file or sqllogictest `slt` file.
#[clap(short, long)]
file: Option<String>,

/// Whether to use in-memory engine
#[clap(long)]
memory: bool,

/// Control the output format
/// - `text`: plain text
/// - `human`: human readable format
Expand Down Expand Up @@ -326,15 +323,12 @@ async fn main() -> Result<()> {
minitrace::set_reporter(ConsoleReporter, Config::default());
}

let db = if args.memory {
info!("using memory engine");
let db = if args.filename == ":memory:" {
info!("Connected to a transient in-memory database.");
Database::new_in_memory()
} else {
info!("using Secondary engine");
let mut options = SecondaryStorageOptions::default_for_cli();
if let Some(path) = args.storage_path {
options.path = PathBuf::new().join(path);
}
options.path = PathBuf::new().join(args.filename);
Database::new_on_disk(options).await
};

Expand Down

0 comments on commit fe6ff85

Please sign in to comment.