Jazz 1.25.+
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes
jazz_bebop::Core Class Reference

Core: The execution unit is now a wrapper around onnx-runtime. More...

#include <core.h>

Inheritance diagram for jazz_bebop::Core:
jazz_bebop::BaseAPI jazz_elements::Container jazz_elements::Service

Public Member Functions

 Core (pLogger a_logger, pConfigFile a_config, pChannels a_channels, pVolatile a_volatile, pPersisted a_persisted)
 Creates a Core service without starting it.
 
virtual pChar const id ()
 
StatusCode start ()
 
StatusCode shut_down ()
 
void base_names (BaseNames &base_names)
 
virtual StatusCode new_entity (pChar p_where)
 
virtual StatusCode new_entity (Locator &where)
 
virtual StatusCode put (pChar p_where, pBlock p_block, int mode=WRITE_AS_BASE_DEFAULT)
 
virtual StatusCode put (Locator &where, pBlock p_block, int mode=WRITE_AS_BASE_DEFAULT)
 
virtual StatusCode remove (pChar p_where)
 
virtual StatusCode remove (Locator &where)
 
virtual StatusCode header (StaticBlockHeader &hea, pChar p_what)
 
virtual StatusCode header (pTransaction &p_txn, pChar p_what)
 
virtual StatusCode header (StaticBlockHeader &hea, Locator &what)
 
virtual StatusCode header (pTransaction &p_txn, Locator &what)
 
virtual StatusCode get (pTransaction &p_txn, pChar p_what)
 
virtual StatusCode get (pTransaction &p_txn, pChar p_what, pBlock p_row_filter)
 
virtual StatusCode get (pTransaction &p_txn, pChar p_what, pChar name)
 
virtual StatusCode get (pTransaction &p_txn, Locator &what)
 
virtual StatusCode get (pTransaction &p_txn, Locator &what, pBlock p_row_filter)
 
virtual StatusCode get (pTransaction &p_txn, Locator &what, pChar name)
 
virtual StatusCode exec (pTransaction &p_txn, Locator &function, pTuple p_args)
 
virtual StatusCode modify (Locator &function, pTuple p_args)
 
- Public Member Functions inherited from jazz_bebop::BaseAPI
 BaseAPI (pLogger a_logger, pConfigFile a_config, pChannels a_channels, pVolatile a_volatile, pPersisted a_persisted)
 Creates a BaseAPI service without starting it.
 
bool parse (ApiQueryState &q_state, pChar p_url, int method, bool recurse=false)
 
bool block_from_const (pTransaction &p_txn, pChar p_const, bool make_tuple=false)
 
virtual StatusCode header (StaticBlockHeader &hea, ApiQueryState &what)
 
virtual StatusCode get (pTransaction &p_txn, ApiQueryState &what)
 
virtual StatusCode put (ApiQueryState &where, pBlock p_block, int mode=WRITE_AS_BASE_DEFAULT)
 
virtual StatusCode remove (ApiQueryState &what)
 
pChannels get_channels ()
 
pVolatile get_volatile ()
 
pPersisted get_persisted ()
 
- Public Member Functions inherited from jazz_elements::Container
 Container (pLogger a_logger, pConfigFile a_config)
 
void enter_read (pTransaction p_txn)
 
void enter_write (pTransaction p_txn)
 
void leave_read (pTransaction p_txn)
 
void leave_write (pTransaction p_txn)
 
StatusCode new_block (pTransaction &p_txn, int cell_type, int *dim, int fill_tensor=FILL_NEW_DONT_FILL, int stringbuff_size=0, const char *p_text=nullptr, char eol='\n', AttributeMap *att=nullptr)
 
StatusCode new_block (pTransaction &p_txn, int num_items, StaticBlockHeader p_hea[], Name p_names[], pBlock p_block[], AttributeMap *dims=nullptr, AttributeMap *att=nullptr)
 
