本文整理汇总了Java中com.googlecode.cqengine.IndexedCollection.retrieve方法的典型用法代码示例。如果您正苦于以下问题:Java IndexedCollection.retrieve方法的具体用法?Java IndexedCollection.retrieve怎么用?Java IndexedCollection.retrieve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.googlecode.cqengine.IndexedCollection
的用法示例。
在下文中一共展示了IndexedCollection.retrieve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrieve
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
public void retrieve() {
IndexedCollection<EntityHandle<Car>> cars = new ConcurrentIndexedCollection<>();
// Add some indexes...
UniqueIndex index = onAttribute(Car.FEATURES);
cars.addIndex(index);
index.clear(noQueryOptions());
// Add some objects to the collection...
cars.add(new ResolvedEntityHandle<>(new Car(1, "ford focus", "foo", Arrays.asList("spare tyre", "sunroof"))));
cars.add(new ResolvedEntityHandle<>(new Car(2, "ford taurus", "bar", Arrays.asList("radio", "cd player"))));
ResultSet<EntityHandle<Car>> radio = cars.retrieve(equal(Car.FEATURES, "radio"));
assertEquals(radio.size(), 1);
radio.close();
ResultSet<EntityHandle<Car>> unknown = cars.retrieve(equal(Car.FEATURES, "unknown"));
assertEquals(unknown.size(), 0);
unknown.close();
index.clear(noQueryOptions());
}
示例2: matchesSimpleAttribute
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Override
protected boolean matchesSimpleAttribute(SimpleAttribute<O, HybridTimestamp> attribute, O object, QueryOptions
queryOptions) {
Query<O> actualQuery = query == null ? queryFunction.apply(object) : query;
Optional<Boolean> terminatedQuery = terminatedQuery(object, actualQuery, queryOptions);
if (terminatedQuery.isPresent()) {
return terminatedQuery.get();
}
HybridTimestamp value = attribute.getValue(object, queryOptions);
IndexedCollection<O> collection = (IndexedCollection<O>) getCollection(queryOptions);
try (ResultSet<O> resultSet = collection.retrieve(and(
actualQuery,
greaterThan(timestampAttribute, value)))) {
return matches(resultSet, actualQuery, object, queryOptions);
}
}
示例3: matchesNonSimpleAttribute
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Override
protected boolean matchesNonSimpleAttribute(Attribute<O, HybridTimestamp> attribute, O object, QueryOptions
queryOptions) {
Query<O> actualQuery = query == null ? queryFunction.apply(object) : query;
Optional<Boolean> terminatedQuery = terminatedQuery(object, actualQuery, queryOptions);
if (terminatedQuery.isPresent()) {
return terminatedQuery.get();
}
Iterable<HybridTimestamp> values = attribute.getValues(object, queryOptions);
List<Query<O>> conditions = StreamSupport.stream(values.spliterator(), false)
.map(v -> greaterThan(timestampAttribute, v))
.collect(Collectors.toList());
Query<O> timestampQuery = conditions.size() == 1 ? conditions.get(0) : new Or<>(conditions);
IndexedCollection<O> collection = (IndexedCollection<O>) getCollection(queryOptions);
try (ResultSet<O> resultSet = collection.retrieve(and(
actualQuery,
timestampQuery))) {
return matches(resultSet, actualQuery, object, queryOptions);
}
}
示例4: indexingExistingData
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
public void indexingExistingData() {
IndexedCollection<EntityHandle<Car>> cars = new ConcurrentIndexedCollection<>();
UniqueIndex index = onAttribute(Car.FEATURES);
index.clear(noQueryOptions());
// Add some objects to the collection...
cars.add(new ResolvedEntityHandle<>(new Car(1, "ford focus", "foo", Arrays.asList("spare tyre", "sunroof"))));
cars.add(new ResolvedEntityHandle<>(new Car(2, "ford taurus", "bar", Arrays.asList("radio", "cd player"))));
// Add some indexes...
cars.addIndex(index);
ResultSet<EntityHandle<Car>> radio = cars.retrieve(equal(Car.FEATURES, "radio"));
assertEquals(radio.size(), 1);
radio.close();
ResultSet<EntityHandle<Car>> unknown = cars.retrieve(equal(Car.FEATURES, "unknown"));
assertEquals(unknown.size(), 0);
unknown.close();
index.clear(noQueryOptions());
}
示例5: reindexData
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
public void reindexData() {
IndexedCollection<EntityHandle<Car>> cars = new ConcurrentIndexedCollection<>();
UniqueIndex index = onAttribute(Car.FEATURES);
index.clear(noQueryOptions());
// Add some objects to the collection...
cars.add(new ResolvedEntityHandle<>(new Car(1, "ford focus", "foo", Arrays.asList("spare tyre", "sunroof"))));
cars.add(new ResolvedEntityHandle<>(new Car(2, "ford taurus", "bar", Arrays.asList("radio", "cd player"))));
cars.addIndex(index);
IndexedCollection<EntityHandle<Car>> cars1 = new ConcurrentIndexedCollection<>();
UniqueIndex index1 = onAttribute(Car.FEATURES);
cars1.addAll(cars);
cars1.addIndex(index1);
ResultSet<EntityHandle<Car>> radio = cars.retrieve(equal(Car.FEATURES, "radio"));
assertEquals(radio.size(), 1);
radio.close();
index.clear(noQueryOptions());
index1.clear(noQueryOptions());
}
示例6: retrieveLess
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
public void retrieveLess() {
IndexedCollection<EntityHandle<Car>> collection = new ConcurrentIndexedCollection<>();
SortedKeyStatisticsIndex<String, EntityHandle<Car>> PRICE_INDEX = onAttribute(Car.PRICE);
PRICE_INDEX.clear(noQueryOptions());
collection.addIndex(PRICE_INDEX);
collection.addAll(CarFactory.createCollectionOfCars(10));
try (ResultSet<EntityHandle<Car>> resultSet = collection.retrieve(lessThan(Car.PRICE, 3999.99))) {
assertEquals(resultSet.size(), 1);
assertEquals(resultSet.uniqueResult().get().getModel(), "Accord");
}
try (ResultSet<EntityHandle<Car>> resultSet = collection.retrieve(lessThanOrEqualTo(Car.PRICE, 3999.99))) {
assertEquals(resultSet.size(), 2);
ArrayList<EntityHandle<Car>> values = Lists.newArrayList(resultSet.iterator());
assertTrue(values.stream().anyMatch(h -> h.get().getModel().contentEquals("Fusion")));
assertTrue(values.stream().anyMatch(h -> h.get().getModel().contentEquals("Accord")));
}
}
示例7: retrieveGreater
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
public void retrieveGreater() {
IndexedCollection<EntityHandle<Car>> collection = new ConcurrentIndexedCollection<>();
SortedKeyStatisticsIndex<String, EntityHandle<Car>> PRICE_INDEX = onAttribute(Car.PRICE);
PRICE_INDEX.clear(noQueryOptions());
collection.addIndex(PRICE_INDEX);
collection.addAll(CarFactory.createCollectionOfCars(10));
try (ResultSet<EntityHandle<Car>> resultSet = collection.retrieve(greaterThan(Car.PRICE, 8500.00))) {
assertEquals(resultSet.size(), 1);
assertEquals(resultSet.uniqueResult().get().getModel(), "M6");
}
try (ResultSet<EntityHandle<Car>> resultSet = collection.retrieve(greaterThanOrEqualTo(Car.PRICE, 8500.00))) {
assertEquals(resultSet.size(), 2);
ArrayList<EntityHandle<Car>> values = Lists.newArrayList(resultSet.iterator());
assertTrue(values.stream().anyMatch(h -> h.get().getModel().contentEquals("M6")));
assertTrue(values.stream().anyMatch(h -> h.get().getModel().contentEquals("Prius")));
}
}
示例8: retrieveBetween
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
public void retrieveBetween() {
IndexedCollection<EntityHandle<Car>> collection = new ConcurrentIndexedCollection<>();
SortedKeyStatisticsIndex<String, EntityHandle<Car>> PRICE_INDEX = onAttribute(Car.PRICE);
PRICE_INDEX.clear(noQueryOptions());
collection.addIndex(PRICE_INDEX);
collection.addAll(CarFactory.createCollectionOfCars(10));
try (ResultSet<EntityHandle<Car>> resultSet = collection.retrieve(between(Car.PRICE, 8000.00, 9001.00))) {
assertEquals(resultSet.size(), 2);
ArrayList<EntityHandle<Car>> values = Lists.newArrayList(resultSet.iterator());
assertTrue(values.stream().anyMatch(h -> h.get().getModel().contentEquals("M6")));
assertTrue(values.stream().anyMatch(h -> h.get().getModel().contentEquals("Prius")));
}
}
示例9: indexQuantization_SpanningTwoBucketsMidRange
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
public void indexQuantization_SpanningTwoBucketsMidRange() {
IndexedCollection<EntityHandle<Car>> collection = new ConcurrentIndexedCollection<>();
Index<EntityHandle<Car>> index = withQuantizerOnAttribute(IntegerQuantizer.withCompressionFactor(10),
Car.CAR_ID);
index.clear(noQueryOptions());
collection.addIndex(index);
collection.addAll(CarFactory.createCollectionOfCars(100));
// Merge cost should be 20 because this query spans 2 buckets (each containing 10 objects)...
ResultSet<EntityHandle<Car>> resultSet = collection.retrieve(between(Car.CAR_ID, 47, 53));
assertEquals(resultSet.getMergeCost(), 20);
resultSet.close();
// 7 objects match the query (between is inclusive)...
resultSet = collection.retrieve(between(Car.CAR_ID, 47, 53));
assertEquals(resultSet.size(), 7);
resultSet.close();
// The matching objects are...
List<Integer> carIdsFound = retrieveCarIds(collection, between(Car.CAR_ID, 47, 53));
assertEquals(carIdsFound, asList(47, 48, 49, 50, 51, 52, 53));
}
示例10: indexQuantization_FirstBucket
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
public void indexQuantization_FirstBucket() {
IndexedCollection<EntityHandle<Car>> collection = new ConcurrentIndexedCollection<>();
Index<EntityHandle<Car>> index = withQuantizerOnAttribute(IntegerQuantizer.withCompressionFactor(10),
Car.CAR_ID);
index.clear(noQueryOptions());
collection.addIndex(index);
collection.addAll(CarFactory.createCollectionOfCars(100));
// Merge cost should be 10, because objects matching this query are in a single bucket...
ResultSet<EntityHandle<Car>> resultSet = collection.retrieve(between(Car.CAR_ID, 2, 4));
assertEquals(resultSet.getMergeCost(), 10);
resultSet.close();
// 3 objects match the query...
resultSet = collection.retrieve(between(Car.CAR_ID, 2, 4));
assertEquals(resultSet.size(), 3);
resultSet.close();
List<Integer> carIdsFound = retrieveCarIds(collection, between(Car.CAR_ID, 2, 4));
assertEquals(carIdsFound, asList(2, 3, 4));
}
示例11: indexQuantization_LastBucket
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
public void indexQuantization_LastBucket() {
IndexedCollection<EntityHandle<Car>> collection = new ConcurrentIndexedCollection<>();
Index<EntityHandle<Car>> index = withQuantizerOnAttribute(IntegerQuantizer.withCompressionFactor(10),
Car.CAR_ID);
index.clear(noQueryOptions());
collection.addIndex(index);
collection.addAll(CarFactory.createCollectionOfCars(100));
// Merge cost should be 10, because objects matching this query are in a single bucket...
ResultSet<EntityHandle<Car>> resultSet = collection.retrieve(between(Car.CAR_ID, 96, 98));
assertEquals(resultSet.getMergeCost(), 10);
resultSet.close();
// 3 objects match the query...
resultSet = collection.retrieve(between(Car.CAR_ID, 96, 98));
assertEquals(resultSet.size(), 3);
resultSet.close();
List<Integer> carIdsFound = retrieveCarIds(collection, between(Car.CAR_ID, 96, 98));
assertEquals(carIdsFound, asList(96, 97, 98));
}
示例12: indexQuantization_ComplexQuery
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
public void indexQuantization_ComplexQuery() {
IndexedCollection<EntityHandle<Car>> collection = new ConcurrentIndexedCollection<>();
Index<EntityHandle<Car>> index = withQuantizerOnAttribute(IntegerQuantizer.withCompressionFactor(10),
Car.CAR_ID);
index.clear(noQueryOptions());
collection.addIndex(index);
collection.addAll(CarFactory.createCollectionOfCars(100));
Query<EntityHandle<Car>> query = and(between(Car.CAR_ID, 96, 98), greaterThan(Car.CAR_ID, 95));
// 3 objects match the query...
ResultSet<EntityHandle<Car>> resultSet = collection.retrieve(query);
assertEquals(resultSet.size(), 3);
resultSet.close();
List<Integer> carIdsFound = retrieveCarIds(collection, query);
assertEquals(carIdsFound, asList(96, 97, 98));
// Merge cost should be 10, because objects matching this query are in a single bucket...
resultSet = collection.retrieve(query);
assertEquals(resultSet.getMergeCost(), 10);
resultSet.close();
}
示例13: retrieveEqual
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
public void retrieveEqual() {
IndexedCollection<EntityHandle<Car>> collection = new ConcurrentIndexedCollection<>();
KeyStatisticsIndex<String, EntityHandle<Car>> MANUFACTURER_INDEX =
(KeyStatisticsIndex<String, EntityHandle<Car>>) onAttribute(Car.MANUFACTURER);
MANUFACTURER_INDEX.clear(noQueryOptions());
collection.addIndex(MANUFACTURER_INDEX);
collection.addAll(CarFactory.createCollectionOfCars(10));
ResultSet<EntityHandle<Car>> cars = collection.retrieve(equal(Car.MANUFACTURER, "Honda"));
assertTrue(cars.isNotEmpty());
assertTrue(streamOf(cars).allMatch(car -> car.get().getManufacturer().contentEquals("Honda")));
cars.close();
MANUFACTURER_INDEX.clear(noQueryOptions());
}
示例14: byteArrayEquality
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
public void byteArrayEquality() {
IndexedCollection<EntityHandle<Car>> collection = createIndexedCollection(Car.class);
SimpleAttribute<Car, byte[]> attr = new SimpleAttribute<Car, byte[]>(Car.class,
(Class<EntityHandle<Car>>) ((Class<?>)getClass()),
byte[].class, "bytearray") {
@Override public byte[] getValue(Car object, QueryOptions queryOptions) {
return object.getManufacturer().getBytes();
}
};
HashIndex index = onAttribute(attr);
index.clear(noQueryOptions());
collection.addIndex(index);
collection.addAll(CarFactory.createCollectionOfCars(10));
ResultSet<EntityHandle<Car>> cars = collection.retrieve(equal(attr, "Honda".getBytes()));
assertTrue(cars.isNotEmpty());
assertTrue(streamOf(cars).allMatch(car -> car.get().getManufacturer().contentEquals("Honda")));
cars.close();
index.clear(noQueryOptions());
}
示例15: indexExistingData
import com.googlecode.cqengine.IndexedCollection; //导入方法依赖的package包/类
@Test
public void indexExistingData() {
IndexedCollection<EntityHandle<Car>> collection = new ConcurrentIndexedCollection<>();
KeyStatisticsIndex<String, EntityHandle<Car>> MANUFACTURER_INDEX =
(KeyStatisticsIndex<String, EntityHandle<Car>>) onAttribute(Car.MANUFACTURER);
MANUFACTURER_INDEX.clear(noQueryOptions());
collection.addAll(CarFactory.createCollectionOfCars(10));
collection.addIndex(MANUFACTURER_INDEX);
ResultSet<EntityHandle<Car>> cars = collection.retrieve(equal(Car.MANUFACTURER, "Honda"));
assertTrue(cars.isNotEmpty());
assertTrue(streamOf(cars).allMatch(car -> car.get().getManufacturer().contentEquals("Honda")));
cars.close();
MANUFACTURER_INDEX.clear(noQueryOptions());
}