public interface Database
Modifier and Type | Interface and Description |
---|---|
static interface |
Database.Predicate<T>
Boolean-valued function for
filtering a
database. |
Modifier and Type | Field and Description |
---|---|
static java.lang.Object |
AEVT
Names the AEVT index.
|
static java.lang.Object |
AVET
Names the AVET index.
|
static java.lang.Object |
EAVT
Names the EAVT index.
|
static java.lang.Object |
VAET
Names the VAET index.
|
Modifier and Type | Method and Description |
---|---|
Database |
asOf(java.lang.Object t)
Returns the value of the database filtered to include data up to
t , inclusive |
java.lang.Long |
asOfT()
|
Attribute |
attribute(java.lang.Object attrId)
Returns information about an attribute.
|
long |
basisT()
t value of the most recent transaction in this db.
|
java.lang.Iterable<Datom> |
datoms(java.lang.Object index,
java.lang.Object... components)
Implements the Datoms API
for raw access to matching index data.
|
java.util.Map |
dbStats()
Queries for database stats.
|
java.lang.Object |
entid(java.lang.Object entityId)
Returns the entity id associated with any kind of entity identifier.
|
java.lang.Object |
entidAt(java.lang.Object partition,
java.lang.Object timePoint)
Returns a fabricated entity id in the supplied partition whose
T component is at or after the supplied t
|
Entity |
entity(java.lang.Object entityId)
Returns an entity: a lazy, dynamic associative view of datoms sharing an entity id.
|
Database |
filter(Database.Predicate<Datom> pred)
Returns a value of the database containing only Datoms satisfying the predicate.
|
Database |
filter(java.lang.Object pred) |
Database |
history()
Returns a history database value containing all assertions and retractions across time.
|
java.lang.String |
id()
Opaque, globally unique database id.
|
java.lang.Object |
ident(java.lang.Object idOrKey)
Returns the symbolic keyword associated with an id, or the key itself if passed.
|
java.util.stream.Stream<java.lang.Object> |
indexPull(java.lang.Object options)
"Walks an index, pulling entities via :e if :avet or :v if :aevt,
using the selector, returning a Stream of the results.
|
java.lang.Iterable<Datom> |
indexRange(java.lang.Object attrid,
java.lang.Object start,
java.lang.Object end)
Returns a range of AVET-indexed datoms.
|
java.lang.Object |
invoke(java.lang.Object entityId,
java.lang.Object... args)
|
boolean |
isFiltered()
Does database have a filter set with e.g.
|
boolean |
isHistory()
True for databases created with
history() |
long |
nextT()
next t value that will be assigned by this database.
|
java.util.Map |
pull(java.lang.Object pattern,
java.lang.Object entityId)
Returns a hierarchical selection of attributes for entityId.
|
java.util.List<java.util.Map> |
pullMany(java.lang.Object pattern,
java.util.List entityIds)
Returns hierarchical selections of attributes for entityIds.
|
java.lang.Iterable<Datom> |
seekDatoms(java.lang.Object index,
java.lang.Object... components)
Raw access to index data, starting at nearest match to input
|
Database |
since(java.lang.Object t)
Returns the value of the database filtered to include only data since
t , exclusive |
java.lang.Long |
sinceT()
|
java.util.Map |
with(java.util.List txData)
Returns a database with
txData applied locally in memory. |
static final java.lang.Object EAVT
Names the EAVT index.
Pass to APIs that take an index name such as datoms(Object, Object...)
.
static final java.lang.Object AEVT
Names the AEVT index.
Pass to APIs that take an index name such as datoms(Object, Object...)
.
static final java.lang.Object AVET
Names the AVET index.
Pass to APIs that take an index name such as datoms(Object, Object...)
.
static final java.lang.Object VAET
Names the VAET index.
Pass to APIs that take an index name such as datoms(Object, Object...)
.
java.lang.String id()
long basisT()
long nextT()
java.lang.Long asOfT()
java.lang.Long sinceT()
boolean isHistory()
history()
java.util.Map with(java.util.List txData)
Returns a database with txData
applied locally in memory.
txData
- in the same format as expected by transact
Database asOf(java.lang.Object t)
t
, inclusivet
- a time-pointDatabase since(java.lang.Object t)
t
, exclusivet
- a time-pointDatabase history()
Returns a history database value containing all assertions and retractions across time.
A history database can be used for datoms(Object, Object...)
and indexRange(Object, Object, Object)
,
for queries
, and for asOf(Object)
and since(Object)
.
A history database cannot be used with APIs that require a single point-in-time,
i.e. entity(Object)
or with(java.util.List)
.
Note that queries will return all of the additions and retractions, which can be distinguished
by Datom.added()
Database filter(Database.Predicate<Datom> pred)
Returns a value of the database containing only Datoms satisfying the predicate.
The predicate will be passed the unfiltered db and a Datom Chained calls tofilter
compose predicates with logical 'and'.pred
- a Predicate<Datom>
or clojure fn
Database filter(java.lang.Object pred)
boolean isFiltered()
filter(datomic.Database.Predicate)
?Entity entity(java.lang.Object entityId)
entityId
- an entity identifierEntity
Attribute attribute(java.lang.Object attrId)
attrId
- an entity identifier for an attributejava.lang.Object ident(java.lang.Object idOrKey)
idOrKey
- an id or keywordjava.lang.Object entid(java.lang.Object entityId)
entityId
- an entity identifierjava.lang.Object entidAt(java.lang.Object partition, java.lang.Object timePoint)
Returns a fabricated entity id in the supplied partition whose T component is at or after the supplied t
. Entity ids sort by partition, then T component, such T components interleaving with transaction numbers. Thus this method can be used to fabricate a time-based entity id component for use in #seekDatoms.partition
- an entity identifier for a partitiontimePoint
- a time-pointjava.lang.Object invoke(java.lang.Object entityId, java.lang.Object... args)
entityId
- an entity identifierargs
- the arguments to the database functionjava.lang.Iterable<Datom> datoms(java.lang.Object index, java.lang.Object... components)
Implements the Datoms API for raw access to matching index data.
The index must be supplied, and, optionally, one or more leading components of the index can be supplied to narrow the result. EAVT and AEVT indexes will contain all datoms AVET will contain datoms for attributes where either:db/index
or :db/unique
are true.
VAET will contain datoms for attributes of :db.type/ref - it is the reverse indexjava.lang.Iterable<Datom> seekDatoms(java.lang.Object index, java.lang.Object... components)
Raw access to index data, starting at nearest match to input
. Arguments are the same as todatoms(java.lang.Object, java.lang.Object...)
, but their interpretation is different in two
important ways:
seekDatoms
is for more advanced applications, and datoms(Object, Object...)
should be preferred wherever it is adequate.
seekDatoms
is typically used in conjunction with entidAt(Object, Object)
to implement new entity scans.java.lang.Iterable<Datom> indexRange(java.lang.Object attrid, java.lang.Object start, java.lang.Object end)
Returns a range of AVET-indexed datoms.
attrid
- an entity identifier naming an indexed attribute.start
- start value or null if from beginningend
- end value (non-inclusive), or null if through endIterable
over Datom
positioned between start (inclusive) and end (exclusive)java.util.Map pull(java.lang.Object pattern, java.lang.Object entityId)
pattern
- A pattern,
or a String containing a pattern serialized into edn.entityId
- An entity identifierjava.util.stream.Stream<java.lang.Object> indexPull(java.lang.Object options)
options
- a data structure describing the indexPull serialized into edn
:index
, :selector
, :start
, and :reverse
keys:index |
:avet or :aevt |
:selector |
a pull selector (see 'pull') |
:start |
A vector in the same order as the index indicating the initial position. At least :a must be specified. Iteration is limited to datoms matching :a. |
:reverse |
optional, when true iterate the index in reverse order |
Stream
of the indexPull resultsjava.util.List<java.util.Map> pullMany(java.lang.Object pattern, java.util.List entityIds)
pattern
- A pattern, or a String containing
a pattern serialized into edn.entityIds
- A list of entity identifiersjava.util.Map dbStats()
:datoms |
total count of datoms in the (history) database |