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


Java Attribute类代码示例

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


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

示例1: matchesNonSimpleAttribute

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

示例2: ensureTargetIsFound

import com.googlecode.cqengine.attribute.Attribute; //导入依赖的package包/类
private void ensureTargetIsFound(Attribute<EntityHandle<O>, A> attribute, QueryOptions queryOptions) {
    if (target == null) {
        Iterable<EntityHandle<O>> collection = queryOptions.get(Iterable.class);
        if (collection == null) {
            throw new RuntimeException(
                    toString() + " has to be supported by the target index or queryOptions should" +
                    " include IndexedCollection key");
        }
        Iterator<EntityHandle<O>> iterator = collection.iterator();
        A targetValue = null;
        while (iterator.hasNext()) {
            EntityHandle<O> next = iterator.next();
            Iterable<A> values = attribute.getValues(next, queryOptions);
            for (A value : values) {
                if (target == null || isBetterValue(value, targetValue)) {
                    target = next;
                    targetValue = value;
                }
            }
        }
    }
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:23,代码来源:ComparingQuery.java

示例3: All

import com.googlecode.cqengine.attribute.Attribute; //导入依赖的package包/类
public All(Class<O> attributeType) {
    super(new Attribute<EntityHandle<O>, O>() {
        @Override
        public Class<EntityHandle<O>> getObjectType() {
            return null;
        }

        @Override
        public Class<O> getAttributeType() {
            return attributeType;
        }

        @Override
        public String getAttributeName() {
            return "true";
        }

        @Override
        public Iterable<O> getValues(EntityHandle<O> object, QueryOptions queryOptions) {
            return Collections.singletonList(object.get());
        }
    });
    this.attributeType = attributeType;
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:25,代码来源:EntityQueryFactory.java

示例4: None

import com.googlecode.cqengine.attribute.Attribute; //导入依赖的package包/类
public None(Class<O> attributeType) {
    super(new Attribute<EntityHandle<O>, O>() {
        @Override
        public Class<EntityHandle<O>> getObjectType() {
            return null;
        }

        @Override
        public Class<O> getAttributeType() {
            return attributeType;
        }

        @Override
        public String getAttributeName() {
            return "true";
        }

        @Override
        public Iterable<O> getValues(EntityHandle<O> object, QueryOptions queryOptions) {
            return Collections.singletonList(object.get());
        }
    });
    this.attributeType = attributeType;
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:25,代码来源:EntityQueryFactory.java

示例5: testInMany

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

示例6: main

import com.googlecode.cqengine.attribute.Attribute; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
    // Generate an attribute from bytecode to read the Car.model field...
    Map<String, ? extends Attribute<Car, ?>> attributes = AttributeBytecodeGenerator.createAttributes(Car.class);
    Attribute<Car, String> MODEL = (Attribute<Car, String>) attributes.get("model");

    // Create a collection of 10 Car objects (Ford Focus, Honda Civic etc.)...
    IndexedCollection<Car> cars = new ConcurrentIndexedCollection<Car>();
    cars.addAll(CarFactory.createCollectionOfCars(10));

    // Retrieve the cars whose Car.model field is "Civic" (i.e. the Honda Civic)...
    ResultSet<Car> results = cars.retrieve(equal(MODEL, "Civic"));
    for (Car car : results) {
        System.out.println(car);
    }
    // ..prints:
    // Car{carId=3, manufacturer='Honda', model='Civic', color=WHITE, doors=5, price=4000.0, features=[grade b]}
}
 
开发者ID:npgall,项目名称:cqengine,代码行数:19,代码来源:GenerateAttributeByteCode.java

示例7: testInNone

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

示例8: IsLatestEntity

import com.googlecode.cqengine.attribute.Attribute; //导入依赖的package包/类
/**
 * @deprecated
 * @param collection collection to query against
 * @param queryFunction query returning function
 * @param timestampAttribute timestamp attribute.
 */
@Deprecated
public IsLatestEntity(IndexedCollection<O> collection,
                      Function<O, Query<O>> queryFunction,
                      Attribute<O, HybridTimestamp> timestampAttribute) {
    super(timestampAttribute);
    this.collection = collection;
    this.queryFunction = queryFunction;
    this.timestampAttribute = timestampAttribute;
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:16,代码来源:IsLatestEntity.java

示例9: matchesNonSimpleAttribute

import com.googlecode.cqengine.attribute.Attribute; //导入依赖的package包/类
@Override
protected boolean matchesNonSimpleAttribute(Attribute<EntityHandle<O>, Boolean> attribute, EntityHandle<O> object,
                                            QueryOptions queryOptions) {
    if (!scope.matches(object, queryOptions)) {
        return false;
    }
    Iterable<EntityHandle<O>> iterable = queryOptions.get(Iterable.class);
    Map<Object, Object> options = new HashMap<>(queryOptions.getOptions());
    options.put(Iterable.class, new FilteringIterable<>(scope, iterable, queryOptions));
    return query.matches(object, new QueryOptions(options));
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:12,代码来源:Scoped.java

示例10: getIndexMatrix

import com.googlecode.cqengine.attribute.Attribute; //导入依赖的package包/类
@Override
protected List<IndexCapabilities> getIndexMatrix() {
    return Arrays.asList(
            new IndexCapabilities<Attribute>("Hash",
                                             new IndexFeature[]{IndexFeature.EQ, IndexFeature.IN, IndexFeature.QZ},
                                             attr -> HashIndex.onAttribute(compatibleAttribute(attr))),
            new IndexCapabilities<Attribute>("Unique",
                                             new IndexFeature[]{IndexFeature.UNIQUE, IndexFeature.EQ, IndexFeature.IN},
                                             attr -> UniqueIndex.onAttribute(compatibleAttribute(attr))),
            new IndexCapabilities<Attribute[]>("Compound",
                                               new IndexFeature[]{IndexFeature.COMPOUND, IndexFeature.EQ, IndexFeature.IN, IndexFeature.QZ},
                                               attrs -> {
                                                   Attribute[] attributes = (Attribute[]) Arrays.stream(attrs)
                                                                                                .map(attr -> compatibleAttribute(attr))
                                                                                                .toArray();
                                                   return CompoundIndex.onAttributes(attributes);
                                               }),
            new IndexCapabilities<Attribute>("Navigable",
                                             new IndexFeature[]{IndexFeature.EQ, IndexFeature.IN, IndexFeature.QZ, IndexFeature.LT, IndexFeature.GT, IndexFeature.BT},
                                             attr -> NavigableIndex.onAttribute(compatibleAttribute(attr))),
            new IndexCapabilities<Attribute>("RadixTree",
                                             new IndexFeature[]{IndexFeature.EQ, IndexFeature.IN, IndexFeature.SW},
                                             attr -> RadixTreeIndex.onAttribute(compatibleAttribute(attr))),
            new IndexCapabilities<Attribute>("ReversedRadixTree",
                                             new IndexFeature[]{IndexFeature.EQ, IndexFeature.IN, IndexFeature.EW},
                                             attr -> ReversedRadixTreeIndex.onAttribute(compatibleAttribute(attr))),
            new IndexCapabilities<Attribute>("InvertedRadixTree",
                                             new IndexFeature[]{IndexFeature.EQ, IndexFeature.IN, IndexFeature.CI},
                                             attr -> InvertedRadixTreeIndex.onAttribute(compatibleAttribute(attr))),
            new IndexCapabilities<Attribute>("SuffixTree",
                                             new IndexFeature[]{IndexFeature.EQ, IndexFeature.IN, IndexFeature.EW, IndexFeature.SC},
                                             attr -> SuffixTreeIndex.onAttribute(compatibleAttribute(attr)))
    );

}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:36,代码来源:MemoryIndexEngine.java

示例11: matchesNonSimpleAttribute

import com.googlecode.cqengine.attribute.Attribute; //导入依赖的package包/类
@Override
protected boolean matchesNonSimpleAttribute(Attribute<O, Object> attribute, O object,
                                            QueryOptions queryOptions) {
    for (Object attributeValue : attribute.getValues(object, queryOptions)) {
        if (attributeValue.equals(getValue())) {
            return true;
        }
    }
    return false;
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:11,代码来源:MemoryIndexEngine.java

示例12: compatibleAttribute

import com.googlecode.cqengine.attribute.Attribute; //导入依赖的package包/类
public static <O extends Entity, A> Attribute<EntityHandle<O>, ?> compatibleAttribute(Attribute<EntityHandle<O>, A>
                                                                                   attribute) {
    if (attribute.getAttributeType() == byte[].class) {
        return new ByteArrayWrappingAttribute<>((Attribute<EntityHandle<O>, byte[]>) attribute);
    } else {
        return attribute;
    }
}
 
开发者ID:eventsourcing,项目名称:es4j,代码行数:9,代码来源:MemoryIndexEngine.java

示例13: getIndex

import com.googlecode.cqengine.attribute.Attribute; //导入依赖的package包/类
/**
 *
 * @param attr the attribute against which the
 * index will be built
 * @return an instance of {@link NavigableIndex}
 */
@Override @SuppressWarnings({"unchecked","rawtypes"})
public Index<O> getIndex(Attribute<O,?> attribute) {
    if(Comparable.class.isAssignableFrom(attribute.getAttributeType()))
        return NavigableIndex.onAttribute((Attribute < O, ? extends Comparable>)attribute);
    
    throw new IllegalArgumentException(NavigableIndex.class.getName() 
            + " cannot be applied on " 
            + attribute.getAttributeName() 
            + " because it does not extend " 
            + Comparable.class.getName());
}
 
开发者ID:cr0wbar,项目名称:Bananarama,代码行数:18,代码来源:NavigableIndexProvider.java

示例14: getIndex

import com.googlecode.cqengine.attribute.Attribute; //导入依赖的package包/类
/**
 * 
 * @param attr the attribute against which the
 * index will be built
 * @return an instance of {@link DiskIndex}
 */
@SuppressWarnings("unchecked")
@Override
public Index<O> getIndex(Attribute<O, ?> attr) {
    
    if(attr instanceof SimpleAttribute)
        return (Index<O>) DiskIndex.onAttribute((SimpleAttribute)attr);
    throw new IllegalArgumentException(attr.toString() + " must be an instance of SimpleAttribute in order to be persisted on disk");
}
 
开发者ID:cr0wbar,项目名称:Bananarama,代码行数:15,代码来源:DiskIndexProvider.java

示例15: getIndex

import com.googlecode.cqengine.attribute.Attribute; //导入依赖的package包/类
/**
 * 
 * @param attribute
 * @param attr the attribute against which the
 * index will be built
 * @return an instance of {@link RadixTreeIndex}
 */
@SuppressWarnings("unchecked")
@Override
public Index<O> getIndex(Attribute<O,?> attribute) {
    if(CharSequence.class.isAssignableFrom(attribute.getAttributeType()))
        return RadixTreeIndex.onAttribute((Attribute < O, ? extends CharSequence>)attribute);
    
    throw new IllegalArgumentException(RadixTreeIndex.class.getName() 
            + " cannot be applied on " 
            + attribute.getAttributeName() 
            + " because it does not extend " 
            + CharSequence.class.getName());
}
 
开发者ID:cr0wbar,项目名称:Bananarama,代码行数:20,代码来源:RadixTreeIndexProvider.java


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