v0.2.0 #205
ecton
announced in
Announcements
v0.2.0
#205
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Breaking Changes
bonsaidb::core::Error::DocumentConflict
now contains aHeader
instead ofjust the document's ID. This allows an application to re-submit an update with
the updated header without another request to the database.
StorageConfiguratation::vault_key_storage
now uses anArc
instead of aBox
. This change allowsStorageConfiguration
andServerConfiguration
toimplement
Clone
.Document::create_new_revision
has been removed. It was meant to be aninternal function.
Document
now requiresAsRef<Header>
andAsMut<Header>
instead ofDeref<Header>
/DerefMut
. The publicly visible change is that the shortcutof accessing
document.header.emit_*
through deref by usingdocument.emit_*
will no longer work. This impacts
CollectionDocument
,OwnedDocument
, andBorrowedDocument
.This removes a little magic, but in some code flows, it was impossible to use
Deref anyways due to Deref borrowing the entire document, not just the header.
Collection::PrimaryKey
is a new associated type that allows customizing thetype that uniquely identifies documents inside of a
Collection
. Users of thederive macro will be unaffected by this change. If you're upgrading existing
collections and wish to maintain backwards compatibility, use
u64
as thetype.
A
natural_id()
function can now be implemented onSerializedCollection
orDefaultSerialization
which allows extracting a primary key value from a newdocument being pushed
A new example,
primary-keys.rs
, as been added showing basic usage ofchanging the primary key type. This change resulted in a sequnce of breaking
changes that will be listed independently.
Key
has been moved frombonsaidb::core::schema::view
tobonsaidb::core::key
.Key::as/from_big_endian_bytes
have been renamed toKey::as/from_ord_bytes
.Key::first_value()
andKey::next_value()
are new provided functions. Bydefault, these functions return
NextValueError::Unsupported
.Key::first_value()
allows aKey
type to define the first value in itssequence. For example,
0_u64
is the result ofu64::first_value()
.Key::next_value()
allows aKey
type to find the next value in sequencefrom the current value. Implementors should never wrap, and should instead
return
NextValueError::WouldWrap
.Sensible defaults have been implemented for all numeric types.
Connection
and its related types have had all previously hard-codedprimary keys pf
u64
changed to generic parameters that can accept either aDocumentId
orCollection::PrimaryKey
. The affected methods are:Connection::insert
Connection::overwrite
Connection::get
Connection::get_multiple
Connection::list
connection::Collection::insert
connection::Collection::overwrite
connection::Collection::get
connection::Collection::get_multiple
connection::Collection::list
SerializedCollection::insert
SerializedCollection::insert_into
SerializedCollection::overwrite
SerializedCollection::overwrite_into
SerializedCollection::get
SerializedCollection::get_multiple
SerializedCollection::list
transaction::Operation::insert_serialized
transaction::Operation::overwrite_serialized
Header::id
has changed fromu64
toDocumentId
, andCollectionHeader<PrimaryKey>
has been added which containsCollection::PrimaryKey
deserialized.These previous usages of
Header
have been changed toCollectionHeader
:Connection::insert
result typeConnection::overwrite
result typeconnection::Collection::insert
result typeconnection::Collection::insert_bytes
result typeconnection::Collection::push
result typeconnection::Collection::push_bytes
result typeCollectionDocument::header
The
Header::emit*
functions have been moved to a new trait,Emit
. Thistrait is implemented by both
Header
andCollectionHeader
. The functions moved are:emit()
emit_key()
emit_value()
emit_key_and_value()
These functions now return a
Result
, as encoding a primary key value canfail if it is larger than
DocumentId::MAX_LENGTH
.HasHeader
is a new trait that allows accessing aHeader
generically frommany types. This type is used in
Connection::delete
andconnection::Collection::delete
.Types and functions that used
u64
as a document ID have been replaced withDocumentId
s. The number of locations are too many to list. If you need toconvert from a u64 to a
DocumentId
, you can useDocumentId::from_u64()
.Document::contents
andDocument::set_contents
are now ore "painful" toaccess due to the generic parameter added to
Document
.SerializedCollection::document_contents(doc)
andSerializedCollection::set_document_contents(doc, new_contents)
have beenprovided as easier ways to invoke the same functionality. For example:
Becomes:
Backups made prior to
0.2.0
will not be able to be restored with thisupdated version. The document IDs are encoded differently than in prior
versions.
Added
Optional compression is now available, using the LZ4 algorithm.
StorageConfiguration::default_compression
controls the setting. When usingthe
bonsaidb
crate, the feature can be made available using eitherlocal-compression
orserver-compression
. When usingbonsaidb-server
orbonsaidb-local
directly, the feature name iscompression
.This compression is currently applied on all chunks of data written to
BonsaiDb that are larger than a hardcoded threshold. This includes the
Key-Value store. The threshold may be configurable in the future.
Some of the benchmark suite has been expanded to include comparisons between
local storage with and without compression.
Added ability to "overwrite" documents without checking the stored revision
information. Because this removes a layer of safety, it has its own permissible
action:
DocumentAction::Overwrite
. The functions that have been added are:connection::Connection::overwrite
connection::Collection::overwrite
schema::SerializedCollection::overwrite
schema::SerializedCollection::overwrite_into
document::CollectionDocument::overwrite
transaction::Transaction::overwrite
transaction::Operation::overwrite
Changed
Internal dependencies between crates are now pinned based on their needs. This
means that
bonsaidb-sever
will require a matching verison ofbonsaidb-local
when compiling. A simple example of a change that is abreaking compilation change but is not breaking from a compatibility
standpoint is a change to a structure where
#[serde(rename)]
is used toremap an old value to a new value.
The only crate currently not pinning its dependencies is
bonsaidb-keystorage-s3
. This crate, and hopefully many crates to come, areonly tying themselves to the public API of BonsaiDb.
This may generate slightly more crate updates than absolutely necessary, but
for a small team it seems like the most manageable approach.
Fixed
version specified in the view definiton. This allows internal structures to be
upgraded transparently.
mapping job has finished if the view's integrity check spawns one before
allowing the transaction to begin.
This discussion was created from the release v0.2.0.
Beta Was this translation helpful? Give feedback.
All reactions