StatusCode new_block (pTransaction &p_txn, pBlock p_from, pBlock p_row_filter, AttributeMap *att=nullptr)
 
StatusCode new_block (pTransaction &p_txn, pTuple p_from, pChar name, AttributeMap *att=nullptr)
 
StatusCode new_block (pTransaction &p_txn, pBlock p_from_text, int cell_type, pKind p_as_kind=nullptr, AttributeMap *att=nullptr)
 
StatusCode new_block (pTransaction &p_txn, pBlock p_from_raw, pChar p_fmt=nullptr, bool ret_as_string=false, AttributeMap *att=nullptr)
 
StatusCode new_block (pTransaction &p_txn, int cell_type)
 
StatusCode new_block (pTransaction &p_txn, Index &index)
 
virtual StatusCode new_transaction (pTransaction &p_txn)
 
virtual void destroy_transaction (pTransaction &p_txn)
 
virtual StatusCode locate (Locator &location, pChar p_what)
 
virtual StatusCode copy (pChar p_where, pChar p_what)
 
virtual StatusCode as_locator (Locator &result, pChar p_what)
 
virtual StatusCode locate (Locator &location, Locator &what)
 
virtual StatusCode copy (Locator &where, Locator &what)
 
StatusCode unwrap_received (pTransaction &p_txn)
 
StatusCode unwrap_received (pTransaction &p_txn, pBlock p_maybe_block, int rec_size)
 
void base_names (BaseNames &base_names)
 
- Public Member Functions inherited from jazz_elements::Service
 Service (pLogger a_logger, pConfigFile a_config)
 
void log (int loglevel, const char *message)
 
void log_printf (int loglevel, const char *fmt,...)
 
bool get_conf_key (const char *key, int &value)
 
bool get_conf_key (const char *key, double &value)
 
bool get_conf_key (const char *key, std::string &value)
 

Private Attributes

DataSpaces data_spaces
 The data spaces.
 
Fields fields
 The fields.
 
Bop bop
 The Bop compiler.
 

Additional Inherited Members

- Data Fields inherited from jazz_bebop::BaseAPI
TenBitPtrLUT base_server
 A LUT to convert TenBitsAtAddress(base) into a pContainer.
 
- Data Fields inherited from jazz_elements::Service
pLogger p_log
 The logger.
 
pConfigFile p_conf
 The configuration file.
 
- Protected Member Functions inherited from jazz_bebop::BaseAPI
bool parse_locator (Locator &loc, pChar p_url)
 
int move_const (pChar p_buff, int buff_size, pChar p_url, pChar p_base=nullptr)
 
StatusCode get_right_local (pTransaction &p_txn, ApiQueryState &q_state)
 
StatusCode get_right_remote (pTransaction &p_txn, ApiQueryState &q_state)
 
StatusCode get_left_local (pTransaction &p_txn, ApiQueryState &q_state)
 
StatusCode put_left_local (ApiQueryState &q_state, pBlock p_block)
 
- Protected Member Functions inherited from jazz_elements::Container
void * malloc (size_t size)
 
pBlock block_malloc (size_t size)
 
void lock_container ()
 
void unlock_container ()
 
StatusCode destroy_container ()
 
int from_hex (char c)
 
- Protected Attributes inherited from jazz_bebop::BaseAPI
pChannels p_channels
 The Channels container.
 
pVolatile p_volatile
 The Volatile container.
 
pPersisted p_persisted
 The Persisted container.
 
- Protected Attributes inherited from jazz_elements::Container
int max_transactions
 The configured ONE_SHOT_MAX_TRANSACTIONS.
 
uint64_t warn_alloc_bytes
 Taken from ONE_SHOT_WARN_BLOCK_KBYTES.
 
uint64_t fail_alloc_bytes
 Taken from ONE_SHOT_ERROR_BLOCK_KBYTES.
 
