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


Java Entry类代码示例

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


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

示例1: selectGeneByChromsomeCriteria

import javax.cache.Cache.Entry; //导入依赖的package包/类
/**
 * method assumes ChromosomeCriteria is set.
 * 
 * @param k
 *            - gene index in Chromosome.
 * @return
 */
private long selectGeneByChromsomeCriteria(int k) {
    List<Gene> genes = new ArrayList();

    StringBuffer sbSqlClause = new StringBuffer("_val like '");
    sbSqlClause.append("%");
    sbSqlClause.append(config.getChromosomeCritiera().getCriteria().get(k));
    sbSqlClause.append("%'");

    IgniteCache<Long, Gene> cache = ignite.cache(GAGridConstants.GENE_CACHE);

    SqlQuery sql = new SqlQuery(Gene.class, sbSqlClause.toString());

    try (QueryCursor<Entry<Long, Gene>> cursor = cache.query(sql)) {
        for (Entry<Long, Gene> e : cursor)
            genes.add(e.getValue());
    }

    int idx = selectRandomIndex(genes.size());

    Gene gene = genes.get(idx);
    return gene.id();
}
 
开发者ID:techbysample,项目名称:gagrid,代码行数:30,代码来源:GAGrid.java

示例2: getChromosomes

import javax.cache.Cache.Entry; //导入依赖的package包/类
/**
 *  Retrieve chromosomes
 *  
 * @param ignite
 * @param query
 * @return
 */
public static List<Chromosome> getChromosomes(Ignite ignite, String query)
{
 List<Chromosome> chromosomes = new ArrayList();
 
       IgniteCache<Long, Chromosome> populationCache = ignite.getOrCreateCache(PopulationCacheConfig.populationCache());
      
       SqlQuery sql = new SqlQuery(Chromosome.class, query);

       try (QueryCursor<Entry<Long, Chromosome>> cursor = populationCache.query(sql)) {
           for (Entry<Long, Chromosome> e : cursor)
         	  chromosomes.add(e.getValue());
           }
 
 return chromosomes;
}
 
开发者ID:techbysample,项目名称:gagrid,代码行数:23,代码来源:GAGridUtils.java

示例3: getGenesForChromosome

import javax.cache.Cache.Entry; //导入依赖的package包/类
/**
 *  
 * @param ignite
 * @param chromosome
 * @return List<Gene> 
 */
public static List<Gene> getGenesForChromosome(Ignite ignite, Chromosome chromosome) {
    List<Gene> genes = new ArrayList();
    IgniteCache<Long, Gene> cache = ignite.cache(GAGridConstants.GENE_CACHE);
    StringBuffer sbSqlClause = new StringBuffer();
    sbSqlClause.append("_key IN ");
    String sqlInClause = Arrays.toString(chromosome.getGenes());

    sqlInClause = sqlInClause.replace("[", "(");
    sqlInClause = sqlInClause.replace("]", ")");

    sbSqlClause.append(sqlInClause);

    SqlQuery sql = new SqlQuery(Gene.class, sbSqlClause.toString());

    try (QueryCursor<Entry<Long, Gene>> cursor = cache.query(sql)) {
        for (Entry<Long, Gene> e : cursor)
            genes.add(e.getValue());
    }

    return genes;
}
 
开发者ID:techbysample,项目名称:gagrid,代码行数:28,代码来源:GAGridUtils.java

示例4: selectGeneByChromsomeCriteria

import javax.cache.Cache.Entry; //导入依赖的package包/类
/**
 * method assumes ChromosomeCriteria is set.
 * 
 * @param k - gene index in Chromosome.
 *            
 * @return long
 */
private long selectGeneByChromsomeCriteria(int k) {
    List<Gene> genes = new ArrayList();

    StringBuffer sbSqlClause = new StringBuffer("_val like '");
    sbSqlClause.append("%");
    sbSqlClause.append(config.getChromosomeCritiera().getCriteria().get(k));
    sbSqlClause.append("%'");

    IgniteCache<Long, Gene> cache = ignite.cache(GAGridConstants.GENE_CACHE);

    SqlQuery sql = new SqlQuery(Gene.class, sbSqlClause.toString());

    try (QueryCursor<Entry<Long, Gene>> cursor = cache.query(sql)) {
        for (Entry<Long, Gene> e : cursor)
            genes.add(e.getValue());
    }

    int idx = selectRandomIndex(genes.size());

    Gene gene = genes.get(idx);
    return gene.id();
}
 
开发者ID:techbysample,项目名称:gagrid,代码行数:30,代码来源:MutateTask.java

示例5: getChromosome

