Java Code Examples for com.googlecode.cqengine.attribute.Attribute#getValues()
The following examples show how to use
com.googlecode.cqengine.attribute.Attribute#getValues() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LongestPrefix.java From cqengine with Apache License 2.0 | 6 votes |
@Override public Iterable<O> getMatchesForNonSimpleAttribute(Attribute<O, A> attribute, ObjectSet<O> objectsInCollection, QueryOptions queryOptions) { List<O> results = new ArrayList<>(); int currentCount = -1; for (O object : objectsInCollection) { Iterable<A> attributeValues = attribute.getValues(object, queryOptions); for (A attributeValue : attributeValues) { int count = countPrefixChars(value, attributeValue); if (count == 0) { continue; } if (count > currentCount) { currentCount = count; results.clear(); results.add(object); } else if (count == currentCount) { results.add(object); } } } return results; }
Example 2
Source File: StringIsContainedIn.java From cqengine with Apache License 2.0 | 5 votes |
@Override protected boolean matchesNonSimpleAttribute(Attribute<O, A> attribute, O object, QueryOptions queryOptions) { for (A attributeValue : attribute.getValues(object, queryOptions)) { // Same as string contains, except we swap the arguments... if (StringContains.containsFragment(value, attributeValue)) { return true; } } return false; }
Example 3
Source File: Equal.java From cqengine with Apache License 2.0 | 5 votes |
@Override protected boolean matchesNonSimpleAttribute(Attribute<O, A> attribute, O object, QueryOptions queryOptions) { for (A attributeValue : attribute.getValues(object, queryOptions)) { if (value.equals(attributeValue)) { return true; } } return false; }
Example 4
Source File: StringContains.java From cqengine with Apache License 2.0 | 5 votes |
@Override protected boolean matchesNonSimpleAttribute(Attribute<O, A> attribute, O object, QueryOptions queryOptions) { for (A attributeValue : attribute.getValues(object, queryOptions)) { if (containsFragment(attributeValue, value)) { return true; } } return false; }
Example 5
Source File: StringIsPrefixOf.java From cqengine with Apache License 2.0 | 5 votes |
@Override protected boolean matchesNonSimpleAttribute(Attribute<O, A> attribute, O object, QueryOptions queryOptions) { for (A attributeValue : attribute.getValues(object, queryOptions)) { if (StringStartsWith.matchesValue(value, attributeValue, queryOptions)) { return true; } } return false; }
Example 6
Source File: Has.java From cqengine with Apache License 2.0 | 5 votes |
@Override protected boolean matchesNonSimpleAttribute(Attribute<O, A> attribute, O object, QueryOptions queryOptions) { for (A attributeValue : attribute.getValues(object, queryOptions)) { if (attributeValue != null) { return true; } } return false; }
Example 7
Source File: In.java From cqengine with Apache License 2.0 | 5 votes |
@Override protected boolean matchesNonSimpleAttribute(Attribute<O, A> attribute, O object, QueryOptions queryOptions) { for (A attributeValue : attribute.getValues(object, queryOptions)) { if (values.contains(attributeValue)) { return true; } } return false; }
Example 8
Source File: StringEndsWith.java From cqengine with Apache License 2.0 | 5 votes |
@Override protected boolean matchesNonSimpleAttribute(Attribute<O, A> attribute, O object, QueryOptions queryOptions) { for (A attributeValue : attribute.getValues(object, queryOptions)) { if (matchesValue(attributeValue, queryOptions)) { return true; } } return false; }
Example 9
Source File: StringStartsWith.java From cqengine with Apache License 2.0 | 5 votes |
@Override protected boolean matchesNonSimpleAttribute(Attribute<O, A> attribute, O object, QueryOptions queryOptions) { for (A attributeValue : attribute.getValues(object, queryOptions)) { if (matchesValue(attributeValue, value, queryOptions)) { return true; } } return false; }
Example 10
Source File: StringMatchesRegex.java From cqengine with Apache License 2.0 | 5 votes |
@Override protected boolean matchesNonSimpleAttribute(Attribute<O, A> attribute, O object, QueryOptions queryOptions) { for (A attributeValue : attribute.getValues(object, queryOptions)) { if (matchesValue(attributeValue, queryOptions)) { return true; } } return false; }
Example 11
Source File: Min.java From cqengine with Apache License 2.0 | 5 votes |
@Override public Iterable<O> getMatchesForNonSimpleAttribute(Attribute<O, A> attribute, ObjectSet<O> objectsInCollection, QueryOptions queryOptions) { A minimumValue = null; Set<O> results = new HashSet<>(); for (O object : objectsInCollection) { Iterable<A> attributeValues = attribute.getValues(object, queryOptions); for (A attributeValue : attributeValues) { minimumValue = evaluate(object, attributeValue, minimumValue, results); } } return results; }
Example 12
Source File: Max.java From cqengine with Apache License 2.0 | 5 votes |
@Override public Iterable<O> getMatchesForNonSimpleAttribute(Attribute<O, A> attribute, ObjectSet<O> objectsInCollection, QueryOptions queryOptions) { A maximumValue = null; Set<O> results = new HashSet<>(); for (O object : objectsInCollection) { Iterable<A> attributeValues = attribute.getValues(object, queryOptions); for (A attributeValue : attributeValues) { maximumValue = evaluate(object, attributeValue, maximumValue, results); } } return results; }
Example 13
Source File: CompoundAttribute.java From cqengine with Apache License 2.0 | 5 votes |
/** * Returns a list of {@link CompoundValueTuple} objects for the given object, containing all possible combinations * of attribute values against which the object can be indexed. * <p/> * See documentation on this class itself for details of the algorithm used to generate these tuples. * * @param object The object from which all {@link com.googlecode.cqengine.index.compound.support.CompoundValueTuple}s are required * @param queryOptions * @return tuples representing all possible combinations of attribute values against which the object can be indexed */ @Override public Iterable<CompoundValueTuple<O>> getValues(O object, QueryOptions queryOptions) { // STEP 1. // For each individual attribute comprising the compound attribute, // ask the attribute to return a list of values for the field it references in the object. // We get a list of values for each field because, because some fields can have multiple values, // as supported by MultiValueAttribute. We end up with List<List<Object>>, the outer list containing // individual lists of values from each attribute, inner lists containing values... List<Iterable<Object>> attributeValueLists = new ArrayList<Iterable<Object>>(attributes.size()); for (Attribute<O, ?> attribute : attributes) { @SuppressWarnings({"unchecked"}) Iterable<Object> values = (Iterable<Object>) attribute.getValues(object, queryOptions); attributeValueLists.add(values); } // STEP 2. // Generate all combinations of attribute values across these attributes. // For example, if we have the following lists of values from attributes: // Values for first attribute: 1 // Values for second attribute: "bar", "baz" // Values for third attribute: 2.0, 3.0, 4.0 // ...then we should generate and index the object against the following tuples: // [[1, bar, 2.0], [1, bar, 3.0], [1, bar, 4.0], [1, baz, 2.0], [1, baz, 3.0], [1, baz, 4.0]] List<List<Object>> listsOfValueCombinations = TupleCombinationGenerator.generateCombinations(attributeValueLists); // STEP 3. // Wrap each of the unique combinations in a CompoundValueTuple object... List<CompoundValueTuple<O>> tuples = new ArrayList<CompoundValueTuple<O>>(listsOfValueCombinations.size()); for (List<Object> valueCombination : listsOfValueCombinations) { tuples.add(new CompoundValueTuple<O>(valueCombination)); } // Return the list of CompoundValueTuple objects... return tuples; }
Example 14
Source File: TestUtil.java From cqengine with Apache License 2.0 | 5 votes |
/** * Returns the values of the given attribute in objects returned by the given result set. * <p/> * The set returned preserves the order of objects returned by the result set, but eliminates duplicates. */ @SuppressWarnings({"JavaDoc"}) public static <O, A> Set<A> valuesOf(Attribute<O, A> attribute, ResultSet<O> resultSet) { Set<A> attributeValues = new LinkedHashSet<A>(); for (O object : resultSet) { for (A value : attribute.getValues(object, noQueryOptions())) { attributeValues.add(value); } } return attributeValues; }