uint64_t alloc_bytes
 The current allocation in bytes.
 
pTransaction p_buffer
 The buffer for the transactions.
 
pTransaction p_free
 The free list of transactions.
 
bool alloc_warning_issued
 True if a warning was issued for over-allocation.
 
Lock32 _lock_
 A lock for the deque of transactions.
 

Detailed Description

Core: The execution unit is now a wrapper around onnx-runtime.

This class:

Manages dataspaces.
Manages fields.
Manages life cycle of Snippets: create from source, from object, update, delete.
Compiles or decompiles Snippets.
Manages onnx runtime sessions.
Runs bop objects.

API Container interface:

This is the only interface this class has. Everything, is done using this interface, even when this object is used by a ModelsAPI.

Everything here can be called from the API + destroy_transaction() (You don't override destroy_transaction() since you don't override new_transaction()). Of course, not everything must be supported, but since it could be called by some possibly nonsensical API query, it is better to reject whatever is not supported with a proper error code.

The class must support all forms of: new_entity, put, remove, header, get, exec, modify.

Unlike in other containers, the override is based on only on types, using the locate() mechanism is optional. Unlike in other containers, copy() is not called from the API. copy() is just an internal function to copy inside a Container in the most efficient way.

Constructor & Destructor Documentation

◆ Core()

jazz_bebop::Core::Core ( pLogger  a_logger,
pConfigFile  a_config,
pChannels  a_channels,
pVolatile  a_volatile,
pPersisted  a_persisted 
)

Creates a Core service without starting it.

Parameters
a_loggerA pointer to the logger.
a_configA pointer to the configuration.
a_channelsA pointer to an initialized Channels Container.
a_volatileA pointer to an initialized Volatile Container.
a_persistedA pointer to an initialized Persisted Container.

Member Function Documentation

◆ id()

pChar const jazz_bebop::Core::id ( )
virtual

Return object ID.

Returns
A string identifying the object that is especially useful to track uplifts and versions.

Reimplemented from jazz_bebop::BaseAPI.

◆ start()

StatusCode jazz_bebop::Core::start ( )
virtual

Starts the Core service

Returns
SERVICE_NO_ERROR if successful, an error code otherwise.

Reimplemented from jazz_bebop::BaseAPI.

◆ shut_down()

StatusCode jazz_bebop::Core::shut_down ( )
virtual

Shuts down the Core Service

Returns
SERVICE_NO_ERROR if successful, an error code otherwise.

Reimplemented from jazz_bebop::BaseAPI.

◆ base_names()

void jazz_bebop::Core::base_names ( BaseNames base_names)

Add the base names for this ModelsAPI.

Parameters
base_namesA BaseNames map passed by reference to which the base names of this object are added by this call.

◆ new_entity() [1/2]

StatusCode jazz_bebop::Core::new_entity ( pChar  p_where)
virtual

"Easy" interface for creating entities: This parses p_where and, on success, calls the native new_entity() equivalent.

Parameters
p_whereSome string that as_locator() can parse into a Locator. E.g. //base/entity
Returns
SERVICE_NO_ERROR on success or some negative value (error).

What an entity is, is Container and base dependent. It can be an lmdb database, a folder in a filesystem, a Volatile tree, ...

Reimplemented from jazz_elements::Container.

◆ new_entity() [2/2]

StatusCode jazz_bebop::Core::new_entity ( Locator where)
virtual

The "native" interface: This is what really does the job and must be implemented in the Container descendants.

Parameters
whereSome destination Locator to the block. (See Node Method Reference in the documentation of the class Volatile.)
Returns
SERVICE_NOT_IMPLEMENTED since this method must be implemented in the Container descendants.

NOTE**: The root Container class does not implement this.

Reimplemented from jazz_elements::Container.

◆ put() [1/2]

StatusCode jazz_bebop::Core::put ( pChar  p_where,
pBlock  p_block,
int  mode = WRITE_AS_BASE_DEFAULT 
)
virtual

