• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java QueryFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: main

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
public static void main(String[] args) {
   ConfigurationBuilder builder = new ConfigurationBuilder();
   builder.indexing().index(Index.ALL)
      .addProperty("default.directory_provider", "ram")
      .addProperty("lucene_version", "LUCENE_CURRENT");
   // Construct a simple local cache manager with default configuration
   DefaultCacheManager cacheManager = new DefaultCacheManager(builder.build());
   // Obtain the default cache
   Cache<String, Person> cache = cacheManager.getCache();
   // Store some entries
   cache.put("person1", new Person("William", "Shakespeare"));
   cache.put("person2", new Person("William", "Wordsworth"));
   cache.put("person3", new Person("John", "Milton"));
   // Obtain a query factory for the cache
   QueryFactory queryFactory = Search.getQueryFactory(cache);
   // Construct a query
   Query query = queryFactory.from(Person.class).having("name").eq("William").toBuilder().build();
   // Execute the query
   List<Person> matches = query.list();
   // List the results
   matches.forEach(person -> System.out.printf("Match: %s", person));
   // Stop the cache manager and release all resources
   cacheManager.stop();
}
 
开发者ID:infinispan,项目名称:infinispan-simple-tutorials,代码行数:25,代码来源:InfinispanQuery.java


示例2: testAttributeQuery

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
@Test
public void testAttributeQuery() throws Exception {

   remoteCache0.put(1, createEmployee1());
   remoteCache0.put(2, createEmployee2());

   QueryFactory qf = Search.getQueryFactory(remoteCache1);

   Query query = qf.from(Employee.class)
         .having("ssn").eq("12357").toBuilder()
         .build();
   List<Employee> list = query.list();
   assertNotNull(list);
   assertEquals(1, list.size());

}
 
开发者ID:leads-project,项目名称:infinispan-avro,代码行数:17,代码来源:MultiHotRodQueryTest.java


示例3: getRules

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
@Override
public List<?> getRules(final String clientIPAddress) {
    try {
        final RemoteCache<String, Rule> ruleCache = cacheManagerForIndexableCaches.getCache(SinkitCacheName.infinispan_rules.toString());
        final ImmutablePair<String, String> startEndAddresses = CIDRUtils.getStartEndAddresses(clientIPAddress);
        final String clientIPAddressPaddedBigInt = startEndAddresses.getLeft();
        log.log(Level.FINE, "Getting key [" + clientIPAddress + "] which actually translates to BigInteger zero padded representation " + "[" + clientIPAddressPaddedBigInt + "]");
        // Let's try to hit it
        Rule rule = ruleCache.withFlags(Flag.SKIP_CACHE_LOAD).get(clientIPAddressPaddedBigInt);
        if (rule != null) {
            return Collections.singletonList(rule);
        }
        QueryFactory qf = Search.getQueryFactory(ruleCache);
        Query query = qf.from(Rule.class)
                .having("startAddress").lte(clientIPAddressPaddedBigInt)
                .and()
                .having("endAddress").gte(clientIPAddressPaddedBigInt)
                .toBuilder().build();
        return query.list();
    } catch (Exception e) {
        log.log(Level.SEVERE, "getRules client address troubles", e);
        // TODO: Proper Error codes.
        return null;
    }
}
 
开发者ID:whalebone,项目名称:sinkit-core,代码行数:26,代码来源:WebApiEJB.java


示例4: getAllRules

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
@Override
public List<?> getAllRules() {
    try {
        final RemoteCache<String, Rule> ruleCache = cacheManagerForIndexableCaches.getCache(SinkitCacheName.infinispan_rules.toString());
        log.log(Level.SEVERE, "getAllRules: This is a very expensive operation.");
        final QueryFactory qf = Search.getQueryFactory(ruleCache);
        final Query query = qf.from(Rule.class).build();
        // Hundreds of records...
        List<Rule> results = query.list();
        return results;
    } catch (Exception e) {
        log.log(Level.SEVERE, "getRules client address troubles", e);
        // TODO: Proper Error codes.
        return null;
    }
}
 
开发者ID:whalebone,项目名称:sinkit-core,代码行数:17,代码来源:WebApiEJB.java


