Skip to content
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
2 changes: 1 addition & 1 deletion cpp_test/test_line_sender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ TEST_CASE("Test timestamp column.")
.at(now_nanos_ts);

std::stringstream ss;
ss << "test ts1=12345t,ts2=" << now_micros << "t,ts3=" << now_micros << "t "
ss << "test ts1=12345t,ts2=" << now_micros << "t,ts3=" << now_nanos << "n "
<< now_nanos << "\n";
const auto exp = ss.str();
CHECK(buffer.peek() == exp);
Expand Down
25 changes: 16 additions & 9 deletions questdb-rs/src/ingress/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
******************************************************************************/
use crate::ingress::ndarr::{check_and_get_array_bytes_size, ArrayElementSealed};
use crate::ingress::{
ndarr, ArrayElement, DebugBytes, NdArrayView, ProtocolVersion, Timestamp, TimestampMicros,
TimestampNanos, ARRAY_BINARY_FORMAT_TYPE, DOUBLE_BINARY_FORMAT_TYPE, MAX_ARRAY_DIMS,
MAX_NAME_LEN_DEFAULT,
ndarr, ArrayElement, DebugBytes, NdArrayView, ProtocolVersion, Timestamp, TimestampNanos,
ARRAY_BINARY_FORMAT_TYPE, DOUBLE_BINARY_FORMAT_TYPE, MAX_ARRAY_DIMS, MAX_NAME_LEN_DEFAULT,
};
use crate::{error, Error};
use std::fmt::{Debug, Formatter};
Expand Down Expand Up @@ -281,7 +280,7 @@ impl<'a> TryFrom<&'a str> for TableName<'a> {
}
}

impl<'a> AsRef<str> for TableName<'a> {
impl AsRef<str> for TableName<'_> {
fn as_ref(&self) -> &str {
self.name
}
Expand Down Expand Up @@ -368,7 +367,7 @@ impl<'a> TryFrom<&'a str> for ColumnName<'a> {
}
}

impl<'a> AsRef<str> for ColumnName<'a> {
impl AsRef<str> for ColumnName<'_> {
fn as_ref(&self) -> &str {
self.name
}
Expand Down Expand Up @@ -1148,11 +1147,19 @@ impl Buffer {
{
self.write_column_key(name)?;
let timestamp: Timestamp = value.try_into()?;
let timestamp: TimestampMicros = timestamp.try_into()?;
let mut buf = itoa::Buffer::new();
let printed = buf.format(timestamp.as_i64());
self.output.extend_from_slice(printed.as_bytes());
self.output.push(b't');
match timestamp {
Timestamp::Micros(ts) => {
let printed = buf.format(ts.as_i64());
self.output.extend_from_slice(printed.as_bytes());
self.output.push(b't');
}
Timestamp::Nanos(ts) => {
let printed = buf.format(ts.as_i64());
self.output.extend_from_slice(printed.as_bytes());
self.output.push(b'n');
}
}
Ok(self)
}

Expand Down
2 changes: 1 addition & 1 deletion questdb-rs/src/ingress/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ fn parse_key_pair(auth: &conf::EcdsaAuthParams) -> Result<EcdsaKeyPair> {

struct DebugBytes<'a>(pub &'a [u8]);

impl<'a> Debug for DebugBytes<'a> {
impl Debug for DebugBytes<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "b\"")?;

Expand Down
10 changes: 4 additions & 6 deletions questdb-rs/src/tests/sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,8 @@ fn test_basics(
"test,t1=v1 ".as_bytes(),
f64_to_bytes("f1", 0.5, version).as_slice(),
format!(
",ts1=12345t,ts2={}t,ts3={}t {}\n",
ts_micros_num,
ts_nanos_num / 1000i64,
ts_nanos_num
",ts1=12345t,ts2={}t,ts3={ts_nanos_num}n {ts_nanos_num}\n",
ts_micros_num
)
.as_bytes(),
]
Expand Down Expand Up @@ -540,7 +538,7 @@ fn test_timestamp_overloads() -> TestResult {
)?)?;

let exp = concat!(
"tbl_name a=12345t,b=-100000000t,c=12345t,d=-12345t,e=-1t,f=-10t 1000\n",
"tbl_name a=12345t,b=-100000000t,c=12345678n,d=-12345678n,e=-1t,f=-10000n 1000\n",
"tbl_name a=1000000t 5000000000\n"
)
.as_bytes();
Expand All @@ -561,7 +559,7 @@ fn test_chrono_timestamp() -> TestResult {
let mut buffer = Buffer::new(ProtocolVersion::V2);
buffer.table(tbl_name)?.column_ts("a", ts)?.at(ts)?;

let exp = b"tbl_name a=1000000t 1000000000\n";
let exp = b"tbl_name a=1000000000n 1000000000\n";
assert_eq!(buffer.as_bytes(), exp);

Ok(())
Expand Down
Loading