"Easy" interface for Block storing: This parses p_where and, on success, calls the native put() equivalent.

Parameters
p_whereSome string that as_locator() can parse into a Locator. E.g. //base/entity/key
p_blockA block to be stored. Notice it is a block, not a Transaction. If necessary, the Container will make a copy, write to disc, PUT it via http, etc. The container does not own the pointer in any way.
modeSome writing restriction that should return an error if not supported. It controls overriding or writing just the data as when writing to a file.
Returns
SERVICE_NO_ERROR on success or some negative value (error).

Reimplemented from jazz_elements::Container.

◆ put() [2/2]

StatusCode jazz_bebop::Core::put ( Locator where,
pBlock  p_block,
int  mode = WRITE_AS_BASE_DEFAULT 
)
virtual

The "native" interface: This is what really does the job and must be implemented in the Container descendants.

Parameters
whereSome destination Locator to the block. (See Node Method Reference in the documentation of the class Volatile.)
p_blockThe Block to be stored in Volatile. The Block hash and dated will be updated by this call!!
modeSome writing restriction, either WRITE_ONLY_IF_EXISTS or WRITE_ONLY_IF_NOT_EXISTS. WRITE_TENSOR_DATA returns the error SERVICE_ERROR_WRONG_ARGUMENTS
Returns
SERVICE_NOT_IMPLEMENTED since this method must be implemented in the Container descendants.

NOTE**: The root Container class does not implement this.

Reimplemented from jazz_elements::Container.

◆ remove() [1/2]

StatusCode jazz_bebop::Core::remove ( pChar  p_where)
virtual

"Easy" interface for deleting entities and blocks: This parses p_where and, on success, calls the native header() equivalent.

Parameters
p_whereSome string that as_locator() can parse into a Locator. E.g. //base/entity or //base/entity/key
Returns
SERVICE_NO_ERROR on success or some negative value (error).

What an entity is, is Container and base dependent. It can be an lmdb database, a folder in a filesystem, a Volatile tree, ...

Reimplemented from jazz_elements::Container.

◆ remove() [2/2]

StatusCode jazz_bebop::Core::remove ( Locator where)
virtual

The "native" interface: This is what really does the job and must be implemented in the Container descendants.

Parameters
whereThe block or entity to be removed. (See Node Method Reference in the documentation of the class Volatile.)
Returns
SERVICE_NOT_IMPLEMENTED since this method must be implemented in the Container descendants.

NOTE**: The root Container class does not implement this.

Reimplemented from jazz_elements::Container.

◆ header() [1/4]

StatusCode jazz_bebop::Core::header ( StaticBlockHeader hea,
pChar  p_what 
)
virtual

"Easy" interface metadata of a Block retrieval. This parses p_what and, on success, calls the native header() equivalent.

Parameters
heaA StaticBlockHeader structure that will receive the metadata.
p_whatSome string that as_locator() can parse into a Locator. E.g. //base/entity/key
Returns
SERVICE_NO_ERROR on success (and a valid hea), or some negative value (error).

This is a faster, not involving RAM allocation version of the other form of header. For a tensor, is will be the only thing you need, but for a Kind or a Tuple, you probably want the types of all its items and need to pass a pTransaction to hold the data.

Reimplemented from jazz_elements::Container.

◆ header() [2/4]

StatusCode jazz_bebop::Core::header ( pTransaction p_txn,
pChar  p_what 
)
virtual

"Easy" interface metadata of a Block retrieval. This parses p_what and, on success, calls the native header() equivalent.

Parameters
p_txnA pointer to a Transaction passed by reference. If successful, the Container will return a pointer to a Transaction inside the Container.
p_whatSome string that as_locator() can parse into a Locator. E.g. //base/entity/key
Returns
SERVICE_NO_ERROR on success (and a valid p_txn), or some negative value (error).

