public interface DataAccessObject
Interface for accessing data in LensKit.
LensKit data is represented by entities; see org.lenskit.data.entities
DAOs must be thread-safe, but individual streams they return need not be.
Modifier and Type | Method and Description |
---|---|
LongSet |
getEntityIds(EntityType type)
Get the IDs of all entities with a particular type.
|
java.util.Set<EntityType> |
getEntityTypes()
Get the types of entities that are available in this DAO.
|
Entity |
lookupEntity(EntityType type,
long id)
Look up an entity by ID.
|
<E extends Entity> |
lookupEntity(EntityType type,
long id,
java.lang.Class<E> view)
Look up an entity by ID and project it to a view class.
|
<V extends Entity> |
query(java.lang.Class<V> type)
Start a query for a particular type using the fluent query interface.
|
Query<Entity> |
query(EntityType type)
Start a query using the fluent query interface.
|
<E extends Entity> |
streamEntities(EntityQuery<E> query)
Stream entities in response to a query.
|
ObjectStream<Entity> |
streamEntities(EntityType type)
Stream all entities of a particular type.
|
<E extends Entity> |
streamEntityGroups(EntityQuery<E> query,
TypedName<java.lang.Long> grpCol)
Stream entities in response to a query, grouping them by a long ID.
|
java.util.Set<EntityType> getEntityTypes()
Get the types of entities that are available in this DAO.
LongSet getEntityIds(EntityType type)
Get the IDs of all entities with a particular type.
type
- The entity type.@Nullable Entity lookupEntity(EntityType type, long id)
Look up an entity by ID.
type
- The entity type.id
- The entity ID.null
if no such entity exists.@Nullable <E extends Entity> E lookupEntity(EntityType type, long id, java.lang.Class<E> view)
Look up an entity by ID and project it to a view class.
type
- The entity type.id
- The entity ID.view
- The view class.null
if no such entity exists.java.lang.IllegalArgumentException
- if the entity cannot be projected to view
.ObjectStream<Entity> streamEntities(EntityType type)
Stream all entities of a particular type.
type
- The entity type.<E extends Entity> ObjectStream<E> streamEntities(EntityQuery<E> query)
Stream entities in response to a query.
query
- The query.E
- The view class type.UnsupportedQueryException
- if the query cannot be satisfied.<E extends Entity> ObjectStream<IdBox<java.util.List<E>>> streamEntityGroups(EntityQuery<E> query, TypedName<java.lang.Long> grpCol)
Stream entities in response to a query, grouping them by a long ID.
query
- The query.grpCol
- The column to group by.E
- The view class type.UnsupportedQueryException
- if the query cannot be satisfiedQuery<Entity> query(EntityType type)
Start a query using the fluent query interface.
type
- The type of entity to retrieve.<V extends Entity> Query<V> query(java.lang.Class<V> type)
Start a query for a particular type using the fluent query interface. This method looks up the entity type using the DefaultEntityType
annotation on the view class.
type
- The view class type.java.lang.IllegalArgumentException
- if the type has no DefaultEntityType
annotation.