Skip to content

Commit

Permalink
chore(rust): resolve deprecate warnings (#1662)
Browse files Browse the repository at this point in the history
<!--
**Thanks for contributing to Fury.**

**If this is your first time opening a PR on fury, you can refer to
[CONTRIBUTING.md](https://github.com/apache/incubator-fury/blob/main/CONTRIBUTING.md).**

Contribution Checklist

- The **Apache Fury (incubating)** community has restrictions on the
naming of pr titles. You can also find instructions in
[CONTRIBUTING.md](https://github.com/apache/incubator-fury/blob/main/CONTRIBUTING.md).

- Fury has a strong focus on performance. If the PR you submit will have
an impact on performance, please benchmark it first and provide the
benchmark result here.
-->

## What does this PR do?

<!-- Describe the purpose of this PR. -->

- Resolve deprecate warnings from `chrono` dep
- Remove patch version in Cargo.toml

## Related issues

<!--
Is there any related issue? Please attach here.

- #xxxx0
- #xxxx1
- #xxxx2
-->

N/A

## Does this PR introduce any user-facing change?

<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/incubator-fury/issues/new/choose)
describing the need to do so and update the document if necessary.
-->

- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?

No

## Benchmark

<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
-->

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
  • Loading branch information
waynexia authored May 30, 2024
1 parent cdcb3b2 commit 7ac2c6e
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 21 deletions.
13 changes: 9 additions & 4 deletions rust/fury-derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ rust-version.workspace = true
proc-macro = true

[dependencies]
proc-macro2 = { default-features = false, version = "1.0.66" }
syn = { default-features = false, version = "2.0.26", features = ["parsing", "proc-macro", "derive", "printing"] }
quote = { default-features = false, version = "1.0.31" }
thiserror = { default-features = false, version = "1.0.43" }
proc-macro2 = { default-features = false, version = "1.0" }
syn = { default-features = false, version = "2.0", features = [
"parsing",
"proc-macro",
"derive",
"printing",
] }
quote = { default-features = false, version = "1.0" }
thiserror = { default-features = false, version = "1.0" }
16 changes: 8 additions & 8 deletions rust/fury/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ edition.workspace = true
rust-version.workspace = true

[dependencies]
proc-macro2 = { default-features = false, version = "1.0.66" }
syn = { default-features = false, version = "2.0.26", features = ["full", "fold"] }
quote = { default-features = false, version = "1.0.31" }
fury-derive = { path="../fury-derive"}
lazy_static = { version = "1.4.0" }
byteorder = { version = "1.4.3" }
chrono = "0.4.26"
thiserror = { default-features = false, version = "1.0.43" }
proc-macro2 = { default-features = false, version = "1.0" }
syn = { default-features = false, version = "2.0", features = ["full", "fold"] }
quote = { default-features = false, version = "1.0" }
fury-derive = { path = "../fury-derive" }
lazy_static = { version = "1.4" }
byteorder = { version = "1.4" }
chrono = "0.4"
thiserror = { default-features = false, version = "1.0" }
2 changes: 1 addition & 1 deletion rust/fury/src/deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl<T: Deserialize + Eq + std::hash::Hash> Deserialize for HashSet<T> {
impl Deserialize for NaiveDateTime {
fn read(deserializer: &mut DeserializerState) -> Result<Self, Error> {
let timestamp = deserializer.reader.u64();
let ret = NaiveDateTime::from_timestamp_millis(timestamp as i64);
let ret = DateTime::from_timestamp_millis(timestamp as i64).map(|dt| dt.naive_utc());
match ret {
Some(r) => Ok(r),
None => Err(Error::NaiveDateTime),
Expand Down
6 changes: 3 additions & 3 deletions rust/fury/src/row/row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

use crate::{buffer::Writer, Error};
use byteorder::{ByteOrder, LittleEndian};
use chrono::{Days, NaiveDate, NaiveDateTime};
use chrono::{DateTime, Days, NaiveDate, NaiveDateTime};
use std::collections::BTreeMap;
use std::marker::PhantomData;

Expand Down Expand Up @@ -109,12 +109,12 @@ impl<'a> Row<'a> for NaiveDateTime {
type ReadResult = Result<NaiveDateTime, Error>;

fn write(v: &Self, writer: &mut Writer) {
writer.i64(v.timestamp_millis());
writer.i64(v.and_utc().timestamp_millis());
}

fn cast(bytes: &[u8]) -> Self::ReadResult {
let timestamp = LittleEndian::read_u64(bytes);
let ret = NaiveDateTime::from_timestamp_millis(timestamp as i64);
let ret = DateTime::from_timestamp_millis(timestamp as i64).map(|dt| dt.naive_utc());
match ret {
Some(r) => Ok(r),
None => Err(Error::NaiveDateTime),
Expand Down
4 changes: 3 additions & 1 deletion rust/fury/src/serializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,9 @@ impl<T: Serialize> Serialize for HashSet<T> {

impl Serialize for NaiveDateTime {
fn write(&self, serializer: &mut SerializerState) {
serializer.writer.u64(self.timestamp_millis() as u64);
serializer
.writer
.u64(self.and_utc().timestamp_millis() as u64);
}

fn reserved_space() -> usize {
Expand Down
4 changes: 2 additions & 2 deletions rust/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ publish = false
fury = { path = "../fury" }
fury-derive = { path = "../fury-derive" }

chrono = "0.4.26"
lazy_static = { version = "1.4.0" }
chrono = "0.4"
lazy_static = { version = "1.4" }
4 changes: 2 additions & 2 deletions rust/tests/tests/test_complex_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// specific language governing permissions and limitations
// under the License.

use chrono::{NaiveDate, NaiveDateTime};
use chrono::{DateTime, NaiveDate, NaiveDateTime};
use fury::{from_buffer, to_buffer, Fury};
use std::collections::HashMap;

Expand Down Expand Up @@ -60,7 +60,7 @@ fn complex_struct() {
op: Some("option".to_string()),
op2: None,
date: NaiveDate::from_ymd_opt(2025, 12, 12).unwrap(),
time: NaiveDateTime::from_timestamp_opt(1689912359, 0).unwrap(),
time: DateTime::from_timestamp(1689912359, 0).unwrap().naive_utc(),
c5: 2.0,
c6: 4.0,
};
Expand Down

0 comments on commit 7ac2c6e

Please sign in to comment.