Skip to content

Commit

Permalink
chore: specify import style in rustfmt (#460)
Browse files Browse the repository at this point in the history
Signed-off-by: Ruihang Xia <[email protected]>

Signed-off-by: Ruihang Xia <[email protected]>
  • Loading branch information
waynexia authored Nov 15, 2022
1 parent ecb2d76 commit 1565c8d
Show file tree
Hide file tree
Showing 212 changed files with 779 additions and 1,416 deletions.
221 changes: 2 additions & 219 deletions Cargo.lock

Large diffs are not rendered by default.

40 changes: 16 additions & 24 deletions benchmarks/src/bin/nyc-taxi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,24 @@
#![feature(once_cell)]
#![allow(clippy::print_stdout)]

use std::{
collections::HashMap,
path::{Path, PathBuf},
sync::Arc,
time::Instant,
};

use arrow::{
array::{ArrayRef, PrimitiveArray, StringArray, TimestampNanosecondArray},
datatypes::{DataType, Float64Type, Int64Type},
record_batch::RecordBatch,
};
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::sync::Arc;
use std::time::Instant;

use arrow::array::{ArrayRef, PrimitiveArray, StringArray, TimestampNanosecondArray};
use arrow::datatypes::{DataType, Float64Type, Int64Type};
use arrow::record_batch::RecordBatch;
use clap::Parser;
use client::{
admin::Admin,
api::v1::{
codec::InsertBatch, column::Values, insert_expr, Column, ColumnDataType, ColumnDef,
CreateExpr, InsertExpr,
},
Client, Database, Select,
};
use client::admin::Admin;
use client::api::v1::codec::InsertBatch;
use client::api::v1::column::Values;
use client::api::v1::{insert_expr, Column, ColumnDataType, ColumnDef, CreateExpr, InsertExpr};
use client::{Client, Database, Select};
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
use parquet::{
arrow::{ArrowReader, ParquetFileArrowReader},
file::{reader::FileReader, serialized_reader::SerializedFileReader},
};
use parquet::arrow::{ArrowReader, ParquetFileArrowReader};
use parquet::file::reader::FileReader;
use parquet::file::serialized_reader::SerializedFileReader;
use tokio::task::JoinSet;

const DATABASE_NAME: &str = "greptime";
Expand Down
3 changes: 1 addition & 2 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
group_imports = "StdExternalCrate"


imports_granularity = "Module"
3 changes: 1 addition & 2 deletions src/api/src/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use snafu::prelude::*;

use crate::error::{self, Result};
use crate::v1::column::Values;
use crate::v1::Column;
use crate::v1::ColumnDataType;
use crate::v1::{Column, ColumnDataType};

#[derive(Debug, PartialEq, Eq)]
pub struct ColumnDataTypeWrapper(ColumnDataType);
Expand Down
5 changes: 3 additions & 2 deletions src/api/src/result.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use common_error::prelude::ErrorExt;

use crate::v1::codec::SelectResult;
use crate::v1::{
admin_result, codec::SelectResult, object_result, AdminResult, MutateResult, ObjectResult,
ResultHeader, SelectResult as SelectResultRaw,
admin_result, object_result, AdminResult, MutateResult, ObjectResult, ResultHeader,
SelectResult as SelectResultRaw,
};

pub const PROTOCOL_VERSION: u32 = 1;
Expand Down
8 changes: 2 additions & 6 deletions src/api/src/serde.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
pub use prost::DecodeError;
use prost::Message;

use crate::v1::codec::InsertBatch;
use crate::v1::codec::PhysicalPlanNode;
use crate::v1::codec::RegionNumber;
use crate::v1::codec::SelectResult;
use crate::v1::codec::{InsertBatch, PhysicalPlanNode, RegionNumber, SelectResult};
use crate::v1::meta::TableRouteValue;

macro_rules! impl_convert_with_bytes {
Expand Down Expand Up @@ -36,8 +33,7 @@ mod tests {
use std::ops::Deref;

use crate::v1::codec::*;
use crate::v1::column;
use crate::v1::Column;
use crate::v1::{column, Column};

const SEMANTIC_TAG: i32 = 0;

Expand Down
3 changes: 1 addition & 2 deletions src/api/src/v1/meta.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
tonic::include_proto!("greptime.v1.meta");

use std::collections::HashMap;
use std::hash::Hash;
use std::hash::Hasher;
use std::hash::{Hash, Hasher};

pub const PROTOCOL_VERSION: u64 = 1;

Expand Down
6 changes: 3 additions & 3 deletions src/catalog/src/local/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ use table::table::TableIdProvider;
use table::TableRef;

use crate::error::{
CatalogNotFoundSnafu, IllegalManagerStateSnafu, OpenTableSnafu, SchemaNotFoundSnafu,
SystemCatalogSnafu, SystemCatalogTypeMismatchSnafu, TableExistsSnafu, TableNotFoundSnafu,
CatalogNotFoundSnafu, IllegalManagerStateSnafu, OpenTableSnafu, ReadSystemCatalogSnafu, Result,
SchemaExistsSnafu, SchemaNotFoundSnafu, SystemCatalogSnafu, SystemCatalogTypeMismatchSnafu,
TableExistsSnafu, TableNotFoundSnafu,
};
use crate::error::{ReadSystemCatalogSnafu, Result, SchemaExistsSnafu};
use crate::local::memory::{MemoryCatalogManager, MemoryCatalogProvider, MemorySchemaProvider};
use crate::system::{
decode_system_catalog, Entry, SystemCatalogTable, TableEntry, ENTRY_TYPE_INDEX, KEY_INDEX,
Expand Down
3 changes: 1 addition & 2 deletions src/catalog/src/local/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use std::any::Any;
use std::collections::hash_map::Entry;
use std::collections::HashMap;
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::Arc;
use std::sync::RwLock;
use std::sync::{Arc, RwLock};

use common_catalog::consts::MIN_USER_TABLE_ID;
use snafu::OptionExt;
Expand Down
5 changes: 2 additions & 3 deletions src/catalog/src/remote/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@ use table::TableRef;
use tokio::sync::Mutex;

use crate::error::{
CatalogNotFoundSnafu, CreateTableSnafu, InvalidCatalogValueSnafu, OpenTableSnafu,
SchemaNotFoundSnafu, TableExistsSnafu,
CatalogNotFoundSnafu, CreateTableSnafu, InvalidCatalogValueSnafu, InvalidTableSchemaSnafu,
OpenTableSnafu, Result, SchemaNotFoundSnafu, TableExistsSnafu,
};
use crate::error::{InvalidTableSchemaSnafu, Result};
use crate::remote::{Kv, KvBackendRef};
use crate::{
handle_system_table_request, CatalogList, CatalogManager, CatalogProvider, CatalogProviderRef,
Expand Down
8 changes: 3 additions & 5 deletions src/catalog/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ use std::any::Any;
use std::collections::HashMap;
use std::sync::Arc;

use common_catalog::consts::{DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME};
use common_catalog::consts::{
INFORMATION_SCHEMA_NAME, SYSTEM_CATALOG_NAME, SYSTEM_CATALOG_TABLE_ID,
SYSTEM_CATALOG_TABLE_NAME,
DEFAULT_CATALOG_NAME, DEFAULT_SCHEMA_NAME, INFORMATION_SCHEMA_NAME, SYSTEM_CATALOG_NAME,
SYSTEM_CATALOG_TABLE_ID, SYSTEM_CATALOG_TABLE_NAME,
};
use common_query::logical_plan::Expr;
use common_query::physical_plan::PhysicalPlanRef;
use common_query::physical_plan::RuntimeEnv;
use common_query::physical_plan::{PhysicalPlanRef, RuntimeEnv};
use common_recordbatch::SendableRecordBatchStream;
use common_telemetry::debug;
use common_time::timestamp::Timestamp;
Expand Down
3 changes: 2 additions & 1 deletion src/client/examples/insert.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::collections::HashMap;

use api::v1::{codec::InsertBatch, *};
use api::v1::codec::InsertBatch;
use api::v1::*;
use client::{Client, Database};
fn main() {
tracing::subscriber::set_global_default(tracing_subscriber::FmtSubscriber::builder().finish())
Expand Down
13 changes: 6 additions & 7 deletions src/client/examples/logical.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
use api::v1::{ColumnDataType, ColumnDef, CreateExpr};
use client::{admin::Admin, Client, Database};
use client::admin::Admin;
use client::{Client, Database};
use prost_09::Message;
use substrait_proto::protobuf::{
plan_rel::RelType as PlanRelType,
read_rel::{NamedTable, ReadType},
rel::RelType,
PlanRel, ReadRel, Rel,
};
use substrait_proto::protobuf::plan_rel::RelType as PlanRelType;
use substrait_proto::protobuf::read_rel::{NamedTable, ReadType};
use substrait_proto::protobuf::rel::RelType;
use substrait_proto::protobuf::{PlanRel, ReadRel, Rel};
use tracing::{event, Level};

fn main() {
Expand Down
6 changes: 3 additions & 3 deletions src/client/examples/physical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use std::sync::Arc;

use client::{Client, Database};
use common_grpc::MockExecution;
use datafusion::physical_plan::{
expressions::Column, projection::ProjectionExec, ExecutionPlan, PhysicalExpr,
};
use datafusion::physical_plan::expressions::Column;
use datafusion::physical_plan::projection::ProjectionExec;
use datafusion::physical_plan::{ExecutionPlan, PhysicalExpr};
use tracing::{event, Level};

fn main() {
Expand Down
4 changes: 1 addition & 3 deletions src/client/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use common_query::Output;
use snafu::prelude::*;

use crate::database::PROTOCOL_VERSION;
use crate::error;
use crate::Client;
use crate::Result;
use crate::{error, Client, Result};

#[derive(Clone, Debug)]
pub struct Admin {
Expand Down
9 changes: 3 additions & 6 deletions src/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ use api::v1::greptime_client::GreptimeClient;
use api::v1::*;
use common_grpc::channel_manager::ChannelManager;
use parking_lot::RwLock;
use snafu::OptionExt;
use snafu::ResultExt;
use snafu::{OptionExt, ResultExt};
use tonic::transport::Channel;

use crate::error;
use crate::load_balance::LoadBalance;
use crate::load_balance::Loadbalancer;
use crate::Result;
use crate::load_balance::{LoadBalance, Loadbalancer};
use crate::{error, Result};

#[derive(Clone, Debug, Default)]
pub struct Client {
Expand Down
11 changes: 4 additions & 7 deletions src/client/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use api::v1::{
SelectExpr,
};
use common_error::status_code::StatusCode;
use common_grpc::AsExcutionPlan;
use common_grpc::DefaultAsPlanImpl;
use common_grpc::{AsExcutionPlan, DefaultAsPlanImpl};
use common_insert::column_to_vector;
use common_query::Output;
use common_recordbatch::{RecordBatch, RecordBatches};
Expand All @@ -17,12 +16,10 @@ use datatypes::prelude::*;
use datatypes::schema::{ColumnSchema, Schema};
use snafu::{ensure, OptionExt, ResultExt};

use crate::error;
use crate::error::ColumnToVectorSnafu;
use crate::{
error::{ConvertSchemaSnafu, DatanodeSnafu, DecodeSelectSnafu, EncodePhysicalSnafu},
Client, Result,
use crate::error::{
ColumnToVectorSnafu, ConvertSchemaSnafu, DatanodeSnafu, DecodeSelectSnafu, EncodePhysicalSnafu,
};
use crate::{error, Client, Result};

pub const PROTOCOL_VERSION: u32 = 1;

Expand Down
8 changes: 3 additions & 5 deletions src/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ pub mod load_balance;

pub use api;

pub use self::{
client::Client,
database::{Database, ObjectResult, Select},
error::{Error, Result},
};
pub use self::client::Client;
pub use self::database::{Database, ObjectResult, Select};
pub use self::error::{Error, Result};
7 changes: 2 additions & 5 deletions src/cmd/src/bin/greptime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ use std::fmt;

use clap::Parser;
use cmd::error::Result;
use cmd::frontend;
use cmd::metasrv;
use cmd::{datanode, standalone};
use common_telemetry::logging::error;
use common_telemetry::logging::info;
use cmd::{datanode, frontend, metasrv, standalone};
use common_telemetry::logging::{error, info};

#[derive(Parser)]
#[clap(name = "greptimedb")]
Expand Down
6 changes: 2 additions & 4 deletions src/cmd/src/metasrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ use meta_srv::bootstrap;
use meta_srv::metasrv::MetaSrvOptions;
use snafu::ResultExt;

use crate::error;
use crate::error::Error;
use crate::error::Result;
use crate::toml_loader;
use crate::error::{Error, Result};
use crate::{error, toml_loader};

#[derive(Parser)]
pub struct Command {
Expand Down
3 changes: 2 additions & 1 deletion src/common/error/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ impl<'a, E: ErrorExt + ?Sized> fmt::Debug for DebugFormat<'a, E> {
mod tests {
use std::any::Any;

use snafu::{prelude::*, Backtrace, GenerateImplicitData};
use snafu::prelude::*;
use snafu::{Backtrace, GenerateImplicitData};

use super::*;

Expand Down
3 changes: 2 additions & 1 deletion src/common/error/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ pub mod mock;
pub mod status_code;

pub mod prelude {
pub use snafu::{prelude::*, Backtrace, ErrorCompat};
pub use snafu::prelude::*;
pub use snafu::{Backtrace, ErrorCompat};

pub use crate::ext::{BoxedError, ErrorExt};
pub use crate::format::DebugFormat;
Expand Down
3 changes: 1 addition & 2 deletions src/common/function-macro/tests/test_derive.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use common_function_macro::as_aggr_func_creator;
use common_function_macro::AggrFuncTypeStore;
use common_function_macro::{as_aggr_func_creator, AggrFuncTypeStore};
use static_assertions::{assert_fields, assert_impl_all};

#[as_aggr_func_creator]
Expand Down
3 changes: 2 additions & 1 deletion src/common/function/src/scalars/aggregate/argmax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use common_function_macro::{as_aggr_func_creator, AggrFuncTypeStore};
use common_query::error::{BadAccumulatorImplSnafu, CreateAccumulatorSnafu, Result};
use common_query::logical_plan::{Accumulator, AggregateFunctionCreator};
use common_query::prelude::*;
use datatypes::prelude::*;
use datatypes::vectors::ConstantVector;
use datatypes::{prelude::*, with_match_primitive_type_id};
use datatypes::with_match_primitive_type_id;
use snafu::ensure;

// https://numpy.org/doc/stable/reference/generated/numpy.argmax.html
Expand Down
3 changes: 2 additions & 1 deletion src/common/function/src/scalars/aggregate/argmin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ use common_function_macro::{as_aggr_func_creator, AggrFuncTypeStore};
use common_query::error::{BadAccumulatorImplSnafu, CreateAccumulatorSnafu, Result};
use common_query::logical_plan::{Accumulator, AggregateFunctionCreator};
use common_query::prelude::*;
use datatypes::prelude::*;
use datatypes::vectors::ConstantVector;
use datatypes::{prelude::*, with_match_primitive_type_id};
use datatypes::with_match_primitive_type_id;
use snafu::ensure;

// // https://numpy.org/doc/stable/reference/generated/numpy.argmin.html
Expand Down
3 changes: 2 additions & 1 deletion src/common/function/src/scalars/aggregate/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ use common_query::error::{
};
use common_query::logical_plan::{Accumulator, AggregateFunctionCreator};
use common_query::prelude::*;
use datatypes::prelude::*;
use datatypes::types::PrimitiveType;
use datatypes::value::ListValue;
use datatypes::vectors::{ConstantVector, ListVector};
use datatypes::{prelude::*, with_match_primitive_type_id};
use datatypes::with_match_primitive_type_id;
use num_traits::AsPrimitive;
use snafu::{ensure, OptionExt, ResultExt};

Expand Down
3 changes: 2 additions & 1 deletion src/common/function/src/scalars/aggregate/mean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ use common_query::error::{
};
use common_query::logical_plan::{Accumulator, AggregateFunctionCreator};
use common_query::prelude::*;
use datatypes::prelude::*;
use datatypes::vectors::{ConstantVector, Float64Vector, UInt64Vector};
use datatypes::{prelude::*, with_match_primitive_type_id};
use datatypes::with_match_primitive_type_id;
use num_traits::AsPrimitive;
use snafu::{ensure, OptionExt};

Expand Down
3 changes: 2 additions & 1 deletion src/common/function/src/scalars/aggregate/polyval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ use common_query::error::{
};
use common_query::logical_plan::{Accumulator, AggregateFunctionCreator};
use common_query::prelude::*;
use datatypes::prelude::*;
use datatypes::types::PrimitiveType;
use datatypes::value::ListValue;
use datatypes::vectors::{ConstantVector, Int64Vector, ListVector};
use datatypes::{prelude::*, with_match_primitive_type_id};
use datatypes::with_match_primitive_type_id;
use num_traits::AsPrimitive;
use snafu::{ensure, OptionExt, ResultExt};

Expand Down
3 changes: 1 addition & 2 deletions src/common/function/src/scalars/function_registry.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! functions registry
use std::collections::HashMap;
use std::sync::Arc;
use std::sync::RwLock;
use std::sync::{Arc, RwLock};

use once_cell::sync::Lazy;

Expand Down
Loading

0 comments on commit 1565c8d

Please sign in to comment.