Simplify imports

next
Sayan Nandan 2 years ago
parent e887d5fcc2
commit 0df1acd2be
No known key found for this signature in database
GPG Key ID: 8BC07A0A4D41DD52

@ -24,17 +24,18 @@
* *
*/ */
use crate::{runner::Runner, tokenizer}; use {
use clap::{load_yaml, App}; crate::{runner::Runner, tokenizer},
use crossterm::{ clap::{load_yaml, App},
crossterm::{
cursor, execute, cursor, execute,
terminal::{Clear, ClearType}, terminal::{Clear, ClearType},
},
libsky::{URL, VERSION},
rustyline::{config::Configurer, error::ReadlineError, Editor},
skytable::{Pipeline, Query},
std::{io::stdout, process},
}; };
use libsky::{URL, VERSION};
use readline::{config::Configurer, error::ReadlineError, Editor};
use rustyline as readline;
use skytable::{Pipeline, Query};
use std::{io::stdout, process};
const ADDR: &str = "127.0.0.1"; const ADDR: &str = "127.0.0.1";
const SKYSH_HISTORY_FILE: &str = ".sky_history"; const SKYSH_HISTORY_FILE: &str = ".sky_history";

@ -23,15 +23,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
* *
*/ */
use crate::tokenizer;
use core::fmt; use {
use crossterm::style::{Color, Print, ResetColor, SetForegroundColor}; crate::tokenizer,
use skytable::error::Error; core::fmt,
use skytable::types::Array; crossterm::style::{Color, Print, ResetColor, SetForegroundColor},
use skytable::types::FlatElement; skytable::{
use skytable::Pipeline; aio, error::Error, types::Array, types::FlatElement, Element, Pipeline, Query, RespCode,
use skytable::Query; },
use skytable::{aio, Element, RespCode}; };
type SkyResult<T> = Result<T, Error>; type SkyResult<T> = Result<T, Error>;

@ -24,11 +24,14 @@
* *
*/ */
use crate::util; use {
use crate::HarnessResult; crate::{util, HarnessResult},
use std::path::Path; std::{
use std::{path::PathBuf, process::Command}; path::{Path, PathBuf},
use zip::CompressionMethod; process::Command,
},
zip::CompressionMethod,
};
/// The binaries that will be present in a bundle /// The binaries that will be present in a bundle
pub const BINARIES: [&str; 4] = ["skyd", "sky-bench", "skysh", "sky-migrate"]; pub const BINARIES: [&str; 4] = ["skyd", "sky-bench", "skysh", "sky-migrate"];

