Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: TPC-H dbgen #3313

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Language: Cpp
BasedOnStyle: LLVM
IndentWidth: 4
TabWidth: 4
UseTab: Never
ColumnLimit: 120
AllowShortIfStatementsOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
SortIncludes: true
---
Language: "Proto"
BasedOnStyle: Google
AlignConsecutiveDeclarations: true
Expand Down
122 changes: 122 additions & 0 deletions Cargo.lock

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

15 changes: 15 additions & 0 deletions crates/rayexec_dbgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "rayexec_dbgen"
version.workspace = true
edition.workspace = true

[dependencies]
rayexec_error = { path = "../rayexec_error" }
rayexec_bullet = { path = "../rayexec_bullet" }
rayexec_execution = { path = "../rayexec_execution" }
fmtutil = { path = "../fmtutil" }
futures = { workspace = true }

[build-dependencies]
bindgen = "0.65.1"
cc = "1.0"
32 changes: 32 additions & 0 deletions crates/rayexec_dbgen/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use std::env;
use std::path::PathBuf;

use bindgen::CargoCallbacks;

fn main() {
cc::Build::new()
.files([
"tpch_dbgen/dbgen.c",
"tpch_dbgen/permute.c",
"tpch_dbgen/build.c",
"tpch_dbgen/bm_utils.c",
"tpch_dbgen/rng64.c",
"tpch_dbgen/rnd.c",
"tpch_dbgen/text.c",
"tpch_dbgen/speed_seed.c",
])
.compile("dbgen");

let header_path = PathBuf::from("tpch_dbgen/dbgen.h").canonicalize().unwrap();
let header_str = header_path.to_str().unwrap();

let bindings = bindgen::Builder::default()
.header(header_str)
.allowlist_function("generate_table_data")
.parse_callbacks(Box::new(CargoCallbacks))
.generate()
.unwrap();

let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("tpch_dbgen_bindings.rs");
bindings.write_to_file(out_path).unwrap()
}
34 changes: 34 additions & 0 deletions crates/rayexec_dbgen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use rayexec_execution::datasource::{DataSource, DataSourceBuilder};
use rayexec_execution::functions::table::TableFunction;
use rayexec_execution::runtime::Runtime;
use tpch::TpchGen;

pub mod tpch;

extern "C" {
fn foo_function();
}

pub fn add(left: u64, right: u64) -> u64 {
unsafe { foo_function() };
left + right
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DbgenDataSource<R> {
runtime: R,
}

impl<R: Runtime> DataSourceBuilder<R> for DbgenDataSource<R> {
fn initialize(runtime: R) -> Box<dyn DataSource> {
Box::new(Self { runtime })
}
}

impl<R: Runtime> DataSource for DbgenDataSource<R> {
fn initialize_table_functions(&self) -> Vec<Box<dyn TableFunction>> {
vec![Box::new(TpchGen {
runtime: self.runtime.clone(),
})]
}
}
6 changes: 6 additions & 0 deletions crates/rayexec_dbgen/src/tpch/bindings.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(dead_code)]

include!(concat!(env!("OUT_DIR"), "/tpch_dbgen_bindings.rs"));
Loading
Loading