Package elki.database.relation
Class MaterializedRelation<O>
- java.lang.Object
-
- elki.database.relation.MaterializedRelation<O>
-
- Type Parameters:
O
- Data type
- All Implemented Interfaces:
ModifiableRelation<O>
,Relation<O>
public class MaterializedRelation<O> extends java.lang.Object implements ModifiableRelation<O>
Represents a single representation. This is attached to a DBIDs object, which you are supposed to manage first. I.e. put the new DBID in, then invoke set(), remove the DBID, then delete().TODO: is this semantic sane?
- Since:
- 0.4.0
- Author:
- Erich Schubert
-
-
Field Summary
Fields Modifier and Type Field Description private DataStore<O>
content
Map to hold the objects of the database.private StaticDBIDs
ids
The DBIDs this is supposed to be defined for.private java.lang.String
name
The relation name.private SimpleTypeInformation<O>
type
The class of objects we store.
-
Constructor Summary
Constructors Constructor Description MaterializedRelation(SimpleTypeInformation<O> type, DBIDs ids)
Constructor.MaterializedRelation(java.lang.String name, SimpleTypeInformation<O> type, DBIDs ids)
Constructor.MaterializedRelation(java.lang.String name, SimpleTypeInformation<O> type, DBIDs ids, DataStore<O> content)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
delete(DBIDRef id)
Delete an objects values.O
get(DBIDRef id)
Get the representation of an object.SimpleTypeInformation<O>
getDataTypeInformation()
Get the data type of this representationStaticDBIDs
getDBIDs()
Get the IDs the query is defined for.java.lang.String
getLongName()
Get a long (human readable) name for the relation.void
insert(DBIDRef id, O val)
Set (or insert) an object representation.DBIDIter
iterDBIDs()
Get an iterator access to the DBIDs.int
size()
Get the number of DBIDs.
-
-
-
Field Detail
-
type
private final SimpleTypeInformation<O> type
The class of objects we store.
-
ids
private final StaticDBIDs ids
The DBIDs this is supposed to be defined for. Note: we only keep an unmodifiable reference.
-
name
private java.lang.String name
The relation name.
-
-
Constructor Detail
-
MaterializedRelation
public MaterializedRelation(SimpleTypeInformation<O> type, DBIDs ids)
Constructor.- Parameters:
type
- Type informationids
- IDs
-
MaterializedRelation
public MaterializedRelation(java.lang.String name, SimpleTypeInformation<O> type, DBIDs ids)
Constructor.- Parameters:
name
- Nametype
- Type informationids
- IDs
-
MaterializedRelation
public MaterializedRelation(java.lang.String name, SimpleTypeInformation<O> type, DBIDs ids, DataStore<O> content)
Constructor.- Parameters:
name
- Nametype
- Type informationids
- IDscontent
- Content
-
-
Method Detail
-
get
public O get(DBIDRef id)
Description copied from interface:Relation
Get the representation of an object.
-
insert
public void insert(DBIDRef id, O val)
Description copied from interface:ModifiableRelation
Set (or insert) an object representation.- Specified by:
insert
in interfaceModifiableRelation<O>
- Parameters:
id
- Object IDval
- Value
-
delete
public void delete(DBIDRef id)
Delete an objects values.- Specified by:
delete
in interfaceModifiableRelation<O>
- Parameters:
id
- ID to delete
-
getDBIDs
public StaticDBIDs getDBIDs()
Description copied from interface:Relation
Get the IDs the query is defined for.If possible, prefer
Relation.iterDBIDs()
.
-
iterDBIDs
public DBIDIter iterDBIDs()
Description copied from interface:Relation
Get an iterator access to the DBIDs.To iterate over all IDs, use the following code fragment:
for(DBIDIter iter = relation.iterDBIDs(); iter.valid(); iter.advance()) { relation.get(iter); // Get the current element }
-
size
public int size()
Description copied from interface:Relation
Get the number of DBIDs.
-
getDataTypeInformation
public SimpleTypeInformation<O> getDataTypeInformation()
Description copied from interface:Relation
Get the data type of this representation- Specified by:
getDataTypeInformation
in interfaceRelation<O>
- Returns:
- Data type
-
getLongName
public java.lang.String getLongName()
Description copied from interface:Relation
Get a long (human readable) name for the relation.- Specified by:
getLongName
in interfaceRelation<O>
- Returns:
- Relation name
-
-