/** * Create instance of this class. * * @param tr Trainer to sequentially compose. * @param datasetMapping Dataaset mapping. * @param shouldStop Predicate depending on index and model produced by the last trainer * indicating if composition process should stop. * @param out2Input Function for conversion of output of model into input of next model. */ public SameTrainersSequentialComposition( DatasetTrainer<IgniteModel<I, O>, L> tr, IgniteBiFunction<Integer, ? super IgniteModel<I, O>, IgniteFunction<LabeledVector<L>, LabeledVector<L>>> datasetMapping, IgniteBiPredicate<Integer, IgniteModel<I, O>> shouldStop, IgniteFunction<O, I> out2Input) { super(null, null, datasetMapping); this.tr = tr; this.shouldStop = (iteration, model) -> iteration != 0 && shouldStop.apply(iteration, model); this.out2Input = out2Input; }
/** {@inheritDoc} */ @Override public boolean apply(K k, V v){ try { return scanFilter == null || scanFilter.apply(k, v); } catch (Throwable e) { throw new IgniteException(e); } }
/** {@inheritDoc} */ @Override public <K, V> ModelsSequentialComposition<I, O, O> fit(DatasetBuilder<K, V> datasetBuilder, FeatureLabelExtractor<K, V, L> extractor) { int i = 0; IgniteModel<I, O> currMdl = null; IgniteFunction<LabeledVector<L>, LabeledVector<L>> mapping = IgniteFunction.identity(); List<IgniteModel<I, O>> mdls = new ArrayList<>(); while (!shouldStop.apply(i, currMdl)) { currMdl = tr.fit(datasetBuilder, extractor.andThen(mapping)); mdls.add(currMdl); if (shouldStop.apply(i, currMdl)) break; mapping = datasetMapping.apply(i, currMdl); i++; } return ModelsSequentialComposition.ofSame(mdls, out2Input); } }
.entrySet() .stream() .filter(en -> filter.apply(en.getKey(), en.getValue())) .map(en -> new UpstreamEntry<>(en.getKey(), en.getValue())) .forEach(entriesList::add);
&& recordFilter != null && !recordFilter.apply(rec.type(), ptr)) return FilteredRecord.INSTANCE; else if (marshalledMode) {
&& recordFilter != null && !recordFilter.apply(recType, ptr)) { int toSkip = ptr.length() - REC_TYPE_SIZE - FILE_WAL_POINTER_SIZE - CRC_SIZE;
/** {@inheritDoc} */ @Override protected GridCommunicationClient createTcpClient(ClusterNode node, int connIdx) throws IgniteCheckedException { if (pred.apply(getLocalNode(), node)) { Map<String, Object> attrs = new HashMap<>(node.attributes()); attrs.put(createAttributeName(ATTR_ADDRS), Collections.singleton("127.0.0.1")); attrs.put(createAttributeName(ATTR_PORT), 47200); attrs.put(createAttributeName(ATTR_EXT_ADDRS), Collections.emptyList()); attrs.put(createAttributeName(ATTR_HOST_NAMES), Collections.emptyList()); ((TcpDiscoveryNode)node).setAttributes(attrs); } return super.createTcpClient(node, connIdx); }
if (filter.apply(lRow, rRow)) { foundLeft = true; notFoundRight.remove(rRow);
if (!cb.apply(nodeId, evt)) ctx.continuous().stopRoutine(routineId);
@Override public void run() throws Exception { try { IgniteCache<Object, Object> cache = jcache(); IgniteBiPredicate<Object, Object> p = new IgniteBiPredicate<Object, Object>() { @Override public boolean apply(Object k, Object v) { assertNotNull(k); assertNotNull(v); return valueOf(k) >= 20 && valueOf(v) < 40; } }; Map<Object, Object> exp = new HashMap<>(); for (int i = 0; i < CNT; i++) { Object key = key(i); Object val = value(i); cache.put(key, val); if (p.apply(key, val)) exp.put(key, val); } registerEventListeners(exp, true); QueryCursor<Cache.Entry<Object, Object>> q = cache.query(new ScanQuery<>(p)); checkQueryResults(exp, q); } finally { stopListeners(); } } });
if (filter.apply(key, val)) { int part = affinity.partition(key);
boolean replicate, long ttl) { if (p != null && !p.apply(key.value(ctx.cacheObjectContext(), false), val)) return;
@Override public void run() throws Exception { try { IgniteCache<Object, Object> cache = jcache(); ClusterNode locNode = testedGrid().cluster().localNode(); Map<Object, Object> map = new HashMap<>(); IgniteBiPredicate<Object, Object> filter = new IgniteBiPredicate<Object, Object>() { @Override public boolean apply(Object k, Object v) { assertNotNull(k); assertNotNull(v); return valueOf(k) >= 20 && valueOf(v) < 40; } }; for (int i = 0; i < CNT; i++) { Object key = key(i); Object val = value(i); cache.put(key, val); if (!isClientMode() && (cacheMode() == REPLICATED || testedGrid().affinity(cacheName()).isPrimary(locNode, key)) && filter.apply(key, val)) map.put(key, val); } registerEventListeners(map, true); QueryCursor<Cache.Entry<Object, Object>> q = cache.query(new ScanQuery<>(filter).setLocal(true)); checkQueryResults(map, q); } finally { stopListeners(); } } });