示例5: deleteRulesByCustomer

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
@Override
public String deleteRulesByCustomer(Integer customerId) {
    int counter = 0;
    //TODO: Shouldn't this be done by a one Infinispan DSL removal call?
    try {
        final RemoteCache<String, Rule> ruleCache = cacheManagerForIndexableCaches.getCache(SinkitCacheName.infinispan_rules.toString());
        final QueryFactory qf = Search.getQueryFactory(ruleCache);
        Query query = qf.from(Rule.class)
                .having("customerId").eq(customerId)
                .toBuilder().build();
        // TODO: Use CloseableIterator
        Iterator iterator = query.list().iterator();
        while (iterator.hasNext()) {
            ruleCache.remove(((Rule) iterator.next()).getStartAddress());
            counter++;
        }
        return counter + " RULES DELETED FOR CUSTOMER ID: " + customerId;
    } catch (Exception e) {
        log.log(Level.SEVERE, "deleteRulesByCustomer", e);
        // TODO: Proper Error codes.
        return null;
    }
}
 
开发者ID:whalebone,项目名称:sinkit-core,代码行数:24,代码来源:WebApiEJB.java


示例6: getBeerByIbuBetweenIQ

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
public List<Beer> getBeerByIbuBetweenIQ(double low, double high){
    QueryFactory queryFactory = Search.getQueryFactory(cache);
    org.infinispan.query.dsl.Query infinispanQuery =
            queryFactory.from(Beer.class)
                    .orderBy("ibu", SortOrder.ASC)
                    .having("ibu")
                    .between(low,high)
                    .build();
    return infinispanQuery.list();
}
 
开发者ID:briantward,项目名称:jdg-lab,代码行数:11,代码来源:IndexedCacheBeerService.java


示例7: getAllBeers

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
public List<Beer> getAllBeers(boolean desc) {
    QueryFactory queryFactory = Search.getQueryFactory(cache);
    org.infinispan.query.dsl.QueryBuilder infinispanQueryBuilder =
            queryFactory.from(Beer.class);

    if(desc){
        infinispanQueryBuilder.orderBy("id", SortOrder.DESC);
    }
    org.infinispan.query.dsl.Query infinispanQuery = infinispanQueryBuilder.build();
    return infinispanQuery.list();
}
 
开发者ID:briantward,项目名称:jdg-lab,代码行数:12,代码来源:CacheBeerService.java


示例8: getBeerByWildcardDescription

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
public List<Beer> getBeerByWildcardDescription(String description){
    QueryFactory queryFactory = Search.getQueryFactory(cache);
    org.infinispan.query.dsl.Query infinispanQuery =
            queryFactory.from(Beer.class)
                    .having("description")
                    .like("%" + description + "%")
                    .build();
    return infinispanQuery.list();
}
 
开发者ID:briantward,项目名称:jdg-lab,代码行数:10,代码来源:CacheBeerService.java


示例9: rulesLookup

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
/**
 * There are 3 ways to find the result, in ascending order by their cost:
 * 1. local cache of already found results based on clientIPAddressPaddedBigInt
 * 2. getting key clientIPAddressPaddedBigInt from the cache of Rules
 * 3. lookup in the cache of Rules based on subnets
 * <p>
 * TODO: List? Array? Map with additional data? Let's think this over.
 * TODO: Replace/factor out duplicated code in .getRules out of webApiEJB
 *
 * @param clientIPAddressPaddedBigInt
 * @return list of rules
 */
private List<Rule> rulesLookup(final String clientIPAddressPaddedBigInt, final RemoteCache<String, Rule> ruleCache) {
    try {
        log.log(Level.FINE, "Getting key BigInteger zero padded representation " + clientIPAddressPaddedBigInt);
        // Let's search subnets
        final String keyInCache = DigestUtils.md5Hex(clientIPAddressPaddedBigInt + clientIPAddressPaddedBigInt);
        log.log(Level.FINE, "keyInCache: " + keyInCache + ", from: " + (clientIPAddressPaddedBigInt + clientIPAddressPaddedBigInt));

        final List<Rule> cached = ruleLocalCache.get(keyInCache);
        if (cached != null) {
            return cached;
        } else {
            // Let's try to hit it
            final Rule rule = ruleCache.withFlags(Flag.SKIP_CACHE_LOAD).get(clientIPAddressPaddedBigInt);
            if (rule != null) {
                return Collections.singletonList(rule);
            }
            final QueryFactory qf = Search.getQueryFactory(ruleCache);
            final Query query = qf.from(Rule.class)
                    .having("startAddress").lte(clientIPAddressPaddedBigInt)
                    .and()
                    .having("endAddress").gte(clientIPAddressPaddedBigInt)
                    .toBuilder().build();
            if (query != null) {
                final List<Rule> result = query.list();
                ruleLocalCache.put(keyInCache, result);
                return result;

            }
            return Collections.emptyList();
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, "getRules client address troubles", e);
        return null;
    }
}
 
