Skip to content

Commit 7eee1ee

Browse files
authored
VER: Release 0.18.2
2 parents a4ef81e + 59d064b commit 7eee1ee

File tree

16 files changed

+164
-27
lines changed

16 files changed

+164
-27
lines changed

CHANGELOG.md

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

3+
## 0.18.2 - 2024-06-18
4+
5+
### Enhancements
6+
- Added new `shutdown` method to async encoders to more easily ensure the end
7+
of output is written and I/O cleaned up. Previously this required a call to
8+
`.get_mut().shutdown().await`
9+
- Changed `AsyncDynWriter` and `AsyncDbnEncoder::with_zstd` to use a zstd checksum like
10+
the sync equivalents
11+
- Added new publisher values for `XNAS.BASIC` and `XNAS.NLS`
12+
13+
### Bug fixes
14+
- Fixed bug where DBN metadata would still be upgraded after passing `AsIs` to
15+
`DbnDecoder::set_upgrade_policy` and `AsyncDbnDecoder::set_upgrade_policy`
16+
317
## 0.18.1 - 2024-06-04
418

519
### Enhancements
@@ -8,7 +22,7 @@
822
- Added new off-market publisher values for `IFEU.IMPACT` and `NDEX.IMPACT`
923

1024
### Bug fixes
11-
- Fix descriptions for `FINN` and `FINY` publishers.
25+
- Fixed descriptions for `FINN` and `FINY` publishers
1226

1327
## 0.18.0 - 2024-05-21
1428

@@ -451,7 +465,7 @@
451465
- Added new `OHLCV_EOD` rtype for future daily OHLCV schema based on the trading
452466
session
453467
- Added new `SType::Nasdaq` and `SType::Cms` to support querying US equities datasets
454-
using either convention, regardless of the original convention of the dataset.
468+
using either convention, regardless of the original convention of the dataset
455469
- Relaxed `pyo3`, `tokio`, and `zstd` dependency version requirements
456470
- Added `FIXED_PRICE_SCALE` constant to `databento_dbn` Python package
457471
- Added generated field metadata for each record type to aid in pandas DataFrame
@@ -466,15 +480,15 @@
466480
## 0.8.0 - 2023-07-19
467481
### Enhancements
468482
- Switched from `anyhow::Error` to custom `dbn::Error` for all public fallible functions
469-
and methods. This should make it easier to disambiguate between error types.
483+
and methods. This should make it easier to disambiguate between error types
470484
- `EncodeDbn::encode_record` and `EncodeDbn::record_record_ref` no longer treat a
471485
`BrokenPipe` error differently
472486
- Added `AsyncDbnDecoder`
473487
- Added `pretty::Px` and `pretty::Ts` newtypes to expose price and timestamp formatting
474488
logic outside of CSV and JSON encoding
475489
- Added interning for Python strings
476490
- Added `rtype` to encoded JSON and CSV to aid differeniating between different record types.
477-
This is particularly important when working with live data.
491+
This is particularly important when working with live data
478492
- Added `pretty_` Python attributes for DBN price fields
479493
- Added `pretty_` Python attributes for DBN UTC timestamp fields
480494

@@ -491,7 +505,7 @@
491505
- Updated `InstrumentDefMsg` serialization order to serialize `raw_symbol`,
492506
`security_update_action`, and `instrument_class` earlier given their importance
493507
- Removed `bool` return value from `EncodeDbn::encode_record` and
494-
`EncodeDbn::record_record_ref`. These now return `dbn::Result<()>`.
508+
`EncodeDbn::record_record_ref`. These now return `dbn::Result<()>`
495509

496510
### Bug fixes
497511
- Fixed handling of NUL byte when encoding DBN to CSV and JSON

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ resolver = "2"
1111
[workspace.package]
1212
authors = ["Databento <[email protected]>"]
1313
edition = "2021"
14-
version = "0.18.1"
14+
version = "0.18.2"
1515
documentation = "https://docs.databento.com"
1616
repository = "https://github.com/databento/dbn"
1717
license = "Apache-2.0"

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.18.1"
3+
version = "0.18.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.18.1"
20+
version = "0.18.2"
2121
authors = [
2222
{ name = "Databento", email = "[email protected]" }
2323
]

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.18.1", default-features = false }
19+
dbn = { path = "../dbn", version = "=0.18.2", default-features = false }
2020

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

rust/dbn/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ serde = ["dep:serde", "time/parsing", "time/serde"]
2525
trivial_copy = []
2626

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

3030
async-compression = { version = "0.4.11", features = ["tokio", "zstd"], optional = true }
3131
csv = { workspace = true }

rust/dbn/src/decode/dbn/async.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ where
102102

103103
/// Sets the behavior for decoding DBN data of previous versions.
104104
pub fn set_upgrade_policy(&mut self, upgrade_policy: VersionUpgradePolicy) {
105-
self.metadata.upgrade(upgrade_policy);
105+
self.metadata
106+
.set_version(self.decoder.version, upgrade_policy);
106107
self.decoder.set_upgrade_policy(upgrade_policy);
107108
}
108109

rust/dbn/src/decode/dbn/sync.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ where
8585