Unlike its faster form, this allocates a Block and therefore, it is equivalent to a new_block() call. On success, it will return a Transaction that belongs to the Container and must be destroy_transaction()-ed when the caller is done.

For Tensors it will allocate a block that only has the StaticBlockHeader (What you can more efficiently get from the other form.) For Kinds, the metadata of all the items is exactly the same a .get() call returns. For Tuples, it does what you expect: returning a Block with the metadata of all the items without the data.

Reimplemented from jazz_elements::Container.

◆ header() [3/4]

StatusCode jazz_bebop::Core::header ( StaticBlockHeader hea,
Locator what 
)
virtual

The "native" interface: This is what really does the job and must be implemented in the Container descendants.

Parameters
heaA StaticBlockHeader structure that will receive the metadata.
whatSome Locator to the block. (See Node Method Reference in the documentation of the class Volatile.)
Returns
SERVICE_NOT_IMPLEMENTED since this method must be implemented in the Container descendants.

NOTE**: The root Container class does not implement this.

Reimplemented from jazz_elements::Container.

◆ header() [4/4]

StatusCode jazz_bebop::Core::header ( pTransaction p_txn,
Locator what 
)
virtual

The "native" interface: This is what really does the job and must be implemented in the Container descendants.

Parameters
p_txnA pointer to a Transaction passed by reference. If successful, the Container will return a pointer to a Transaction inside the Container.
whatSome Locator to the block. (See Node Method Reference in the documentation of the class Volatile.)
Returns
SERVICE_NOT_IMPLEMENTED since this method must be implemented in the Container descendants.

NOTE**: The root Container class does not implement this.

Reimplemented from jazz_elements::Container.

◆ get() [1/6]

StatusCode jazz_bebop::Core::get ( pTransaction p_txn,
pChar  p_what 
)
virtual

"Easy" interface complete Block retrieval. This parses p_what and, on success, calls the native get() equivalent.

Parameters
p_txnA pointer to a Transaction passed by reference. If successful, the Container will return a pointer to a Transaction inside the Container.
p_whatSome string that as_locator() can parse into a Locator. E.g. //base/entity/key
Returns
SERVICE_NO_ERROR on success (and a valid p_txn), or some negative value (error).

Usage-wise, this is equivalent to a new_block() call. On success, it will return a Transaction that belongs to the Container and must be destroy_transaction()-ed when the caller is done.

Reimplemented from jazz_elements::Container.

◆ get() [2/6]

StatusCode jazz_bebop::Core::get ( pTransaction p_txn,
pChar  p_what,
pBlock  p_row_filter 
)
virtual

"Easy" interface selection of rows in a Block retrieval. This parses p_what and, on success, calls the native get() equivalent.

Parameters
p_txnA pointer to a Transaction passed by reference. If successful, the Container will return a pointer to a Transaction inside the Container.
p_whatSome string that as_locator() can parse into a Locator. E.g. //base/entity/key
p_row_filterThe block we want to use as a filter. This is either a tensor of boolean or integer that can_filter(p_from).
Returns
SERVICE_NO_ERROR on success (and a valid p_txn), or some negative value (error).

Usage-wise, this is equivalent to a new_block() call. On success, it will return a Transaction that belongs to the Container and must be destroy_transaction()-ed when the caller is done.

Reimplemented from jazz_elements::Container.

◆ get() [3/6]

StatusCode jazz_bebop::Core::get ( pTransaction p_txn,
pChar  p_what,
pChar  name 
)
virtual

"Easy" interface selection of a tensor in a Tuple retrieval. This parses p_what and, on success, calls the native get() equivalent.

Parameters
p_txnA pointer to a Transaction passed by reference. If successful, the Container will return a pointer to a Transaction inside the Container.
p_whatSome string that as_locator() can parse into a Locator. E.g. //base/entity/key
nameThe name of the item to be selected.
Returns
SERVICE_NO_ERROR on success (and a valid p_txn), or some negative value (error).

