当前位置: 首页>>代码示例>>Java>>正文


Java SimpleAttribute类代码示例

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


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

示例1: matchesSimpleAttribute

import com.googlecode.cqengine.attribute.SimpleAttribute; //导入依赖的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);
    }
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:17,代码来源:IsLatestEntity.java

示例2: matchesSimpleAttribute

import com.googlecode.cqengine.attribute.SimpleAttribute; //导入依赖的package包/类
@Override
protected boolean matchesSimpleAttribute(SimpleAttribute<O, A> attribute, O object, QueryOptions queryOptions) {
    A attributeValue = attribute.getValue(object, queryOptions);
    if (lowerInclusive && upperInclusive) {
        if (lowerValue.compareTo(attributeValue) <= 0 && upperValue.compareTo(attributeValue) >= 0) {
            return true;
        }
    }
    else if (lowerInclusive) {
        if (lowerValue.compareTo(attributeValue) <= 0 && upperValue.compareTo(attributeValue) > 0) {
            return true;
        }
    }
    else if (upperInclusive) {
        if (lowerValue.compareTo(attributeValue) < 0 && upperValue.compareTo(attributeValue) >= 0) {
            return true;
        }
    }
    else {
        if (lowerValue.compareTo(attributeValue) < 0 && upperValue.compareTo(attributeValue) > 0) {
            return true;
        }
    }
    return false;
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:26,代码来源:Between.java

示例3: validatePersistenceArgument

import com.googlecode.cqengine.attribute.SimpleAttribute; //导入依赖的package包/类
/**
 * Helper method for {@link #validatePersistenceArguments(Persistence, Persistence, List)}. See documentation of
 * that method for details.
 */
static <O, A extends Comparable<A>> SimpleAttribute<O, A> validatePersistenceArgument(Persistence<O, A> persistence, SimpleAttribute<O, A> primaryKeyAttribute) {
    if (persistence == null) {
        throw new NullPointerException("The Persistence argument cannot be null.");
    }
    if (persistence.getPrimaryKeyAttribute() == null) {
        throw new IllegalArgumentException("All Persistence implementations in a CompositePersistence must have a primary key.");
    }
    if (primaryKeyAttribute == null) {
        primaryKeyAttribute = persistence.getPrimaryKeyAttribute();
    }
    else if (!primaryKeyAttribute.equals(persistence.getPrimaryKeyAttribute())) {
        throw new IllegalArgumentException("All Persistence implementations must be on the same primary key.");
    }
    return primaryKeyAttribute;
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:20,代码来源:CompositePersistence.java

示例4: unionResultSets

import com.googlecode.cqengine.attribute.SimpleAttribute; //导入依赖的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

示例5: SQLiteIdentityIndex

import com.googlecode.cqengine.attribute.SimpleAttribute; //导入依赖的package包/类
public SQLiteIdentityIndex(final SimpleAttribute<O, A> primaryKeyAttribute) {
    this.sqLiteIndex = new SQLiteIndex<A, O, byte[]>(
            primaryKeyAttribute,
            new SerializingAttribute(primaryKeyAttribute.getObjectType(), byte[].class),
            new DeserializingAttribute(byte[].class, primaryKeyAttribute.getObjectType()),
            "") {
        // Override getEffectiveIndex() in the SQLiteIndex to return a reference to this index...
        @Override
        public Index<O> getEffectiveIndex() {
            return SQLiteIdentityIndex.this.getEffectiveIndex();
        }
    };
    this.objectType = primaryKeyAttribute.getObjectType();
    this.primaryKeyAttribute = primaryKeyAttribute;
    this.foreignKeyAttribute = new ForeignKeyAttribute();
    this.pojoSerializer = createSerializer(objectType);
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:18,代码来源:SQLiteIdentityIndex.java

示例6: SQLiteIndex

import com.googlecode.cqengine.attribute.SimpleAttribute; //导入依赖的package包/类
/**
 * Constructor. Note the index should normally be created via the static factory methods instead.
 *
 * @param attribute The {@link Attribute} on which the index will be built.
 * @param primaryKeyAttribute The {@link SimpleAttribute} with which the index will retrieve the object key.
 * @param foreignKeyAttribute The {@link SimpleAttribute} to map a query result into the domain object.
 * @param tableNameSuffix An optional string to append the end of the table name used by this index;
 *                        This can be an empty string, but cannot be null; If not an empty string, the string
 *                        should only contain characters suitable for use in a SQLite table name; therefore see
 *                        {@link DBUtils#sanitizeForTableName(String)}
 */
public SQLiteIndex(final Attribute<O, A> attribute,
                   final SimpleAttribute<O, K> primaryKeyAttribute,
                   final SimpleAttribute<K, O> foreignKeyAttribute,
                   final String tableNameSuffix) {

    super(attribute, new HashSet<Class<? extends Query>>() {{
        add(Equal.class);
        add(In.class);
        add(LessThan.class);
        add(GreaterThan.class);
        add(Between.class);
        add(StringStartsWith.class);
        add(Has.class);
    }});

    this.tableName = sanitizeForTableName(attribute.getAttributeName()) + tableNameSuffix;
    this.primaryKeyAttribute = primaryKeyAttribute;
    this.foreignKeyAttribute = foreignKeyAttribute;
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:31,代码来源:SQLiteIndex.java

示例7: testSerialization

import com.googlecode.cqengine.attribute.SimpleAttribute; //导入依赖的package包/类
@Test
public void testSerialization() {
    SQLiteIdentityIndex<Integer, Car> index = new SQLiteIdentityIndex<Integer, Car>(
            Car.CAR_ID
    );

    SimpleAttribute<Car, byte[]> serializingAttribute = index.new SerializingAttribute(Car.class, byte[].class);
    SimpleAttribute<byte[], Car> deserializingAttribute = index.new DeserializingAttribute(byte[].class, Car.class);

    Car c1 = CarFactory.createCar(1);
    byte[] s1 = serializingAttribute.getValue(c1, noQueryOptions());
    Car c2 = deserializingAttribute.getValue(s1, noQueryOptions());
    byte[] s2 = serializingAttribute.getValue(c2, noQueryOptions());
    Assert.assertEquals(c1, c2);
    Assert.assertArrayEquals(s1, s2);
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:17,代码来源:SQLiteIdentityIndexTest.java

示例8: testGetDistinctKeys_AllAscending

import com.googlecode.cqengine.attribute.SimpleAttribute; //导入依赖的package包/类
@Test
public void testGetDistinctKeys_AllAscending(){
    ConnectionManager connectionManager = temporaryInMemoryDatabase.getConnectionManager(true);
    SQLiteIndex<String, Car, Integer> offHeapIndex = SQLiteIndex.onAttribute(
            Car.MODEL,
            Car.CAR_ID,
            new SimpleAttribute<Integer, Car>() {
                @Override
                public Car getValue(Integer carId, QueryOptions queryOptions) {
                    return CarFactory.createCar(carId);
                }
            }
    );
    offHeapIndex.addAll(createObjectSetOfCars(10), createQueryOptions(connectionManager));

    List<String> expected = Arrays.asList("Accord", "Avensis", "Civic", "Focus", "Fusion", "Hilux", "Insight", "M6", "Prius", "Taurus");
    List<String> actual = Lists.newArrayList(offHeapIndex.getDistinctKeys(createQueryOptions(connectionManager)));
    assertEquals(expected, actual);
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:20,代码来源:SQLiteIndexTest.java

示例9: testGetDistinctKeys_AllDescending

import com.googlecode.cqengine.attribute.SimpleAttribute; //导入依赖的package包/类
@Test
public void testGetDistinctKeys_AllDescending(){
    ConnectionManager connectionManager = temporaryInMemoryDatabase.getConnectionManager(true);
    SQLiteIndex<String, Car, Integer> offHeapIndex = SQLiteIndex.onAttribute(
            Car.MODEL,
            Car.CAR_ID,
            new SimpleAttribute<Integer, Car>() {
                @Override
                public Car getValue(Integer carId, QueryOptions queryOptions) {
                    return CarFactory.createCar(carId);
                }
            }
    );
    offHeapIndex.addAll(createObjectSetOfCars(10), createQueryOptions(connectionManager));

    List<String> expected = Arrays.asList("Taurus", "Prius", "M6", "Insight", "Hilux", "Fusion", "Focus", "Civic", "Avensis", "Accord");
    List<String> actual = Lists.newArrayList(offHeapIndex.getDistinctKeysDescending(createQueryOptions(connectionManager)));
    assertEquals(expected, actual);
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:20,代码来源:SQLiteIndexTest.java

示例10: testGetDistinctKeys_GreaterThanInclusiveAscending

import com.googlecode.cqengine.attribute.SimpleAttribute; //导入依赖的package包/类
@Test
public void testGetDistinctKeys_GreaterThanInclusiveAscending(){
    ConnectionManager connectionManager = temporaryInMemoryDatabase.getConnectionManager(true);
    SQLiteIndex<String, Car, Integer> offHeapIndex = SQLiteIndex.onAttribute(
            Car.MODEL,
            Car.CAR_ID,
            new SimpleAttribute<Integer, Car>() {
                @Override
                public Car getValue(Integer carId, QueryOptions queryOptions) {
                    return CarFactory.createCar(carId);
                }
            }
    );
    offHeapIndex.addAll(createObjectSetOfCars(10), createQueryOptions(connectionManager));
    List<String> expected, actual;

    expected = Arrays.asList("Accord", "Avensis", "Civic", "Focus", "Fusion", "Hilux", "Insight", "M6", "Prius", "Taurus");
    actual = Lists.newArrayList(offHeapIndex.getDistinctKeys("Accord", true, null, true, createQueryOptions(connectionManager)));
    assertEquals(expected, actual);
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:21,代码来源:SQLiteIndexTest.java

示例11: testGetDistinctKeys_LessThanInclusiveAscending

import com.googlecode.cqengine.attribute.SimpleAttribute; //导入依赖的package包/类
@Test
public void testGetDistinctKeys_LessThanInclusiveAscending(){
    ConnectionManager connectionManager = temporaryInMemoryDatabase.getConnectionManager(true);
    SQLiteIndex<String, Car, Integer> offHeapIndex = SQLiteIndex.onAttribute(
            Car.MODEL,
            Car.CAR_ID,
            new SimpleAttribute<Integer, Car>() {
                @Override
                public Car getValue(Integer carId, QueryOptions queryOptions) {
                    return CarFactory.createCar(carId);
                }
            }
    );
    offHeapIndex.addAll(createObjectSetOfCars(10), createQueryOptions(connectionManager));
    List<String> expected, actual;

    expected = Arrays.asList("Accord", "Avensis", "Civic", "Focus", "Fusion", "Hilux", "Insight", "M6", "Prius");
    actual = Lists.newArrayList(offHeapIndex.getDistinctKeys(null, true, "Prius", true, createQueryOptions(connectionManager)));
    assertEquals(expected, actual);
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:21,代码来源:SQLiteIndexTest.java

示例12: testGetDistinctKeys_BetweenExclusiveAscending

import com.googlecode.cqengine.attribute.SimpleAttribute; //导入依赖的package包/类
@Test
public void testGetDistinctKeys_BetweenExclusiveAscending(){
    ConnectionManager connectionManager = temporaryInMemoryDatabase.getConnectionManager(true);
    SQLiteIndex<String, Car, Integer> offHeapIndex = SQLiteIndex.onAttribute(
            Car.MODEL,
            Car.CAR_ID,
            new SimpleAttribute<Integer, Car>() {
                @Override
                public Car getValue(Integer carId, QueryOptions queryOptions) {
                    return CarFactory.createCar(carId);
                }
            }
    );
    offHeapIndex.addAll(createObjectSetOfCars(10), createQueryOptions(connectionManager));
    List<String> expected, actual;

    expected = Arrays.asList("Focus", "Fusion", "Hilux");
    actual = Lists.newArrayList(offHeapIndex.getDistinctKeys("Civic", false, "Insight", false, createQueryOptions(connectionManager)));
    assertEquals(expected, actual);
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:21,代码来源:SQLiteIndexTest.java

示例13: testGetDistinctKeys_BetweenInclusiveAscending

import com.googlecode.cqengine.attribute.SimpleAttribute; //导入依赖的package包/类
@Test
public void testGetDistinctKeys_BetweenInclusiveAscending(){
    ConnectionManager connectionManager = temporaryInMemoryDatabase.getConnectionManager(true);
    SQLiteIndex<String, Car, Integer> offHeapIndex = SQLiteIndex.onAttribute(
            Car.MODEL,
            Car.CAR_ID,
            new SimpleAttribute<Integer, Car>() {
                @Override
                public Car getValue(Integer carId, QueryOptions queryOptions) {
                    return CarFactory.createCar(carId);
                }
            }
    );
    offHeapIndex.addAll(createObjectSetOfCars(10), createQueryOptions(connectionManager));
    List<String> expected, actual;

    expected = Arrays.asList("Civic", "Focus", "Fusion", "Hilux", "Insight");
    actual = Lists.newArrayList(offHeapIndex.getDistinctKeys("Civic", true, "Insight", true, createQueryOptions(connectionManager)));
    assertEquals(expected, actual);
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:21,代码来源:SQLiteIndexTest.java

示例14: testGetDistinctKeys_BetweenInclusiveDescending

import com.googlecode.cqengine.attribute.SimpleAttribute; //导入依赖的package包/类
@Test
public void testGetDistinctKeys_BetweenInclusiveDescending(){
    ConnectionManager connectionManager = temporaryInMemoryDatabase.getConnectionManager(true);
    SQLiteIndex<String, Car, Integer> offHeapIndex = SQLiteIndex.onAttribute(
            Car.MODEL,
            Car.CAR_ID,
            new SimpleAttribute<Integer, Car>() {
                @Override
                public Car getValue(Integer carId, QueryOptions queryOptions) {
                    return CarFactory.createCar(carId);
                }
            }
    );
    offHeapIndex.addAll(createObjectSetOfCars(10), createQueryOptions(connectionManager));
    List<String> expected, actual;

    expected = Arrays.asList("Insight", "Hilux", "Fusion", "Focus", "Civic");
    actual = Lists.newArrayList(offHeapIndex.getDistinctKeysDescending("Civic", true, "Insight", true, createQueryOptions(connectionManager)));
    assertEquals(expected, actual);
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:21,代码来源:SQLiteIndexTest.java

示例15: testGetCountOfDistinctKeys

import com.googlecode.cqengine.attribute.SimpleAttribute; //导入依赖的package包/类
@Test
public void testGetCountOfDistinctKeys(){
    ConnectionManager connectionManager = temporaryInMemoryDatabase.getConnectionManager(true);
    SQLiteIndex<String, Car, Integer> offHeapIndex = SQLiteIndex.onAttribute(
            Car.MANUFACTURER,
            Car.CAR_ID,
            new SimpleAttribute<Integer, Car>() {
                @Override
                public Car getValue(Integer carId, QueryOptions queryOptions) {
                    return CarFactory.createCar(carId);
                }
            }
    );
    offHeapIndex.addAll(createObjectSetOfCars(20), createQueryOptions(connectionManager));

    Assert.assertEquals(Integer.valueOf(4), offHeapIndex.getCountOfDistinctKeys(createQueryOptions(connectionManager)));
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:18,代码来源:SQLiteIndexTest.java


注:本文中的com.googlecode.cqengine.attribute.SimpleAttribute类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。