Skip to content

Commit fe81859

Browse files
authored
Merge branch 'databendlabs:main' into main
2 parents e15e7c9 + ada713c commit fe81859

File tree

13 files changed

+1123
-113
lines changed

13 files changed

+1123
-113
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## [v0.4.3] - 2024-09-30
2+
3+
### Fixed
4+
Fix: Fix compare object value with different length panic (#59)
5+
6+
## [v0.4.2] - 2024-09-19
7+
8+
### Added
9+
Feat: make `preserve_order` a default feature (#56)
10+
111
## [v0.4.1] - 2024-07-18
212

313
### Fixed

Cargo.toml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ keywords = ["json", "jsonb", "jsonpath"]
2222
license = "Apache-2.0"
2323
name = "jsonb"
2424
repository = "https://github.com/datafuselabs/jsonb"
25-
version = "0.4.1"
25+
version = "0.4.3"
2626
rust-version = "1.77"
2727

2828
[dependencies]
@@ -33,9 +33,7 @@ nom = "7.1.3"
3333
ordered-float = { version = "4.2", default-features = false }
3434
rand = { version = "0.8.5", features = ["small_rng"] }
3535
ryu = "1.0"
36-
serde_json = { version = "1.0", default-features = false, features = [
37-
"preserve_order",
38-
] }
36+
serde_json = { version = "1.0", default-features = false, features = ["std"] }
3937

4038
[dev-dependencies]
4139
goldenfile = "1.7"
@@ -45,6 +43,9 @@ simd-json = "0.13.10"
4543
mockalloc = "0.1.2"
4644
criterion = "0.5.1"
4745

46+
[features]
47+
default = ["serde_json/preserve_order"]
48+
4849
[[bench]]
4950
name = "parser"
5051
harness = false

src/de.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@ use super::value::Value;
4040
/// `Number`, `String` and `Container`. They have three different decode methods.
4141
/// 1. `Null`, `True` and `False` can be obtained by `JEntry`, no extra work required.
4242
/// 2. `Number` and `String` has related `RawData`, `JEntry` store the length
43-
/// or offset of this data, the `Value` can be read out and then decoded.
43+
/// or offset of this data, the `Value` can be read out and then decoded.
4444
/// 3. `Container` is actually a nested `Array` or `Object` with the same structure,
45-
/// `JEntry` store the length or offset of the lower-level `Header`,
46-
/// from where the same decode process can begin.
47-
48-
/// `RawData` is the encoded `Value`.
49-
/// `Number` is a variable-length `Decimal`, store both int and float value.
50-
/// `String` is the original string, can be borrowed directly without extra decode.
51-
/// `Array` and `Object` is a lower-level encoded `JSONB` value.
52-
/// The upper-level doesn't care about the specific content.
53-
/// Decode can be executed recursively.
54-
55-
/// Decode `JSONB` Value from binary bytes.
45+
/// `JEntry` store the length or offset of the lower-level `Header`,
46+
/// from where the same decode process can begin.
47+
///
48+
/// `RawData` is the encoded `Value`.
49+
/// `Number` is a variable-length `Decimal`, store both int and float value.
50+
/// `String` is the original string, can be borrowed directly without extra decode.
51+
/// `Array` and `Object` is a lower-level encoded `JSONB` value.
52+
/// The upper-level doesn't care about the specific content.
53+
/// Decode can be executed recursively.
54+
///
55+
/// Decode `JSONB` Value from binary bytes.
5656
pub fn from_slice(buf: &[u8]) -> Result<Value<'_>, Error> {
5757
let mut decoder = Decoder::new(buf);
5858
match decoder.decode() {
@@ -122,7 +122,7 @@ impl<'a> Decoder<'a> {
122122
}
123123
NUMBER_TAG => {
124124
let offset = jentry.length as usize;
125-
let n = Number::decode(&self.buf[..offset]);
125+
let n = Number::decode(&self.buf[..offset])?;
126126
self.buf = &self.buf[offset..];
127127
Ok(Value::Number(n))
128128
}

src/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,15 @@ pub enum Error {
7979
InvalidJsonb,
8080
InvalidJsonbHeader,
8181
InvalidJsonbJEntry,
82+
InvalidJsonbNumber,
8283

8384
InvalidJsonPath,
8485
InvalidJsonPathPredicate,
8586
InvalidKeyPath,
8687

8788
InvalidJsonType,
89+
InvalidObject,
90+
ObjectDuplicateKey,
8891

8992
Syntax(ParseErrorCode, usize),
9093
}

0 commit comments

Comments
 (0)