/** * @param futId Future ID. * @param txKeys Target tx keys. */ public TxLocksRequest(long futId, Set<IgniteTxKey> txKeys) { A.notEmpty(txKeys, "txKeys"); this.futId = futId; this.txKeys = txKeys; }
/** * Create an intance of ParametricVectorGenerator. * * @param paramGenerator Parameter generator. * @param perDimensionGenerators Per dimension generators. */ public ParametricVectorGenerator(RandomProducer paramGenerator, IgniteFunction<Double, Double>... perDimensionGenerators) { A.notEmpty(perDimensionGenerators, "perDimensionGenerators.length != 0"); this.perDimensionGenerators = Arrays.asList(perDimensionGenerators); this.randomProducer = paramGenerator; }
/** {@inheritDoc} */ @Override public Double apply(double[] estimations) { A.notEmpty(estimations, "estimations vector"); Map<Double, Integer> cntrsByCls = new HashMap<>(); for (Double predictedValue : estimations) { Integer cntrVal = cntrsByCls.getOrDefault(predictedValue, 0) + 1; cntrsByCls.put(predictedValue, cntrVal); } return cntrsByCls.entrySet().stream() .max(Comparator.comparing(Map.Entry::getValue)) .get().getKey(); } }
/** * @param seed Seed. * @return GaussianMixtureDataStream instance. */ public GaussianMixtureDataStream build(long seed) { A.notEmpty(componentGenerators, "this.means.size()"); return new GaussianMixtureDataStream(componentGenerators, seed); } }
/** {@inheritDoc} */ @Override public Double apply(double[] estimations) { A.notEmpty(estimations, "estimations vector"); return Arrays.stream(estimations).reduce(0.0, Double::sum) / estimations.length; } }
/** * Creates {@link VectorGenerator} with vectors having feature values in according to * preudorandom producers. * * @param producers Feature value producers. * @return Vector generator. */ public static VectorGenerator vectorize(RandomProducer... producers) { A.notEmpty(producers, "producers"); return () -> VectorUtils.of(Arrays.stream(producers).mapToDouble(Supplier::get).toArray()); } }
/** * Builds VectorGeneratorsFamily instance. * * @param seed Seed. * @return Vector generators family. */ public VectorGeneratorsFamily build(long seed) { A.notEmpty(family, "family.size != 0"); double sumOfWeigts = weights.stream().mapToDouble(x -> x).sum(); double[] probs = weights.stream().mapToDouble(w -> w / sumOfWeigts).toArray(); List<VectorGenerator> mappedFamilily = family.stream().map(mapper).collect(Collectors.toList()); return new VectorGeneratorsFamily(mappedFamilily, new DiscreteRandomProducer(seed, probs)); } }
/** {@inheritDoc} */ @Override public IgniteFuture<?> addData(Collection<? extends Map.Entry<K, V>> entries) { A.notEmpty(entries, "entries"); checkSecurityPermission(SecurityPermission.CACHE_PUT); Collection<DataStreamerEntry> batch = new ArrayList<>(entries.size()); for (Map.Entry<K, V> entry : entries) { KeyCacheObject key = cacheObjProc.toCacheKeyObject(cacheObjCtx, null, entry.getKey(), true); CacheObject val = cacheObjProc.toCacheObject(cacheObjCtx, entry.getValue(), true); batch.add(new DataStreamerEntry(key, val)); } return addDataInternal(batch); }
/** {@inheritDoc} */ @Override public final ClusterGroup forNodeIds(Collection<UUID> ids) { A.notEmpty(ids, "ids"); guard(); try { Set<UUID> nodeIds = U.newHashSet(ids.size()); for (UUID id : ids) { if (contains(id)) nodeIds.add(id); } return new ClusterGroupAdapter(ctx, subjId, nodeIds); } finally { unguard(); } }
/** * Prepares the partitions. * * @param parts Partitions. */ protected int[] prepare(int[] parts) { if (parts == null) return null; A.notEmpty(parts, "Partitions"); boolean sorted = true; // Try to do validation in one pass, if array is already sorted. for (int i = 0; i < parts.length; i++) { if (i < parts.length - 1) if (parts[i] > parts[i + 1]) sorted = false; else if (sorted) validateDups(parts[i], parts[i + 1]); A.ensure(0 <= parts[i] && parts[i] < CacheConfiguration.MAX_PARTITIONS_COUNT, "Illegal partition"); } // Sort and validate again. if (!sorted) { Arrays.sort(parts); for (int i = 0; i < parts.length; i++) { if (i < parts.length - 1) validateDups(parts[i], parts[i + 1]); } } return parts; }
/** {@inheritDoc} */ @Override public void disableLocal(int[] types) { A.notEmpty(types, "types"); guard(); try { ctx.event().disableEvents(types); } finally { unguard(); } }
/** {@inheritDoc} */ @Override public final ClusterGroup forNodes(Collection<? extends ClusterNode> nodes) { A.notEmpty(nodes, "nodes"); guard(); try { Set<UUID> nodeIds = U.newHashSet(nodes.size()); for (ClusterNode n : nodes) if (contains(n)) nodeIds.add(n.id()); return new ClusterGroupAdapter(ctx, subjId, nodeIds); } finally { unguard(); } }
/** {@inheritDoc} */ @Override public void enableLocal(int[] types) { A.notEmpty(types, "types"); guard(); try { ctx.event().enableEvents(types); } finally { unguard(); } }
/** {@inheritDoc} */ @Override public void localListen(IgnitePredicate<? extends Event> lsnr, int[] types) { A.notNull(lsnr, "lsnr"); A.notEmpty(types, "types"); guard(); try { ctx.event().addLocalEventListener(lsnr, types); } finally { unguard(); } }
/** * Call implementation. * * @param jobs Jobs. * @return Internal future. */ private <R> IgniteInternalFuture<Collection<R>> callAsync0(Collection<? extends IgniteCallable<R>> jobs) { A.notEmpty(jobs, "jobs"); guard(); try { return ctx.closure().callAsync(BALANCE, (Collection<? extends Callable<R>>)jobs, prj.nodes(), execName); } finally { unguard(); } }
/** * Run implementation. * * @param jobs Jobs. * @return Internal future. */ private IgniteInternalFuture<?> runAsync0(Collection<? extends IgniteRunnable> jobs) { A.notEmpty(jobs, "jobs"); guard(); try { return ctx.closure().runAsync(BALANCE, jobs, prj.nodes(), execName); } finally { unguard(); } }
/** * Call with reducer implementation. * * @param jobs Jobs. * @param rdc Reducer. * @return Internal future. */ private <R1, R2> IgniteInternalFuture<R2> callAsync0(Collection<? extends IgniteCallable<R1>> jobs, IgniteReducer<R1, R2> rdc) { A.notEmpty(jobs, "jobs"); A.notNull(rdc, "rdc"); guard(); try { return ctx.closure().forkjoinAsync(BALANCE, jobs, rdc, prj.nodes(), execName); } finally { unguard(); } }
/** * Returns vector generator of vectors from multidimension gauss distribution. * * @param means Mean values per dimension. * @param variances Variance values per dimension. * @param seed Seed. * @return Generator. */ public static VectorGenerator gauss(Vector means, Vector variances, Long seed) { A.notEmpty(means.asArray(), "mean.size() != 0"); A.ensure(means.size() == variances.size(), "mean.size() == variances.size()"); RandomProducer[] producers = new RandomProducer[means.size()]; for (int i = 0; i < producers.length; i++) producers[i] = new GaussRandomProducer(means.get(i), variances.get(i), seed *= 2); return RandomProducer.vectorize(producers); }
/** * @param params Params */ @SafeVarargs ComplexParameter(ConfigParameter<T>... params) { A.notEmpty(params, "params"); this.params = params; if (params.length == 1) name = params[0].name(); else { SB sb = new SB(params[0].name()); for (int i = 1; i < params.length; i++) sb.a('-').a(params[i]); name = sb.toString(); } }
/** {@inheritDoc} */ @Override public void disableLocal(int[] types) { A.notEmpty(types, "types"); guard(); try { ctx.event().disableEvents(types); } finally { unguard(); } }