8686
/// Sets the behavior for decoding DBN data of previous versions.
8787
pub fn set_upgrade_policy(&mut self, upgrade_policy: VersionUpgradePolicy) {
88-
self.metadata.upgrade(upgrade_policy);
88+
self.metadata
89+
.set_version(self.decoder.version, upgrade_policy);
8990
self.decoder.set_upgrade_policy(upgrade_policy);
9091
}
9192
}

rust/dbn/src/encode.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,17 @@ fn zstd_encoder<'a, W: io::Write>(writer: W) -> Result<zstd::stream::AutoFinishE
211211
Ok(zstd_encoder.auto_finish())
212212
}
213213

214+
#[cfg(feature = "async")]
215+
fn async_zstd_encoder<W: tokio::io::AsyncWriteExt + Unpin>(
216+
writer: W,
217+
) -> async_compression::tokio::write::ZstdEncoder<W> {
218+
async_compression::tokio::write::ZstdEncoder::with_quality_and_params(
219+
writer,
220+
async_compression::Level::Precise(ZSTD_COMPRESSION_LEVEL),
221+
&[async_compression::zstd::CParameter::checksum_flag(true)],
222+
)
223+
}
224+
214225
#[cfg(test)]
215226
mod test_data {
216227
use fallible_streaming_iterator::FallibleStreamingIterator;

rust/dbn/src/encode/dbn/async.rs

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ use async_compression::tokio::write::ZstdEncoder;
44
use tokio::io;
55

66
use crate::{
7-
encode::DbnEncodable, record_ref::RecordRef, Error, Metadata, Result, SymbolMapping,
8-
DBN_VERSION, NULL_LIMIT, NULL_RECORD_COUNT, NULL_SCHEMA, NULL_STYPE, UNDEF_TIMESTAMP,
7+
encode::{async_zstd_encoder, DbnEncodable},
8+
record_ref::RecordRef,
9+
Error, Metadata, Result, SymbolMapping, DBN_VERSION, NULL_LIMIT, NULL_RECORD_COUNT,
10+
NULL_SCHEMA, NULL_STYPE, UNDEF_TIMESTAMP,
911
};
1012

1113
/// An async encoder for DBN streams.
@@ -84,6 +86,14 @@ where
8486
pub async fn flush(&mut self) -> Result<()> {
8587
self.record_encoder.flush().await
8688
}
89+
90+
/// Initiates or attempts to shut down the inner writer.
91+
///
92+
/// # Errors
93+
/// This function returns an error if the shut down did not complete successfully.
94+
pub async fn shutdown(self) -> Result<()> {
95+
self.record_encoder.shutdown().await
96+
}
8797
}
8898

8999
impl<W> Encoder<ZstdEncoder<W>>
@@ -103,7 +113,7 @@ where
103113
/// metadata may have been partially written, but future calls will begin writing
104114
/// the encoded metadata from the beginning.
105115
pub async fn with_zstd(writer: W, metadata: &Metadata) -> Result<Self> {
106-
Self::new(ZstdEncoder::new(writer), metadata).await
116+
Self::new(async_zstd_encoder(writer), metadata).await
107117
}
108118
}
109119

@@ -171,6 +181,17 @@ where
171181
.map_err(|e| Error::io(e, "flushing output".to_owned()))
172182
}
173183

184+
/// Initiates or attempts to shut down the inner writer.
185+
///
186+
/// # Errors
187+
/// This function returns an error if the shut down did not complete successfully.
188+
pub async fn shutdown(mut self) -> Result<()> {
189+
self.writer
190+
.shutdown()
191+
.await
192+
.map_err(|e| Error::io(e, "shutting down".to_owned()))
193+
}
194+
174195
/// Returns a reference to the underlying writer.
175196
pub fn get_ref(&self) -> &W {
176197
&self.writer
@@ -291,11 +312,38 @@ where
291312
Ok(())
292313
}
293314

315+
/// Returns a reference to the underlying writer.
316+
pub fn get_ref(&self) -> &W {
317+
&self.writer
318+
}
319+
294320
/// Returns a mutable reference to the underlying writer.
295321
pub fn get_mut(&mut self) -> &mut W {
296322
&mut self.writer
297323
}
298324

325+
/// Flushes any buffered content to the true output.
326+
///
327+
/// # Errors
328+
/// This function returns an error if it's unable to flush the underlying writer.
329+
pub async fn flush(&mut self) -> Result<()> {
330+
self.writer
331+
.flush()
332+
.await
333+
.map_err(|e| Error::io(e, "flushing output".to_owned()))
334+
}
335+
336+
/// Initiates or attempts to shut down the inner writer.
337+
///
338+
/// # Errors
339+
/// This function returns an error if the shut down did not complete successfully.
340+
pub async fn shutdown(mut self) -> Result<()> {
341+
self.writer
342+
.shutdown()
343+
.await
344+
.map_err(|e| Error::io(e, "shutting down".to_owned()))
345+
}
346+
299347
/// Consumes the encoder returning the original writer.
300348
pub fn into_inner(self) -> W {
301349
self.writer
@@ -430,7 +478,7 @@ where
430478
/// Creates a new [`MetadataEncoder`] that will Zstandard compress the DBN data
431479
/// written to `writer`.
432480
pub fn with_zstd(writer: W) -> Self {
433-
Self::new(ZstdEncoder::new(writer))
481+
Self::new(async_zstd_encoder(writer))
434482
}
435483
}
436484

0 commit comments

Comments
 (0)