Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 13 additions & 15 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,23 @@ version = "0.2.0"
authors = ["OceanBase OBKV Developers", "CeresDB Authors <ceresdbservice@gmail.com>"]
edition = "2021"

[workspace]
members = ["ycsb-rs"]

[workspace.package]
version = "0.2.0"
authors = ["OceanBase OBKV Developers", "CeresDB Authors <ceresdbservice@gmail.com>"]
edition = "2021"

[workspace]
members = [
"ycsb-rs",
]

[lib]
name = "obkv"

[[bench]]
name = "concurrent_insert"
harness = false
path = "benches/concurrent_insert/mod.rs"

[workspace.dependencies]
anyhow = "1.0"
log = "0.4"
toml = "0.7.3"
prometheus-client = "0.21"
tokio = { version = "1", features = ["full"] }
toml = "0.7.3"

[lib]
name = "obkv"

[dependencies]
anyhow = { workspace = true }
Expand Down Expand Up @@ -71,8 +64,13 @@ serial_test = "2.0"
serial_test_derive = "2.0"
tempfile = "3.0"
test-log = "0.2"
time = "0.3"
time = "0.3.36"
tokio-test = "0.4"

[[bench]]
name = "concurrent_insert"
harness = false
path = "benches/concurrent_insert/mod.rs"

