Skip to content

Commit dbc6e7c

Browse files
authored
VER: Release 0.36.2
2 parents d8693fd + a9cf539 commit dbc6e7c

File tree

9 files changed

+105
-33
lines changed

9 files changed

+105
-33
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## 0.36.2 - 2025-07-08
4+
5+
### Enhancements
6+
- Upgraded `async-compression` version to 0.4.25
7+
- Upgraded `pyo3` version to 0.25.1
8+
9+
### Bug fixes
10+
- Fixed change in behavior where Python `DBNDecoder.decode()` wouldn't always decode all
11+
available data on the first call
12+
313
## 0.36.1 - 2025-06-17
414

515
### Bug fixes

Cargo.lock

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ resolver = "2"
1111
[workspace.package]
1212
authors = ["Databento <[email protected]>"]
1313
edition = "2021"
14-
version = "0.36.1"
14+
version = "0.36.2"
1515
documentation = "https://databento.com/docs"
1616
repository = "https://github.com/databento/dbn"
1717
license = "Apache-2.0"
1818

1919
[workspace.dependencies]
2020
anyhow = "1.0.98"
2121
csv = "1.3"
22-
pyo3 = "0.25.0"
23-
pyo3-build-config = "0.25.0"
22+
pyo3 = "0.25.1"
23+
pyo3-build-config = "0.25.1"
2424
rstest = "0.25.0"
2525
serde = { version = "1.0", features = ["derive"] }
2626
time = "0.3.41"

c/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ crate-type = ["staticlib"]
1616
[dependencies]
1717
anyhow = { workspace = true }
1818
dbn = { path = "../rust/dbn", features = [] }
19-
libc = "0.2.172"
19+
libc = "0.2.174"
2020

2121
[build-dependencies]
2222
cbindgen = { version = "0.29.0", default-features = false }

python/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "databento-dbn"
3-
version = "0.36.1"
3+
version = "0.36.2"
44
description = "Python bindings for encoding and decoding Databento Binary Encoding (DBN)"
55
authors = ["Databento <[email protected]>"]
66
license = "Apache-2.0"
@@ -17,7 +17,7 @@ build-backend = "maturin"
1717

1818
[project]
1919
name = "databento-dbn"
20-
version = "0.36.1"
20+
version = "0.36.2"
2121
authors = [
2222
{ name = "Databento", email = "[email protected]" }
2323
]

python/src/dbn_decoder.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use dbn::{
77
};
88

99
#[pyclass(module = "databento_dbn", name = "DBNDecoder")]
10+
#[derive(Debug)]
1011
pub struct DbnDecoder {
1112
fsm: DbnFsm,
1213
}
@@ -32,11 +33,20 @@ impl DbnDecoder {
3233
.map_err(to_py_err)?
3334
.upgrade_policy(upgrade_policy)
3435
.skip_metadata(!has_metadata)
36+
.compat_size(if upgrade_policy == VersionUpgradePolicy::AsIs {
37+
0
38+
} else {
39+
DbnFsm::DEFAULT_BUF_SIZE
40+
})
3541
.build()
3642
.map_err(to_py_err)?;
3743
Ok(Self { fsm })
3844
}
3945

