Skip to content

Commit

Permalink
feat: init implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
WenyXu authored and waynexia committed Nov 3, 2023
1 parent 3363a70 commit f9e3265
Show file tree
Hide file tree
Showing 26 changed files with 3,883 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
/Cargo.lock
17 changes: 17 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "orc-rs"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
arrow = "42.0.0"
bytes = "1.4"
chrono = "0.4.26"
flate2 = "1"
fallible-streaming-iterator = { version = "0.1" }
paste = "1.0.12"
prost = { version = "0.11.9" }
lazy_static = "1.4.0"
snafu = "0.7.4"
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.PHONY: fmt
fmt: ## Format all the Rust code.
cargo fmt --all


.PHONY: clippy
clippy: ## Check clippy rules.
cargo clippy --workspace --all-targets -- -D warnings
2 changes: 2 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
group_imports = "StdExternalCrate"
imports_granularity = "Module"
79 changes: 79 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
use std::str::Utf8Error;

use arrow::error::ArrowError;
pub use snafu::prelude::*;
use snafu::Location;

use crate::proto::r#type::Kind;

#[derive(Debug, Snafu)]
#[snafu(visibility(pub))]
pub enum Error {
#[snafu(display("Failed to seek, source: {}", source))]
SeekError {
source: std::io::Error,
location: Location,
},

#[snafu(display("Failed to read, source: {}", source))]
IoError {
source: std::io::Error,
location: Location,
},

#[snafu(display("Invalid input, message: {}", msg))]
InvalidInput { msg: String, location: Location },

#[snafu(display("Out of sepc, message: {}", msg))]
OutOfSpec { msg: String, location: Location },

#[snafu(display("Failed to decode float, source: {}", source))]
DecodeFloat {
location: Location,
source: std::io::Error,
},

#[snafu(display("Failed to decode proto, source: {}", source))]
DecodeProto {
location: Location,
source: prost::DecodeError,
},

#[snafu(display("No types found"))]
NoTypes { location: Location },

#[snafu(display("unsupported type: {:?}", kind))]
UnsupportedType { location: Location, kind: Kind },

#[snafu(display("Field not found: {:?}", name))]
FieldNotFOund { location: Location, name: String },

#[snafu(display("Invalid column : {:?}", name))]
InvalidColumn { location: Location, name: String },

#[snafu(display("Failed to convert to timestamp"))]
InvalidTimestamp { location: Location },

#[snafu(display("Failed to convert to date"))]
InvalidDate { location: Location },

#[snafu(display("Failed to add day to a date"))]
AddDays { location: Location },

#[snafu(display("Invalid utf8, source: {}", source))]
InvalidUft8 {
location: Location,
source: Utf8Error,
},

#[snafu(display("Out of bound at: {}", index))]
OutOfBound { location: Location, index: usize },

#[snafu(display("Failed to convert to record batch: {}", source))]
ConvertRecordBatch {
location: Location,
source: ArrowError,
},
}

pub type Result<T> = std::result::Result<T, Error>;
23 changes: 23 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#![feature(trait_upcasting)]
#![allow(incomplete_features)]
#![feature(iterator_try_collect)]
#![feature(iter_next_chunk)]

pub mod error;
pub mod proto;
pub mod reader;

pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}
}
Loading

0 comments on commit f9e3265

Please sign in to comment.