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


Java IgnitePredicate.apply方法代码示例

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


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

示例1: compoundPredicate

import org.apache.ignite.lang.IgnitePredicate; //导入方法依赖的package包/类
/**
 * @param p Predicate.
 * @param types Event types.
 * @return Compound predicate.
 */
private static <T extends Event> IgnitePredicate<T> compoundPredicate(final IgnitePredicate<T> p,
    @Nullable final int... types) {

    return F.isEmpty(types) ? p :
        new IgnitePredicate<T>() {
            @Override public boolean apply(T t) {
                for (int type : types) {
                    if (type == t.type())
                        return p.apply(t);
                }

                return false;
            }
        };
}
 
开发者ID:apache,项目名称:ignite,代码行数:21,代码来源:IgniteEventsImpl.java

示例2: partition

import org.apache.ignite.lang.IgnitePredicate; //导入方法依赖的package包/类
/**
 * Partitions input collection in two: first containing elements for which given
 * predicate evaluates to {@code true} - and second containing the elements for which
 * predicate evaluates to {@code false}.
 *
 * @param c Input collection.
 * @param p Partitioning predicate.
 * @param <V> Type of the collection elements.
 * @return Tuple of two collections: first containing elements for which given predicate
 *      evaluates to {@code true} - and second containing the elements for which predicate
 *      evaluates to {@code false}.
 */
@Deprecated
public static <V> IgniteBiTuple<Collection<V>, Collection<V>> partition(Iterable<? extends V> c,
    IgnitePredicate<? super V> p) {
    A.notNull(c, "c", p, "p");

    Collection<V> c1 = new LinkedList<>();
    Collection<V> c2 = new LinkedList<>();

    for (V v : c) {
        if (p.apply(v))
            c1.add(v);
        else
            c2.add(v);
    }

    return t(c1, c2);
}
 
开发者ID:apache,项目名称:ignite,代码行数:30,代码来源:GridFunc.java

示例3: backupWithFiltering

import org.apache.ignite.lang.IgnitePredicate; //导入方法依赖的package包/类
/**
 * Performs main backup logic.
 *
 * @param destination to where backup should be saved.
 * @param filteringCondition specifies which data (based on metadata) out of all available ones should be included
 * in backup
 * @throws IOException in case of errors during backup
 */
private void backupWithFiltering(URI destination, IgnitePredicate<Metadata> filteringCondition,
    String snapshotLabel) throws IOException {
    try {
        Iterable<Metadata> metadatas;
        try (Exporter.WriterProvider provider = exporter.write(destination)) {
            try (Exporter.Writer writer = provider.open(METADATA_RESOURCE_NAME)) {
                metadatas = metadataManager.backup(writer);
            }
        }
        Collection<Metadata> filteredMetadatas = new ArrayList<>();
        for (Metadata metadata : metadatas) {
            if (filteringCondition.apply(metadata)) {
                filteredMetadatas.add(metadata);
            }
        }
        create(snapshotLabel); // create new head
        Map<String, List<Metadata>> byCache = keyValueManager.getSnapshotsByCache(filteredMetadatas);
        if (byCache.isEmpty()) {
            return;
        }
        ignite.compute().execute(new BackupTaskSplitAdapter(destination), byCache);
    }
    catch (Exception e) {
        exporter.cleanup(destination);
        throw e;
    }
}
 
开发者ID:epam,项目名称:Lagerta,代码行数:36,代码来源:CommandServiceImpl.java

示例4: findTablesInFrom

import org.apache.ignite.lang.IgnitePredicate; //导入方法依赖的package包/类
/**
 * Processes all the tables and subqueries using the given closure.
 *
 * @param from FROM element.
 * @param c Closure each found table and subquery will be passed to. If returns {@code true} the we need to stop.
 * @return {@code true} If we have found.
 */