import javax.cache.Cache.Entry; //导入依赖的package包/类
private Chromosome getChromosome(Long key) {
    IgniteCache<Long, Chromosome> cache = ignite.cache(GAGridConstants.POPULATION_CACHE);
    StringBuffer sbSqlClause = new StringBuffer();
    sbSqlClause.append("_key IN (");
    sbSqlClause.append(key);
    sbSqlClause.append(")");

    Chromosome chromosome = null;

    SqlQuery sql = new SqlQuery(Chromosome.class, sbSqlClause.toString());

    try (QueryCursor<Entry<Long, Chromosome>> cursor = cache.query(sql)) {
        for (Entry<Long, Chromosome> e : cursor)
            chromosome = (e.getValue())

            ;
    }

    return chromosome;
}
 
开发者ID:techbysample,项目名称:gagrid,代码行数:21,代码来源:TruncateSelectionTask.java

示例6: maybeFireExistingQueryResults

import javax.cache.Cache.Entry; //导入依赖的package包/类
private void maybeFireExistingQueryResults() {
    if (!endpoint.isFireExistingQueryResults()) {
        LOG.info(String.format("Skipping existing cache results for cache name = %s.", endpoint.getCacheName()));
        return;
    }

    LOG.info(String.format("Processing existing cache results for cache name = %s.", endpoint.getCacheName()));

    for (Entry<Object, Object> entry : cursor) {
        Exchange exchange = createExchange(entry.getValue());
        exchange.getIn().setHeader(IgniteConstants.IGNITE_CACHE_KEY, entry.getKey());
        getAsyncProcessor().process(createExchange(entry), new AsyncCallback() {
            @Override
            public void done(boolean doneSync) {
                // do nothing
            }
        });
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:IgniteCacheContinuousQueryConsumer.java

示例7: testQuery

import javax.cache.Cache.Entry; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testQuery() {
    IgniteCache<String, String> cache = ignite().getOrCreateCache("testcache1");
    Set<String> keys = new HashSet<>();

    for (int i = 0; i < 100; i++) {
        cache.put("k" + i, "v" + i);
        keys.add("k" + i);
    }

    Query<Entry<String, String>> query = new ScanQuery<String, String>(new IgniteBiPredicate<String, String>() {
        private static final long serialVersionUID = 1L;

        @Override
        public boolean apply(String key, String value) {
            return Integer.parseInt(key.replace("k", "")) >= 50;
        }
    });

    List results = template.requestBodyAndHeader("ignite:cache:testcache1?operation=QUERY", keys, IgniteConstants.IGNITE_CACHE_QUERY, query, List.class);
    assert_().that(results.size()).isEqualTo(50);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:IgniteCacheTest.java

示例8: get

import javax.cache.Cache.Entry; //导入依赖的package包/类
public List<Person> get(String name, String timesplice) {
	IgniteCache<UUID, Person> cache = ignite.cache(timesplice);
	if (cache == null) {
		return Arrays.asList();
	}

	SqlQuery<Object, Object> sqlQuery = new SqlQuery<>(Person.class, " name = ?").setArgs(name);

	List<Person> list = new ArrayList<>();
	try (QueryCursor<Entry<Object, Object>> queryCursor = cache.query(sqlQuery)) {
		for (Entry<Object, Object> entry : queryCursor) {
			list.add((Person) entry.getValue());
		}
	}

	return list;
}
 
开发者ID:sdcuike,项目名称:Ignite-2015,代码行数:18,代码来源:IgniteDao.java

示例9: main

import javax.cache.Cache.Entry; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException {

		try (Ignite ignite = Ignition.start("config/default-config.xml")) {

			CacheConfiguration<String, LocalDateTime> cacheCfg = new CacheConfiguration<>("CacheQueriesScanQueryExample");
			cacheCfg.setCacheMode(CacheMode.PARTITIONED).setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.HOURS, 3)));

			try (IgniteCache<String, LocalDateTime> igniteCache = ignite.getOrCreateCache(cacheCfg)) {

				LocalDateTime now = LocalDateTime.now();

				igniteCache.put("doctor", now);
				igniteCache.put("doctor who", now.plusHours(10L));
				igniteCache.put("doctor who", now.minusYears(1L));

				System.out.println("--------ScanQuery----------");
				try (QueryCursor<Entry<Object, Object>> query = igniteCache.query(new ScanQuery<>((k, v) -> v.equals(now)))) {
					for (Entry<Object, Object> entry : query) {
						System.out.println(entry.getKey() + ":" + entry.getValue());
					}
				}
			}
		}
	}
 
开发者ID:sdcuike,项目名称:Ignite-2015,代码行数:25,代码来源:CacheQueriesScanQueryExample.java

示例10: peekNext

import javax.cache.Cache.Entry; //导入依赖的package包/类
/**
 * Peeks the next element. Calling this method multiple times will always return
 * the same value, until {@link #next()} is called. This method skips all invalid
 * Holders.   
 * 
 * @return The next element, or null if there is no next element
 */
private java.util.Map.Entry<K, AccessTimeObjectHolder<V>> peekNext()
{
	if (nextElement != null)
		return nextElement;
	
	while (true)
	{
		if (!mapIterator.hasNext())
			return null;
		java.util.Map.Entry<K, AccessTimeObjectHolder<V>> entry = mapIterator.next();
		AccessTimeObjectHolder<V> holder = entry.getValue();
		if (!holder.isInvalid())
		{
			nextElement = entry;
			return nextElement;
		}
	}
}
 
