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 clap::{load_yaml, App};
use crossterm::{
cursor, execute,
terminal::{Clear, ClearType},
use {
crate::{runner::Runner, tokenizer},
clap::{load_yaml, App},
crossterm::{
cursor, execute,
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 SKYSH_HISTORY_FILE: &str = ".sky_history";

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

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

@ -24,17 +24,19 @@
*
*/
use crate::{
build::{self, BuildMode},
util, HarnessError, HarnessResult,
use {
crate::{
build::{self, BuildMode},
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
pub fn get_bundle_name() -> String {

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

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

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

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

@ -24,24 +24,26 @@
*
*/
use crate::{
build::BuildMode,
util::{self},
HarnessError, HarnessResult,
};
use openssl::{
asn1::Asn1Time,
bn::{BigNum, MsbOption},
error::ErrorStack,
hash::MessageDigest,
pkey::{PKey, Private},
rsa::Rsa,
x509::{
extension::{BasicConstraints, KeyUsage, SubjectKeyIdentifier},
X509NameBuilder, X509,
use {
crate::{
build::BuildMode,
util::{self},
HarnessError, HarnessResult,
},
openssl::{
asn1::Asn1Time,
bn::{BigNum, MsbOption},
error::ErrorStack,
hash::MessageDigest,
pkey::{PKey, Private},
rsa::Rsa,
x509::{
extension::{BasicConstraints, KeyUsage, SubjectKeyIdentifier},
X509NameBuilder, X509,
},
},
std::{fs, io::Write},
};
use std::{fs, io::Write};
mod svc;
/// Run the test suite

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

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

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

@ -59,13 +59,14 @@
#![deny(unused_imports)]
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;
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
/// Nothing is a variant used by the drop implementation to terminate all the workers

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

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

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

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

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

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

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

@ -24,9 +24,10 @@
*
*/
use crate::corestore::table::DataModel;
use crate::corestore::Data;
use crate::dbnet::connection::prelude::*;
use crate::{
corestore::{table::DataModel, Data},
dbnet::connection::prelude::*,
};
const DEFAULT_COUNT: usize = 10;
@ -72,7 +73,8 @@ action!(
DataModel::KV(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 {
con.write_typed_non_null_array_element(&key).await?;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -24,27 +24,29 @@
*
*/
use crate::{
auth::AuthProvider,
config::{ConfigurationSet, SnapshotConfig, SnapshotPref},
corestore::Corestore,
dbnet::{self, Terminator},
diskstore::flock::FileLock,
services,
storage::v1::sengine::SnapshotEngine,
util::{
error::{Error, SkyResult},
os::TerminationSignal,
use {
crate::{
auth::AuthProvider,
config::{ConfigurationSet, SnapshotConfig, SnapshotPref},
corestore::Corestore,
dbnet::{self, Terminator},
diskstore::flock::FileLock,
services,
storage::v1::sengine::SnapshotEngine,
util::{
error::{Error, SkyResult},
os::TerminationSignal,
},
},
};
use std::{sync::Arc, thread::sleep};
use tokio::{
sync::{
broadcast,
mpsc::{self, Sender},
std::{sync::Arc, thread::sleep},
tokio::{
sync::{
broadcast,
mpsc::{self, Sender},
},
task::{self, JoinHandle},
time::Duration,
},
task::{self, JoinHandle},
time::Duration,
};
const TERMSIG_THRESHOLD: usize = 3;

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

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

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

@ -24,8 +24,10 @@
*
*/
use super::{ConfigSourceParseResult, Configset, TryFromConfigSource};
use clap::ArgMatches;
use {
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,
/// if the flag is set, the value of SWITCH determines what value it is set to

@ -24,12 +24,14 @@
*
*/
use super::{
AuthSettings, ConfigSourceParseResult, Configset, Modeset, OptString, ProtocolVersion,
TryFromConfigSource,
use {
super::{
AuthSettings, ConfigSourceParseResult, Configset, Modeset, OptString, ProtocolVersion,
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
#[derive(Deserialize, Debug, PartialEq)]

@ -24,16 +24,16 @@
*
*/
use super::{feedback::WarningStack, DEFAULT_IPV4, DEFAULT_PORT};
use crate::config::AuthkeyWrapper;
use crate::dbnet::MAXIMUM_CONNECTION_LIMIT;
use core::fmt;
use core::str::FromStr;
use serde::{
de::{self, Deserializer, Visitor},
Deserialize,
use {
super::{feedback::WarningStack, DEFAULT_IPV4, DEFAULT_PORT},
crate::{config::AuthkeyWrapper, dbnet::MAXIMUM_CONNECTION_LIMIT},
core::{fmt, str::FromStr},
serde::{
de::{self, Deserializer, Visitor},
Deserialize,
},
std::net::IpAddr,
};
use std::net::IpAddr;
/// 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)]
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)]
const EMSG_ENV: &str = "Environment";

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

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

@ -24,22 +24,20 @@
*
*/
use bytes::Bytes;
use core::any;
use core::borrow::Borrow;
use core::borrow::BorrowMut;
use core::cmp::Ordering;
use core::convert::TryFrom;
use core::fmt;
use core::hash::Hash;
use core::hash::Hasher;
use core::iter::FromIterator;
use core::mem::ManuallyDrop;
use core::mem::MaybeUninit;
use core::ops;
use core::ptr;
use core::slice;
use core::str;
use {
bytes::Bytes,
core::{
any,
borrow::{Borrow, BorrowMut},
cmp::Ordering,
convert::TryFrom,
fmt,
hash::{Hash, Hasher},
iter::FromIterator,
mem::{ManuallyDrop, MaybeUninit},
ops, ptr, slice, str,
},
};
/// 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

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

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

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

@ -26,17 +26,16 @@
#![allow(unused)] // TODO(@ohsayan): Plonk this
use crate::corestore::map::{
bref::{Entry, OccupiedEntry, Ref, VacantEntry},
iter::{BorrowedIter, OwnedIter},
Skymap,
use {
crate::corestore::map::{
bref::{Entry, OccupiedEntry, Ref, VacantEntry},
iter::{BorrowedIter, OwnedIter},
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>;

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

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

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

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

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

@ -27,24 +27,26 @@
#![allow(clippy::manual_map)] // avoid LLVM bloat
#![allow(unused)] // TODO(@ohsayan): Plonk this
use crate::util::compiler;
use core::borrow::Borrow;
use core::fmt;
use core::hash::BuildHasher;
use core::hash::Hash;
use core::hash::Hasher;
use core::iter::FromIterator;
use core::mem;
use parking_lot::RwLock;
use parking_lot::RwLockReadGuard;
use parking_lot::RwLockWriteGuard;
use std::collections::hash_map::RandomState;
use std::num::NonZeroUsize;
use std::thread::available_parallelism;
use {
self::{
bref::{Entry, OccupiedEntry, Ref, RefMut, VacantEntry},
iter::{BorrowedIter, OwnedIter},
},
crate::util::compiler,
core::{
borrow::Borrow,
fmt,
hash::{BuildHasher, Hash, Hasher},
iter::FromIterator,
mem,
num::NonZeroUsize,
},
parking_lot::{RwLock, RwLockReadGuard, RwLockWriteGuard},
std::{collections::hash_map::RandomState, thread::available_parallelism},
};
pub mod bref;
use iter::{BorrowedIter, OwnedIter};
pub mod iter;
use bref::{Entry, OccupiedEntry, Ref, RefMut, VacantEntry};
type LowMap<K, V> = hashbrown::raw::RawTable<(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
//! and destructor.
use super::KeyspaceResult;
use crate::auth::Authmap;
use crate::corestore::array::Array;
use crate::corestore::htable::Coremap;
use crate::corestore::table::Table;
use crate::corestore::table::{SystemDataModel, SystemTable};
use crate::registry;
use crate::util::Wrapper;
use core::borrow::Borrow;
use core::hash::Hash;
use std::sync::Arc;
use {
super::KeyspaceResult,
crate::{
auth::Authmap,
corestore::{
array::Array,
htable::Coremap,
table::{SystemDataModel, SystemTable, Table},
},
registry,
util::Wrapper,
},
core::{borrow::Borrow, hash::Hash},
std::sync::Arc,
};
uninit_array! {
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)]
use crate::corestore::{memstore::DdlError, KeyspaceResult};
use crate::dbnet::connection::prelude::Corestore;
use crate::kvengine::{KVEListmap, KVEStandard, LockedVec};
use crate::protocol::interface::ProtocolSpec;
use crate::util;
use crate::{
actions::ActionResult,
auth::Authmap,
corestore::{htable::Coremap, Data},
dbnet::connection::prelude::Corestore,
kvengine::{KVEListmap, KVEStandard, LockedVec},
protocol::interface::ProtocolSpec,
util,
};
pub trait DescribeTable {
type Table;

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

@ -35,28 +35,30 @@
//! 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.
use crate::{
actions::{ActionError, ActionResult},
auth::AuthProvider,
corestore::Corestore,
dbnet::{
connection::prelude::FutureResult,
tcp::{BufferedSocketStream, Connection},
Terminator,
},
protocol::{
interface::{ProtocolRead, ProtocolSpec, ProtocolWrite},
Query,
},
queryengine, IoResult,
};
use bytes::{Buf, BytesMut};
#[cfg(windows)]
use std::io::ErrorKind;
use std::{marker::PhantomData, sync::Arc};
use tokio::{
io::{AsyncReadExt, AsyncWriteExt, BufWriter},
sync::{mpsc, Semaphore},
use {
crate::{
actions::{ActionError, ActionResult},
auth::AuthProvider,
corestore::Corestore,
dbnet::{
connection::prelude::FutureResult,
tcp::{BufferedSocketStream, Connection},
Terminator,
},
protocol::{
interface::{ProtocolRead, ProtocolSpec, ProtocolWrite},
Query,
},
queryengine, IoResult,
},
bytes::{Buf, BytesMut},
std::{marker::PhantomData, sync::Arc},
tokio::{
io::{AsyncReadExt, AsyncWriteExt, BufWriter},
sync::{mpsc, Semaphore},
},
};
pub type QueryWithAdvance = (Query, usize);

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

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

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

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

@ -24,18 +24,20 @@
*
*/
use super::ParseError;
use crate::{
corestore::{
booltable::{BytesBoolTable, BytesNicheLUT},
buffers::Integer64,
use {
super::ParseError,
crate::{
corestore::{
booltable::{BytesBoolTable, BytesNicheLUT},
buffers::Integer64,
},
dbnet::connection::{QueryResult, QueryWithAdvance, RawConnection, Stream},
util::FutureResult,
IoResult,
},
dbnet::connection::{QueryResult, QueryWithAdvance, RawConnection, Stream},
util::FutureResult,
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

@ -24,9 +24,11 @@
*
*/
use super::UnsafeSlice;
use bytes::Bytes;
use core::{hint::unreachable_unchecked, iter::FusedIterator, ops::Deref, slice::Iter};
use {
super::UnsafeSlice,
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
/// left to the caller who has to guarantee:

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

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

@ -24,18 +24,20 @@
*
*/
use crate::{
corestore::buffers::Integer64,
dbnet::connection::{QueryWithAdvance, RawConnection, Stream},
protocol::{
interface::{ProtocolRead, ProtocolSpec, ProtocolWrite},
ParseError, Skyhash2,
use {
crate::{
corestore::buffers::Integer64,
dbnet::connection::{QueryWithAdvance, RawConnection, Stream},
protocol::{
interface::{ProtocolRead, ProtocolSpec, ProtocolWrite},
ParseError, Skyhash2,
},
util::FutureResult,
IoResult,
},
util::FutureResult,
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 {
// spec information

@ -24,13 +24,14 @@
*
*/
use super::{
super::raw_parser::{RawParser, RawParserExt, RawParserMeta},
Parser, PipelinedQuery, Query, SimpleQuery,
use {
super::{
super::raw_parser::{RawParser, RawParserExt, RawParserMeta},
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 Packets = Vec<Vec<u8>>;

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

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

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

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

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

@ -24,9 +24,7 @@
*
*/
use crate::corestore::memstore::ObjectID;
use core::fmt;
use std::io::Error as IoError;
use {crate::corestore::memstore::ObjectID, core::fmt, std::io::Error as IoError};
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
//! the table level
use super::{bytemarks, interface};
use crate::corestore::memstore::SYSTEM;
use crate::corestore::{
map::iter::BorrowedIter,
memstore::{Keyspace, Memstore, ObjectID, SystemKeyspace},
table::{DataModel, SystemDataModel, SystemTable, Table},
use {
super::{bytemarks, interface},
crate::{
corestore::{
map::iter::BorrowedIter,
memstore::SYSTEM,
memstore::{Keyspace, Memstore, ObjectID, SystemKeyspace},
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 {
/// This storage target needs a reinit of the tree despite no preload trip.

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

@ -33,10 +33,10 @@
and we won't read into others' memory (or corrupt our own).
*/
use crate::storage::v1::Data;
use core::mem;
use core::ptr;
use core::slice;
use {
crate::storage::v1::Data,
core::{mem, ptr, slice},
};
const SIZE_64BIT: usize = mem::size_of::<u64>();
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 crate::corestore::htable::Coremap;
use crate::corestore::Data;
use core::hash::Hash;
use core::mem;
use core::slice;
use std::collections::HashSet;
use std::io::Write;
use {
crate::corestore::{array::Array, htable::Coremap, Data},
core::{hash::Hash, mem, slice},
std::{collections::HashSet, io::Write},
};
// for some astronomical reasons do not mess with this
#[macro_use]
mod macros;

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

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

@ -28,24 +28,26 @@
//!
//! Routines for unflushing data
use super::bytemarks;
use crate::{
corestore::{
memstore::{Keyspace, Memstore, ObjectID, SystemKeyspace, SYSTEM},
table::{SystemTable, Table},
use {
super::bytemarks,
crate::{
corestore::{
memstore::{Keyspace, Memstore, ObjectID, SystemKeyspace, SYSTEM},
table::{SystemTable, Table},
},
storage::v1::{
de::DeserializeInto,
error::{ErrorContext, StorageEngineError, StorageEngineResult},
flush::Autoflush,
interface::DIR_KSROOT,
preload::LoadedPartfile,
Coremap,
},
util::Wrapper,
},
storage::v1::{
de::DeserializeInto,
error::{ErrorContext, StorageEngineError, StorageEngineResult},
flush::Autoflush,
interface::DIR_KSROOT,
preload::LoadedPartfile,
Coremap,
},
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>;
const PRELOAD_PATH: &str = "data/ks/PRELOAD";

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

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

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

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

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

@ -24,8 +24,10 @@
*
*/
use super::{persist_load, persist_store, PERSIST_TEST_SET_SIZE};
use sky_macros::dbtest_func as dbtest;
use {
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_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 sky_macros::dbtest_func as dbtest;
use {
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];

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save