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

#14 in #user-key

Download history 134/week @ 2024-07-22 136/week @ 2024-07-29 183/week @ 2024-08-05 129/week @ 2024-08-12 129/week @ 2024-08-19 188/week @ 2024-08-26 133/week @ 2024-09-02 105/week @ 2024-09-09 124/week @ 2024-09-16 183/week @ 2024-09-23 89/week @ 2024-09-30 137/week @ 2024-10-14 77/week @ 2024-10-21 78/week @ 2024-10-28 111/week @ 2024-11-04

403 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

~89MB
~854K SLoC