• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java SimpleNullableAttribute类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.googlecode.cqengine.attribute.SimpleNullableAttribute的典型用法代码示例。如果您正苦于以下问题:Java SimpleNullableAttribute类的具体用法?Java SimpleNullableAttribute怎么用?Java SimpleNullableAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

SimpleNullableAttribute类属于com.googlecode.cqengine.attribute包,在下文中一共展示了SimpleNullableAttribute类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: unionResultSets

点赞 3

import com.googlecode.cqengine.attribute.SimpleNullableAttribute; //导入依赖的package包/类
/**
 * If a query option specifying logical deduplication was supplied, wrap the given result sets in
 * {@link ResultSetUnion}, otherwise wrap in {@link ResultSetUnionAll}.
 * <p/>
 * An exception is if the index is built on a SimpleAttribute, we can avoid deduplication and always use
 * {@link ResultSetUnionAll}, because the same object could not exist in more than one {@link StoredResultSet}.
 *
 * @param results Provides the result sets to union
 * @param query The query for which the union is being constructed
 * @param queryOptions Specifies whether or not logical deduplication is required
 * @return A union view over the given result sets
 */
ResultSet<O> unionResultSets(Iterable<? extends ResultSet<O>> results, Query<O> query, QueryOptions queryOptions) {
    if (DeduplicationOption.isLogicalElimination(queryOptions)
            && !(getAttribute() instanceof SimpleAttribute || getAttribute() instanceof SimpleNullableAttribute)) {
        return new ResultSetUnion<O>(results, query, queryOptions) {
            @Override
            public int getRetrievalCost() {
                return INDEX_RETRIEVAL_COST;
            }
        };
    }
    else {
        return new ResultSetUnionAll<O>(results, query, queryOptions) {
            @Override
            public int getRetrievalCost() {
                return INDEX_RETRIEVAL_COST;
            }
        };
    }
}
 

开发者ID:npgall,
项目名称:cqengine,
代码行数:32,
代码来源:SuffixTreeIndex.java

示例2: testInMany

点赞 3

import com.googlecode.cqengine.attribute.SimpleNullableAttribute; //导入依赖的package包/类
@Test
public void testInMany() {
    // Create an indexed collection (note: could alternatively use CQEngine.copyFrom() existing collection)...
    IndexedCollection<Car> cars = new ConcurrentIndexedCollection<Car>();

    Attribute<Car, String> NAME = new SimpleNullableAttribute<Car, String>("name") {
        public String getValue(Car car, QueryOptions queryOptions) {
            return car.name;
        }
    };
    cars.addIndex(NavigableIndex.onAttribute(NAME));

    // Add some objects to the collection...
    cars.add(new Car(1, "ford", null, null));
    cars.add(new Car(2, "honda", null, null));
    cars.add(new Car(3, "toyota", null, null));

    Assert.assertEquals(cars.retrieve(in(NAME, "ford", "honda")).size(), 2);
    Assert.assertEquals(cars.retrieve(in(NAME, Arrays.asList("ford", "honda"))).size(), 2);
}
 

开发者ID:npgall,
项目名称:cqengine,
代码行数:21,
代码来源:InTest.java

示例3: testInOne

点赞 3

import com.googlecode.cqengine.attribute.SimpleNullableAttribute; //导入依赖的package包/类
@Test
public void testInOne() {
    // Create an indexed collection (note: could alternatively use CQEngine.copyFrom() existing collection)...
    IndexedCollection<Car> cars = new ConcurrentIndexedCollection<Car>();

    Attribute<Car, String> NAME = new SimpleNullableAttribute<Car, String>("name") {
        public String getValue(Car car, QueryOptions queryOptions) {
            return car.name;
        }
    };
    cars.addIndex(NavigableIndex.onAttribute(NAME));

    // Add some objects to the collection...
    cars.add(new Car(1, "ford", null, null));
    cars.add(new Car(2, "honda", null, null));
    cars.add(new Car(3, "toyota", null, null));

    Assert.assertEquals(cars.retrieve(in(NAME, "ford")).size(), 1);
    Assert.assertEquals(cars.retrieve(in(NAME, Collections.singletonList("ford"))).size(), 1);
}
 

开发者ID:npgall,
项目名称:cqengine,
代码行数:21,
代码来源:InTest.java

示例4: testInNone

点赞 3

import com.googlecode.cqengine.attribute.SimpleNullableAttribute; //导入依赖的package包/类
@Test
public void testInNone() {
    // Create an indexed collection (note: could alternatively use CQEngine.copyFrom() existing collection)...
    IndexedCollection<Car> cars = new ConcurrentIndexedCollection<Car>();

    Attribute<Car, String> NAME = new SimpleNullableAttribute<Car, String>("name") {
        public String getValue(Car car, QueryOptions queryOptions) {
            return car.name;
        }
    };
    cars.addIndex(NavigableIndex.onAttribute(NAME));

    // Add some objects to the collection...
    cars.add(new Car(1, "ford", null, null));
    cars.add(new Car(2, "honda", null, null));
    cars.add(new Car(3, "toyota", null, null));

    Assert.assertEquals(cars.retrieve(in(NAME)).size(), 0);
    Assert.assertEquals(cars.retrieve(in(NAME, new ArrayList<String>())).size(), 0);
}
 

