本文整理汇总了Java中org.apache.ignite.IgniteCache.localPeek方法的典型用法代码示例。如果您正苦于以下问题:Java IgniteCache.localPeek方法的具体用法?Java IgniteCache.localPeek怎么用?Java IgniteCache.localPeek使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.IgniteCache
的用法示例。
在下文中一共展示了IgniteCache.localPeek方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: projectionsOfRegions
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
/**
* Get region projections in the form of map (regionIndex -> regionProjections).
*
* @param featureIdx Feature index.
* @param maxDepth Max depth of decision tree.
* @param regionIndexes Indexes of regions for which we want get projections.
* @param blockSize Size of regions block.
* @param affinity Affinity function.
* @param trainingUUID UUID of training.
* @param ignite Ignite instance.
* @return Region projections in the form of map (regionIndex -> regionProjections).
*/
public static Map<Integer, RegionProjection> projectionsOfRegions(int featureIdx, int maxDepth,
IntStream regionIndexes, int blockSize, IgniteFunction<Integer, Object> affinity, UUID trainingUUID,
Ignite ignite) {
HashMap<Integer, RegionProjection> regsForSearch = new HashMap<>();
IgniteCache<RegionKey, List<RegionProjection>> cache = getOrCreate(ignite);
PrimitiveIterator.OfInt itr = regionIndexes.iterator();
int curBlockIdx = -1;
List<RegionProjection> block = null;
Object affinityKey = affinity.apply(featureIdx);
while (itr.hasNext()) {
int i = itr.nextInt();
int blockIdx = i / blockSize;
if (blockIdx != curBlockIdx) {
block = cache.localPeek(key(featureIdx, blockIdx, affinityKey, trainingUUID));
curBlockIdx = blockIdx;
}
if (block == null)
throw new IllegalStateException("Unexpected null block at index " + i);
RegionProjection reg = block.get(i % blockSize);
if (reg.depth() < maxDepth)
regsForSearch.put(i, reg);
}
return regsForSearch;
}
示例2: execute
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
/**
* Perform mutation
*/
public Boolean execute() throws IgniteException {
// TODO Auto-generated method stub
IgniteCache<Long, Chromosome> populationCache = ignite.cache(GAGridConstants.POPULATION_CACHE);
Chromosome chromosome = populationCache.localPeek(key);
long[] geneKeys = chromosome.getGenes();
for (int k = 0; k < this.mutatedGeneKeys.size(); k++) {
{
geneKeys[k] = this.mutatedGeneKeys.get(k);
}
}
chromosome.setGenes(geneKeys);
Transaction tx = ignite.transactions().txStart();
populationCache.put(chromosome.id(), chromosome);
tx.commit();
return Boolean.TRUE;
}
示例3: execute
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
/**
* Perform mutation
*/
public Boolean execute() throws IgniteException {
// TODO Auto-generated method stub
IgniteCache<Long, Chromosome> populationCache = ignite.cache(GAGridConstants.POPULATION_CACHE);
Chromosome chromosome = populationCache.localPeek(key);
long[] geneKeys = chromosome.getGenes();
for (int k = 0; k < this.mutatedGeneKeys.size(); k++) {
// Mutate gene based on MutatonRate
if (this.mutationRate > Math.random()) {
geneKeys[k] = this.mutatedGeneKeys.get(k);
}
}
chromosome.setGenes(geneKeys);
Transaction tx = ignite.transactions().txStart();
populationCache.put(chromosome.id(), chromosome);
tx.commit();
return Boolean.TRUE;
}
示例4: execute
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
/**
* Perform fitness operation utilizing IFitnessFunction
*
* Update chromosome's fitness value
*
*/
public Double execute() throws IgniteException {
IgniteCache<Long, Chromosome> populationCache = ignite.cache(GAGridConstants.POPULATION_CACHE);
IgniteCache<Long, Gene> geneCache = ignite.cache(GAGridConstants.GENE_CACHE);
Chromosome chromosome = populationCache.localPeek(key);
long[] geneKeys = chromosome.getGenes();
List<Gene> genes = new ArrayList();
for (int i = 0; i < geneKeys.length; i++) {
long aKey = geneKeys[i];
Gene aGene = geneCache.localPeek(aKey);
genes.add(aGene);
}
Double value = fitnessFuncton.evaluate(genes);
chromosome.setFitnessScore(value);
Transaction tx = ignite.transactions().txStart();
populationCache.put(chromosome.id(), chromosome);
tx.commit();
return value;
}
示例5: execute
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
/**
* Perform crossover operation
*/
public Object execute() throws IgniteException {
if (this.crossOverRate > Math.random()) {
IgniteCache<Long, Chromosome> populationCache = ignite.cache(GAGridConstants.POPULATION_CACHE);
Transaction tx = ignite.transactions().txStart();
Chromosome chromosome1 = populationCache.localPeek(this.key1);
Chromosome chromosome2 = populationCache.localPeek(this.key2);
long[] genesforChrom1 = chromosome1.getGenes();
long[] genesforChrom2 = chromosome2.getGenes();
Random rn = new Random();
// compute index to start for copying respective genes
int geneIndexStartSwap = rn.nextInt(genesforChrom1.length);
long[] newKeySwapArrayForChrome1 =
Arrays.copyOfRange(genesforChrom2, geneIndexStartSwap, genesforChrom1.length);
long[] newKeySwapArrayForChrome2 =
Arrays.copyOfRange(genesforChrom1, geneIndexStartSwap, genesforChrom1.length);
long[] newGeneKeysForChrom1 = crossOver(newKeySwapArrayForChrome1, geneIndexStartSwap, genesforChrom1);
long[] newGeneKeysForChrom2 = crossOver(newKeySwapArrayForChrome2, geneIndexStartSwap, genesforChrom2);
chromosome1.setGenes(newGeneKeysForChrom1);
populationCache.put(chromosome1.id(), chromosome1);
chromosome2.setGenes(newGeneKeysForChrom2);
populationCache.put(chromosome2.id(), chromosome2);
tx.commit();
}
return null;
}
示例6: values
import org.apache.ignite.IgniteCache; //导入方法依赖的package包/类
/**
* Get values of feature with given index.
*
* @param featIdx Feature index.
* @param ignite Ignite instance.
* @return Values of feature with given index.
*/
public double[] values(int featIdx, Ignite ignite) {
IgniteCache<FeaturesCache.FeatureKey, double[]> featuresCache = ignite.getOrCreateCache(COLUMN_DECISION_TREE_TRAINER_FEATURES_CACHE_NAME);
return featuresCache.localPeek(FeaturesCache.getFeatureCacheKey(featIdx, trainingUUID, input.affinityKey(featIdx, ignite)));
}