Usage-wise, this is equivalent to a new_block() call. On success, it will return a Transaction that belongs to the Container and must be destroy_transaction()-ed when the caller is done.

Reimplemented from jazz_elements::Container.

◆ get() [4/6]

StatusCode jazz_bebop::Core::get ( pTransaction p_txn,
Locator what 
)
virtual

The "native" interface: This is what really does the job and must be implemented in the Container descendants.

Parameters
p_txnA pointer to a Transaction passed by reference. If successful, the Container will return a pointer to a Transaction inside the Container.
whatA valid reference to a block as a locator. E.g. //base/entity/key
Returns
SERVICE_NOT_IMPLEMENTED since this method must be implemented in the Container descendants.

NOTE**: The root Container class does not implement this.

Reimplemented from jazz_elements::Container.

◆ get() [5/6]

StatusCode jazz_bebop::Core::get ( pTransaction p_txn,
Locator what,
pBlock  p_row_filter 
)
virtual

The "native" interface: This is what really does the job and must be implemented in the Container descendants.

Parameters
p_txnA pointer to a Transaction passed by reference. If successful, the Container will return a pointer to a Transaction inside the Container.
whatA valid reference to a block as a locator. E.g. //base/entity/key
p_row_filterThe block we want to use as a filter. This is either a tensor of boolean or integer that can_filter(p_from).
Returns
SERVICE_NOT_IMPLEMENTED since this method must be implemented in the Container descendants.

NOTE**: The root Container class does not implement this.

Reimplemented from jazz_elements::Container.

◆ get() [6/6]

StatusCode jazz_bebop::Core::get ( pTransaction p_txn,
Locator what,
pChar  name 
)
virtual

The "native" interface: This is what really does the job and must be implemented in the Container descendants.

Parameters
p_txnA pointer to a Transaction passed by reference. If successful, the Container will return a pointer to a Transaction inside the Container.
whatA valid reference to a block as a locator. E.g. //base/entity/key
nameThe name of the item to be selected.
Returns
SERVICE_NOT_IMPLEMENTED since this method must be implemented in the Container descendants.

NOTE**: The root Container class does not implement this.

Reimplemented from jazz_elements::Container.

◆ exec()

StatusCode jazz_bebop::Core::exec ( pTransaction p_txn,
Locator function,
pTuple  p_args 
)
virtual

The function call interface for exec: Execute a function or a model.

Parameters
p_txnA pointer to a Transaction passed by reference. If successful, the Container will return a pointer to a Transaction inside the Container.
functionSome description of a service. In general base/entity/key. In Channels the key must be empty and the entity is the pipeline. In Core, the key is field/snippet, In Model (via ModelAPI), model/(entry point).
p_argsA Tuple passed as argument to the call that is not modified.
Returns
SERVICE_ERROR_NOT_APPLICABLE since this method must be implemented in the Container descendants.

Usage-wise, this is equivalent to a new_block() call. On success, it will return a Transaction that belongs to the Container and must be destroy_transaction()-ed when the caller is done.

Reimplemented from jazz_elements::Container.

◆ modify()

StatusCode jazz_bebop::Core::modify ( Locator function,
pTuple  p_args 
)
virtual

The function call interface for modify: In jazz_elements, this is only implemented in Channels.

Parameters
functionSome description of a service. In general base/entity/key. In Channels the key must be empty and the entity is the pipeline.
p_argsIn Channels: A Tuple with two items, "input" with the data passed to the service and "result" with the data returned. The result will be overridden in-place without any allocation.
Returns
SERVICE_ERROR_NOT_APPLICABLE since this method must be implemented in the Container descendants.

modify() is similar to exec(), but, rather than creating a new block with the result, it modifies the Tuple p_args.

Reimplemented from jazz_elements::Container.


The documentation for this class was generated from the following files: