Skip to content

Commit

Permalink
Support for encoding directives, arg groups, length-prefixed e-expres…
Browse files Browse the repository at this point in the history
…sions (#796)

* Adds EncodingDirective variant to SystemStreamItem
* Adds support for switching encodings midstream
* Adds support for parameter cardinality modifiers
* Adds support for reading argument groups
* Adds support for length-prefixed e-expressions
* Optimizes and simplifies macro evaluation
* Simplifies struct expansion logic
* Adds static analysis optimizations to template evaluation
* Adds support for lazily evaluating top-level e-expressions
* Adds more Ion 1.1 encodings to the `read_many_structs` benchmark
* Shrinks many data types
  • Loading branch information
zslayton authored Jul 31, 2024
1 parent 99ec403 commit b245172
Show file tree
Hide file tree
Showing 67 changed files with 7,227 additions and 2,319 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ edition = "2021"
# We need at least 1.65 for GATs[1] and 1.67 for `ilog`[2]
# [1] https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html
# [2] https://blog.rust-lang.org/2023/01/26/Rust-1.67.0.html#stabilized-apis
rust-version = "1.67"
rust-version = "1.77"

[features]
default = []
Expand Down Expand Up @@ -63,6 +63,7 @@ smallvec = { version = "1.9.0", features = ["const_generics"] }
bumpalo = { version = "3.15.3", features = ["collections", "std"] }
digest = { version = "0.9", optional = true }
ice_code = "0.1.4"
rustc-hash = "2.0.0"
sha2 = { version = "0.9", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
serde_with = { version = "3.7.0", optional = true }
Expand Down
495 changes: 435 additions & 60 deletions benches/read_many_structs.rs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions benches/write_many_structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ mod benchmark {
&[
black_box("SUCCESS"),
black_box("example-client-1"),
black_box("aws-us-east-5f-18b4fa"),
black_box("aws-us-east-5f-abc-123"),
black_box("region 4"),
black_box("2022-12-07T20:59:59.744000Z"),
],
Expand Down Expand Up @@ -73,7 +73,7 @@ mod benchmark {
symbol_id(black_box(21)),
// $22 = example-client-1
symbol_id(black_box(22)),
// $23 = aws-us-east-5f-18b4fa
// $23 = aws-us-east-5f-abc-123
symbol_id(black_box(23)),
// $24 = region 4
symbol_id(black_box(24)),
Expand All @@ -92,7 +92,7 @@ mod benchmark {
// them wouldn't be beneficial.
.write(black_box("6"))? // thread_name
.write(black_box("1"))? // client_num
.write(symbol_id(black_box(10)))?; // host_id: "18b4fa" ($10)
.write(symbol_id(black_box(10)))?; // host_id: "abc-123" ($10)
let mut nested_eexp = eexp.eexp_writer(1)?;
nested_eexp
// $11 = region 4
Expand All @@ -109,7 +109,7 @@ mod benchmark {
.write(black_box(418))? // thread_id
.write(black_box("6"))? // thread_name
.write(black_box("1"))? // client_num
.write(black_box("18b4fa"))?; // host_id
.write(black_box("abc-123"))?; // host_id
let mut nested_eexp = eexp.eexp_writer(1)?;
nested_eexp
.write(black_box("region 4"))?
Expand Down
19 changes: 18 additions & 1 deletion src/element/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,34 @@ use crate::lazy::encoding::Encoding;
use crate::write_config::WriteConfig;
use crate::IonResult;
use std::cmp::Ordering;
use std::fmt::{Debug, Formatter};
use std::io;

/// An iterable, addressable series of Ion [`Element`]s.
///
/// A `Sequence` is not itself an Ion value type, but can represent a series of Ion values appearing
/// in a [`List`](crate::List), a [`SExp`](crate::SExp), or at the top level.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq)]
pub struct Sequence {
elements: Vec<Element>,
}

impl Debug for Sequence {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "Sequence<")?;
let mut is_first = true;
for element in self {
if is_first {
write!(f, "{element}")?;
} else {
write!(f, ", {element}")?;
is_first = false;
}
}
write!(f, ">")
}
}

impl Sequence {
pub fn new<E: Into<Element>, I: IntoIterator<Item = E>>(elements: I) -> Sequence {
let elements = elements.into_iter().map(|e| e.into()).collect();
Expand Down
Loading

0 comments on commit b245172

Please sign in to comment.