public class Mentat extends Object
Constructor and Description |
---|
Mentat()
Open a connection to an in-memory Store.
|
Mentat(JNA.Store rawPointer)
Create a new Mentat with the provided pointer to a Mentat Store
|
Mentat(String dbPath)
Open a connection to a Store in a given location.
If the store does not already exist, one will be created. |
Modifier and Type | Method and Description |
---|---|
InProgress |
beginTransaction()
Start a new transaction
TODO: Throw an exception if the result contains an error.
|
void |
cache(String attribute,
CacheDirection direction)
Add an attribute to the cache.
|
void |
close() |
protected void |
destroyPointer(JNA.Store p) |
long |
entIdForAttribute(String attribute)
Get the the `Entid` of the attribute
|
InProgressBuilder |
entityBuilder()
Creates a new transaction (
InProgress ) and returns an InProgressBuilder for
that transaction. |
EntityBuilder |
entityBuilder(long entid)
Creates a new transaction (
InProgress ) and returns an EntityBuilder for the
entity with `entid` for that transaction. |
EntityBuilder |
entityBuilder(String tempId)
Creates a new transaction (
InProgress ) and returns an EntityBuilder for a new
entity with `tempId` for that transaction. |
protected void |
finalize() |
Query |
query(String query)
Start a query.
|
void |
registerObserver(String key,
String[] attributes,
TxObserverCallback callback)
Register an callback and a set of attributes to observer for transaction observation.
|
TxReport |
transact(String transaction)
Simple transact of an EDN string.
|
void |
unregisterObserver(String key)
Unregister the observer that was registered with the provided key such that it will no longer be called
if a transaction occurs that affects the attributes that the observer was registered to observe.
|
TypedValue |
valueForAttributeOfEntity(String attribute,
long entid)
Retrieve a single value of an attribute for an Entity
TODO: Throw an exception if the result contains an error.
|
public Mentat(String dbPath)
dbPath
- The URI as a String of the store to open.public Mentat()
public Mentat(JNA.Store rawPointer)
rawPointer
- A pointer to a Mentat Store.public void cache(String attribute, CacheDirection direction)
CacheDirection
determines how that attribute can be
looked up.
TODO: Throw an exception if cache action fails. https://github.com/mozilla/mentat/issues/700attribute
- The attribute to cachedirection
- The direction the attribute should be keyed.
FORWARD caches values for an attribute keyed by entity
(i.e. find values and entities that have this attribute, or find values of attribute for an entity)
REVERSE caches entities for an attribute keyed by value.
(i.e. find entities that have a particular value for an attribute).
BOTH adds an attribute such that it is cached in both directions.public TxReport transact(String transaction)
transaction
- The string, as EDN, to be transacted.TxReport
of the completed transactionpublic long entIdForAttribute(String attribute)
attribute
- The string represeting the attribute whose `Entid` we are after. The string is represented as `:namespace/name`.public Query query(String query)
query
- The string represeting the the query to be executed.Query
representing the query that can be executed.public TypedValue valueForAttributeOfEntity(String attribute, long entid)
attribute
- The string the attribute whose value is to be returned. The string is represented as `:namespace/name`.entid
- The `Entid` of the entity we want the value from.TypedValue
containing the value of the attribute for the entity.public void registerObserver(String key, String[] attributes, TxObserverCallback callback)
key
- `String` representing an identifier for the observer.attributes
- An array of Strings representing the attributes that the observer wishes
to be notified about if they are referenced in a transaction.callback
- the function to call when an observer notice is fired.public void unregisterObserver(String key)
key
- String representing an identifier for the observer.public InProgress beginTransaction()
InProgress
used to manage the transactionpublic InProgressBuilder entityBuilder()
InProgress
) and returns an InProgressBuilder
for
that transaction.
TODO: Throw an exception if the result contains an error. https://github.com/mozilla/mentat/issues/700InProgressBuilder
for a new transaction.public EntityBuilder entityBuilder(long entid)
InProgress
) and returns an EntityBuilder
for the
entity with `entid` for that transaction.
TODO: Throw an exception if the result contains an error. https://github.com/mozilla/mentat/issues/700entid
- The `Entid` for this entity.EntityBuilder
for a new transaction.public EntityBuilder entityBuilder(String tempId)
InProgress
) and returns an EntityBuilder
for a new
entity with `tempId` for that transaction.
TODO: Throw an exception if the result contains an error. https://github.com/mozilla/mentat/issues/700tempId
- The temporary identifier for this entity.EntityBuilder
for a new transaction.protected void destroyPointer(JNA.Store p)
public void close()
close
in interface AutoCloseable