| Interface | Description |
|---|---|
| Index<V,T> |
An index on a single field.
|
| Index2<V1,V2,T> |
An index on two fields.
|
| Index3<V1,V2,V3,T> |
An index on three fields.
|
| Index4<V1,V2,V3,V4,T> |
An index on a four fields.
|
Indexes provide fast lookup of objects based on field value(s). The Index* interfaces in this package have
generic type parameters that correspond to the field value type(s), plus a final generic type parameter
corresponding to the "target type". For example, an index on field int getAccountNumber() of type
User will be represented by a Index<Integer, User>, and may be viewed
either as a NavigableSet<Tuple2<Integer, User>>
or a NavigableMap<Integer, NavigableSet<User>>.
Simple and Composite Indexes
A simple index on a single field value is created by setting indexed="true" on the
@JField annotation.
Composite indexes on multiple fields are also supported. These are useful when the target type needs to be sorted
on multiple fields; for simple searching on multiple fields, it suffices to have independent, single-field indexes,
which can be intersected via NavigableSets.intersection(), etc.
A composite index on two fields String getUsername() and float getBalance() of type User
will be represented by a Index2<String, Float, User>; a composite index on
three fields of type X, Y, and Z by a Index3<X, Y, Z, User>, etc.
A composite index may be viewed as a set of tuples of indexed and target values, or as various mappings from one or more indexed field values to subsequent values. A composite index may also be viewed as a simpler index on any prefix of the indexed fields.
Complex Sub-Fields
Only simple fields may be indexed, but the indexed field can be either a normal object field or a sub-field of
a complex Set, List, or Map field. However,
complex sub-fields may not appear in composite indexes.
For those complex sub-fields that can contain duplicate values (namely, List element and
Map value), the associated distinguishing value (respectively, List index
and Map key) is appended to the index and becomes the new target type.
Therefore the resulting index types associated with indexes on complex sub-fields are follows:
Copyright © 2016. All rights reserved.