Package alluxio.collections
Class NonUniqueFieldIndex<T,V>
- java.lang.Object
-
- alluxio.collections.NonUniqueFieldIndex<T,V>
-
- Type Parameters:
T
- type of objects in this indexV
- type of the field used for indexing
- All Implemented Interfaces:
FieldIndex<T,V>
,java.lang.Iterable<T>
@ThreadSafe public class NonUniqueFieldIndex<T,V> extends java.lang.Object implements FieldIndex<T,V>
A class representing a non-unique index. A non-unique index is an index where an index value can map to one or more objects.
-
-
Constructor Summary
Constructors Constructor Description NonUniqueFieldIndex(IndexDefinition<T,V> indexDefinition)
Constructs a newNonUniqueFieldIndex
instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T object)
Adds an object o to the index.void
clear()
Removes all the entries in this index.boolean
containsField(V fieldValue)
Returns whether there is an object with the specified index field value in the set.boolean
containsObject(T object)
Returns whether there is an object in the set.java.util.Set<T>
getByField(V value)
Gets a subset of objects with the specified field value.T
getFirst(V value)
Gets an object from the set of objects with the specified field value.java.util.Iterator<T>
iterator()
Returns an iterator over the elements in this index.boolean
remove(T object)
Removes the object o from the index.int
size()
-
-
-
Constructor Detail
-
NonUniqueFieldIndex
public NonUniqueFieldIndex(IndexDefinition<T,V> indexDefinition)
Constructs a newNonUniqueFieldIndex
instance.- Parameters:
indexDefinition
- definition of index
-
-
Method Detail
-
add
public boolean add(T object)
Description copied from interface:FieldIndex
Adds an object o to the index.- Specified by:
add
in interfaceFieldIndex<T,V>
- Parameters:
object
- the object to add to the index- Returns:
- true if object is added successfully, false otherwise
-
remove
public boolean remove(T object)
Description copied from interface:FieldIndex
Removes the object o from the index.- Specified by:
remove
in interfaceFieldIndex<T,V>
- Parameters:
object
- the object to remove from index- Returns:
- whether the specified element was in the index
-
clear
public void clear()
Description copied from interface:FieldIndex
Removes all the entries in this index.- Specified by:
clear
in interfaceFieldIndex<T,V>
-
containsField
public boolean containsField(V fieldValue)
Description copied from interface:FieldIndex
Returns whether there is an object with the specified index field value in the set.- Specified by:
containsField
in interfaceFieldIndex<T,V>
- Parameters:
fieldValue
- the field value to be satisfied- Returns:
- true if there is one such object, otherwise false
-
containsObject
public boolean containsObject(T object)
Description copied from interface:FieldIndex
Returns whether there is an object in the set.- Specified by:
containsObject
in interfaceFieldIndex<T,V>
- Parameters:
object
- the object to be checked- Returns:
- true if there is one such object, otherwise false
-
getByField
public java.util.Set<T> getByField(V value)
Description copied from interface:FieldIndex
Gets a subset of objects with the specified field value. If there is no object with the specified field value, an empty set is returned.- Specified by:
getByField
in interfaceFieldIndex<T,V>
- Parameters:
value
- the field value to be satisfied- Returns:
- the set of objects or an empty set if no such object exists
-
getFirst
public T getFirst(V value)
Description copied from interface:FieldIndex
Gets an object from the set of objects with the specified field value.- Specified by:
getFirst
in interfaceFieldIndex<T,V>
- Parameters:
value
- the field value to be satisfied- Returns:
- the object or null if there is no such object
-
iterator
public java.util.Iterator<T> iterator()
Description copied from interface:FieldIndex
Returns an iterator over the elements in this index. The elements are returned in no particular order. Note that the behavior of the iterator is unspecified if the underlying collection is modified while a thread is going through the iterator.- Specified by:
iterator
in interfaceFieldIndex<T,V>
- Specified by:
iterator
in interfacejava.lang.Iterable<T>
- Returns:
- an iterator over the elements in this
FieldIndex
-
size
public int size()
- Specified by:
size
in interfaceFieldIndex<T,V>
- Returns:
- the number of objects in this index set
-
-