Skip to content
Proyectos

Acerca de

A Protocol Buffers database

Datos y análisis

Cómo se miden estas cifras

Crecimiento de estrellas medido

in 24h
Recopilando historial
in 7 days
Recopilando historial
in 15 days
Recopilando historial
in 1 month
Recopilando historial

Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.

README.md

Original

ProfaneDB

ProfaneDB is a database for Protocol Buffer objects.
The key used for retrieval of objects is defined within .proto files, this is then used to store a single copy of each object, and allow references between objects without data duplication.

Configuration and usage

For a more detailed explanation, go to the project's website.

Schema definition

Schema definition comes with every message definition, using Protocol Buffer field options:

Exactly one key per message can be set, a schema with more is rejected at startup

import "profanedb/protobuf/options.proto";

message Test {
    int32 field_one_int = 1 [ (profanedb.protobuf.options).key = true ];
    string field_two_str = 2;
    bool field_three_bool = 3;
    bytes field_four_bytes = 4;
    
    Nested field_five_nested = 5;
}

message Nested {
    string nested_field_one_str = 1 [ (profanedb.protobuf.options).key = true ];
    int64 nested_field_two_int = 2;
    double nested_field_three_double = 3;
}

ProfaneDB can either be used as a gRPC server (service definition in profanedb/protobuf/db.proto) or as a library (interface in profanedb/db.hpp).

References

A field whose type has a key (field_five_nested above) is stored as a reference:

  • Put stores the nested message on its own, under its key. If only its key field is set, it is just a reference: the message already stored under that key is left as it is.
  • Get resolves references back into whole messages. A reference that would loop back to a message being resolved, or that points to a deleted message, comes back with only its key field set. So a Put of what Get returned never overwrites data.
  • Delete removes only the message under the given key. Deleting a missing key is not an error.

Repeated fields and map values of a type with a key are references too, one per element.

A Put writes the message and everything it embeds in one atomic batch.

Keys

Key.value is the key field written as text: integers in decimal, floating point in its shortest exact form (1e-07), enums by number, bool as 1 or 0, strings and bytes as they are, messages in deterministic wire format. A repeated key puts $ before each element, and \ before any $ or \ within an element.

A key at its default value (0, "") is a valid key. A map cannot be a key, as it has no canonical order: such a schema is rejected at startup.

CLI parameters

profanedb_server --rocksdb_path /tmp/profanedb -I /usr/local/include -S /your/schema/dir
Parameter Default Description
-I, --proto_path required Import paths, for google/protobuf/*.proto, profanedb/protobuf/*.proto and other dependencies. Repeatable.
-S, --schema_path required Your definitions, with the key option set. Every .proto file below it is loaded, following symlinks, each directory once. Repeatable.
--rocksdb_path required Where RocksDB keeps its data.
--listen 127.0.0.1:50051 Address to listen on. There is no authentication or TLS, so expose it beyond localhost with care.
--log_level info trace, debug, info, warning, error or fatal.

SIGINT (Ctrl-C) or SIGTERM stops the server cleanly: it finishes the requests in progress and closes RocksDB.

The gRPC service answers NOT_FOUND for a Get of a missing key, and INVALID_ARGUMENT for a type not in the schema, a payload that does not parse, or a message without a key.

Build

ProfaneDB uses CMake (3.16 or later) and C++20. It depends on

  • Protobuf, 25 or later (tested with 25.9 and 34.1)
  • Boost: log, filesystem, program_options and test (tested with 1.89)
  • RocksDB (tested with 10.10)
  • gRPC, only for the server (tested with 1.80)

shell.nix pins all of them, and is what CI uses:

nix-shell --run '
  cmake -S . -B build -G Ninja -DBUILD_PROFANEDB_SERVER=ON -DBUILD_TESTS=ON &&
  cmake --build build &&
  ctest --test-dir build --output-on-failure'

Options

CMake Option Default Description
BUILD_SHARED_LIBS ON Build libprofanedb as a shared library, to embed ProfaneDB
BUILD_PROFANEDB_SERVER OFF Build ProfaneDB gRPC server
BUILD_TESTS OFF Build tests, run with ctest
PROTOBUF_PROTO_DIR found Directory with google/protobuf/*.proto, which the tests load

Explorar proyectos relacionados

Cargando…