@SuppressWarnings("RedundantCast")
private static boolean findTablesInFrom(GridSqlElement from, IgnitePredicate<GridSqlElement> c) {
    if (from == null)
        return false;

    if (from instanceof GridSqlTable || from instanceof GridSqlSubquery)
        return c.apply(from);

    if (from instanceof GridSqlJoin) {
        // Left and right.
        if (findTablesInFrom((GridSqlElement)from.child(0), c))
            return true;

        if (findTablesInFrom((GridSqlElement)from.child(1), c))
            return true;

        // We don't process ON condition because it is not a joining part of from here.
        return false;
    }
    else if (from instanceof GridSqlAlias)
        return findTablesInFrom((GridSqlElement)from.child(), c);
    else if (from instanceof GridSqlFunction)
        return false;

    throw new IllegalStateException(from.getClass().getName() + " : " + from.getSQL());
}
 
开发者ID:apache,项目名称:ignite,代码行数:34,代码来源:DmlAstUtils.java

示例5: checkFiles

import org.apache.ignite.lang.IgnitePredicate; //导入方法依赖的package包/类
/**
 * Validate files depending on {@link DataStorageConfiguration#getWalSegments()}  and create if need. Check end
 * when exit condition return false or all files are passed.
 *
 * @param startWith Start with.
 * @param create Flag create file.
 * @param p Predicate Exit condition.
 * @throws IgniteCheckedException if validation or create file fail.
 */
