Class Index
- Direct Known Subclasses:
CompositeIndex
,SimpleIndex
ObjType
.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Encoding<T>
genericize
(Encoding<T> encoding) Genericize the given encoding for use in a index.Get the field encoding(s).List<SimpleField<?>>
Get the indexed field(s).abstract AbstractCoreIndex<ObjId>
getIndex
(Transaction tx) Get this index's view of the given transaction.byte[]
Get thebyte[]
key in the underlying key/value store corresponding to the given value tuple and target object in this index.byte[]
Get thebyte[]
key in the underlying key/value store corresponding to the given value tuple in this index.Get the object type that contains the field(s) in this index.boolean
Determine whether this is a composite index, i.e., and index on two or more fields.toString()
abstract <R> R
visit
(IndexSwitch<R> target) Apply visitor pattern.Methods inherited from class io.permazen.core.SchemaItem
getName, getSchema, getSchemaId, getStorageId
-
Method Details
-
getObjType
Get the object type that contains the field(s) in this index.- Returns:
- indexed fields' object type
-
getFields
Get the indexed field(s).- Returns:
- list of indexed fields
-
getEncodings
Get the field encoding(s).Note that the core API treats reference fields with the same name as the same field, regardless of their object type restrictions. Therefore, the encodings in an index corresponding to reference fields do not have type restrictions and therefore can be different from the encodings associated with the fields themselves.
- Returns:
- list of indexed fields
-
isComposite
public boolean isComposite()Determine whether this is a composite index, i.e., and index on two or more fields.- Returns:
- true if composite
-
getIndex
Get this index's view of the given transaction.- Parameters:
tx
- transaction- Returns:
- view of this index in
tx
- Throws:
IllegalArgumentException
- iftx
is null
-
getKey
Get thebyte[]
key in the underlying key/value store corresponding to the given value tuple in this index.The returned key will be the prefix of all index entries with the given value tuple over all objects.
- Parameters:
values
- indexed values- Returns:
- the corresponding
KVDatabase
key - Throws:
IllegalArgumentException
- ifvalues
is nullIllegalArgumentException
- ifvalues
has the wrong length for this indexIllegalArgumentException
- if any value invalues
has the wrong type- See Also:
-
getKey
Get thebyte[]
key in the underlying key/value store corresponding to the given value tuple and target object in this index.- Parameters:
id
- target object IDvalues
- indexed values- Returns:
- the corresponding
KVDatabase
key - Throws:
IllegalArgumentException
- ifvalues
is nullIllegalArgumentException
- ifvalues
has the wrong length for this indexIllegalArgumentException
- if any value invalues
has the wrong type- See Also:
-
visit
Apply visitor pattern.- Type Parameters:
R
- visitor return type- Parameters:
target
- target to invoke- Returns:
- return value from the method of
target
corresponding to this instance's type - Throws:
NullPointerException
- iftarget
is null
-
toString
- Specified by:
toString
in classSchemaItem
-
genericize
Genericize the given encoding for use in a index.For encodings other than
ReferenceEncoding
, this just returns the given encoding unchanged. ForReferenceEncoding
, this returns the encoding with all type restrictions removed. This is required because the type restrictions associated with reference fields are allowed to vary across schemas without changing the identity of the field. When querying indexes, reference fields are instead restricted according to the types specified in the query.- Parameters:
encoding
- simple field encoding- Returns:
encoding
genericized for use in an index, orencoding
itself if no change is needed
-