[profile.release]
debug = true
2 changes: 1 addition & 1 deletion src/client/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl ObTableFilterList {
where
I: IntoIterator<Item = Filter>,
{
self.filters.extend(filters.into_iter())
self.filters.extend(filters)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/client/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ impl Drop for QueryStreamResult {
pub enum QueryResultSet {
#[default]
None,
Some(QueryStreamResult),
Some(Box<QueryStreamResult>),
}

impl QueryResultSet {
Expand All @@ -403,7 +403,7 @@ impl QueryResultSet {
}

pub fn from_stream_result(stream_result: QueryStreamResult) -> Self {
QueryResultSet::Some(stream_result)
QueryResultSet::Some(Box::new(stream_result))
}

pub fn cache_size(&self) -> usize {
Expand Down
15 changes: 4 additions & 11 deletions src/client/table_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use std::{
borrow::Borrow,
collections::HashMap,
isize,
sync::{
atomic::{AtomicBool, AtomicI64, AtomicIsize, AtomicUsize, Ordering},
Arc, Mutex, RwLock,
Expand Down Expand Up @@ -155,7 +154,7 @@ impl ServerRoster {
return;
}

let mut priority: isize = isize::min_value();
let mut priority: isize = isize::MIN;

for addr in self.roster.rl().iter() {
if addr.priority() > priority {
Expand All @@ -169,13 +168,7 @@ impl ServerRoster {
pub fn max_priority(&self) -> isize {
let p = self.max_priority.load(Ordering::Acquire);

if p < -MAX_PRIORITY {
-MAX_PRIORITY
} else if p > MAX_PRIORITY {
MAX_PRIORITY
} else {
p
}
p.clamp(-MAX_PRIORITY, MAX_PRIORITY)
}
}

Expand Down Expand Up @@ -679,6 +672,7 @@ impl ObTableClientInner {
result
}

#[allow(clippy::mutable_key_type)]
fn add_ob_table_to_roster(
&self,
addr: &ObServerAddr,
Expand Down Expand Up @@ -2607,9 +2601,8 @@ impl ObTableAggregation {
pub async fn execute(mut self) -> Result<HashMap<String, Value>> {
// In order to get cache size.
self.table_query = self.table_query.select(self.aggregation_operations);
let mut query_set = self.table_query.execute().await.map_err(|e| {
let mut query_set = self.table_query.execute().await.inspect_err(|_e| {
error!("fail to execute aggregate");
e
})?;
let aggregate_option = query_set.next().await;
match aggregate_option {
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ impl Error {
} else if let Error::Common(CommonErrCode::ConnPool, message) = self {
// conn_pool will produced this error if all connection to a server is shutdown
// which means we need refresh
return message.ends_with("are all removed");
message.ends_with("are all removed")
} else {
false
}
Expand Down
2 changes: 2 additions & 0 deletions src/location/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ impl ObTableLocation {
}
}

#[allow(clippy::mutable_key_type)]
fn get_pool_from_cache(
&self,
pools: &HashMap<ObServerAddr, HashMap<String, Arc<my::Pool>>>,
Expand All @@ -645,6 +646,7 @@ impl ObTableLocation {
}

/// Invalidate expired mysql pools.
#[allow(clippy::mutable_key_type)]
pub fn invalidate_mysql_pools(&self, valid_addrs: &[ObServerAddr]) {
let valid_addrs: HashSet<ObServerAddr> = valid_addrs.iter().cloned().collect();
self.mysql_pools
Expand Down
33 changes: 29 additions & 4 deletions src/location/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@

use std::{
collections::HashMap,
i32, i64,
sync::{atomic::AtomicUsize, Arc},
u8,
};

use chrono::Utc;
Expand Down Expand Up @@ -53,8 +51,35 @@ pub struct LocationUtil {}
impl LocationUtil {
pub fn get_ob_version_from_server(conn: &mut my::PooledConn) -> Result<()> {
if ob_vsn_major() == 0 {
let sql = "SELECT /*+READ_CONSISTENCY(WEAK)*/ OB_VERSION() AS CLUSTER_VERSION";
for row in conn.query::<Row, &str>(sql)? {
let sql_4x = "SELECT /*+READ_CONSISTENCY(WEAK)*/ OB_VERSION() AS CLUSTER_VERSION";
let sql_2x = "SELECT /*+READ_CONSISTENCY(WEAK)*/ VERSION() AS CLUSTER_VERSION";

// try sql_4x first
let result = conn.query::<Row, &str>(sql_4x);
let rows = match result {
Ok(rows) => rows,
Err(_) => {
// if sql_4x failed, try sql_2x
match conn.query::<Row, &str>(sql_2x) {
Ok(rows) => rows,
Err(e) => {
error!(
"Both OB_VERSION() and VERSION() are not supported, err:{}",
e
);
return Err(CommonErr(
CommonErrCode::ConvertFailed,
format!(
"Both OB_VERSION() and VERSION() are not supported, err:{e}"
),
));
}
}
}
};

// process the query results
for row in rows {
let cluster_version = match my::from_row_opt(row) {
Ok(version) => version,
Err(e) => {
Expand Down
1 change: 0 additions & 1 deletion src/rpc/conn_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use std::{
cmp,
sync::{Arc, Condvar, Mutex},
time::{Duration, Instant},
u32,
};

use tokio::time::sleep;
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/protocol/lsop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ impl ObTableSingleOpEntity {
) -> Result<()> {
bit_map.clear();
column_names.clear();
let bm_len = (len + 7) / 8;
let bm_len = len.div_ceil(8);
for idx in 0..bm_len {
bit_map.push(decode_u8(src)?);
for bit_idx in 0usize..8 {
Expand Down
2 changes: 1 addition & 1 deletion src/serde_obkv/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<'de> Deserializer<'de> {
}
}

impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
impl<'de> de::Deserializer<'de> for &mut Deserializer<'de> {
type Error = Error;

forward_to_deserialize_any! {
Expand Down
2 changes: 1 addition & 1 deletion src/serde_obkv/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,6 @@ use std::io;

impl From<Error> for io::Error {
fn from(e: Error) -> io::Error {
io::Error::new(io::ErrorKind::Other, format!("cause: {e}"))
io::Error::other(format!("cause: {e}"))
}
}
30 changes: 15 additions & 15 deletions src/serde_obkv/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,9 @@ impl<'a> ser::SerializeStruct for SerializeStruct<'a> {
type Ok = ();

/// encode table entity properties
fn serialize_field<V: ?Sized>(&mut self, key: &'static str, value: &V) -> Result<()>
fn serialize_field<V>(&mut self, key: &'static str, value: &V) -> Result<()>
where
V: ser::Serialize,
V: ?Sized + ser::Serialize,
{
if self.first {
match self.ser {
Expand Down Expand Up @@ -393,9 +393,9 @@ impl<'a> ser::SerializeMap for SerializeStruct<'a> {
type Error = Error;
type Ok = ();

fn serialize_key<T: ?Sized>(&mut self, key: &T) -> Result<()>
fn serialize_key<T>(&mut self, key: &T) -> Result<()>
where
T: Serialize,
T: ?Sized + Serialize,
{
match self.ser {
Serializer::Output(_, ref mut raw_key) => *raw_key = true,
Expand All @@ -410,18 +410,18 @@ impl<'a> ser::SerializeMap for SerializeStruct<'a> {
ret
}

fn serialize_value<T: ?Sized>(&mut self, value: &T) -> Result<()>
fn serialize_value<T>(&mut self, value: &T) -> Result<()>
where
T: Serialize,
T: ?Sized + Serialize,
{
value.serialize(&mut *self.ser)
}

/// encode table entity properties
fn serialize_entry<K: ?Sized, V: ?Sized>(&mut self, key: &K, value: &V) -> Result<()>
fn serialize_entry<K, V>(&mut self, key: &K, value: &V) -> Result<()>
where
K: Serialize,
V: Serialize,
K: ?Sized + Serialize,
V: ?Sized + Serialize,
{
if self.first {
match self.ser {
Expand Down Expand Up @@ -450,9 +450,9 @@ impl<'a> ser::SerializeSeq for SerializeArray<'a> {
type Error = Error;
type Ok = ();

fn serialize_element<T: ?Sized>(&mut self, elem: &T) -> Result<()>
fn serialize_element<T>(&mut self, elem: &T) -> Result<()>
where
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
elem.serialize(&mut *self.ser)?;
Ok(())
Expand All @@ -467,9 +467,9 @@ impl<'a> ser::SerializeTuple for SerializeArray<'a> {
type Error = Error;
type Ok = ();

fn serialize_element<T: ?Sized>(&mut self, elem: &T) -> Result<()>
fn serialize_element<T>(&mut self, elem: &T) -> Result<()>
where
T: ser::Serialize,
T: ?Sized + ser::Serialize,
{
ser::SerializeSeq::serialize_element(self, elem)
}
Expand All @@ -483,9 +483,9 @@ impl<'a> ser::SerializeTupleStruct for SerializeArray<'a> {
type Error = Error;
type Ok = ();

fn serialize_field<V: ?Sized>(&mut self, value: &V) -> Result<()>
fn serialize_field<V>(&mut self, value: &V) -> Result<()>
where
V: ser::Serialize,
V: ?Sized + ser::Serialize,
{
ser::SerializeSeq::serialize_element(self, value)
}
Expand Down
Loading