开发者ID:trivago,项目名称:triava,代码行数:26,代码来源:TCacheHolderIterator.java

示例11: peekNext

import javax.cache.Cache.Entry; //导入依赖的package包/类
/**
 * Peeks the next element. Calling this method multiple times will always return
 * the same value, until {@link #next()} is called. This method skips all invalid
 * Holders.   
 * 
 * @return The next element, or null if there is no nbext element
 */
private java.util.Map.Entry<K, AccessTimeObjectHolder<V>> peekNext()
{
	if (nextElement != null)
		return nextElement;
	
	while (true)
	{
		if (!mapIterator.hasNext())
			return null;
		java.util.Map.Entry<K, AccessTimeObjectHolder<V>> entry = mapIterator.next();
		AccessTimeObjectHolder<V> holder = entry.getValue();
		if (!holder.isInvalid())
		{
			nextElement = entry;
			return nextElement;
		}
	}
}
 
开发者ID:trivago,项目名称:triava,代码行数:26,代码来源:TCacheEntryIterator.java

示例12: testExpire

import javax.cache.Cache.Entry; //导入依赖的package包/类
/**
	 * Simple expiration time check.
	 * 
	 * <pre>
	 * -|-|-------------------------|-|---------------------> t
	 *  | |                         | |
	 *  | timePutAtOrBefore         | timeMustExpireBefore = timePutAtOrBefore + maxIdleTime
	 *  |                           |
	 *  cache.put()                 actual expiration time (10 ms precision)
	 * </pre>
	 */
	@Test
	public void testExpire()
	{
		cache.put("1", 2);
		long timePutAtOrBefore = System.currentTimeMillis();
		
		TCacheHolderIterator<String, Integer> iterator = cache.iterator();
		Entry<String, TCacheHolder<Integer>> first = iterator.next();
		TCacheHolder<Integer> holder = first.getValue();
		
//		long timeNow = System.currentTimeMillis();
		long timeMustExpireBefore = timePutAtOrBefore + maxIdleTimeMillis*1000;
		long expTime = holder.getExpirationTime();
		
		assertTrue("expirationTime later than expected: " + holder.getExpirationTime() + " >= " + timeMustExpireBefore, expTime < timeMustExpireBefore);
	}
 
开发者ID:trivago,项目名称:triava,代码行数:28,代码来源:CacheExpirationChecks.java

示例13: getGenesInOrderForChromosome

import javax.cache.Cache.Entry; //导入依赖的package包/类
/**
 * 
 * Retrieve genes in order
 * 
 * @param ignite
 * @param chromosome
 * @return List<Gene>
 */

public static List<Gene> getGenesInOrderForChromosome(Ignite ignite, Chromosome chromosome) {
    List<Gene> genes = new ArrayList();
    IgniteCache<Long, Gene> cache = ignite.cache(GAGridConstants.GENE_CACHE);
  
    long[] primaryKeys = chromosome.getGenes();
    
    for (int k =0; k< primaryKeys.length; k++)
    {
    
      StringBuffer sbSqlClause = new StringBuffer();
      sbSqlClause.append("_key IN ");
      sbSqlClause.append("(");
      sbSqlClause.append(primaryKeys[k]);
      sbSqlClause.append(")");
      
      SqlQuery sql = new SqlQuery(Gene.class, sbSqlClause.toString());

       try (QueryCursor<Entry<Long, Gene>> cursor = cache.query(sql)) {
        for (Entry<Long, Gene> e : cursor)
            genes.add(e.getValue());
        }
    }
   
    return genes;
}
 
开发者ID:techbysample,项目名称:gagrid,代码行数:35,代码来源:GAGridUtils.java

示例14: writeAll

import javax.cache.Cache.Entry; //导入依赖的package包/类
@Override
public void writeAll(Collection<Entry<? extends K, ? extends V>> entries)
    throws CacheWriterException {
  List<Put> puts = createPuts(entries);
  long start = System.currentTimeMillis();
  put(puts);
  long time = System.currentTimeMillis() - start;
  logger.debug("Put " + puts.size() + " values in " + time + "ms");
}
 
开发者ID:bakdata,项目名称:ignite-hbase,代码行数:10,代码来源:HBaseCacheStore.java

示例15: createPut

import javax.cache.Cache.Entry; //导入依赖的package包/类
private Put createPut(Entry<? extends K, ? extends V> entry) {
  try {
    Put put = new Put(keySerializer.serialize(entry.getKey()));
    put.addColumn(family(), QUALIFIER, valueSerializer.serialize(entry.getValue()));
    return put;
  } catch (SerializationException e) {
    throw new CacheWriterException("Failed to create put", e);
  }
}
 
开发者ID:bakdata,项目名称:ignite-hbase,代码行数:10,代码来源:HBaseCacheStore.java


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