开发者ID:whalebone,项目名称:sinkit-core,代码行数:48,代码来源:DNSApiEJB.java


示例10: InfinispanRemoteQueryAdapter

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
public InfinispanRemoteQueryAdapter(QueryFactory queryFactory) {
    this.queryFactory = queryFactory;
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:4,代码来源:InfinispanRemoteQueryAdapter.java


示例11: createQueryAdapter

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
public <T> QueryAdapter<T> createQueryAdapter(Class<T> entityClass) {
    RemoteCache<?, T> cache = getCache(entityClass);
    QueryFactory qf = org.infinispan.client.hotrod.Search.getQueryFactory(cache);
    return new InfinispanRemoteQueryAdapter<>(qf);
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:6,代码来源:InfinispanRemoteDatasourceMapper.java


示例12: InfinispanCriteriaConverter

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
public InfinispanCriteriaConverter(QueryFactory queryFactory, QueryBuilder queryBuilder) {
    this.queryFactory = queryFactory;
    this.queryBuilder = queryBuilder;
}
 
开发者ID:snowdrop,项目名称:spring-data-snowdrop,代码行数:5,代码来源:InfinispanCriteriaConverter.java


示例13: build

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
@Override
public Query build(QueryFactory<Query> queryFactory) {
    return queryFactory.from(User.class)
        .having("name").like("%abc%")
        .toBuilder().build();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:InfinispanRemoteQueryProducerIT.java


示例14: build

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
@Override
public Query build(QueryFactory<Query> queryFactory) {
    return queryFactory.from(User.class)
        .having("name").like("CQ%")
        .toBuilder().build();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:InfinispanContinuousQueryIT.java


示例15: QueryBuilder

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
public QueryBuilder(RemoteCacheImpl cache, QueryFactory qf, Schema schema) {
   super(qf,GenericData.Record.class.getName());
   this.cache = cache;
   this.schema = schema;
}
 
开发者ID:leads-project,项目名称:infinispan-avro,代码行数:6,代码来源:QueryBuilder.java


示例16: getResourceQueryFactory

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
@Produces
@InventoryResource
public QueryFactory getResourceQueryFactory() {
    return queryResource;
}
 
开发者ID:hawkular,项目名称:hawkular-commons,代码行数:6,代码来源:InventoryConfig.java


示例17: getResourceTypeQueryFactory

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
@Produces
@InventoryResourceType
public QueryFactory getResourceTypeQueryFactory() {
    return queryResourceType;
}
 
开发者ID:hawkular,项目名称:hawkular-commons,代码行数:6,代码来源:InventoryConfig.java


示例18: getQueryBuilder

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
	private static QueryBuilder getQueryBuilder(String cacheName, ObjectConnection conn) throws TranslatorException {
		
		Cache c = (Cache) conn.getCacheContainer().getCache(cacheName);
		
		// changed from 8.7.x (Infin. 6.1) to
		// upstream where only Infin  6.0 is available
		QueryFactory qf = Search.getSearchManager(c).getQueryFactory();
//		QueryFactory qf = Search.getQueryFactory(c);  
			
		Class<?> type = conn.getType(cacheName);
	    		  
	    QueryBuilder qb = qf.from(type);

	    return qb;
	}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:17,代码来源:DSLSearch.java


示例19: getQueryFactory

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
@SuppressWarnings({ "unused", "rawtypes" })
@Override
public QueryFactory getQueryFactory(String cacheName) throws TranslatorException {
	
	return Search.getQueryFactory(getCache(cacheName));
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:7,代码来源:InfinispanConnectionImpl.java


示例20: getQueryBuilder

import org.infinispan.query.dsl.QueryFactory; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
private static QueryBuilder getQueryBuilder(String cacheName, InfinispanConnection conn) throws TranslatorException {
	
	Class<?> type = conn.getType(cacheName);
	
	QueryFactory qf = conn.getQueryFactory(cacheName);
    		  
    QueryBuilder qb = qf.from(type);

    return qb;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:12,代码来源:DSLSearch.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BlobColumnListElementGenerator类代码示例发布时间:2022-05-22
下一篇:
Java Await类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap