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


Java IgniteCache.query方法代码示例

本文整理汇总了Java中org.apache.ignite.IgniteCache.query方法的典型用法代码示例。如果您正苦于以下问题:Java IgniteCache.query方法的具体用法?Java IgniteCache.query怎么用?Java IgniteCache.query使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ignite.IgniteCache的用法示例。


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

示例1: selectGeneByChromsomeCriteria

import org.apache.ignite.IgniteCache; //导入方法依赖的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 org.apache.ignite.IgniteCache; //导入方法依赖的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 org.apache.ignite.IgniteCache; //导入方法依赖的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 org.apache.ignite.IgniteCache; //导入方法依赖的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 org.apache.ignite.IgniteCache; //导入方法依赖的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: executeWithHints

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
private Iterable<List<?>> executeWithHints(IgniteCache<Object, BinaryObject> cache, SqlFieldsQuery sqlQuery, QueryHints hints) {
	Iterable<List<?>> result;

	if ( hints.isLocal() ) {
		if ( !provider.isClientMode() ) {
			sqlQuery.setLocal( true );
		}
	}
	if ( hints.isAffinityRun() ) {
		result = provider.affinityCall( cache.getName(), hints.getAffinityKey(), sqlQuery );
	}
	else {
		result = cache.query( sqlQuery );
	}

	return result;
}
 
开发者ID:hibernate,项目名称:hibernate-ogm-ignite,代码行数:18,代码来源:IgniteDialect.java

示例7: getNumberOfAssociations

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
@Override
public long getNumberOfAssociations(SessionFactory sessionFactory) {
	int associationCount = 0;
	IgniteDatastoreProvider datastoreProvider = getProvider( sessionFactory );
	for ( CollectionPersister collectionPersister : ( (SessionFactoryImplementor) sessionFactory ).getCollectionPersisters().values() ) {
		AssociationKeyMetadata associationKeyMetadata = ( (OgmCollectionPersister) collectionPersister ).getAssociationKeyMetadata();
		if ( associationKeyMetadata.getAssociationKind() == AssociationKind.ASSOCIATION ) {
			IgniteCache<Object, BinaryObject> associationCache = getAssociationCache( sessionFactory, associationKeyMetadata );
			StringBuilder query = new StringBuilder( "SELECT " )
										.append( StringHelper.realColumnName( associationKeyMetadata.getColumnNames()[0] ) )
										.append( " FROM " ).append( associationKeyMetadata.getTable() );
			SqlFieldsQuery sqlQuery = datastoreProvider.createSqlFieldsQueryWithLog( query.toString(), null );
			Iterable<List<?>> queryResult = associationCache.query( sqlQuery );
			Set<Object> uniqs = new HashSet<>();
			for ( List<?> row : queryResult ) {
				Object value = row.get( 0 );
				if ( value != null ) {
					uniqs.add( value );
				}
			}
			associationCount += uniqs.size();
		}
	}
	return associationCount;
}
 
开发者ID:hibernate,项目名称:hibernate-ogm-ignite,代码行数:26,代码来源:IgniteTestHelper.java

示例8: getMostPopulatedCities

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
private static void getMostPopulatedCities(IgniteCache countryCache) {
    SqlFieldsQuery query = new SqlFieldsQuery(
        "SELECT name, population FROM country " +
        "ORDER BY population DESC LIMIT 10");

    FieldsQueryCursor<List<?>> cursor = countryCache.query(query);

    Iterator<List<?>> iterator = cursor.iterator();

    System.out.println();
    System.out.println(">>> 10 Most Populated Cities:");

    while (iterator.hasNext()) {
        List row = iterator.next();

        System.out.println("    >>> " + row.get(1) + " people live in " + row.get(0));
    }
}
 
开发者ID:dmagda,项目名称:ignite_world_demo,代码行数:19,代码来源:SqlDataProcessing.java

示例9: getTopCitiesInThreeCountries

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
private static void getTopCitiesInThreeCountries(IgniteCache countryCache) {
    SqlFieldsQuery query = new SqlFieldsQuery(
        "SELECT country.name, city.name, MAX(city.population) as max_pop FROM country " +
        "JOIN city ON city.countrycode = country.code " +
        "WHERE country.code IN ('USA','RUS','CHN') " +
        "GROUP BY country.name, city.name ORDER BY max_pop DESC LIMIT 3");

    FieldsQueryCursor<List<?>> cursor = countryCache.query(query);

    Iterator<List<?>> iterator = cursor.iterator();

    System.out.println();
    System.out.println(">>> 3 Most Populated Cities in US, RUS and CHN:");

    while (iterator.hasNext()) {
        List row = iterator.next();

        System.out.println("    >>> " + row.get(2) + " people live in " + row.get(1) + ", " + row.get(0));
    }
}
 
开发者ID:dmagda,项目名称:ignite_world_demo,代码行数:21,代码来源:SqlDataProcessing.java

示例10: getGenesInOrderForChromosome

import org.apache.ignite.IgniteCache; //导入方法依赖的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

示例11: calculateAverageFitness

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
/**
 * Calculate average fitness value
 * 
 * @return Double
 */

private Double calculateAverageFitness() {

    double avgFitnessScore = 0;

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

    // Execute query to get names of all employees.
    SqlFieldsQuery sql = new SqlFieldsQuery("select AVG(FITNESSSCORE) from Chromosome");

    // Iterate over the result set.
    try (QueryCursor<List<?>> cursor = cache.query(sql)) {
        for (List<?> row : cursor)
            avgFitnessScore = (Double) row.get(0);
    }

    return avgFitnessScore;
}
 
开发者ID:techbysample,项目名称:gagrid,代码行数:24,代码来源:GAGrid.java

示例12: getCityDetails

import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
private static void getCityDetails(IgniteCache cityCache, int cityId) {
    SqlFieldsQuery query = new SqlFieldsQuery("SELECT * FROM City WHERE id = ?").setArgs(cityId);

    FieldsQueryCursor<List<?>> cursor = cityCache.query(query);

    Iterator<List<?>> iterator = cursor.iterator();

    int colCount = cursor.getColumnsCount();

    System.out.println();
    System.out.println(">>> City Info:");

    while (iterator.hasNext()) {
        List row = iterator.next();

        for (int i = 0; i < colCount; i++)
            System.out.println(row.get(i));
    }
}
 
开发者ID:dmagda,项目名称:ignite_world_demo,代码行数:20,代码来源:SqlDataProcessing.java


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