private void checkFiles(
    int startWith,
    boolean create,
    @Nullable IgnitePredicate<Integer> p,
    @Nullable IgniteInClosure<Integer> completionCallback
) throws IgniteCheckedException {
    for (int i = startWith; i < dsCfg.getWalSegments() && (p == null || p.apply(i)); i++) {
        File checkFile = new File(walWorkDir, FileDescriptor.fileName(i));

        if (checkFile.exists()) {
            if (checkFile.isDirectory())
                throw new IgniteCheckedException("Failed to initialize WAL log segment (a directory with " +
                    "the same name already exists): " + checkFile.getAbsolutePath());
            else if (checkFile.length() != dsCfg.getWalSegmentSize() && mode == WALMode.DEFAULT)
                throw new IgniteCheckedException("Failed to initialize WAL log segment " +
                    "(WAL segment size change is not supported in 'DEFAULT' WAL mode) " +
                    "[filePath=" + checkFile.getAbsolutePath() +
                    ", fileSize=" + checkFile.length() +
                    ", configSize=" + dsCfg.getWalSegments() + ']');
        }
        else if (create)
            createFile(checkFile);

        if (completionCallback != null)
            completionCallback.apply(i);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:37,代码来源:FileWriteAheadLogManager.java

示例6: dumpWithReset

import org.apache.ignite.lang.IgnitePredicate; //导入方法依赖的package包/类
/**
 * Dump existing queue to stdout and atomically replace it with given.
 *
 * @param q2 Queue.
 * @param filter Filter for logged debug items.
 * @return Empty string.
 */
public static String dumpWithReset(
    @Nullable ConcurrentLinkedQueue<Item> q2,
    @Nullable IgnitePredicate<Item> filter
) {
    ConcurrentLinkedQueue<Item> q;

    do {
        q = que.get();

        if (q == null)
            break; // Stopped.
    }
    while (!que.compareAndSet(q, q2));

    Collection<Item> col = null;

    if (filter == null)
        col = q;
    else if (q != null) {
        col = new ArrayList<>();

        for (Item item : q) {
            if (filter.apply(item))
                col.add(item);
        }
    }

    dump(col);

    return "";
}
 
开发者ID:apache,项目名称:ignite,代码行数:39,代码来源:GridDebug.java

示例7: checkAndSet

import org.apache.ignite.lang.IgnitePredicate; //导入方法依赖的package包/类
/**
 * Atomically updates value only if passed in predicate returns {@code true}.
 *
 * @param p Predicate to check.
 * @param update Value to set.
 * @return {@code True} if value was set.
 */
public boolean checkAndSet(IgnitePredicate<Long> p, long update) {
    while (true) {
        long cur = get();

        if (p.apply(cur)) {
            if (compareAndSet(cur, update))
                return true;
        }
        else
            return false;
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:GridAtomicLong.java

示例8: hasNextX

import org.apache.ignite.lang.IgnitePredicate; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override public boolean hasNextX() {
    if (GridFunc.isEmpty(preds))
        return iter.hasNext();
    else {
        if (!moved)
            return more;
        else {
            more = false;

            while (iter.hasNext()) {
                elem = iter.next();

                boolean isAll = true;

                for (IgnitePredicate<? super T1> r : preds)
                    if (r != null && !r.apply(elem)) {
                        isAll = false;

                        break;
                    }

                if (isAll) {
                    more = true;
                    moved = false;

                    return true;
                }
            }

            elem = null; // Give to GC.

            return false;
        }
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:37,代码来源:TransformFilteringIterator.java

示例9: checkAndSet

import org.apache.ignite.lang.IgnitePredicate; //导入方法依赖的package包/类
/**
 * Atomically updates value only if passed in predicate returns {@code true}.
 *
 * @param p Predicate to check.
 * @param update Value to set.
 * @return {@code True} if value was set.
 */
public boolean checkAndSet(IgnitePredicate<Integer> p, int update) {
    while (true) {
        int cur = get();

        if (p.apply(cur)) {
            if (compareAndSet(cur, update))
                return true;
        }
        else
            return false;
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:GridAtomicInteger.java

示例10: passIgniteConfigFilter

import org.apache.ignite.lang.IgnitePredicate; //导入方法依赖的package包/类
/**
 * @param variation Variation.
 * @return {@code True} if variation pass filters.
 */
private boolean passIgniteConfigFilter(int[] variation) {
    ConfigVariationsFactory factory = new ConfigVariationsFactory(igniteParams, variation, null, null);

    IgniteConfiguration cfg = factory.getConfiguration(null, null);

    if (igniteCfgFilters != null) {
        for (IgnitePredicate<IgniteConfiguration> filter : igniteCfgFilters) {
            if (!filter.apply(cfg))
                return false;
        }
    }

    return true;
}
 
开发者ID:apache,项目名称:ignite,代码行数:19,代码来源:ConfigVariationsTestSuiteBuilder.java

示例11: passCacheConfigFilter

import org.apache.ignite.lang.IgnitePredicate; //导入方法依赖的package包/类
/**
 * @param variation Variation.
 * @return {@code True} if variation pass filters.
 */
private boolean passCacheConfigFilter(int[] variation) {
    ConfigVariationsFactory factory = new ConfigVariationsFactory(null, null, cacheParams, variation);

    CacheConfiguration cfg = factory.cacheConfiguration(null);

    if (cacheCfgFilters != null) {
        for (IgnitePredicate<CacheConfiguration> filter : cacheCfgFilters) {
            if (!filter.apply(cfg))
                return false;
        }
    }

    return true;
}
 
开发者ID:apache,项目名称:ignite,代码行数:19,代码来源:ConfigVariationsTestSuiteBuilder.java

示例12: populateCache

import org.apache.ignite.lang.IgnitePredicate; //导入方法依赖的package包/类
/**
 * Fill cache.
 *
 * @throws IgniteCheckedException if failed.
 */
private static Set<Integer> populateCache(IgniteEx ignite, boolean loc, int cnt,
    IgnitePredicate<Integer> expectedEntryFilter) throws IgniteCheckedException {
    IgniteInternalCache<Integer, Person> cache = ignite.cachex(PERSON_CACHE);

    assertNotNull(cache);

    Random rand = new Random();

    HashSet<Integer> exp = new HashSet<>();

    Affinity<Integer> aff = cache.affinity();

    ClusterNode localNode = cache.context().localNode();

    for (int i = 0; i < cnt; i++) {
        int val = rand.nextInt(cnt);

        cache.put(val, new Person(String.valueOf(val), val));

        if (expectedEntryFilter.apply(val) && (!loc || aff.isPrimary(localNode, val)))
            exp.add(val);
    }

    return exp;
}
 
开发者ID:apache,项目名称:ignite,代码行数:31,代码来源:GridCacheFullTextQuerySelfTest.java

示例13: applyUpdatesOnRecovery

import org.apache.ignite.lang.IgnitePredicate; //导入方法依赖的package包/类
/**
 * Apply update from some iterator and with specific filters.
 *
 * @param it WalIterator.
 * @param recPredicate Wal record filter.
 * @param entryPredicate Entry filter.
 * @param partStates Partition to restore state.
 */
public void applyUpdatesOnRecovery(
    WALIterator it,
    IgnitePredicate<IgniteBiTuple<WALPointer, WALRecord>> recPredicate,
    IgnitePredicate<DataEntry> entryPredicate,
    Map<T2<Integer, Integer>, T2<Integer, Long>> partStates
) throws IgniteCheckedException {
    while (it.hasNextX()) {
        IgniteBiTuple<WALPointer, WALRecord> next = it.nextX();

        WALRecord rec = next.get2();

        if (!recPredicate.apply(next))
            break;

        switch (rec.type()) {
            case DATA_RECORD:
                checkpointReadLock();

                try {
                    DataRecord dataRec = (DataRecord) rec;

                    for (DataEntry dataEntry : dataRec.writeEntries()) {
                        if (entryPredicate.apply(dataEntry)) {
                            checkpointReadLock();

                            try {
                                int cacheId = dataEntry.cacheId();

                                GridCacheContext cacheCtx = cctx.cacheContext(cacheId);

                                if (cacheCtx != null)
                                    applyUpdate(cacheCtx, dataEntry);
                                else if (log != null)
                                    log.warning("Cache (cacheId=" + cacheId + ") is not started, can't apply updates.");
                            }
                            finally {
                                checkpointReadUnlock();
                            }
                        }
                    }
                }
                finally {
                    checkpointReadUnlock();
                }

                break;

            default:
                // Skip other records.
        }
    }

    checkpointReadLock();

    try {
        restorePartitionState(partStates);
    }
    finally {
        checkpointReadUnlock();
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:70,代码来源:GridCacheDatabaseSharedManager.java

示例14: isAll

import org.apache.ignite.lang.IgnitePredicate; //导入方法依赖的package包/类
/**
 * Tests if all provided predicates evaluate to {@code true} for given value. Note that
 * evaluation will be short-circuit when first predicate evaluated to {@code false} is found.
 *
 * @param t Value to test.
 * @param p Optional set of predicates to use for evaluation. If no predicates provides
 *      this method will always return {@code true}.
 * @param <T> Type of the value and free variable of the predicates.
 * @return Returns {@code true} if given set of predicates is {@code null}, is empty, or all predicates
 *      evaluate to {@code true} for given value, {@code false} otherwise.
 */
public static <T> boolean isAll(@Nullable T t, @Nullable IgnitePredicate<? super T>... p) {
    if (p != null)
        for (IgnitePredicate<? super T> r : p)
            if (r != null && !r.apply(t))
                return false;

    return true;
}
 
开发者ID:apache,项目名称:ignite,代码行数:20,代码来源:GridFunc.java

示例15: isAny

import org.apache.ignite.lang.IgnitePredicate; //导入方法依赖的package包/类
/**
 * Tests if any of provided predicates evaluate to {@code true} for given value. Note
 * that evaluation will be short-circuit when first predicate evaluated to {@code true}
 * is found.
 *
 * @param t Value to test.
 * @param p Optional set of predicates to use for evaluation.
 * @param <T> Type of the value and free variable of the predicates.
 * @return Returns {@code true} if any of predicates evaluates to {@code true} for given
 *      value, {@code false} otherwise. Returns {@code false} if given set of predicates
 *      is {@code null} or empty.
 */
@Deprecated
public static <T> boolean isAny(@Nullable T t, @Nullable IgnitePredicate<? super T>... p) {
    if (p != null)
        for (IgnitePredicate<? super T> r : p)
            if (r != null && r.apply(t))
                return true;

    return false;
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:GridFunc.java


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