@ -24,17 +24,19 @@
* *
*/ */
use crate::{ use {
crate::{
build::{self, BuildMode}, build::{self, BuildMode},
util, HarnessError, HarnessResult, util, HarnessError, HarnessResult,
},
libsky::VERSION,
std::{
fs,
io::{Read, Write},
path::{Path, PathBuf},
},
zip::{write::FileOptions, ZipWriter},
}; };
use libsky::VERSION;
use std::fs;
use std::io::Read;
use std::io::Write;
use std::path::Path;
use std::path::PathBuf;
use zip::{write::FileOptions, ZipWriter};
/// Returns the bundle name /// Returns the bundle name
pub fn get_bundle_name() -> String { pub fn get_bundle_name() -> String {

@ -24,10 +24,10 @@
* *
*/ */
use crate::build::BuildMode; use {
use crate::linuxpkg::LinuxPackageType; crate::{build::BuildMode, linuxpkg::LinuxPackageType, HarnessError, HarnessResult},
use crate::{HarnessError, HarnessResult}; std::{env, process},
use std::{env, process}; };
const HELP: &str = "\ const HELP: &str = "\
harness harness

@ -24,8 +24,7 @@
* *
*/ */
use crate::util::ExitCode; use {crate::util::ExitCode, std::fmt};
use std::fmt;
pub type HarnessResult<T> = Result<T, HarnessError>; pub type HarnessResult<T> = Result<T, HarnessError>;
#[derive(Debug)] #[derive(Debug)]

@ -24,9 +24,13 @@
* *
*/ */
use crate::build::{self, BuildMode}; use {
use crate::{util, HarnessResult}; crate::{
use libsky::VERSION; build::{self, BuildMode},
{util, HarnessResult},
},
libsky::VERSION,
};
/// The Linux package type /// The Linux package type
#[derive(Copy, Clone)] #[derive(Copy, Clone)]

@ -37,12 +37,14 @@ mod presetup;
mod test; mod test;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
use crate::{ use std::{env, process};
use {
crate::{
cli::HarnessWhat, cli::HarnessWhat,
error::{HarnessError, HarnessResult}, error::{HarnessError, HarnessResult},
},
env_logger::Builder,
}; };
use env_logger::Builder;
use std::{env, process};
const ROOT_DIR: &str = env!("ROOT_DIR"); const ROOT_DIR: &str = env!("ROOT_DIR");

@ -24,12 +24,13 @@
* *
*/ */
use crate::{ use {
crate::{
build::BuildMode, build::BuildMode,
util::{self}, util::{self},
HarnessError, HarnessResult, HarnessError, HarnessResult,
}; },
use openssl::{ openssl::{
asn1::Asn1Time, asn1::Asn1Time,
bn::{BigNum, MsbOption}, bn::{BigNum, MsbOption},
error::ErrorStack, error::ErrorStack,
@ -40,8 +41,9 @@ use openssl::{
extension::{BasicConstraints, KeyUsage, SubjectKeyIdentifier}, extension::{BasicConstraints, KeyUsage, SubjectKeyIdentifier},
X509NameBuilder, X509, X509NameBuilder, X509,
}, },
},
std::{fs, io::Write},
}; };
use std::{fs, io::Write};
mod svc; mod svc;
/// Run the test suite /// Run the test suite

@ -24,17 +24,19 @@
* *
*/ */
use crate::{
util::{self},
HarnessError, HarnessResult, ROOT_DIR,
};
use skytable::{error::Error, Connection, SkyResult};
#[cfg(windows)] #[cfg(windows)]
use std::os::windows::process::CommandExt; use std::os::windows::process::CommandExt;
use std::{ use {
crate::{
util::{self},
HarnessError, HarnessResult, ROOT_DIR,
},
skytable::{error::Error, Connection, SkyResult},
std::{
io::ErrorKind, io::ErrorKind,
path::Path, path::Path,
process::{Child, Command}, process::{Child, Command},
},
}; };
#[cfg(windows)] #[cfg(windows)]

@ -24,14 +24,15 @@
* *
*/ */
use crate::util::WORKSPACE_ROOT; use {
use crate::{ crate::{
build::{self, BuildMode}, build::{self, BuildMode},
bundle, linuxpkg, util, bundle, linuxpkg, util,
util::WORKSPACE_ROOT,
},
libsky::VERSION,
std::{env, path::PathBuf},
}; };
use libsky::VERSION;
use std::env;
use std::path::PathBuf;
#[test] #[test]
fn file_names() { fn file_names() {

@ -24,12 +24,19 @@
* *
*/ */
use crate::build::BuildMode; use {
use crate::{HarnessError, HarnessResult}; crate::{
use std::env; build::BuildMode,
use std::ffi::OsStr; {HarnessError, HarnessResult},
use std::path::{Path, PathBuf}; },
use std::process::{Child, Command, Output}; std::{
env,
ffi::OsStr,
path::{Path, PathBuf},
process::{Child, Command, Output},
},
};
pub type ExitCode = Option<i32>; pub type ExitCode = Option<i32>;
#[cfg(not(test))] #[cfg(not(test))]

@ -59,13 +59,14 @@
#![deny(unused_imports)] #![deny(unused_imports)]
pub mod traits; pub mod traits;
use core::marker::PhantomData;
use crossbeam_channel::Receiver as CReceiver;
use crossbeam_channel::Sender as CSender;
use crossbeam_channel::{bounded, unbounded};
pub use rayon; pub use rayon;
use rayon::prelude::*;
use std::thread; use {
core::marker::PhantomData,
crossbeam_channel::{bounded, unbounded, Receiver as CReceiver, Sender as CSender},
rayon::prelude::{IntoParallelIterator, ParallelIterator},
std::thread,
};
/// A Job. The UIn type parameter is the type that will be used to execute the action /// A Job. The UIn type parameter is the type that will be used to execute the action
/// Nothing is a variant used by the drop implementation to terminate all the workers /// Nothing is a variant used by the drop implementation to terminate all the workers

@ -27,10 +27,10 @@
//! # `DEL` queries //! # `DEL` queries
//! This module provides functions to work with `DEL` queries //! This module provides functions to work with `DEL` queries
use crate::corestore::table::DataModel; use crate::{
use crate::dbnet::connection::prelude::*; corestore::table::DataModel, dbnet::connection::prelude::*,
use crate::kvengine::encoding::ENCODING_LUT_ITER; kvengine::encoding::ENCODING_LUT_ITER, util::compiler,
use crate::util::compiler; };
action!( action!(
/// Run a `DEL` query /// Run a `DEL` query

@ -27,11 +27,10 @@
//! # `EXISTS` queries //! # `EXISTS` queries
//! This module provides functions to work with `EXISTS` queries //! This module provides functions to work with `EXISTS` queries
use crate::corestore::table::DataModel; use crate::{
use crate::dbnet::connection::prelude::*; corestore::table::DataModel, dbnet::connection::prelude::*,
use crate::kvengine::encoding::ENCODING_LUT_ITER; kvengine::encoding::ENCODING_LUT_ITER, queryengine::ActionIter, util::compiler,
use crate::queryengine::ActionIter; };
use crate::util::compiler;
action!( action!(
/// Run an `EXISTS` query /// Run an `EXISTS` query

@ -24,8 +24,7 @@
* *
*/ */
use crate::dbnet::connection::prelude::*; use crate::{dbnet::connection::prelude::*, queryengine::ActionIter};
use crate::queryengine::ActionIter;
action!( action!(
/// Delete all the keys in the database /// Delete all the keys in the database

@ -27,8 +27,7 @@
//! # `GET` queries //! # `GET` queries
//! This module provides functions to work with `GET` queries //! This module provides functions to work with `GET` queries
use crate::dbnet::connection::prelude::*; use crate::{dbnet::connection::prelude::*, util::compiler};
use crate::util::compiler;
action!( action!(
/// Run a `GET` query /// Run a `GET` query

@ -24,8 +24,8 @@
* *
*/ */
use crate::corestore::Data; use crate::{corestore::Data, dbnet::connection::prelude::*};
use crate::dbnet::connection::prelude::*;
const LEN: &[u8] = "LEN".as_bytes(); const LEN: &[u8] = "LEN".as_bytes();
const LIMIT: &[u8] = "LIMIT".as_bytes(); const LIMIT: &[u8] = "LIMIT".as_bytes();
const VALUEAT: &[u8] = "VALUEAT".as_bytes(); const VALUEAT: &[u8] = "VALUEAT".as_bytes();

@ -24,9 +24,7 @@
* *
*/ */
use crate::corestore::Data; use crate::{corestore::Data, dbnet::connection::prelude::*, util::compiler};
use crate::dbnet::connection::prelude::*;
use crate::util::compiler;
const CLEAR: &[u8] = "CLEAR".as_bytes(); const CLEAR: &[u8] = "CLEAR".as_bytes();
const PUSH: &[u8] = "PUSH".as_bytes(); const PUSH: &[u8] = "PUSH".as_bytes();

@ -30,9 +30,7 @@ mod macros;
pub mod lget; pub mod lget;
pub mod lmod; pub mod lmod;
use crate::corestore::Data; use crate::{corestore::Data, dbnet::connection::prelude::*, kvengine::LockedVec};
use crate::dbnet::connection::prelude::*;
use crate::kvengine::LockedVec;
action! { action! {
/// Handle an `LSET` query for the list model /// Handle an `LSET` query for the list model

@ -24,9 +24,10 @@
* *
*/ */
use crate::corestore::table::DataModel; use crate::{
use crate::corestore::Data; corestore::{table::DataModel, Data},
use crate::dbnet::connection::prelude::*; dbnet::connection::prelude::*,
};
const DEFAULT_COUNT: usize = 10; const DEFAULT_COUNT: usize = 10;
@ -72,7 +73,8 @@ action!(
DataModel::KV(kv) => kv.get_inner_ref().get_keys(count), DataModel::KV(kv) => kv.get_inner_ref().get_keys(count),
DataModel::KVExtListmap(kv) => kv.get_inner_ref().get_keys(count), DataModel::KVExtListmap(kv) => kv.get_inner_ref().get_keys(count),
}; };
con.write_typed_non_null_array_header(items.len(), tsymbol).await?; con.write_typed_non_null_array_header(items.len(), tsymbol)
.await?;
for key in items { for key in items {
con.write_typed_non_null_array_element(&key).await?; con.write_typed_non_null_array_element(&key).await?;
} }

@ -24,10 +24,10 @@
* *
*/ */
use crate::dbnet::connection::prelude::*; use crate::{
use crate::kvengine::encoding::ENCODING_LUT_ITER; dbnet::connection::prelude::*, kvengine::encoding::ENCODING_LUT_ITER, queryengine::ActionIter,
use crate::queryengine::ActionIter; util::compiler,
use crate::util::compiler; };
action!( action!(
/// Run an `MGET` query /// Run an `MGET` query

@ -50,10 +50,10 @@ pub mod strong;
pub mod update; pub mod update;
pub mod uset; pub mod uset;
pub mod whereami; pub mod whereami;
use crate::corestore::memstore::DdlError; use {
use crate::protocol::interface::ProtocolSpec; crate::{corestore::memstore::DdlError, protocol::interface::ProtocolSpec, util},
use crate::util; std::io::Error as IoError,
use std::io::Error as IoError; };
/// A generic result for actions /// A generic result for actions
pub type ActionResult<T> = Result<T, ActionError>; pub type ActionResult<T> = Result<T, ActionError>;

@ -24,11 +24,10 @@
* *
*/ */
use crate::corestore; use crate::{
use crate::dbnet::connection::prelude::*; corestore, dbnet::connection::prelude::*, kvengine::encoding::ENCODING_LUT_ITER,
use crate::kvengine::encoding::ENCODING_LUT_ITER; queryengine::ActionIter, util::compiler,
use crate::queryengine::ActionIter; };
use crate::util::compiler;
action!( action!(
/// Run an MPOP action /// Run an MPOP action

@ -24,10 +24,10 @@
* *
*/ */
use crate::corestore::Data; use crate::{
use crate::dbnet::connection::prelude::*; corestore::Data, dbnet::connection::prelude::*, kvengine::encoding::ENCODING_LUT_ITER_PAIR,
use crate::kvengine::encoding::ENCODING_LUT_ITER_PAIR; util::compiler,
use crate::util::compiler; };
action!( action!(
/// Run an `MSET` query /// Run an `MSET` query

@ -24,10 +24,10 @@
* *
*/ */
use crate::corestore::Data; use crate::{
use crate::dbnet::connection::prelude::*; corestore::Data, dbnet::connection::prelude::*, kvengine::encoding::ENCODING_LUT_ITER_PAIR,
use crate::kvengine::encoding::ENCODING_LUT_ITER_PAIR; util::compiler,
use crate::util::compiler; };
action!( action!(
/// Run an `MUPDATE` query /// Run an `MUPDATE` query

@ -27,10 +27,7 @@
//! # `SET` queries //! # `SET` queries
//! This module provides functions to work with `SET` queries //! This module provides functions to work with `SET` queries
use crate::corestore; use crate::{corestore::Data, dbnet::connection::prelude::*, queryengine::ActionIter};
use crate::dbnet::connection::prelude::*;
use crate::queryengine::ActionIter;
use corestore::Data;
action!( action!(
/// Run a `SET` query /// Run a `SET` query

@ -24,12 +24,16 @@
* *
*/ */
use crate::actions::strong::StrongActionResult; use {
use crate::dbnet::connection::prelude::*; crate::{
use crate::kvengine::{KVEStandard, SingleEncoder}; actions::strong::StrongActionResult,
use crate::protocol::iter::DerefUnsafeSlice; dbnet::connection::prelude::*,
use crate::util::compiler; kvengine::{KVEStandard, SingleEncoder},
use core::slice::Iter; protocol::iter::DerefUnsafeSlice,
util::compiler,
},
core::slice::Iter,
};
action! { action! {
/// Run an `SDEL` query /// Run an `SDEL` query

@ -24,14 +24,17 @@
* *
*/ */
use crate::actions::strong::StrongActionResult; use {
use crate::corestore::Data; crate::{
use crate::dbnet::connection::prelude::*; actions::strong::StrongActionResult,
use crate::kvengine::DoubleEncoder; corestore::Data,
use crate::kvengine::KVEStandard; dbnet::connection::prelude::*,
use crate::protocol::iter::DerefUnsafeSlice; kvengine::{DoubleEncoder, KVEStandard},
use crate::util::compiler; protocol::iter::DerefUnsafeSlice,
use core::slice::Iter; util::compiler,
},
core::slice::Iter,
};
action! { action! {
/// Run an `SSET` query /// Run an `SSET` query

@ -24,14 +24,17 @@
* *
*/ */
use crate::actions::strong::StrongActionResult; use {
use crate::corestore::Data; crate::{
use crate::dbnet::connection::prelude::*; actions::strong::StrongActionResult,
use crate::kvengine::DoubleEncoder; corestore::Data,
use crate::kvengine::KVEStandard; dbnet::connection::prelude::*,
use crate::protocol::iter::DerefUnsafeSlice; kvengine::{DoubleEncoder, KVEStandard},
use crate::util::compiler; protocol::iter::DerefUnsafeSlice,
use core::slice::Iter; util::compiler,
},
core::slice::Iter,
};
action! { action! {
/// Run an `SUPDATE` query /// Run an `SUPDATE` query

@ -25,11 +25,12 @@
*/ */
mod sdel_concurrency_tests { mod sdel_concurrency_tests {
use super::super::sdel; use {
use crate::corestore::Data; super::super::sdel,
use crate::kvengine::KVEStandard; crate::{corestore::Data, kvengine::KVEStandard},
use std::sync::Arc; std::{sync::Arc, thread},
use std::thread; };
#[test] #[test]
fn test_snapshot_okay() { fn test_snapshot_okay() {
let kve = KVEStandard::init(true, true); let kve = KVEStandard::init(true, true);
@ -69,11 +70,12 @@ mod sdel_concurrency_tests {
} }
mod sset_concurrency_tests { mod sset_concurrency_tests {
use super::super::sset; use {
use crate::corestore::Data; super::super::sset,
use crate::kvengine::KVEStandard; crate::{corestore::Data, kvengine::KVEStandard},
use std::sync::Arc; std::{sync::Arc, thread},
use std::thread; };
#[test] #[test]
fn test_snapshot_okay() { fn test_snapshot_okay() {
let kve = KVEStandard::init(true, true); let kve = KVEStandard::init(true, true);
@ -110,11 +112,12 @@ mod sset_concurrency_tests {
} }
mod supdate_concurrency_tests { mod supdate_concurrency_tests {
use super::super::supdate; use {
use crate::corestore::Data; super::super::supdate,
use crate::kvengine::KVEStandard; crate::{corestore::Data, kvengine::KVEStandard},
use std::sync::Arc; std::{sync::Arc, thread},
use std::thread; };
#[test] #[test]
fn test_snapshot_okay() { fn test_snapshot_okay() {
let kve = KVEStandard::init(true, true); let kve = KVEStandard::init(true, true);

@ -28,8 +28,7 @@
//! This module provides functions to work with `UPDATE` queries //! This module provides functions to work with `UPDATE` queries
//! //!
use crate::corestore::Data; use crate::{corestore::Data, dbnet::connection::prelude::*};
use crate::dbnet::connection::prelude::*;
action!( action!(
/// Run an `UPDATE` query /// Run an `UPDATE` query

@ -24,11 +24,10 @@
* *
*/ */
use crate::corestore::Data; use crate::{
use crate::dbnet::connection::prelude::*; corestore::Data, dbnet::connection::prelude::*, kvengine::encoding::ENCODING_LUT_ITER_PAIR,
use crate::kvengine::encoding::ENCODING_LUT_ITER_PAIR; queryengine::ActionIter, util::compiler,
use crate::queryengine::ActionIter; };
use crate::util::compiler;
action!( action!(
/// Run an `USET` query /// Run an `USET` query

@ -24,11 +24,14 @@
* *
*/ */
use crate::dbnet::connection::prelude::*; use {
use crate::kvengine::encoding; crate::{
use crate::storage::v1::sengine::SnapshotActionResult; dbnet::connection::prelude::*, kvengine::encoding,
use core::str; storage::v1::sengine::SnapshotActionResult,
use std::path::{Component, PathBuf}; },
core::str,
std::path::{Component, PathBuf},
};
action!( action!(
/// Create a snapshot /// Create a snapshot

@ -24,11 +24,13 @@
* *
*/ */
use crate::{ use {
crate::{
corestore::booltable::BoolTable, dbnet::connection::prelude::*, corestore::booltable::BoolTable, dbnet::connection::prelude::*,
storage::v1::interface::DIR_ROOT, storage::v1::interface::DIR_ROOT,
},
libsky::VERSION,
}; };
use ::libsky::VERSION;
const INFO: &[u8] = b"info"; const INFO: &[u8] = b"info";
const METRIC: &[u8] = b"metric"; const METRIC: &[u8] = b"metric";

@ -24,7 +24,8 @@
* *
*/ */
use crate::{ use {
crate::{
auth::AuthProvider, auth::AuthProvider,
config::{ConfigurationSet, SnapshotConfig, SnapshotPref}, config::{ConfigurationSet, SnapshotConfig, SnapshotPref},
corestore::Corestore, corestore::Corestore,
@ -36,15 +37,16 @@ use crate::{
error::{Error, SkyResult}, error::{Error, SkyResult},
os::TerminationSignal, os::TerminationSignal,
}, },
}; },
use std::{sync::Arc, thread::sleep}; std::{sync::Arc, thread::sleep},
use tokio::{ tokio::{
sync::{ sync::{
broadcast, broadcast,
mpsc::{self, Sender}, mpsc::{self, Sender},
}, },
task::{self, JoinHandle}, task::{self, JoinHandle},
time::Duration, time::Duration,
},
}; };
const TERMSIG_THRESHOLD: usize = 3; const TERMSIG_THRESHOLD: usize = 3;

@ -24,8 +24,11 @@
* *
*/ */
use super::provider::{Authkey, AUTHKEY_SIZE}; use {
use crate::corestore::array::Array; super::provider::{Authkey, AUTHKEY_SIZE},
crate::corestore::array::Array,
};
type AuthkeyArray = Array<u8, { AUTHKEY_SIZE }>; type AuthkeyArray = Array<u8, { AUTHKEY_SIZE }>;
const RAN_BYTES_SIZE: usize = 40; const RAN_BYTES_SIZE: usize = 40;

@ -24,13 +24,16 @@
* *
*/ */
use super::keys; use {
use crate::actions::{ActionError, ActionResult}; super::keys,
use crate::corestore::array::Array; crate::{
use crate::corestore::htable::Coremap; actions::{ActionError, ActionResult},
use crate::protocol::interface::ProtocolSpec; corestore::{array::Array, htable::Coremap},
use crate::util::err; protocol::interface::ProtocolSpec,
use std::sync::Arc; util::err,
},
std::sync::Arc,
};
// constants // constants
/// Size of an authn key in bytes /// Size of an authn key in bytes

@ -35,9 +35,11 @@ mod keys {
} }
mod authn { mod authn {
use crate::actions::ActionError; use crate::{
use crate::auth::AuthProvider; actions::ActionError,
use crate::protocol::{interface::ProtocolSpec, Skyhash2}; auth::AuthProvider,
protocol::{interface::ProtocolSpec, Skyhash2},
};
const ORIG: &[u8; 40] = b"c4299d190fb9a00626797fcc138c56eae9971664"; const ORIG: &[u8; 40] = b"c4299d190fb9a00626797fcc138c56eae9971664";

@ -24,8 +24,10 @@
* *
*/ */
use super::{ConfigSourceParseResult, Configset, TryFromConfigSource}; use {
use clap::ArgMatches; super::{ConfigSourceParseResult, Configset, TryFromConfigSource},
clap::ArgMatches,
};
/// A flag. The flag is said to be set if `self.set` is true and unset if `self.set` is false. However, /// A flag. The flag is said to be set if `self.set` is true and unset if `self.set` is false. However,
/// if the flag is set, the value of SWITCH determines what value it is set to /// if the flag is set, the value of SWITCH determines what value it is set to

@ -24,12 +24,14 @@
* *
*/ */
use super::{ use {
super::{
AuthSettings, ConfigSourceParseResult, Configset, Modeset, OptString, ProtocolVersion, AuthSettings, ConfigSourceParseResult, Configset, Modeset, OptString, ProtocolVersion,
TryFromConfigSource, TryFromConfigSource,
},
serde::Deserialize,
std::net::IpAddr,
}; };
use serde::Deserialize;
use std::net::IpAddr;
/// This struct is an _object representation_ used for parsing the TOML file /// This struct is an _object representation_ used for parsing the TOML file
#[derive(Deserialize, Debug, PartialEq)] #[derive(Deserialize, Debug, PartialEq)]

@ -24,16 +24,16 @@
* *
*/ */
use super::{feedback::WarningStack, DEFAULT_IPV4, DEFAULT_PORT}; use {
use crate::config::AuthkeyWrapper; super::{feedback::WarningStack, DEFAULT_IPV4, DEFAULT_PORT},
use crate::dbnet::MAXIMUM_CONNECTION_LIMIT; crate::{config::AuthkeyWrapper, dbnet::MAXIMUM_CONNECTION_LIMIT},
use core::fmt; core::{fmt, str::FromStr},
use core::str::FromStr; serde::{
use serde::{
de::{self, Deserializer, Visitor}, de::{self, Deserializer, Visitor},
Deserialize, Deserialize,
},
std::net::IpAddr,
}; };
use std::net::IpAddr;
/// The BGSAVE configuration /// The BGSAVE configuration
/// ///

@ -24,16 +24,14 @@
* *
*/ */
// external imports
use toml::de::Error as TomlError;
// std imports
use core::fmt;
use core::ops;
use std::io::Error as IoError;
// internal imports
use super::{ConfigurationSet, SnapshotConfig, SnapshotPref};
#[cfg(unix)] #[cfg(unix)]
use crate::util::os::ResourceLimit; use crate::util::os::ResourceLimit;
use {
super::{ConfigurationSet, SnapshotConfig, SnapshotPref},
core::{fmt, ops},
std::io::Error as IoError,
toml::de::Error as TomlError,
};
#[cfg(test)] #[cfg(test)]
const EMSG_ENV: &str = "Environment"; const EMSG_ENV: &str = "Environment";

@ -24,14 +24,16 @@
* *
*/ */
// external imports use {
use crate::auth::provider::Authkey; crate::auth::provider::Authkey,
use clap::{load_yaml, App}; clap::{load_yaml, App},
// std imports core::str::FromStr,
use core::str::FromStr; std::{
use std::env::VarError; env::VarError,
use std::fs; fs,
use std::net::{IpAddr, Ipv4Addr}; net::{IpAddr, Ipv4Addr},
},
};
// internal modules // internal modules
mod cfgcli; mod cfgcli;

@ -24,9 +24,11 @@
* *
*/ */
use super::{BGSave, Configset, PortConfig, SnapshotConfig, SnapshotPref, SslOpts, DEFAULT_IPV4}; use {
use crate::ROOT_DIR; super::{BGSave, Configset, PortConfig, SnapshotConfig, SnapshotPref, SslOpts, DEFAULT_IPV4},
use std::fs; crate::ROOT_DIR,
std::fs,
};
// server tests // server tests
// TCP // TCP

@ -24,22 +24,20 @@
* *
*/ */
use bytes::Bytes; use {
use core::any; bytes::Bytes,
use core::borrow::Borrow; core::{
use core::borrow::BorrowMut; any,
use core::cmp::Ordering; borrow::{Borrow, BorrowMut},
use core::convert::TryFrom; cmp::Ordering,
use core::fmt; convert::TryFrom,
use core::hash::Hash; fmt,
use core::hash::Hasher; hash::{Hash, Hasher},
use core::iter::FromIterator; iter::FromIterator,
use core::mem::ManuallyDrop; mem::{ManuallyDrop, MaybeUninit},
use core::mem::MaybeUninit; ops, ptr, slice, str,
use core::ops; },
use core::ptr; };
use core::slice;
use core::str;
/// A compile-time, fixed size array that can have unintialized memory. This array is as /// A compile-time, fixed size array that can have unintialized memory. This array is as
/// efficient as you'd expect a normal array to be, but with the added benefit that you /// efficient as you'd expect a normal array to be, but with the added benefit that you

@ -24,9 +24,7 @@
* *
*/ */
use std::cell::Cell; use std::{cell::Cell, hint::spin_loop, thread};
use std::hint::spin_loop;
use std::thread;
/// Type to perform exponential backoff /// Type to perform exponential backoff
pub struct Backoff { pub struct Backoff {

@ -24,9 +24,10 @@
* *
*/ */
use super::array::Array; use {
use core::ops::Deref; super::array::Array,
use core::str; core::{ops::Deref, str},
};
macro_rules! push_self { macro_rules! push_self {
($self:expr, $what:expr) => { ($self:expr, $what:expr) => {

@ -24,8 +24,10 @@
* *
*/ */
use core::{alloc::Layout, fmt, marker::PhantomData, mem::ManuallyDrop, ops::Deref, ptr, slice}; use {
use std::alloc::dealloc; core::{alloc::Layout, fmt, marker::PhantomData, mem::ManuallyDrop, ops::Deref, ptr, slice},
std::alloc::dealloc,
};
/// A heap-allocated array /// A heap-allocated array
pub struct HeapArray<T> { pub struct HeapArray<T> {

@ -26,17 +26,16 @@
#![allow(unused)] // TODO(@ohsayan): Plonk this #![allow(unused)] // TODO(@ohsayan): Plonk this
use crate::corestore::map::{ use {
crate::corestore::map::{
bref::{Entry, OccupiedEntry, Ref, VacantEntry}, bref::{Entry, OccupiedEntry, Ref, VacantEntry},
iter::{BorrowedIter, OwnedIter}, iter::{BorrowedIter, OwnedIter},
Skymap, Skymap,
},
ahash::RandomState,
bytes::Bytes,
std::{borrow::Borrow, hash::Hash, iter::FromIterator, ops::Deref},
}; };
use ahash::RandomState;
use bytes::Bytes;
use std::borrow::Borrow;
use std::hash::Hash;
use std::iter::FromIterator;
use std::ops::Deref;
type HashTable<K, V> = Skymap<K, V, RandomState>; type HashTable<K, V> = Skymap<K, V, RandomState>;

@ -26,22 +26,21 @@
#![allow(dead_code)] // TODO(@ohsayan): Remove this lint or remove offending methods #![allow(dead_code)] // TODO(@ohsayan): Remove this lint or remove offending methods
use crate::corestore::array::LenScopeGuard; use {
use core::alloc::Layout; crate::corestore::array::LenScopeGuard,
use core::borrow::Borrow; core::{
use core::borrow::BorrowMut; alloc::Layout,
use core::cmp; borrow::{Borrow, BorrowMut},
use core::fmt; cmp, fmt,
use core::hash::{self, Hash}; hash::{self, Hash},
use core::iter::FromIterator; iter::FromIterator,
use core::mem; mem::{self, ManuallyDrop, MaybeUninit},
use core::mem::ManuallyDrop; ops,
use core::mem::MaybeUninit; ptr::{self, NonNull},
use core::ops; slice,
use core::ptr; },
use core::ptr::NonNull; std::alloc as std_alloc,
use core::slice; };
use std::alloc as std_alloc;
pub const fn new_const_iarray<T, const N: usize>() -> IArray<[T; N]> { pub const fn new_const_iarray<T, const N: usize>() -> IArray<[T; N]> {
IArray { IArray {

@ -24,13 +24,15 @@
* *
*/ */
use super::backoff::Backoff; use {
use core::mem; super::backoff::Backoff,
use core::ops::Deref; core::{
use core::ptr; mem,
use core::sync::atomic::AtomicBool; ops::Deref,
use core::sync::atomic::AtomicPtr; ptr,
use core::sync::atomic::Ordering; sync::atomic::{AtomicBool, AtomicPtr, Ordering},
},
};
const ORD_ACQ: Ordering = Ordering::Acquire; const ORD_ACQ: Ordering = Ordering::Acquire;
const ORD_SEQ: Ordering = Ordering::SeqCst; const ORD_SEQ: Ordering = Ordering::SeqCst;

@ -31,12 +31,14 @@
//! the primitives that are defined here //! the primitives that are defined here
//! //!
use super::backoff::Backoff; use {
use std::cell::UnsafeCell; super::backoff::Backoff,
use std::ops::Deref; std::{
use std::ops::DerefMut; cell::UnsafeCell,
use std::sync::atomic::AtomicBool; ops::{Deref, DerefMut},
use std::sync::atomic::Ordering; sync::atomic::{AtomicBool, Ordering},
},
};
const ORD_ACQUIRE: Ordering = Ordering::Acquire; const ORD_ACQUIRE: Ordering = Ordering::Acquire;
const ORD_RELEASE: Ordering = Ordering::Release; const ORD_RELEASE: Ordering = Ordering::Release;

@ -24,18 +24,17 @@
* *
*/ */
use super::LowMap; use {
use crate::util::compiler; super::LowMap,
use crate::util::Unwrappable; crate::util::{compiler, Unwrappable},
use core::hash::BuildHasher; core::{
use core::hash::Hash; hash::{BuildHasher, Hash},
use core::mem; mem,
use core::ops::Deref; ops::{Deref, DerefMut},
use core::ops::DerefMut; },
use parking_lot::RwLockReadGuard; parking_lot::{RwLockReadGuard, RwLockWriteGuard},
use parking_lot::RwLockWriteGuard; std::{collections::hash_map::RandomState, sync::Arc},
use std::collections::hash_map::RandomState; };
use std::sync::Arc;
/// A read-only reference to a bucket /// A read-only reference to a bucket
pub struct Ref<'a, K, V> { pub struct Ref<'a, K, V> {

@ -24,15 +24,13 @@
* *
*/ */
use super::bref::RefMulti; use {
use super::LowMap; super::{bref::RefMulti, LowMap, Skymap},
use super::Skymap; core::mem,
use core::mem; hashbrown::raw::{RawIntoIter, RawIter},
use hashbrown::raw::RawIntoIter; parking_lot::RwLockReadGuard,
use hashbrown::raw::RawIter; std::{collections::hash_map::RandomState, sync::Arc},
use parking_lot::RwLockReadGuard; };
use std::collections::hash_map::RandomState;
use std::sync::Arc;
/// An owned iterator for a [`Skymap`] /// An owned iterator for a [`Skymap`]
pub struct OwnedIter<K, V, S = RandomState> { pub struct OwnedIter<K, V, S = RandomState> {

@ -27,24 +27,26 @@
#![allow(clippy::manual_map)] // avoid LLVM bloat #![allow(clippy::manual_map)] // avoid LLVM bloat
#![allow(unused)] // TODO(@ohsayan): Plonk this #![allow(unused)] // TODO(@ohsayan): Plonk this
use crate::util::compiler; use {
use core::borrow::Borrow; self::{
use core::fmt; bref::{Entry, OccupiedEntry, Ref, RefMut, VacantEntry},
use core::hash::BuildHasher; iter::{BorrowedIter, OwnedIter},
use core::hash::Hash; },
use core::hash::Hasher; crate::util::compiler,
use core::iter::FromIterator; core::{
use core::mem; borrow::Borrow,
use parking_lot::RwLock; fmt,
use parking_lot::RwLockReadGuard; hash::{BuildHasher, Hash, Hasher},
use parking_lot::RwLockWriteGuard; iter::FromIterator,
use std::collections::hash_map::RandomState; mem,
use std::num::NonZeroUsize; num::NonZeroUsize,
use std::thread::available_parallelism; },
parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard},
std::{collections::hash_map::RandomState, thread::available_parallelism},
};
pub mod bref; pub mod bref;
use iter::{BorrowedIter, OwnedIter};
pub mod iter; pub mod iter;
use bref::{Entry, OccupiedEntry, Ref, RefMut, VacantEntry};
type LowMap<K, V> = hashbrown::raw::RawTable<(K, V)>; type LowMap<K, V> = hashbrown::raw::RawTable<(K, V)>;
type ShardSlice<K, V> = [RwLock<LowMap<K, V>>]; type ShardSlice<K, V> = [RwLock<LowMap<K, V>>];

@ -54,17 +54,21 @@
//! So, all your data is at the mercy of [`Memstore`]'s constructor //! So, all your data is at the mercy of [`Memstore`]'s constructor
//! and destructor. //! and destructor.
use super::KeyspaceResult; use {
use crate::auth::Authmap; super::KeyspaceResult,
use crate::corestore::array::Array; crate::{
use crate::corestore::htable::Coremap; auth::Authmap,
use crate::corestore::table::Table; corestore::{
use crate::corestore::table::{SystemDataModel, SystemTable}; array::Array,
use crate::registry; htable::Coremap,
use crate::util::Wrapper; table::{SystemDataModel, SystemTable, Table},
use core::borrow::Borrow; },
use core::hash::Hash; registry,
use std::sync::Arc; util::Wrapper,
},
core::{borrow::Borrow, hash::Hash},
std::sync::Arc,
};
uninit_array! { uninit_array! {
const DEFAULT_ARRAY: [u8; 64] = [b'd', b'e', b'f', b'a', b'u', b'l', b't']; const DEFAULT_ARRAY: [u8; 64] = [b'd', b'e', b'f', b'a', b'u', b'l', b't'];

@ -24,16 +24,17 @@
* *
*/ */
use crate::actions::ActionResult;
use crate::auth::Authmap;
use crate::corestore::htable::Coremap;
use crate::corestore::Data;
#[cfg(test)] #[cfg(test)]
use crate::corestore::{memstore::DdlError, KeyspaceResult}; use crate::corestore::{memstore::DdlError, KeyspaceResult};
use crate::dbnet::connection::prelude::Corestore; use crate::{
use crate::kvengine::{KVEListmap, KVEStandard, LockedVec}; actions::ActionResult,
use crate::protocol::interface::ProtocolSpec; auth::Authmap,
use crate::util; corestore::{htable::Coremap, Data},
dbnet::connection::prelude::Corestore,
kvengine::{KVEListmap, KVEStandard, LockedVec},
protocol::interface::ProtocolSpec,
util,
};
pub trait DescribeTable { pub trait DescribeTable {
type Table; type Table;

@ -25,8 +25,7 @@
*/ */
mod memstore_keyspace_tests { mod memstore_keyspace_tests {
use super::super::memstore::*; use super::super::{memstore::*, table::Table};
use super::super::table::Table;
#[test] #[test]
fn test_drop_keyspace_empty() { fn test_drop_keyspace_empty() {
@ -121,9 +120,11 @@ mod memstore_keyspace_tests {
} }
mod modelcode_tests { mod modelcode_tests {
use super::super::table::Table; use {
use crate::kvengine::KVEListmap; super::super::table::Table,
use crate::kvengine::KVEngine; crate::kvengine::{KVEListmap, KVEngine},
};
#[test] #[test]
fn test_model_code_pure_kve() { fn test_model_code_pure_kve() {
// binstr, binstr // binstr, binstr

@ -35,7 +35,10 @@
//! enables this connection object/type to use methods like read_query enabling it to read and interact with queries and write //! enables this connection object/type to use methods like read_query enabling it to read and interact with queries and write
//! respones in compliance with the Skyhash protocol. //! respones in compliance with the Skyhash protocol.
use crate::{ #[cfg(windows)]
use std::io::ErrorKind;
use {
crate::{
actions::{ActionError, ActionResult}, actions::{ActionError, ActionResult},
auth::AuthProvider, auth::AuthProvider,
corestore::Corestore, corestore::Corestore,
@ -49,14 +52,13 @@ use crate::{
Query, Query,
}, },
queryengine, IoResult, queryengine, IoResult,
}; },
use bytes::{Buf, BytesMut}; bytes::{Buf, BytesMut},
#[cfg(windows)] std::{marker::PhantomData, sync::Arc},
use std::io::ErrorKind; tokio::{
use std::{marker::PhantomData, sync::Arc};
use tokio::{
io::{AsyncReadExt, AsyncWriteExt, BufWriter}, io::{AsyncReadExt, AsyncWriteExt, BufWriter},
sync::{mpsc, Semaphore}, sync::{mpsc, Semaphore},
},
}; };
pub type QueryWithAdvance = (Query, usize); pub type QueryWithAdvance = (Query, usize);

@ -58,6 +58,7 @@ use {
sync::{broadcast, mpsc, Semaphore}, sync::{broadcast, mpsc, Semaphore},
}, },
}; };
pub mod connection; pub mod connection;
#[macro_use] #[macro_use]
mod macros; mod macros;

@ -166,18 +166,27 @@ mod __sys {
//! # Windows platform-specific file locking //! # Windows platform-specific file locking
//! This module contains methods used by the `FileLock` object in this module to lock and/or //! This module contains methods used by the `FileLock` object in this module to lock and/or
//! unlock files. //! unlock files.
use std::fs::File;
use std::io::{Error, Result}; use {
use std::mem; std::{
use std::os::windows::io::AsRawHandle; fs::File,
use std::os::windows::io::FromRawHandle; io::{Error, Result},
use std::ptr; mem,
use winapi::shared::minwindef::{BOOL, DWORD}; os::windows::io::{AsRawHandle, FromRawHandle},
use winapi::um::fileapi::{LockFileEx, UnlockFile}; ptr,
use winapi::um::handleapi::DuplicateHandle; },
use winapi::um::minwinbase::{LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY}; winapi::{
use winapi::um::processthreadsapi::GetCurrentProcess; shared::minwindef::{BOOL, DWORD},
use winapi::um::winnt::{DUPLICATE_SAME_ACCESS, MAXDWORD}; um::{
fileapi::{LockFileEx, UnlockFile},
handleapi::DuplicateHandle,
minwinbase::{LOCKFILE_EXCLUSIVE_LOCK, LOCKFILE_FAIL_IMMEDIATELY},
processthreadsapi::GetCurrentProcess,
winnt::{DUPLICATE_SAME_ACCESS, MAXDWORD},
},
},
};
/// Obtain an exclusive lock and **block** until we acquire it /// Obtain an exclusive lock and **block** until we acquire it
pub fn lock_ex(file: &File) -> Result<()> { pub fn lock_ex(file: &File) -> Result<()> {
lock_file(file, LOCKFILE_EXCLUSIVE_LOCK) lock_file(file, LOCKFILE_EXCLUSIVE_LOCK)
@ -259,12 +268,14 @@ mod __sys {
//! # Unix platform-specific file locking //! # Unix platform-specific file locking
//! This module contains methods used by the `FileLock` object in this module to lock and/or //! This module contains methods used by the `FileLock` object in this module to lock and/or
//! unlock files. //! unlock files.
use libc::c_int; use {
use std::fs::File; libc::c_int,
use std::io::Error; std::{
use std::io::Result; fs::File,
use std::os::unix::io::AsRawFd; io::{Error, Result},
use std::os::unix::io::FromRawFd; os::unix::io::{AsRawFd, FromRawFd},
},
};
extern "C" { extern "C" {
/// Block and acquire an exclusive lock with `libc`'s `flock` /// Block and acquire an exclusive lock with `libc`'s `flock`
@ -327,11 +338,11 @@ mod __sys {
#[cfg(all(target_os = "solaris", unix))] #[cfg(all(target_os = "solaris", unix))]
mod __sys { mod __sys {
//! Solaris doesn't have flock so we'll have to simulate that using fcntl //! Solaris doesn't have flock so we'll have to simulate that using fcntl
use std::fs::File; use std::{
use std::io::Error; fs::File,
use std::io::Result; io::{Error, Result},
use std::os::unix::io::AsRawFd; os::unix::io::{AsRawFd, FromRawFd},
use std::os::unix::io::FromRawFd; };
fn simulate_flock(file: &File, flag: libc::c_int) -> Result<()> { fn simulate_flock(file: &File, flag: libc::c_int) -> Result<()> {
let mut fle = libc::flock { let mut fle = libc::flock {

@ -54,10 +54,10 @@
* - Sayan N. <ohsayan@outlook.com> (July, 2021) * - Sayan N. <ohsayan@outlook.com> (July, 2021)
*/ */
use crate::corestore::booltable::BoolTable; use crate::{
use crate::corestore::booltable::TwoBitLUT; corestore::booltable::{BoolTable, TwoBitLUT},
use crate::protocol::iter::AnyArrayIter; protocol::iter::{AnyArrayIter, BorrowedAnyArrayIter},
use crate::protocol::iter::BorrowedAnyArrayIter; };
type PairFn = fn(&[u8], &[u8]) -> bool; type PairFn = fn(&[u8], &[u8]) -> bool;

@ -30,10 +30,14 @@ pub mod encoding;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
use self::encoding::{ENCODING_LUT, ENCODING_LUT_PAIR}; use {
use crate::corestore::{booltable::BoolTable, htable::Coremap, map::bref::Ref, Data}; self::encoding::{ENCODING_LUT, ENCODING_LUT_PAIR},
use crate::util::compiler; crate::{
use parking_lot::RwLock; corestore::{booltable::BoolTable, htable::Coremap, map::bref::Ref, Data},
util::compiler,
},
parking_lot::RwLock,
};
pub type KVEStandard = KVEngine<Data>; pub type KVEStandard = KVEngine<Data>;
pub type KVEListmap = KVEngine<LockedVec>; pub type KVEListmap = KVEngine<LockedVec>;

@ -24,8 +24,9 @@
* *
*/ */
use super::ParseError; use {
use crate::{ super::ParseError,
crate::{
corestore::{ corestore::{
booltable::{BytesBoolTable, BytesNicheLUT}, booltable::{BytesBoolTable, BytesNicheLUT},
buffers::Integer64, buffers::Integer64,
@ -33,9 +34,10 @@ use crate::{
dbnet::connection::{QueryResult, QueryWithAdvance, RawConnection, Stream}, dbnet::connection::{QueryResult, QueryWithAdvance, RawConnection, Stream},
util::FutureResult, util::FutureResult,
IoResult, IoResult,
},
std::io::{Error as IoError, ErrorKind},
tokio::io::{AsyncReadExt, AsyncWriteExt, BufWriter},
}; };
use std::io::{Error as IoError, ErrorKind};
use tokio::io::{AsyncReadExt, AsyncWriteExt, BufWriter};
/* /*
NOTE TO SELF (@ohsayan): Why do we split everything into separate traits? To avoid mistakes NOTE TO SELF (@ohsayan): Why do we split everything into separate traits? To avoid mistakes

@ -24,9 +24,11 @@
* *
*/ */
use super::UnsafeSlice; use {
use bytes::Bytes; super::UnsafeSlice,
use core::{hint::unreachable_unchecked, iter::FusedIterator, ops::Deref, slice::Iter}; bytes::Bytes,
core::{hint::unreachable_unchecked, iter::FusedIterator, ops::Deref, slice::Iter},
};
/// An iterator over an [`AnyArray`] (an [`UnsafeSlice`]). The validity of the iterator is /// An iterator over an [`AnyArray`] (an [`UnsafeSlice`]). The validity of the iterator is
/// left to the caller who has to guarantee: /// left to the caller who has to guarantee:

@ -25,8 +25,10 @@
*/ */
extern crate test; extern crate test;
use super::{super::Query, Parser}; use {
use test::Bencher; super::{super::Query, Parser},
test::Bencher,
};
#[bench] #[bench]
fn simple_query(b: &mut Bencher) { fn simple_query(b: &mut Bencher) {

@ -25,8 +25,10 @@
*/ */
extern crate test; extern crate test;
use super::{super::Query, Parser}; use {
use test::Bencher; super::{super::Query, Parser},
test::Bencher,
};
#[bench] #[bench]
fn simple_query(b: &mut Bencher) { fn simple_query(b: &mut Bencher) {

@ -24,7 +24,8 @@
* *
*/ */
use crate::{ use {
crate::{
corestore::buffers::Integer64, corestore::buffers::Integer64,
dbnet::connection::{QueryWithAdvance, RawConnection, Stream}, dbnet::connection::{QueryWithAdvance, RawConnection, Stream},
protocol::{ protocol::{
@ -33,9 +34,10 @@ use crate::{
}, },
util::FutureResult, util::FutureResult,
IoResult, IoResult,
},
::sky_macros::compiled_eresp_bytes as eresp,
tokio::io::AsyncWriteExt,
}; };
use ::sky_macros::compiled_eresp_bytes as eresp;
use tokio::io::AsyncWriteExt;
impl ProtocolSpec for Skyhash2 { impl ProtocolSpec for Skyhash2 {
// spec information // spec information

@ -24,13 +24,14 @@
* *
*/ */
use super::{ use {
super::{
super::raw_parser::{RawParser, RawParserExt, RawParserMeta}, super::raw_parser::{RawParser, RawParserExt, RawParserMeta},
Parser, PipelinedQuery, Query, SimpleQuery, Parser, PipelinedQuery, Query, SimpleQuery,
},
crate::protocol::{iter::AnyArrayIter, ParseError},
std::{iter::Map, vec::IntoIter as VecIntoIter},
}; };
use crate::protocol::{iter::AnyArrayIter, ParseError};
use std::iter::Map;
use std::vec::IntoIter as VecIntoIter;
type IterPacketWithLen = Map<VecIntoIter<Vec<u8>>, fn(Vec<u8>) -> (usize, Vec<u8>)>; type IterPacketWithLen = Map<VecIntoIter<Vec<u8>>, fn(Vec<u8>) -> (usize, Vec<u8>)>;
type Packets = Vec<Vec<u8>>; type Packets = Vec<Vec<u8>>;

@ -26,12 +26,11 @@
//! # The Query Engine //! # The Query Engine
use crate::corestore::Corestore;
use crate::dbnet::connection::prelude::*;
use crate::{ use crate::{
actions::{self, ActionError, ActionResult}, actions::{self, ActionError, ActionResult},
admin, auth, blueql, admin, auth, blueql,
corestore::Corestore,
dbnet::connection::prelude::*,
protocol::{iter::AnyArrayIter, PipelinedQuery, SimpleQuery, UnsafeSlice}, protocol::{iter::AnyArrayIter, PipelinedQuery, SimpleQuery, UnsafeSlice},
}; };

@ -29,9 +29,10 @@
//! The registry module provides interfaces for system-wide, global state management //! The registry module provides interfaces for system-wide, global state management
//! //!
use crate::corestore::lock::{QLGuard, QuickLock}; use {
use core::sync::atomic::AtomicBool; crate::corestore::lock::{QLGuard, QuickLock},
use core::sync::atomic::Ordering; core::sync::atomic::{AtomicBool, Ordering},
};
const ORD_ACQ: Ordering = Ordering::Acquire; const ORD_ACQ: Ordering = Ordering::Acquire;
const ORD_REL: Ordering = Ordering::Release; const ORD_REL: Ordering = Ordering::Release;

@ -24,15 +24,17 @@
* *
*/ */
use crate::{ use {
crate::{
config::BGSave, config::BGSave,
corestore::Corestore, corestore::Corestore,
dbnet::Terminator, dbnet::Terminator,
registry, registry,
storage::{self, v1::flush::Autoflush}, storage::{self, v1::flush::Autoflush},
IoResult, IoResult,
},
tokio::time::{self, Duration},
}; };
use tokio::time::{self, Duration};
/// The bgsave_scheduler calls the bgsave task in `Corestore` after `every` seconds /// The bgsave_scheduler calls the bgsave task in `Corestore` after `every` seconds
/// ///

@ -26,11 +26,9 @@
pub mod bgsave; pub mod bgsave;
pub mod snapshot; pub mod snapshot;
use crate::corestore::memstore::Memstore; use crate::{
use crate::diskstore::flock::FileLock; corestore::memstore::Memstore, diskstore::flock::FileLock, storage, util::os, IoResult,
use crate::storage; };
use crate::util::os;
use crate::IoResult;
pub fn restore_data(src: Option<String>) -> IoResult<()> { pub fn restore_data(src: Option<String>) -> IoResult<()> {
if let Some(src) = src { if let Some(src) = src {

@ -24,13 +24,17 @@
* *
*/ */
use crate::config::SnapshotConfig; use {
use crate::corestore::Corestore; crate::{
use crate::dbnet::Terminator; config::SnapshotConfig,
use crate::registry; corestore::Corestore,
use crate::storage::v1::sengine::{SnapshotActionResult, SnapshotEngine}; dbnet::Terminator,
use std::sync::Arc; registry,
use tokio::time::{self, Duration}; storage::v1::sengine::{SnapshotActionResult, SnapshotEngine},
},
std::sync::Arc,
tokio::time::{self, Duration},
};
/// The snapshot service /// The snapshot service
/// ///

@ -24,9 +24,7 @@
* *
*/ */
use crate::corestore::memstore::ObjectID; use {crate::corestore::memstore::ObjectID, core::fmt, std::io::Error as IoError};
use core::fmt;
use std::io::Error as IoError;
pub type StorageEngineResult<T> = Result<T, StorageEngineError>; pub type StorageEngineResult<T> = Result<T, StorageEngineError>;

@ -29,19 +29,22 @@
//! This module contains multiple flush routines: at the memstore level, the keyspace level and //! This module contains multiple flush routines: at the memstore level, the keyspace level and
//! the table level //! the table level
use super::{bytemarks, interface}; use {
use crate::corestore::memstore::SYSTEM; super::{bytemarks, interface},
use crate::corestore::{ crate::{
corestore::{
map::iter::BorrowedIter, map::iter::BorrowedIter,
memstore::SYSTEM,
memstore::{Keyspace, Memstore, ObjectID, SystemKeyspace}, memstore::{Keyspace, Memstore, ObjectID, SystemKeyspace},
table::{DataModel, SystemDataModel, SystemTable, Table}, table::{DataModel, SystemDataModel, SystemTable, Table},
},
registry,
util::Wrapper,
IoResult,
},
core::ops::Deref,
std::{io::Write, sync::Arc},
}; };
use crate::registry;
use crate::util::Wrapper;
use crate::IoResult;
use core::ops::Deref;
use std::io::Write;
use std::sync::Arc;
pub trait StorageTarget { pub trait StorageTarget {
/// This storage target needs a reinit of the tree despite no preload trip. /// This storage target needs a reinit of the tree despite no preload trip.

@ -26,16 +26,20 @@
//! Interfaces with the file system //! Interfaces with the file system
use crate::corestore::memstore::Memstore; use {
use crate::registry; crate::{
use crate::storage::v1::flush::FlushableKeyspace; corestore::memstore::Memstore,
use crate::storage::v1::flush::FlushableTable; registry,
use crate::storage::v1::flush::StorageTarget; storage::v1::flush::{FlushableKeyspace, FlushableTable, StorageTarget},
use crate::IoResult; IoResult,
use core::ops::Deref; },
use std::collections::HashSet; core::ops::Deref,
use std::fs; std::{
use std::io::{BufWriter, Write}; collections::HashSet,
fs,
io::{BufWriter, Write},
},
};
pub const DIR_KSROOT: &str = "data/ks"; pub const DIR_KSROOT: &str = "data/ks";
pub const DIR_SNAPROOT: &str = "data/snaps"; pub const DIR_SNAPROOT: &str = "data/snaps";

@ -33,10 +33,10 @@
and we won't read into others' memory (or corrupt our own). and we won't read into others' memory (or corrupt our own).
*/ */
use crate::storage::v1::Data; use {
use core::mem; crate::storage::v1::Data,
use core::ptr; core::{mem, ptr, slice},
use core::slice; };
const SIZE_64BIT: usize = mem::size_of::<u64>(); const SIZE_64BIT: usize = mem::size_of::<u64>();
const SIZE_128BIT: usize = SIZE_64BIT * 2; const SIZE_128BIT: usize = SIZE_64BIT * 2;

@ -51,14 +51,12 @@ think of using them anywhere outside. This is a specialized parser built for the
*/ */
use crate::corestore::array::Array; use {
use crate::corestore::htable::Coremap; crate::corestore::{array::Array, htable::Coremap, Data},
use crate::corestore::Data; core::{hash::Hash, mem, slice},
use core::hash::Hash; std::{collections::HashSet, io::Write},
use core::mem; };
use core::slice;
use std::collections::HashSet;
use std::io::Write;
// for some astronomical reasons do not mess with this // for some astronomical reasons do not mess with this
#[macro_use] #[macro_use]
mod macros; mod macros;

@ -32,14 +32,18 @@
//! 2. the `PARTMAP` preload that is placed in the ks directory //! 2. the `PARTMAP` preload that is placed in the ks directory
//! //!
use crate::corestore::memstore::Memstore; use {
use crate::corestore::memstore::ObjectID; crate::{
use crate::storage::v1::error::{StorageEngineError, StorageEngineResult}; corestore::memstore::{Memstore, ObjectID},
use crate::IoResult; storage::v1::error::{StorageEngineError, StorageEngineResult},
use core::ptr; IoResult,
use std::collections::HashMap; },
use std::collections::HashSet; core::ptr,
use std::io::Write; std::{
collections::{HashMap, HashSet},
io::Write,
},
};
pub type LoadedPartfile = HashMap<ObjectID, (u8, u8)>; pub type LoadedPartfile = HashMap<ObjectID, (u8, u8)>;

@ -24,23 +24,19 @@
* *
*/ */
use self::queue::Queue; use {
use super::interface::{DIR_RSNAPROOT, DIR_SNAPROOT}; self::queue::Queue,
use crate::corestore::iarray::IArray; super::interface::{DIR_RSNAPROOT, DIR_SNAPROOT},
use crate::corestore::lazy::Lazy; crate::{
use crate::corestore::lock::QuickLock; corestore::{iarray::IArray, lazy::Lazy, lock::QuickLock, memstore::Memstore},
use crate::corestore::memstore::Memstore; storage::v1::flush::{LocalSnapshot, RemoteSnapshot},
use crate::storage::v1::flush::{LocalSnapshot, RemoteSnapshot}; },
use bytes::Bytes; bytes::Bytes,
use chrono::prelude::Utc; chrono::prelude::Utc,
use core::fmt; core::{fmt, str},
use core::str; regex::Regex,
use regex::Regex; std::{collections::HashSet, fs, io::Error as IoError, path::Path, sync::Arc},
use std::collections::HashSet; };
use std::fs;
use std::io::Error as IoError;
use std::path::Path;
use std::sync::Arc;
type QStore = IArray<[String; 64]>; type QStore = IArray<[String; 64]>;
type SnapshotResult<T> = Result<T, SnapshotEngineError>; type SnapshotResult<T> = Result<T, SnapshotEngineError>;

@ -28,8 +28,9 @@
//! //!
//! Routines for unflushing data //! Routines for unflushing data
use super::bytemarks; use {
use crate::{ super::bytemarks,
crate::{
corestore::{ corestore::{
memstore::{Keyspace, Memstore, ObjectID, SystemKeyspace, SYSTEM}, memstore::{Keyspace, Memstore, ObjectID, SystemKeyspace, SYSTEM},
table::{SystemTable, Table}, table::{SystemTable, Table},
@ -43,9 +44,10 @@ use crate::{
Coremap, Coremap,
}, },
util::Wrapper, util::Wrapper,
},
core::mem::transmute,
std::{fs, io::ErrorKind, path::Path, sync::Arc},
}; };
use core::mem::transmute;
use std::{fs, io::ErrorKind, path::Path, sync::Arc};
type PreloadSet = std::collections::HashSet<ObjectID>; type PreloadSet = std::collections::HashSet<ObjectID>;
const PRELOAD_PATH: &str = "data/ks/PRELOAD"; const PRELOAD_PATH: &str = "data/ks/PRELOAD";

@ -24,8 +24,10 @@
* *
*/ */
use crate::auth::provider::testsuite_data; use {
use skytable::{query, Element, RespCode}; crate::auth::provider::testsuite_data,
skytable::{query, Element, RespCode},
};
macro_rules! assert_autherror { macro_rules! assert_autherror {
($con:expr, $query:expr, $eq:expr) => { ($con:expr, $query:expr, $eq:expr) => {

@ -26,9 +26,11 @@
#[sky_macros::dbtest_module] #[sky_macros::dbtest_module]
mod __private { mod __private {
use libstress::utils; use {
use skytable::types::Array; libstress::utils,
use skytable::{query, Element, Query, RespCode}; skytable::{query, types::Array, Element, Query, RespCode},
};
async fn test_create_keyspace() { async fn test_create_keyspace() {
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();
let ksname = utils::rand_alphastring(10, &mut rng); let ksname = utils::rand_alphastring(10, &mut rng);

@ -26,8 +26,8 @@
#[sky_macros::dbtest_module(table = "(string, string)")] #[sky_macros::dbtest_module(table = "(string, string)")]
mod __private { mod __private {
use skytable::types::RawString; use skytable::{types::RawString, Element, RespCode};
use skytable::{Element, RespCode};
async fn test_bad_encoding_set() { async fn test_bad_encoding_set() {
query.push("set"); query.push("set");
query.push("x"); query.push("x");

@ -52,10 +52,13 @@ mod tls {
} }
mod sys { mod sys {
use crate::protocol::{LATEST_PROTOCOL_VERSION, LATEST_PROTOCOL_VERSIONSTRING}; use {
use libsky::VERSION; crate::protocol::{LATEST_PROTOCOL_VERSION, LATEST_PROTOCOL_VERSIONSTRING},
use sky_macros::dbtest_func as dbtest; libsky::VERSION,
use skytable::{query, Element, RespCode}; sky_macros::dbtest_func as dbtest,
skytable::{query, Element, RespCode},
};
#[dbtest] #[dbtest]
async fn sys_info_aerr() { async fn sys_info_aerr() {
runeq!( runeq!(

@ -24,8 +24,10 @@
* *
*/ */
use sky_macros::dbtest_func as dbtest; use {
use skytable::{query, Element}; sky_macros::dbtest_func as dbtest,
skytable::{query, Element},
};
const USERID: &str = "steinbeck"; const USERID: &str = "steinbeck";

@ -24,8 +24,10 @@
* *
*/ */
use super::{persist_load, persist_store, PERSIST_TEST_SET_SIZE}; use {
use sky_macros::dbtest_func as dbtest; super::{persist_load, persist_store, PERSIST_TEST_SET_SIZE},
sky_macros::dbtest_func as dbtest,
};
const PERSIST_CFG_KEYMAP_BIN_BIN_TABLE: &str = "testsuite.persist_bin_bin_tbl"; const PERSIST_CFG_KEYMAP_BIN_BIN_TABLE: &str = "testsuite.persist_bin_bin_tbl";
const PERSIST_DATA_KEYMAP_BIN_BIN_TABLE: [(&[u8], &[u8]); PERSIST_TEST_SET_SIZE] = [ const PERSIST_DATA_KEYMAP_BIN_BIN_TABLE: [(&[u8], &[u8]); PERSIST_TEST_SET_SIZE] = [

@ -24,8 +24,10 @@
* *
*/ */
use super::{persist_load, persist_store, Bin, ListIDBin, ListIDStr, Str, PERSIST_TEST_SET_SIZE}; use {
use sky_macros::dbtest_func as dbtest; super::{persist_load, persist_store, Bin, ListIDBin, ListIDStr, Str, PERSIST_TEST_SET_SIZE},
sky_macros::dbtest_func as dbtest,
};
type ListData<K, V> = [(K, [V; PERSIST_TEST_SET_SIZE]); PERSIST_TEST_SET_SIZE]; type ListData<K, V> = [(K, [V; PERSIST_TEST_SET_SIZE]); PERSIST_TEST_SET_SIZE];

@ -24,12 +24,14 @@
* *
*/ */
use sky_macros::dbtest_func as dbtest; use {
use skytable::{ sky_macros::dbtest_func as dbtest,
skytable::{
aio::Connection, aio::Connection,
query, query,
types::{Array, RawString}, types::{Array, RawString},
Element, Query, RespCode, Element, Query, RespCode,
},
}; };
#[dbtest(skip_if_cfg = "persist-suite", norun = true, port = 2007)] #[dbtest(skip_if_cfg = "persist-suite", norun = true, port = 2007)]

@ -24,8 +24,10 @@
* *
*/ */
use sky_macros::dbtest_func as dbtest; use {
use skytable::{query, Element, RespCode}; sky_macros::dbtest_func as dbtest,
skytable::{query, Element, RespCode},
};
const SNAPSHOT_DISABLED: &str = "err-snapshot-disabled"; const SNAPSHOT_DISABLED: &str = "err-snapshot-disabled";

@ -24,9 +24,11 @@
* *
*/ */
use crate::storage::v1::{error::StorageEngineError, sengine::SnapshotEngineError}; use {
use openssl::{error::ErrorStack as SslErrorStack, ssl::Error as SslError}; crate::storage::v1::{error::StorageEngineError, sengine::SnapshotEngineError},
use std::{fmt, io::Error as IoError}; openssl::{error::ErrorStack as SslErrorStack, ssl::Error as SslError},
std::{fmt, io::Error as IoError},
};
pub type SkyResult<T> = Result<T, Error>; pub type SkyResult<T> = Result<T, Error>;

@ -36,8 +36,16 @@ use {
#[cfg(unix)] #[cfg(unix)]
mod unix { mod unix {
use libc::{rlimit, RLIMIT_NOFILE}; use {
use std::io::Error as IoError; libc::{rlimit, RLIMIT_NOFILE},
std::{
future::Future,
io::Error as IoError,
pin::Pin,
task::{Context, Poll},
},
tokio::signal::unix::{signal, Signal, SignalKind},
};
#[derive(Debug)] #[derive(Debug)]
pub struct ResourceLimit { pub struct ResourceLimit {
@ -87,11 +95,6 @@ mod unix {
let _ = ResourceLimit::get().unwrap(); let _ = ResourceLimit::get().unwrap();
} }
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
use tokio::signal::unix::{signal, Signal, SignalKind};
pub struct TerminationSignal { pub struct TerminationSignal {
sigint: Signal, sigint: Signal,
sigterm: Signal, sigterm: Signal,
@ -121,10 +124,14 @@ mod unix {
#[cfg(windows)] #[cfg(windows)]
mod windows { mod windows {
use std::future::Future; use {
use std::pin::Pin; std::{
use std::task::{Context, Poll}; future::Future,
use tokio::signal::windows::{ctrl_break, ctrl_c, CtrlBreak, CtrlC}; pin::Pin,
task::{Context, Poll},
},
tokio::signal::windows::{ctrl_break, ctrl_c, CtrlBreak, CtrlC},
};
pub struct TerminationSignal { pub struct TerminationSignal {
ctrl_c: CtrlC, ctrl_c: CtrlC,

@ -24,17 +24,19 @@
* *
*/ */
use crate::{report::AggregatedReport, util}; use {
use devtimer::DevTime; self::validation::SQ_RESPCODE_SIZE,
use libstress::{utils::generate_random_byte_vector, PoolConfig}; crate::{report::AggregatedReport, util},
use rand::thread_rng; devtimer::DevTime,
use skytable::{types::RawString, Query}; libstress::{utils::generate_random_byte_vector, PoolConfig},
use std::{ rand::thread_rng,
skytable::{types::RawString, Query},
std::{
io::{Read, Write}, io::{Read, Write},
net::TcpStream, net::TcpStream,
},
}; };
pub mod validation; pub mod validation;
use self::validation::SQ_RESPCODE_SIZE;
const NOTICE_INIT_BENCH: &str = "Finished sanity test. Initializing benchmark ..."; const NOTICE_INIT_BENCH: &str = "Finished sanity test. Initializing benchmark ...";
const NOTICE_INIT_COMPLETE: &str = "Initialization complete! Benchmark started"; const NOTICE_INIT_COMPLETE: &str = "Initialization complete! Benchmark started";

@ -36,13 +36,12 @@ mod util;
mod benchtool; mod benchtool;
mod report; mod report;
mod testkey; mod testkey;
use crate::util::DEFAULT_PACKET_SIZE;
use crate::util::DEFAULT_QUERY_COUNT; use {
use crate::util::DEFAULT_REPEAT; crate::util::{DEFAULT_PACKET_SIZE, DEFAULT_QUERY_COUNT, DEFAULT_REPEAT, DEFAULT_WORKER_COUNT},
use crate::util::DEFAULT_WORKER_COUNT; clap::{load_yaml, App},
// external imports core::hint::unreachable_unchecked,
use clap::{load_yaml, App}; };
use core::hint::unreachable_unchecked;
fn main() { fn main() {
let cfg_layout = load_yaml!("./cli.yml"); let cfg_layout = load_yaml!("./cli.yml");

@ -24,10 +24,11 @@
* *
*/ */
use crate::util; use {
use core::cmp::Ordering; crate::util,
use std::collections::hash_map::Entry; core::cmp::Ordering,
use std::collections::HashMap; std::collections::{hash_map::Entry, HashMap},
};
/// A map of reports /// A map of reports
pub struct AggregatedReport { pub struct AggregatedReport {

@ -24,13 +24,16 @@
* *
*/ */
use crate::{benchtool::validation::SQ_RESPCODE_SIZE, hoststr, sanity_test}; use {
use libstress::utils::generate_random_string_vector; crate::{benchtool::validation::SQ_RESPCODE_SIZE, hoststr, sanity_test},
use libstress::Workpool; libstress::{utils::generate_random_string_vector, Workpool},
use rand::thread_rng; rand::thread_rng,
use skytable::Query; skytable::Query,
use std::io::{Read, Write}; std::{
use std::net::{self, TcpStream}; io::{Read, Write},
net::{self, TcpStream},
},
};
pub fn create_testkeys(host: &str, port: u16, num: usize, connections: usize, size: usize) { pub fn create_testkeys(host: &str, port: u16, num: usize, connections: usize, size: usize) {
if let Err(e) = sanity_test!(host, port) { if let Err(e) = sanity_test!(host, port) {

@ -24,9 +24,7 @@
* *
*/ */
use libstress::utils::ran_string; use {libstress::utils::ran_string, rand::thread_rng, std::error::Error};
use rand::thread_rng;
use std::error::Error;
pub const DEFAULT_WORKER_COUNT: usize = 10; pub const DEFAULT_WORKER_COUNT: usize = 10;
pub const DEFAULT_PACKET_SIZE: usize = 4; pub const DEFAULT_PACKET_SIZE: usize = 4;

@ -24,10 +24,7 @@
* *
*/ */
use crate::util; use {crate::util, proc_macro::TokenStream, quote::quote, syn::AttributeArgs};
use proc_macro::TokenStream;
use quote::quote;
use syn::AttributeArgs;
type OptString = Option<String>; type OptString = Option<String>;

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save