Skip to content
This repository has been archived by the owner on Feb 18, 2024. It is now read-only.

Commit

Permalink
Added fmt and clippy checks to CI. (#522)
Browse files Browse the repository at this point in the history
  • Loading branch information
xudong963 authored Oct 12, 2021
1 parent eead22f commit 9a884e6
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 32 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
- name: Install clippy
run: rustup component add clippy
- name: "clippy --all"
run: cargo clippy --all --tests
run: cargo clippy --all --features=full --tests -- -D warnings

fmt:
name: fmt
Expand All @@ -64,8 +64,8 @@ jobs:
- uses: Swatinem/rust-cache@v1
- name: Install rustfmt
run: rustup component add rustfmt

- run: cargo fmt
- name: Run
run: cargo fmt --all -- --check

miri-checks:
name: Miri
Expand Down
16 changes: 0 additions & 16 deletions src/datatypes/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,19 +278,3 @@ impl std::fmt::Display for Field {
write!(f, "{:?}", self)
}
}

pub(crate) type Metadata = Option<BTreeMap<String, String>>;
pub(crate) type Extension = Option<(String, Option<String>)>;

pub(crate) fn get_extension(metadata: &Option<BTreeMap<String, String>>) -> Extension {
if let Some(metadata) = metadata {
if let Some(name) = metadata.get("ARROW:extension:name") {
let metadata = metadata.get("ARROW:extension:metadata").cloned();
Some((name.clone(), metadata))
} else {
None
}
} else {
None
}
}
23 changes: 21 additions & 2 deletions src/datatypes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ pub use field::Field;
pub use physical_type::*;
pub use schema::Schema;

pub(crate) use field::{get_extension, Extension, Metadata};

/// The set of supported logical types.
/// Each variant uniquely identifies a logical type, which define specific semantics to the data (e.g. how it should be represented).
/// Each variant has a corresponding [`PhysicalType`], obtained via [`DataType::to_physical_type`],
Expand Down Expand Up @@ -270,6 +268,27 @@ fn to_dictionary_index_type(data_type: &DataType) -> DictionaryIndexType {
}

// backward compatibility
use std::collections::BTreeMap;
use std::sync::Arc;

/// typedef for [`Arc<Schema>`].
pub type SchemaRef = Arc<Schema>;

/// typedef for [Option<BTreeMap<String, String>>].
pub type Metadata = Option<BTreeMap<String, String>>;
/// typedef fpr [Option<(String, Option<String>)>].
pub type Extension = Option<(String, Option<String>)>;

/// support get extension for metadata
pub fn get_extension(metadata: &Option<BTreeMap<String, String>>) -> Extension {
if let Some(metadata) = metadata {
if let Some(name) = metadata.get("ARROW:extension:name") {
let metadata = metadata.get("ARROW:extension:metadata").cloned();
Some((name.clone(), metadata))
} else {
None
}
} else {
None
}
}
2 changes: 0 additions & 2 deletions src/io/csv/write/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ use crate::{

use super::iterator::{BufStreamingIterator, StreamingIterator};
use crate::array::{DictionaryArray, DictionaryKey, Offset};
use crate::bitmap::utils::ZipValidity;
use std::any::Any;
use std::slice::Iter;

/// Options to serialize logical types to CSV
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion src/io/ipc/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
use crate::datatypes::{
get_extension, DataType, Extension, Field, IntervalUnit, Metadata, Schema, TimeUnit,
};
use crate::endianess::is_native_little_endian;
use crate::io::ipc::convert::ipc::UnionMode;
use crate::io::ipc::endianess::is_native_little_endian;

mod ipc {
pub use super::super::gen::File::*;
Expand Down
File renamed without changes.
7 changes: 5 additions & 2 deletions src/io/ipc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#![allow(missing_debug_implementations)]
#![allow(non_camel_case_types)]

pub use convert::fb_to_schema;
pub use gen::Message::root_as_message;

#[allow(clippy::redundant_closure)]
#[allow(clippy::needless_lifetimes)]
#[allow(clippy::extra_unused_lifetimes)]
Expand All @@ -12,8 +16,7 @@ pub mod gen;
mod compression;
mod convert;

pub use convert::fb_to_schema;
pub use gen::Message::root_as_message;
mod endianess;
pub mod read;
pub mod write;

Expand Down
2 changes: 1 addition & 1 deletion src/io/ipc/read/read_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::io::{Read, Seek, SeekFrom};
use std::{collections::VecDeque, convert::TryInto};

use crate::buffer::Buffer;
use crate::endianess::is_native_little_endian;
use crate::error::{ArrowError, Result};
use crate::io::ipc::endianess::is_native_little_endian;
use crate::io::ipc::gen::Message::{BodyCompression, CompressionType};
use crate::{bitmap::Bitmap, buffer::MutableBuffer, types::NativeType};

Expand Down
2 changes: 1 addition & 1 deletion src/io/ipc/write/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use super::{write, write_dictionary};
use flatbuffers::FlatBufferBuilder;

use crate::array::Array;
use crate::endianess::is_native_little_endian;
use crate::error::{ArrowError, Result};
use crate::io::ipc::endianess::is_native_little_endian;
use crate::record_batch::RecordBatch;
use crate::{array::DictionaryArray, datatypes::*};

Expand Down
5 changes: 2 additions & 3 deletions src/io/ipc/write/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@
// specific language governing permissions and limitations
// under the License.

use crate::io::ipc::endianess::is_native_little_endian;
use crate::io::ipc::gen::Schema;
use crate::{
array::*,
bitmap::Bitmap,
datatypes::{DataType, PhysicalType},
endianess::is_native_little_endian,
io::ipc::gen::Message,
trusted_len::TrustedLen,
types::NativeType,
};

use crate::io::ipc::gen::Schema;

use super::common::pad_to_8;

fn _write_primitive<T: NativeType>(
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pub mod array;
mod alloc;
pub mod bitmap;
pub mod buffer;
mod endianess;
pub mod error;
pub mod scalar;
pub mod trusted_len;
Expand Down

0 comments on commit 9a884e6

Please sign in to comment.