com.neeve.query.index
Interface IdxField<RECORD,T>

Type Parameters:
RECORD - The record type
T - The field type
All Superinterfaces:
com.google.common.base.Function<RECORD,T>, Serializable
All Known Subinterfaces:
IStoreField<T>, RogLogQueryEngine.RogLogField<T>

public interface IdxField<RECORD,T>
extends com.google.common.base.Function<RECORD,T>, Serializable

An IdxField is used to identify an indexable field relative to a given RECORD type, and serves as a factory for Predicates against the field value.


Nested Class Summary
static class IdxField.KeyMapping<T>
           
 
Method Summary
 IdxField<RECORD,Double> average()
          Create an aggregate field that average of non-null values for this field, null otherwise.
 Predicate<RECORD> between(T lowValue, T highValue)
          Constructs a 'between' predicate for this field.
 T convertToFieldType(Object value)
          Attempts to convert the provided value to a type that is compatible with this field's type (getFieldType().
 IdxField<RECORD,Integer> count()
          Create an aggregate field that counts the non-null occurances of this field.
 Predicate<RECORD> equal(T value)
          Constructs an 'equals' predicate for this field.
 String getCanonicalName()
           
 double getCost()
          Return the cost of applying this field, normalized to the cost of retrieving the relevant record.
 String getFieldPath()
          Gets the field's bean accessor path relative to this fields record type.
 Class<T> getFieldType()
          Gets the type for this field.
 Class<?> getIndexKeyType()
          Gets the type of the value being indexed (may be different from the field type in the presence of a IdxField.KeyMapping
 IdxField.KeyMapping<T> getKeyMapping()
          Gets the key mapping assigned to this field.
 String getName()
          Gets the name of this field.
 Class<? extends RECORD> getRecordType()
          Gets the concrete type against which this field applies.
 Predicate<RECORD> getTypePredicate()
          Returns a constraint against the type(s) that match the field's path.
 Predicate<RECORD> greaterThan(T value)
          Constructs an 'greater than' predicate for this field.
 Predicate<RECORD> greaterThanOrEqual(T value)
          Constructs an 'greater than or equal to' predicate for this field.
 Predicate<RECORD> in(Collection<T> values)
          Constructs an 'in' predicate for this field.
 Predicate<RECORD> in(T... values)
          Constructs an 'in' predicate for this field.
 Predicate<RECORD> is(T value)
          Constructs an 'equals' predicate for this field.
 Predicate<RECORD> isNotNull()
          Constructs an 'IS NOT NULL' predicate against this field
 Predicate<RECORD> isNull()
          Constructs an 'IS NULL' predicate against this field
 boolean isQualified()
          Indicate whether the field is qualified (e.g.
 Predicate<RECORD> lessThan(T value)
          Constructs an 'less than' predicate for this field.
 Predicate<RECORD> lessThanOrEqual(T value)
          Constructs an 'less than or equal to' predicate for this field.
 Predicate<RECORD> like(T value)
          Constructs a 'like' predicatre for this field
 IdxField<RECORD,T> max()
          Create an aggregate field that maximum non-null value of this field, null otherwise.
 IdxField<RECORD,T> min()
          Create an aggregate field that minimum non-null value of this field, null otherwise.
 Predicate<RECORD> regexLike(T value)
          Constructs a 'regex_like' predicatre for this field
 void setKeyMapping(IdxField.KeyMapping<T> keyMapping)
          Assign a mapping from Field values their corresponding index keys.
 IdxField<RECORD,Double> sumDouble()
          Create an aggregate field that sum of non-null values for this field, null otherwise.
 IdxField<RECORD,Long> sumLong()
          Create an aggregate field that sum of non-null values for this field, null otherwise.
 void validateIndexable()
          Validates that this field is indexable.
 
Methods inherited from interface com.google.common.base.Function
apply, equals
 

Method Detail

getTypePredicate

Predicate<RECORD> getTypePredicate()
Returns a constraint against the type(s) that match the field's path.


getRecordType

Class<? extends RECORD> getRecordType()
Gets the concrete type against which this field applies.

Returns:
Gets the concrete type against which this field applies.

getFieldType

Class<T> getFieldType()
Gets the type for this field. This is the type that results from applying a field against an object.

Returns:
The field type.

getName

String getName()
Gets the name of this field. This is a friendly name for a field.

Returns:
The field name.

getFieldPath

String getFieldPath()
Gets the field's bean accessor path relative to this fields record type.

Returns:
Returns the bean path of this field.

equal

Predicate<RECORD> equal(T value)
Constructs an 'equals' predicate for this field.

Parameters:
value - The value to test against.
Returns:
An 'equals' predicate for this field.

is

Predicate<RECORD> is(T value)
Constructs an 'equals' predicate for this field. This is the same as equal(Object), but provided for greater fluency in query contsruction.

Parameters:
value - The value to test against.
Returns:
An 'equals' predicate for this field.

like

Predicate<RECORD> like(T value)
Constructs a 'like' predicatre for this field

Parameters:
value - The like mask to test against
Returns:
A 'like' predicate for this field.

regexLike

Predicate<RECORD> regexLike(T value)
Constructs a 'regex_like' predicatre for this field

Parameters:
value - The regex pattern to test against
Returns:
A 'regex_like' predicate for this field.

greaterThan

Predicate<RECORD> greaterThan(T value)
Constructs an 'greater than' predicate for this field.

Parameters:
value - The value to test against.
Returns:
An greater than predicate for this field.

greaterThanOrEqual

Predicate<RECORD> greaterThanOrEqual(T value)
Constructs an 'greater than or equal to' predicate for this field.

Parameters:
value - The value to test against.
Returns:
An 'greater than or equal to' predicate for this field.

lessThan

Predicate<RECORD> lessThan(T value)
Constructs an 'less than' predicate for this field.

Parameters:
value - The value to test against.
Returns:
An 'less than' predicate for this field.

lessThanOrEqual

Predicate<RECORD> lessThanOrEqual(T value)
Constructs an 'less than or equal to' predicate for this field.

Parameters:
value - The value to test against.
Returns:
An 'less than or equal to' predicate for this field.

between

Predicate<RECORD> between(T lowValue,
                          T highValue)
Constructs a 'between' predicate for this field.

Parameters:
lowValue - The low value to test against.
highValue - The high value to test against.
Returns:
An 'between' predicate for this field.

in

Predicate<RECORD> in(Collection<T> values)
Constructs an 'in' predicate for this field.

Parameters:
values - The values to test agains.
Returns:
An 'in' predicate for this field.

in

Predicate<RECORD> in(T... values)
Constructs an 'in' predicate for this field.

Parameters:
values - The values to test agains.
Returns:
An 'in' predicate for this field.

isNull

Predicate<RECORD> isNull()
Constructs an 'IS NULL' predicate against this field

Returns:
An 'IS NULL' predicate for this field.

isNotNull

Predicate<RECORD> isNotNull()
Constructs an 'IS NOT NULL' predicate against this field

Returns:
An 'IS NOT NULL' predicate for this field.

convertToFieldType

T convertToFieldType(Object value)
                     throws IllegalArgumentException
Attempts to convert the provided value to a type that is compatible with this field's type (getFieldType().

Parameters:
value - The value to convert
Returns:
A type that is compatible with this field's value type
Throws:
IllegalArgumentException - if the type is not convertible.

count

IdxField<RECORD,Integer> count()
Create an aggregate field that counts the non-null occurances of this field.


min

IdxField<RECORD,T> min()
Create an aggregate field that minimum non-null value of this field, null otherwise.


max

IdxField<RECORD,T> max()
Create an aggregate field that maximum non-null value of this field, null otherwise.


sumLong

IdxField<RECORD,Long> sumLong()
Create an aggregate field that sum of non-null values for this field, null otherwise.


sumDouble

IdxField<RECORD,Double> sumDouble()
Create an aggregate field that sum of non-null values for this field, null otherwise.


average

IdxField<RECORD,Double> average()
Create an aggregate field that average of non-null values for this field, null otherwise.


isQualified

boolean isQualified()
Indicate whether the field is qualified (e.g. Customer.firstName) or unqualified (e.g. firstName).

Returns:
whether the field is qualified

getCanonicalName

String getCanonicalName()
Returns:
The canonical name for the field

setKeyMapping

void setKeyMapping(IdxField.KeyMapping<T> keyMapping)
Assign a mapping from Field values their corresponding index keys. E.g. a Date might be mapped to its long value of milliseconds. In the absence of such a mapping the field value itself is used as the index key.

Parameters:
keyMapping - The key mapping to assign.

getKeyMapping

IdxField.KeyMapping<T> getKeyMapping()
Gets the key mapping assigned to this field. In the absence of such a mapping the field value itself is used as the index key and this method should return null.

Returns:
The key mapping or null if not set.

getIndexKeyType

Class<?> getIndexKeyType()
Gets the type of the value being indexed (may be different from the field type in the presence of a IdxField.KeyMapping

Returns:
The type of the value being indexed.

validateIndexable

void validateIndexable()
Validates that this field is indexable.

Throws:
Exception - If the field is not indexable.

getCost

double getCost()
Return the cost of applying this field, normalized to the cost of retrieving the relevant record. I.e. a cost of 1.0 would indicate that applying the field would take as long as retrieving the record.

Returns:
The cost of applying the field


Copyright © 2016 Neeve Research, LLC. All Rights Reserved.