Package elki.database.relation
Class RelationUtil
- java.lang.Object
-
- elki.database.relation.RelationUtil
-
public final class RelationUtil extends java.lang.Object
Utility functions for handling database relation.- Since:
- 0.5.5
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
RelationUtil.AscendingByDoubleRelation
Sort objects by a double relationstatic class
RelationUtil.CollectionFromRelation<O>
Collection view on a database that retrieves the objects when needed.static class
RelationUtil.DescendingByDoubleRelation
Sort objects by a double relationstatic class
RelationUtil.RelationObjectIterator<O>
Iterator class that retrieves the given objects from the database.
-
Constructor Summary
Constructors Modifier Constructor Description private
RelationUtil()
Fake constructor: do not instantiate.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <V extends FeatureVector<?>>
VectorFieldTypeInformation<V>assumeVectorField(Relation<V> relation)
Get the vector field type information from a relation.static double[][]
computeMinMax(Relation<? extends NumberVector> relation)
Determines the minimum and maximum values in each dimension of all objects stored in the given database.static int
dimensionality(Relation<? extends SpatialComparable> relation)
Get the dimensionality of a database relation.static <V extends SpatialComparable>
java.lang.StringgetColumnLabel(Relation<? extends V> rel, int col)
Get the column name or produce a generic label "Column XY".static <V extends NumberVector>
NumberVector.Factory<V>getNumberVectorFactory(Relation<V> relation)
Get the number vector factory of a database relation.static int
maxDimensionality(Relation<? extends SpatialComparable> relation)
Get the dimensionality of a database relation.static double[][]
relationAsMatrix(Relation<? extends NumberVector> relation, ArrayDBIDs ids)
Copy a relation into a double matrix.static <V extends NumberVector,T extends NumberVector>
Relation<V>relationUglyVectorCast(Relation<T> database)
An ugly vector type cast unavoidable in some situations due to Generics.
-
-
-
Method Detail
-
assumeVectorField
public static <V extends FeatureVector<?>> VectorFieldTypeInformation<V> assumeVectorField(Relation<V> relation)
Get the vector field type information from a relation.- Type Parameters:
V
- Vector type- Parameters:
relation
- relation- Returns:
- Vector field type information
-
getNumberVectorFactory
public static <V extends NumberVector> NumberVector.Factory<V> getNumberVectorFactory(Relation<V> relation)
Get the number vector factory of a database relation.- Type Parameters:
V
- Vector type- Parameters:
relation
- relation- Returns:
- Vector field type information
-
dimensionality
public static int dimensionality(Relation<? extends SpatialComparable> relation)
Get the dimensionality of a database relation.- Parameters:
relation
- relation- Returns:
- Database dimensionality
-
maxDimensionality
public static int maxDimensionality(Relation<? extends SpatialComparable> relation)
Get the dimensionality of a database relation.- Parameters:
relation
- relation- Returns:
- Database dimensionality
-
computeMinMax
public static double[][] computeMinMax(Relation<? extends NumberVector> relation)
Determines the minimum and maximum values in each dimension of all objects stored in the given database.- Parameters:
relation
- the database storing the objects- Returns:
- Minimum and Maximum vector for the hyperrectangle
-
relationAsMatrix
public static double[][] relationAsMatrix(Relation<? extends NumberVector> relation, ArrayDBIDs ids)
Copy a relation into a double matrix.This is not recommended unless you need to modify the data temporarily.
- Parameters:
relation
- Relationids
- IDs, with well-defined order (i.e. array)- Returns:
- Data matrix
-
getColumnLabel
public static <V extends SpatialComparable> java.lang.String getColumnLabel(Relation<? extends V> rel, int col)
Get the column name or produce a generic label "Column XY".- Type Parameters:
V
- Vector type- Parameters:
rel
- Relationcol
- Column- Returns:
- Label
-
relationUglyVectorCast
public static <V extends NumberVector,T extends NumberVector> Relation<V> relationUglyVectorCast(Relation<T> database)
An ugly vector type cast unavoidable in some situations due to Generics.- Type Parameters:
V
- Base vector typeT
- Derived vector type (is actually V, too)- Parameters:
database
- Database- Returns:
- Database
-
-