Java Code Examples for com.googlecode.cqengine.query.option.QueryOptions#put()

The following examples show how to use com.googlecode.cqengine.query.option.QueryOptions#put() . 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: CloseableRequestResources.java    From cqengine with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an existing {@link CloseableRequestResources} from the QueryOptions, or adds a new
 * instance to the query options and returns that.
 *
 * @param queryOptions The {@link QueryOptions}
 * @return The existing QueryOptions's CloseableRequestResources or a new instance.
 */
public static CloseableRequestResources forQueryOptions(final QueryOptions queryOptions) {
    CloseableRequestResources closeableRequestResources = queryOptions.get(CloseableRequestResources.class);
    if (closeableRequestResources == null) {
        closeableRequestResources = new CloseableRequestResources();
        queryOptions.put(CloseableRequestResources.class, closeableRequestResources);
    }
    return closeableRequestResources;
}
 
Example 2
Source File: PartialSQLiteIndexTest.java    From cqengine with Apache License 2.0 5 votes vote down vote up
@Test
public void testPartialSQLiteIndex() {
    IndexedCollection<Car> indexedCollection = new ConcurrentIndexedCollection<Car>();
    ConnectionManager connectionManager = temporaryInMemoryDatabase.getConnectionManager(true);
    QueryOptions queryOptions = new QueryOptions();
    queryOptions.put(ConnectionManager.class, connectionManager);
    PartialSQLiteIndex<String, Car, Integer> index = PartialSQLiteIndex.onAttributeWithFilterQuery(Car.MANUFACTURER, OBJECT_TO_ID, ID_TO_OBJECT, between(Car.CAR_ID, 2, 4));
    indexedCollection.addIndex(index, queryOptions);
    indexedCollection.update(Collections.<Car>emptySet(), CarFactory.createCollectionOfCars(10), queryOptions);

    assertEquals(75,         indexedCollection.retrieve(and(equal(Car.MANUFACTURER, "Ford"), between(Car.CAR_ID, 2, 4)), queryOptions).getRetrievalCost());
    assertEquals(2147483647, indexedCollection.retrieve(and(equal(Car.MANUFACTURER, "Ford"), between(Car.CAR_ID, 2, 5)), queryOptions).getRetrievalCost());
}
 
Example 3
Source File: CollectionQueryEngineTest.java    From cqengine with Apache License 2.0 4 votes vote down vote up
static QueryOptions queryOptionsWithOnHeapPersistence() {
    QueryOptions queryOptions = new QueryOptions();
    queryOptions.put(Persistence.class, OnHeapPersistence.withoutPrimaryKey());
    return queryOptions;
}
 
Example 4
Source File: SQLiteIndexTest.java    From cqengine with Apache License 2.0 4 votes vote down vote up
static QueryOptions createQueryOptions(ConnectionManager connectionManager) {
    QueryOptions queryOptions = new QueryOptions();
    queryOptions.put(ConnectionManager.class, connectionManager);
    return queryOptions;
}
 
Example 5
Source File: OffHeapPersistence.java    From cqengine with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a new {@link RequestScopeConnectionManager} and adds it to the given query options with key
 * {@link ConnectionManager}, if an only if no object with that key is already in the query options.
 * This allows the application to supply its own implementation of {@link ConnectionManager} to override the default
 * if necessary.
 *
 * @param queryOptions The query options supplied with the request into CQEngine.
 */
@Override
public void openRequestScopeResources(QueryOptions queryOptions) {
    if (queryOptions.get(ConnectionManager.class) == null) {
        queryOptions.put(ConnectionManager.class, new RequestScopeConnectionManager(this));
    }
}
 
Example 6
Source File: DiskPersistence.java    From cqengine with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a new {@link RequestScopeConnectionManager} and adds it to the given query options with key
 * {@link ConnectionManager}, if an only if no object with that key is already in the query options.
 * This allows the application to supply its own implementation of {@link ConnectionManager} to override the default
 * if necessary.
 *
 * @param queryOptions The query options supplied with the request into CQEngine.
 */
@Override
public void openRequestScopeResources(QueryOptions queryOptions) {
    if (queryOptions.get(ConnectionManager.class) == null) {
        queryOptions.put(ConnectionManager.class, new RequestScopeConnectionManager(this));
    }
}
 
Example 7
Source File: CompositePersistence.java    From cqengine with Apache License 2.0 3 votes vote down vote up
/**
 * Creates a new {@link RequestScopeConnectionManager} and adds it to the given query options with key
 * {@link ConnectionManager}, if an only if no object with that key is already in the query options.
 * This allows the application to supply its own implementation of {@link ConnectionManager} to override the default
 * if necessary.
 *
 * @param queryOptions The query options supplied with the request into CQEngine.
 */
@Override
public void openRequestScopeResources(QueryOptions queryOptions) {
    if (queryOptions.get(ConnectionManager.class) == null) {
        queryOptions.put(ConnectionManager.class, new RequestScopeConnectionManager(this));
    }
}