Module pumpkindb_engine::script [] [src]

PumpkinScript

PumpkinScript is a minimalistic concatenative, stack-based language inspired by Forth.

It is used in PumpkinDB to operate a low-level database "virtual machine" — to manipulate, record and retrieve data.

This is an ultimate gateway to flexibility in how PumpkinDB can operate, what formats can it support, etc.

Reasoning

Why is it important?

In previous incarnations (or, rather, inspirations) of PumpkinDB much more rigid structures, formats and encoding were established as a prerequisite for using it, unnecessarily limiting the applicability and appeal of the technology and ideas behind it. For example, one had to buy into ELF, UUID-based event identification and HLC-based timestamps.

So it was deemed to be important to lift this kind of restrictions in PumpkinDB. But how do we support all the formats without knowing what they are?

What if there was a way to describe how data should be processed, for example, for indexing — in a compact, unambiguous and composable form? Or even for recording data itself? Well, that's where the idea to use something like a Forth-like script was born.

Instead of devising custom protocols for talking to PumpkinDB, the protocol of communication has become a pipeline to a script executor.

So, for example, a command/events set can be recorded with something like this (not an actual script, below is pseudocode):

<command id> <command payload> JOURNAL <event id> <event payload> JOURNAL

This offers us enormous extension and flexibility capabilities. To name a few:

  • Low-level imperative querying (as a foundation for declarative queries)
  • Indexing filters
  • Subscription filters

Features

  • Binary and text (human readable & writable) forms
  • No types, just byte arrays
  • Dynamic code evaluation
  • Zero-copy interpretation (where feasible; currently does not apply to the most important part, the storage itself as transactional model of LMDB precludes us from carrying these references outside of the scope of the transaction)

Reexports

pub use self::dispatcher::Dispatcher;
pub use self::env::Env;

Modules

dispatcher
env
envheap
mod_binaries
mod_core
mod_hash
mod_hlc
mod_json
mod_msg
mod_numbers
mod_stack
mod_storage
mod_string
mod_uuid

Structs

Scheduler

Enums

Error

Error represents an enumeration of possible Executor errors.

ParseError

Parse-related error

RequestMessage

Communication messages used to talk with the Scheduler thread.

ResponseMessage

Messages received from the Scheduler thread.

Functions

offset_by_size

Type Definitions

EnvId
Program
Receiver
Sender
TrySendError