46+
fn __repr__(&self) -> String {
47+
format!("{self:?}")
48+
}
49+
4050
fn write(&mut self, bytes: &[u8]) -> PyResult<()> {
4151
self.fsm.write_all(bytes);
4252
Ok(())
@@ -308,6 +318,42 @@ decoder.write(bytes(record))
308318
records = decoder.decode()
309319
assert len(records) == 1
310320
assert records[0] == record
321+
"#
322+
),
323+
None,
324+
None,
325+
)
326+
})
327+
.unwrap();
328+
}
329+
330+
#[test]
331+
fn test_decode_all_data_in_compat_situation() {
332+
setup();
333+
Python::with_gil(|py| {
334+
Python::run(
335+
py,
336+
c_str!(
337+
r#"from _lib import DBNDecoder, ErrorMsg, ErrorMsgV1, Metadata, Schema, SType
338+
339+
decoder = DBNDecoder()
340+
metadata = Metadata(
341+
version=1,
342+
dataset="GLBX.MDP3",
343+
schema=Schema.MBO,
344+
start=0,
345+
stype_in=SType.RAW_SYMBOL,
346+
stype_out=SType.INSTRUMENT_ID,
347+
)
348+
decoder.write(bytes(metadata))
349+
for _ in range(3):
350+
error = ErrorMsgV1(0, "test")
351+
decoder.write(bytes(error))
352+
records = decoder.decode()
353+
assert len(records) == 4
354+
assert isinstance(records[0], Metadata)
355+
for i in range(1, 4):
356+
assert isinstance(records[i], ErrorMsg)
311357
"#
312358
),
313359
None,

rust/dbn-cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ name = "dbn"
1616
path = "src/main.rs"
1717

1818
[dependencies]
19-
dbn = { path = "../dbn", version = "=0.36.1", default-features = false }
19+
dbn = { path = "../dbn", version = "=0.36.2", default-features = false }
2020

2121
anyhow = { workspace = true }
2222
clap = { version = "4.5", features = ["derive", "wrap_help"] }

rust/dbn/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ serde = ["dep:serde", "time/parsing", "time/serde"]
2525
trivial_copy = []
2626

2727
[dependencies]
28-
dbn-macros = { version = "=0.36.1", path = "../dbn-macros" }
28+
dbn-macros = { version = "=0.36.2", path = "../dbn-macros" }
2929

30-
async-compression = { version = "0.4.23", features = ["tokio", "zstd"], optional = true }
30+
async-compression = { version = "0.4.25", features = ["tokio", "zstd"], optional = true }
3131
csv = { workspace = true }
3232
fallible-streaming-iterator = { version = "0.1.9", features = ["std"] }
3333
# Fast integer to string conversion

rust/dbn/src/decode/dbn/fsm.rs

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use crate::{
2121
};
2222

2323
/// State machine for decoding DBN with bring your own I/O.
24-
#[derive(Debug)]
2524
pub struct DbnFsm {
2625
input_dbn_version: Option<u8>,
2726
upgrade_policy: VersionUpgradePolicy,
@@ -31,6 +30,23 @@ pub struct DbnFsm {
3130
compat_buffer: oval::Buffer,
3231
}
3332

33+
impl std::fmt::Debug for DbnFsm {
34+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35+
let dbg_available_data = self.buffer.available_data().min(MAX_RECORD_LEN);
36+
f.debug_struct("DbnFsm")
37+
.field("input_dbn_version", &self.input_dbn_version)
38+
.field("upgrade_policy", &self.upgrade_policy)
39+
.field("ts_out", &self.ts_out)
40+
.field("state", &self.state)
41+
.field(
42+
"buffer_available_data",
43+
&&self.buffer.data()[..dbg_available_data],
44+
)
45+
.field("compat_buffer_capacity", &self.compat_buffer.capacity())
46+
.finish_non_exhaustive()
47+
}
48+
}
49+
3450
#[derive(Debug, Default)]
3551
enum State {
3652
#[default]
@@ -386,10 +402,7 @@ impl DbnFsm {
386402
let mut compat_bytes = 0;
387403
let mut remaining_compat = self.compat_buffer.space();
388404
let mut expand_compat = false;
389-
while rec_ref_buf.has_capacity(record_count) {
390-
if read_bytes >= self.buffer.available_data() {
391-
break;
392-
}
405+
while rec_ref_buf.has_capacity(record_count) && read_bytes < self.buffer.available_data() {
393406
let remaining_data = &self.buffer.data()[read_bytes..];
394407

395408
let length = remaining_data[0] as usize * RecordHeader::LENGTH_MULTIPLIER;
@@ -463,6 +476,9 @@ impl DbnFsm {
463476
"invalid DBN metadata. Metadata length shorter than fixed length.",
464477
));
465478
}
479+
if self.upgrade_policy.is_upgrade_situation(version) && self.compat_buffer.capacity() == 0 {
480+
self.double_compat_buffer();
481+
}
466482
self.state = State::Metadata { length };
467483
self.buffer.consume_noshift(Self::METADATA_PRELUDE_LEN);
468484
self.buffer

0 commit comments

Comments
 (0)