4 releases

0.1.16-alpha.0 Mar 31, 2023
0.1.13-alpha.0 Mar 17, 2023
0.1.12-alpha.0 Jan 19, 2023
0.1.10-alpha.0 Jan 18, 2023

#12 in #user-key

Download history 94/week @ 2024-01-01 177/week @ 2024-01-08 242/week @ 2024-01-15 79/week @ 2024-01-22 72/week @ 2024-01-29 127/week @ 2024-02-05 156/week @ 2024-02-12 137/week @ 2024-02-19 212/week @ 2024-02-26 136/week @ 2024-03-04 148/week @ 2024-03-11 181/week @ 2024-03-18 377/week @ 2024-03-25 320/week @ 2024-04-01 139/week @ 2024-04-08 177/week @ 2024-04-15

1,015 downloads per month
Used in 119 crates (13 directly)

MIT license

720KB
1K SLoC

bitcoinleveldb-key

This Rust crate is a direct translation of the Bitcoin Core C++ codebase for the key-related components used in LevelDB.

Notice: This crate is part of a direct translation from C++ to Rust of the bitcoin core. As such, some of the function bodies may still be in the process of translation. Please note that this system will become testable once the translation process is complete.

Tokens

InternalFilterPolicy

This is an internal filter policy used in LevelDB.

InternalKey

This is an internal key used for sorting keys in LevelDB.

InternalKeyComparator

This is an internal comparator used for sorting internal keys in LevelDB.

KVMap

This is a map of key-value pairs used in LevelDB.

KVMapConstIterator

This is a constant iterator for a key-value map used in LevelDB.

LookupKey

This is a lookup key used for searching in LevelDB.

ParsedInternalKey

This is a parsed internal key used for sorting internal keys in LevelDB.

SequenceNumber

This is a sequence number used in LevelDB.

TLLessThan

This is a comparator used for sorting internal keys in LevelDB.

ValueType

This is the value type used in LevelDB.

and

This is a logical AND operator used in LevelDB.

append_internal_key

This function is used to append an internal key to a buffer.

clear

This function is used to clear an internal key.

compare

This function is used to compare two slices.

compare_internal_key

This function is used to compare two internal keys.

compare_slices

This function is used to compare two slices.

create_filter

This function is used to create a filter.

debug_string

This function is used to create a debug string for an internal key.

decode_from

This function is used to decode an internal key from a slice.

default

This function is used to create a default internal key comparator.

drop

This function is used to drop an internal key.

encode

This function is used to encode an internal key to a buffer.

extract_user_key

This function is used to extract the user key from an internal key.

find_short_successor

This function is used to find the shortest separator for two internal keys.

find_shortest_separator

This function is used to find the short successor for an internal key.

internal_key

This function is used to create an internal key.

internal_key_encoding_length

This function is used to compute the encoding length of an internal key.

invoke

This function is used to invoke an internal key.

is

This function is used to determine if a value type is valid.

key

This function is is used to create a key.

key_may_match

This function is used to determine if a key may match a filter.

memtable_key

This function is used to create a memtable key.

name

This function is used to get the name of an internal filter policy.

pack_sequence_and_type

This function is used to pack a sequence number and a value type.

parse_internal_key

This function is used to parse an internal key from a slice.

set_from

This function is used to set the value of an internal key.

user_comparator

This function is used to get the user comparator from an internal key.

user_key

This function is used to get the user key from an internal key.

value

This function is used to create a value.

FormatTest

This is a test suite for formatting keys in LevelDB.

dbdbformat_test_main

This is the main test function for formatting keys in LevelDB.

34> how does this interface apply to leveldb?

The bitcoinleveldb-key crate provides Rust implementations of data structures and functions used in the LevelDB key-value store. Specifically, it includes implementations of internal keys, parsed internal keys, and lookup keys used for accessing data in LevelDB. These structures are used to represent and manipulate keys and values stored in the database, as well as to define ordering and comparison functions used to sort keys in the database.

The InternalKey struct represents a key stored in the database, and contains both user data (the user key) as well as metadata used by LevelDB (such as a sequence number and value type). The ParsedInternalKey struct is used to parse an InternalKey into its constituent parts, including the user key, sequence number, and value type. LookupKey is a convenience struct that wraps an InternalKey and provides methods for efficiently searching the database for a key.

The InternalKeyComparator struct provides a comparison function for InternalKey objects that takes into account their sequence numbers and value types. The TLLessThan struct provides a comparison function for user keys that ignores any sequence numbers or value types.

The create_filter function generates a bloom filter from a set of keys, which can be used to efficiently test whether a key exists in the database without having to do a disk lookup.

Overall, these data structures and functions form the backbone of the LevelDB database, allowing for efficient storage and retrieval of key-value pairs.

Dependencies

~90MB
~846K SLoC