开发者ID:npgall,
项目名称:cqengine,
代码行数:21,
代码来源:InTest.java

示例5: testExists

点赞 3

import com.googlecode.cqengine.attribute.SimpleNullableAttribute; //导入依赖的package包/类
@Test
public void testExists() {
    // Create an indexed collection (note: could alternatively use CQEngine.copyFrom() existing collection)...
    IndexedCollection<Car> cars = new ConcurrentIndexedCollection<Car>();

    Attribute<Car, String> NAME = new SimpleNullableAttribute<Car, String>("name") {
        public String getValue(Car car, QueryOptions queryOptions) { return car.name; }
    };
    // Add some indexes...
    cars.addIndex(StandingQueryIndex.onQuery(has(NAME)));
    cars.addIndex(StandingQueryIndex.onQuery(not(has(NAME))));

    // Add some objects to the collection...
    cars.add(new Car(1, "ford focus", "great condition, low mileage", Arrays.asList("spare tyre", "sunroof")));
    cars.add(new Car(2, null, "dirty and unreliable, flat tyre", Arrays.asList("spare tyre", "radio")));
    cars.add(new Car(3, "honda civic", "has a flat tyre and high mileage", Arrays.asList("radio")));

    Assert.assertEquals(cars.retrieve(has(NAME)).size(), 2);
    Assert.assertEquals(cars.retrieve(not(has(NAME))).size(), 1);
}
 

开发者ID:npgall,
项目名称:cqengine,
代码行数:21,
代码来源:HasTest.java

示例6: deduplicateIfNecessary

点赞 2

import com.googlecode.cqengine.attribute.SimpleNullableAttribute; //导入依赖的package包/类
/**
 * <p> If a query option specifying logical deduplication was supplied, wrap the given result sets in {@link ResultSetUnion}, otherwise wrap in {@link ResultSetUnionAll}.
 *
 * <p> There are two exceptions where a {@link ResultSetUnionAll} is used regardless of the logical deduplication query option:
 * <ul>
 *     <li>
 *         If the index is built on a SimpleAttribute which means that the same object could not exist in more than one {@link StoredResultSet}.
 *     </li>
 *     <li>
 *         If the query is an {@link In} query and it is marked as disjoint ( {@link In#isDisjoint()} returns true )
 *     </li>
 * </ul>
 *
 * @param results Provides the result sets to union
 * @param query The query for which the union is being constructed
 * @param queryOptions Specifies whether or not logical deduplication is required
 * @param retrievalCost The resultSet retrieval cost
 * @return A union view over the given result sets
 */
public static <O, A> ResultSet<O> deduplicateIfNecessary(final Iterable<? extends ResultSet<O>> results,
                                                         final Query<O> query,
                                                         final Attribute<O, A> attribute,
                                                         final QueryOptions queryOptions,
                                                         final int retrievalCost) {
    boolean logicalElimination = DeduplicationOption.isLogicalElimination(queryOptions);
    boolean attributeHasAtMostOneValue = (attribute instanceof SimpleAttribute || attribute instanceof SimpleNullableAttribute);
    boolean queryIsADisjointInQuery = query instanceof In && ((In) query).isDisjoint();
    if (!logicalElimination || attributeHasAtMostOneValue || queryIsADisjointInQuery) {
        // No need to deduplicate...
        return new ResultSetUnionAll<O>(results, query, queryOptions) {
            @Override
            public int getRetrievalCost() {
                return retrievalCost;
            }
        };
    } else {
        // We need to deduplicate...
        return new ResultSetUnion<O>(results, query, queryOptions) {
            @Override
            public int getRetrievalCost() {
                return retrievalCost;
            }
        };
    }
}
 

开发者ID:npgall,
项目名称:cqengine,
代码行数:46,
代码来源:IndexSupport.java

示例7: testInNull

点赞 2

import com.googlecode.cqengine.attribute.SimpleNullableAttribute; //导入依赖的package包/类
@Test(expected = NullPointerException.class)
public void testInNull() {
    Attribute<Car, String> NAME = new SimpleNullableAttribute<Car, String>("name") {
        public String getValue(Car car, QueryOptions queryOptions) {
            return car.name;
        }
    };
    in(NAME, (Collection<String>) null);
}
 

开发者ID:npgall,
项目名称:cqengine,
代码行数:10,
代码来源:InTest.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)