Interface Database
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Boolean-valued function forfiltering
a database. -
Field Summary
Modifier and TypeFieldDescriptionstatic final Object
Names the AEVT index.static final Object
Names the AVET index.static final Object
Names the EAVT index.static final Object
Names the VAET index. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of the database filtered to include data up tot
, inclusiveasOfT()
Returns information about an attribute.long
basisT()
t value of the most recent transaction in this db.Implements the Datoms API for raw access to matching index data.dbStats()
Queries for database stats.Returns the entity id associated with any kind of entity identifier.Returns a fabricated entity id in the supplied partition whose T component is at or after the supplied tReturns an entity: a lazy, dynamic associative view of datoms sharing an entity id.filter
(Database.Predicate<Datom> pred) Returns a value of the database containing only Datoms satisfying the predicate.history()
Returns a history database value containing all assertions and retractions across time.id()
Opaque, globally unique database id.Returns the symbolic keyword associated with an id, or the key itself if passed."Walks an index, pulling entities via :e if :avet or :v if :aevt, using the selector, returning a Stream of the results.indexRange
(Object attrid, Object start, Object end) Returns a range of AVET-indexed datoms.boolean
Does database have a filter set with e.g.boolean
True for databases created withhistory()
long
nextT()
next t value that will be assigned by this database.Returns a hierarchical selection of attributes for entityId.Returns hierarchical selections of attributes for entityIds.seekDatoms
(Object index, Object... components) Raw access to index data, starting at nearest match to inputReturns the value of the database filtered to include only data sincet
, exclusivesinceT()
Returns a database withtxData
applied locally in memory.
-
Field Details
-
EAVT
Names the EAVT index.
Pass to APIs that take an index name such as
datoms(Object, Object...)
. -
AEVT
Names the AEVT index.
Pass to APIs that take an index name such as
datoms(Object, Object...)
. -
AVET
Names the AVET index.
Pass to APIs that take an index name such as
datoms(Object, Object...)
. -
VAET
Names the VAET index.
Pass to APIs that take an index name such as
datoms(Object, Object...)
.
-
-
Method Details
-
id
String id()Opaque, globally unique database id.- Returns:
- the database id
-
basisT
long basisT()t value of the most recent transaction in this db.- Returns:
- a t value
-
nextT
long nextT()next t value that will be assigned by this database.- Returns:
- a t value
-
asOfT
Long asOfT()- Returns:
- a t value, or null
-
sinceT
Long sinceT()- Returns:
- a t value, or null
-
isHistory
boolean isHistory()True for databases created withhistory()
- Returns:
- true for history databases
-
with
Returns a database with
It is as if the data was applied in a transaction, but no actual transaction takes place.txData
applied locally in memory.- Parameters:
txData
- in the same format as expected bytransact
- Returns:
- a map as returned by transact
-
asOf
Returns the value of the database filtered to include data up tot
, inclusive- Parameters:
t
- a time-point- Returns:
- the value of the database as of some point t, inclusive
-
since
Returns the value of the database filtered to include only data sincet
, exclusive- Parameters:
t
- a time-point- Returns:
- the value of the database since some point t, exclusive
-
history
Database history()Returns a history database value containing all assertions and retractions across time.
A history database can be used for
datoms(Object, Object...)
andindexRange(Object, Object, Object)
, forqueries
, and forasOf(Object)
andsince(Object)
.A history database cannot be used with APIs that require a single point-in-time, i.e.
entity(Object)
orwith(java.util.List)
.Note that queries will return all of the additions and retractions, which can be distinguished by
Datom.added()
- Returns:
- a history Database
-
filter
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'.- Parameters:
pred
- aPredicate<Datom>
orclojure fn
- Returns:
- the value of the database satisfying the predicate
- Since:
- 0.8.3627
-
filter
-
isFiltered
boolean isFiltered()Does database have a filter set with e.g.filter(datomic.Database.Predicate)
?- Returns:
- true if db has a filter
- Since:
- 0.8.3627
-
entity
Returns an entity: a lazy, dynamic associative view of datoms sharing an entity id.- Parameters:
entityId
- an entity identifier- Returns:
- an
Entity
-
attribute
Returns information about an attribute.- Parameters:
attrId
- an entity identifier for an attribute- Returns:
- an Attribute}
- Since:
- 0.9.4470
-
ident
Returns the symbolic keyword associated with an id, or the key itself if passed.- Parameters:
idOrKey
- an id or keyword- Returns:
- a keyword, or nil if not found
-
entid
Returns the entity id associated with any kind of entity identifier.- Parameters:
entityId
- an entity identifier- Returns:
- an id, or nil if not found
-
entidAt
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.- Parameters:
partition
- an entity identifier for a partitiontimePoint
- a time-point- Returns:
- a fabricated entity id at or after some point t
-
invoke
- Parameters:
entityId
- an entity identifierargs
- the arguments to the database function- Returns:
- the return value of the database function
-
datoms
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 index -
seekDatoms
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:- The match need not be exact. Results will begin with the closest matching datom
- No termination. Results will continue all the way to the end of the index.
seekDatoms
is for more advanced applications, anddatoms(Object, Object...)
should be preferred wherever it is adequate.seekDatoms
is typically used in conjunction withentidAt(Object, Object)
to implement new entity scans. -
indexRange
Returns a range of AVET-indexed datoms.
- Parameters:
attrid
- an entity identifier naming an indexed attribute.start
- start value or null if from beginningend
- end value (non-inclusive), or null if through end- Returns:
- an
Iterable
overDatom
positioned between start (inclusive) and end (exclusive)
-
pull
Returns a hierarchical selection of attributes for entityId.- Parameters:
pattern
- A pattern, or a String containing a pattern serialized into edn.entityId
- An entity identifier- Returns:
- A map containing a selection for the entityId passed in.
- Since:
- 0.9.5040
-
indexPull
"Walks an index, pulling entities via :e if :avet or :v if :aevt, using the selector, returning a Stream of the results.- Parameters:
options
- a data structure describing the indexPull serialized into edn- a map that includes the
: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 - a map that includes the
- Returns:
- an
Stream
of the indexPull results - Since:
- 0.9.6079
-
pullMany
Returns hierarchical selections of attributes for entityIds.- Parameters:
pattern
- A pattern, or a String containing a pattern serialized into edn.entityIds
- A list of entity identifiers- Returns:
- A list of maps containing a selection for each entityId passed in.
- Since:
- 0.9.5040
-
dbStats
Map dbStats()Queries for database stats.- Returns:
- a map with at least the following keys:
:datoms
total count of datoms in the (history) database
-