aboutsummaryrefslogtreecommitdiffstats
path: root/py_bindings/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'py_bindings/src/lib.rs')
-rw-r--r--py_bindings/src/lib.rs374
1 files changed, 187 insertions, 187 deletions
diff --git a/py_bindings/src/lib.rs b/py_bindings/src/lib.rs
index aa79680..498aaaf 100644
--- a/py_bindings/src/lib.rs
+++ b/py_bindings/src/lib.rs
@@ -1,212 +1,212 @@
-use log_db;
-use pyo3::exceptions::PyException;
-use pyo3::prelude::*;
+// use log_db;
+// use pyo3::exceptions::PyException;
+// use pyo3::prelude::*;
-type Field = String;
+// type Field = String;
-#[pyclass]
-#[derive(Clone)]
-struct ValueType {
- record_field: log_db::ValueType,
-}
-
-#[pymethods]
-impl ValueType {
- #[staticmethod]
- fn int() -> Self {
- ValueType {
- record_field: log_db::ValueType::int(),
- }
- }
+// #[pyclass]
+// #[derive(Clone)]
+// struct ValueType {
+// record_field: log_db::ValueType,
+// }
- #[staticmethod]
- fn float() -> Self {
- ValueType {
- record_field: log_db::ValueType::float(),
- }
- }
+// #[pymethods]
+// impl ValueType {
+// #[staticmethod]
+// fn int() -> Self {
+// ValueType {
+// record_field: log_db::ValueType::int(),
+// }
+// }
- #[staticmethod]
- fn string() -> Self {
- ValueType {
- record_field: log_db::ValueType::string(),
- }
- }
+// #[staticmethod]
+// fn float() -> Self {
+// ValueType {
+// record_field: log_db::ValueType::float(),
+// }
+// }
- #[staticmethod]
- fn bytes() -> Self {
- ValueType {
- record_field: log_db::ValueType::bytes(),
- }
- }
+// #[staticmethod]
+// fn string() -> Self {
+// ValueType {
+// record_field: log_db::ValueType::string(),
+// }
+// }
- fn nullable(&self) -> Self {
- ValueType {
- record_field: self.record_field.clone().nullable(),
- }
- }
-}
+// #[staticmethod]
+// fn bytes() -> Self {
+// ValueType {
+// record_field: log_db::ValueType::bytes(),
+// }
+// }
-#[pyclass]
-#[derive(Clone)]
-struct WriteDurability {
- write_durability: log_db::WriteDurability,
-}
+// fn nullable(&self) -> Self {
+// ValueType {
+// record_field: self.record_field.clone().nullable(),
+// }
+// }
+// }
-#[pyclass]
-struct Config {
- #[pyo3(get, set)]
- data_dir: Option<String>,
- #[pyo3(get, set)]
- segment_size: Option<usize>,
- #[pyo3(get, set)]
- fields: Option<Vec<(Field, ValueType)>>,
- #[pyo3(get, set)]
- primary_key: Option<Field>,
- #[pyo3(get, set)]
- secondary_keys: Option<Vec<Field>>,
- #[pyo3(get, set)]
- write_durability: Option<WriteDurability>,
-}
+// #[pyclass]
+// #[derive(Clone)]
+// struct WriteDurability {
+// write_durability: log_db::WriteDurability,
+// }
-#[pymethods]
-impl Config {
- pub fn initialize(&self) -> PyResult<DB> {
- let mut config = log_db::DB::configure();
- if self.data_dir.is_some() {
- config.data_dir(&self.data_dir.as_ref().unwrap().to_string());
- }
- if self.segment_size.is_some() {
- config.segment_size(self.segment_size.unwrap());
- }
- if self.fields.is_some() {
- let mut fields = Vec::new();
- for (field, record_field) in self.fields.as_ref().unwrap() {
- fields.push((field.to_string(), record_field.record_field.clone()));
- }
- config.fields(&fields);
- }
- if self.primary_key.is_some() {
- config.primary_key(self.primary_key.as_ref().unwrap().to_string());
- }
- if self.secondary_keys.is_some() {
- let tmp = self.secondary_keys.as_ref().unwrap();
- config.secondary_keys(&tmp);
- }
- if self.write_durability.is_some() {
- let tmp = self.write_durability.as_ref().unwrap();
- config.write_durability(tmp.write_durability.clone());
- }
+// #[pyclass]
+// struct Config {
+// #[pyo3(get, set)]
+// data_dir: Option<String>,
+// #[pyo3(get, set)]
+// segment_size: Option<usize>,
+// #[pyo3(get, set)]
+// fields: Option<Vec<(Field, ValueType)>>,
+// #[pyo3(get, set)]
+// primary_key: Option<Field>,
+// #[pyo3(get, set)]
+// secondary_keys: Option<Vec<Field>>,
+// #[pyo3(get, set)]
+// write_durability: Option<WriteDurability>,
+// }
- let db = config
- .initialize()
- .map_err(|e| PyException::new_err(e.to_string()))?;
- Ok(DB { db })
- }
-}
+// #[pymethods]
+// impl Config {
+// pub fn initialize(&self) -> PyResult<DB> {
+// let mut config = log_db::DB::configure();
+// if self.data_dir.is_some() {
+// config.data_dir(&self.data_dir.as_ref().unwrap().to_string());
+// }
+// if self.segment_size.is_some() {
+// config.segment_size(self.segment_size.unwrap());
+// }
+// if self.fields.is_some() {
+// let mut fields = Vec::new();
+// for (field, record_field) in self.fields.as_ref().unwrap() {
+// fields.push((field.to_string(), record_field.record_field.clone()));
+// }
+// config.fields(&fields);
+// }
+// if self.primary_key.is_some() {
+// config.primary_key(self.primary_key.as_ref().unwrap().to_string());
+// }
+// if self.secondary_keys.is_some() {
+// let tmp = self.secondary_keys.as_ref().unwrap();
+// config.secondary_keys(&tmp);
+// }
+// if self.write_durability.is_some() {
+// let tmp = self.write_durability.as_ref().unwrap();
+// config.write_durability(tmp.write_durability.clone());
+// }
-#[pyclass]
-#[derive(Clone)]
-struct Value {
- record_value: log_db::Value,
-}
+// let db = config
+// .initialize()
+// .map_err(|e| PyException::new_err(e.to_string()))?;
+// Ok(DB { db })
+// }
+// }
-#[pymethods]
-impl Value {
- #[staticmethod]
- fn int(value: i64) -> Self {
- Value {
- record_value: log_db::Value::Int(value),
- }
- }
+// #[pyclass]
+// #[derive(Clone)]
+// struct Value {
+// record_value: log_db::Value,
+// }
- #[staticmethod]
- fn float(value: f64) -> Self {
- Value {
- record_value: log_db::Value::Float(value),
- }
- }
+// #[pymethods]
+// impl Value {
+// #[staticmethod]
+// fn int(value: i64) -> Self {
+// Value {
+// record_value: log_db::Value::Int(value),
+// }
+// }
- #[staticmethod]
- fn string(value: &str) -> Self {
- Value {
- record_value: log_db::Value::String(value.to_string()),
- }
- }
+// #[staticmethod]
+// fn float(value: f64) -> Self {
+// Value {
+// record_value: log_db::Value::Float(value),
+// }
+// }
- #[staticmethod]
- fn bytes(value: &[u8]) -> Self {
- Value {
- record_value: log_db::Value::Bytes(value.to_vec()),
- }
- }
+// #[staticmethod]
+// fn string(value: &str) -> Self {
+// Value {
+// record_value: log_db::Value::String(value.to_string()),
+// }
+// }
- #[staticmethod]
- fn null() -> Self {
- Value {
- record_value: log_db::Value::Null,
- }
- }
-}
+// #[staticmethod]
+// fn bytes(value: &[u8]) -> Self {
+// Value {
+// record_value: log_db::Value::Bytes(value.to_vec()),
+// }
+// }
-#[pyclass]
-struct Record {
- values: Vec<Value>,
-}
+// #[staticmethod]
+// fn null() -> Self {
+// Value {
+// record_value: log_db::Value::Null,
+// }
+// }
+// }
-#[pymethods]
-impl Record {
- #[new]
- #[pyo3(signature = (*py_args))]
- fn new(py_args: Vec<Value>) -> Self {
- Record { values: py_args }
- }
-}
+// #[pyclass]
+// struct Record {
+// values: Vec<Value>,
+// }
-#[pyclass]
-struct DB {
- db: log_db::DB<Field>,
-}
+// #[pymethods]
+// impl Record {
+// #[new]
+// #[pyo3(signature = (*py_args))]
+// fn new(py_args: Vec<Value>) -> Self {
+// Record { values: py_args }
+// }
+// }
-#[pymethods]
-impl DB {
- fn upsert(&mut self, record: &Record) -> PyResult<()> {
- let values: Vec<log_db::Value> = record
- .values
- .iter()
- .map(|v| v.record_value.clone())
- .collect();
+// #[pyclass]
+// struct DB {
+// db: log_db::DB<Field>,
+// }
- self.db
- .upsert(&log_db::Record::from(&values))
- .map_err(|e| PyException::new_err(e.to_string()))?;
- Ok(())
- }
+// #[pymethods]
+// impl DB {
+// fn upsert(&mut self, record: &Record) -> PyResult<()> {
+// let values: Vec<log_db::Value> = record
+// .values
+// .iter()
+// .map(|v| v.record_value.clone())
+// .collect();
- #[staticmethod]
- pub fn configure() -> Config {
- Config {
- data_dir: None,
- segment_size: None,
- fields: None,
- primary_key: None,
- secondary_keys: None,
- write_durability: None,
- }
- }
-}
+// self.db
+// .upsert(&log_db::Record::from(&values))
+// .map_err(|e| PyException::new_err(e.to_string()))?;
+// Ok(())
+// }
-// #[pyfunction]
-// fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
-// Ok((a + b).to_string())
+// #[staticmethod]
+// pub fn configure() -> Config {
+// Config {
+// data_dir: None,
+// segment_size: None,
+// fields: None,
+// primary_key: None,
+// secondary_keys: None,
+// write_durability: None,
+// }
+// }
// }
-#[pymodule]
-fn log_db_py(m: &Bound<'_, PyModule>) -> PyResult<()> {
- //m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
- m.add_class::<DB>()?;
- m.add_class::<ValueType>()?;
- m.add_class::<Value>()?;
- m.add_class::<Record>()?;
- Ok(())
-}
+// // #[pyfunction]
+// // fn sum_as_string(a: usize, b: usize) -> PyResult<String> {
+// // Ok((a + b).to_string())
+// // }
+
+// #[pymodule]
+// fn log_db_py(m: &Bound<'_, PyModule>) -> PyResult<()> {
+// //m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
+// m.add_class::<DB>()?;
+// m.add_class::<ValueType>()?;
+// m.add_class::<Value>()?;
+// m.add_class::<Record>()?;
+// Ok(())
+// }