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


Java Predicate类代码示例

本文整理汇总了Java中com.hazelcast.query.Predicate的典型用法代码示例。如果您正苦于以下问题:Java Predicate类的具体用法?Java Predicate怎么用?Java Predicate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: findByFilters

import com.hazelcast.query.Predicate; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Collection<LogBean> findByFilters(JsonNode jsonNode) {
	Iterator<String> fieldNames = jsonNode.fieldNames();
	Predicate<String, LogBean> predicate = null;
	while(fieldNames.hasNext()) {
		String field = fieldNames.next();
		String value = jsonNode.get(field).asText();

		Predicate<String, LogBean> tmp = Predicates.equal(field, value);
		if(predicate == null) {
			predicate = tmp;
		} else {
			predicate = Predicates.and(predicate, tmp);
		}
	}
	return logRepository.findByPredicate(predicate);
}
 
开发者ID:Mockenize,项目名称:mockenize-server,代码行数:18,代码来源:LoggingService.java

示例2: getLastPartKeyForUri

import com.hazelcast.query.Predicate; //导入依赖的package包/类
public DocumentKey getLastPartKeyForUri(String uri) {
	IMap<DocumentKey, Document> xdd = nodeEngine.getHazelcastInstance().getMap(CN_XDM_DOCUMENT);
	Predicate<DocumentKey, Document> pp = new PartitionPredicate(uri.hashCode(), Predicates.equal("uri", uri));
	Set<DocumentKey> keys = xdd.keySet(pp);
	DocumentKey last = null;
	for (DocumentKey key: keys) {
		if (last == null) {
			last = key;
		} else {
			if (key.getVersion() > last.getVersion()) {
				last = key;
			}
		}
	}
	// alternatively, can run it on partition via QueryPartitionOperation:
	//QueryPartitionOperation op = new QueryPartitionOperation(query);
	//op.setMapService(svc);
	//int partId = nodeEngine.getPartitionService().getPartitionId(uri.hashCode());
	//op.setPartitionId(partId);
	//op.beforeRun();
	//op.run();
	//QueryResult rs = (QueryResult) op.getResponse();
	logger.trace("getLastPartKeyForUri; uri: {}; returning: {}", uri, last);
	return last;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:26,代码来源:DataDistributionService.java

示例3: getQuery

import com.hazelcast.query.Predicate; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static Predicate<DocumentKey, Document> getQuery(SchemaRepository repo, String pattern) {
	String[] parts = pattern.split(",");
	Predicate<DocumentKey, Document> result = null;
	for (String part: parts) {
		//logger.trace("getDocumentUris; translating query part: {}", part);
		Predicate<DocumentKey, Document> query = toPredicate(repo, part.trim());
		if (query != null) {
			if (result == null) {
				result = query;
			} else {
				result = Predicates.and(result, query);
			}
		} else {
		//	logger.info("getDocumentUris; cannot translate query part '{}' to Predicate, skipping", part);
		}
	}
	return result;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:20,代码来源:DocumentPredicateBuilder.java

示例4: getCollectionDocumentKeys

import com.hazelcast.query.Predicate; //导入依赖的package包/类
Set<Long> getCollectionDocumentKeys(int collectId) {
	//
	Set<DocumentKey> docKeys;
	if (collectId == clnDefault) {
		// TODO: local or global keySet ?!
		docKeys = docCache.keySet();
	} else {
		Predicate<DocumentKey, Document> clp = new CollectionPredicate(collectId);
		// TODO: local or global keySet ?!
		docKeys = docCache.keySet(clp);
	}
	Set<Long> result = new HashSet<>(docKeys.size());
	for (DocumentKey key: docKeys) {
		result.add(key.getKey());
	}
	return result;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:18,代码来源:DocumentManagementImpl.java

示例5: getLastKeysForQuery

import com.hazelcast.query.Predicate; //导入依赖的package包/类
public Collection<DocumentKey> getLastKeysForQuery(Predicate<DocumentKey, Document> query, int fetchSize) {
	MapService svc = nodeEngine.getService(MapService.SERVICE_NAME);
	MapServiceContext mapCtx = svc.getMapServiceContext();
	Query q = new Query(CN_XDM_DOCUMENT, query, IterationType.KEY, null, null);
	List<DocumentKey> results;
	try {
		QueryResult rs = (QueryResult) mapCtx.getMapQueryRunner(CN_XDM_DOCUMENT).runIndexOrPartitionScanQueryOnOwnedPartitions(q);
		results = new ArrayList<>(fetchSize);
		for (QueryResultRow row: rs.getRows()) {
			DocumentKey key = nodeEngine.toObject(row.getKey());
			results.add(key);
			if (fetchSize > 0 && results.size() == fetchSize) {
				break;
			}
		}
		logger.trace("getLastKeysForQuery; query: {}; returning: {}", query, results.size());
		return results;
	} catch (ExecutionException | InterruptedException ex) {
		logger.error("getLastDocumentsForQuery.error: ", ex);
	}
	return null;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:23,代码来源:DataDistributionService.java

示例6: getLastDocumentsForQuery

import com.hazelcast.query.Predicate; //导入依赖的package包/类
public Collection<Document> getLastDocumentsForQuery(Predicate<DocumentKey, Document> query, int fetchSize) {
	MapService svc = nodeEngine.getService(MapService.SERVICE_NAME);
	MapServiceContext mapCtx = svc.getMapServiceContext();
	Query q = new Query(CN_XDM_DOCUMENT, query, IterationType.VALUE, null, null);
	Map<String, Document> results;
	try {
		QueryResult rs = (QueryResult) mapCtx.getMapQueryRunner(CN_XDM_DOCUMENT).runIndexOrPartitionScanQueryOnOwnedPartitions(q);
		results = new HashMap<>(fetchSize);
		for (QueryResultRow row: rs.getRows()) {
			Document doc = nodeEngine.toObject(row.getValue());
			//Document last = results.get(doc.getUri());
			//if (last == null || last.getVersion() < doc.getVersion()) {
				results.put(doc.getUri(), doc);
			//}
			if (fetchSize > 0 && results.size() == fetchSize) {
				break;
			}
		}
		logger.trace("getLastDocumentsForQuery; query: {}; returning: {}", query, results.size());
		return results.values();
	} catch (ExecutionException | InterruptedException ex) {
		logger.error("getLastDocumentsForQuery.error: ", ex);
	}
	return null;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:26,代码来源:DataDistributionService.java

示例7: entrySet

import com.hazelcast.query.Predicate; //导入依赖的package包/类
@JMXOperation("entrySet")
@JMXDescription("EntrySet")
public String entrySet(final String query) {
    final Predicate predicate = query != null && query.trim().length() > 0 ?
            new SqlPredicate(query) : null;
    final Collection<Map.Entry> values = predicate != null ?
            getManagedObject().entrySet(predicate) :
            getManagedObject().entrySet();
    final StringBuilder sb = new StringBuilder().append("{");
    for (final Iterator<Map.Entry> it = values.iterator(); it.hasNext(); ) {
        final Map.Entry next = it.next();
        // workaround due to bug with hasNext
        if (sb.length() > 1) {
            sb.append(", ");
        }
        sb.append("key:").append(next.getKey()).append(", value:").append(next.getValue());
    }
    return sb.append("}").toString();
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:20,代码来源:MapMBean.java

示例8: getMapKeys

import com.hazelcast.query.Predicate; //导入依赖的package包/类
public Data getMapKeys(final IMap<Object, Object> map, final Data key, final Data value) {
    Entries entries = null;
    if (value == null) {
        entries = (Entries) map.entrySet();
    } else {
        final Predicate p = (Predicate) toObject(value);
        entries = (Entries) map.entrySet(p);
    }
    final Collection<Map.Entry> colEntries = entries.getKeyValues();
    final Keys keys = new Keys(new ArrayList<Data>(colEntries.size() << 1));
    for (final Object obj : colEntries) {
        final KeyValue entry = (KeyValue) obj;
        keys.add(toData(entry));
    }
    return toData(keys);
}
 
开发者ID:mdogan,项目名称:hazelcast-archive,代码行数:17,代码来源:ClientHandlerService.java

示例9: complete

import com.hazelcast.query.Predicate; //导入依赖的package包/类
@Override
protected KeyValueQuery<Predicate<?, ?>> complete(Predicate<?, ?> criteria, Sort sort) {

	KeyValueQuery<Predicate<?, ?>> keyValueQuery;

	if (this.limit == 0) {
		keyValueQuery = new KeyValueQuery<Predicate<?, ?>>(criteria);
	} else {
		keyValueQuery = new KeyValueQuery<Predicate<?, ?>>(new PagingPredicate(criteria, this.limit));
	}

	if (sort != null) {
		keyValueQuery.setSort(sort);
	}
	return keyValueQuery;
}
 
开发者ID:hazelcast,项目名称:spring-data-hazelcast,代码行数:17,代码来源:HazelcastQueryCreator.java

示例10: fromInequalityVariant

import com.hazelcast.query.Predicate; //导入依赖的package包/类
private Predicate<?, ?> fromInequalityVariant(Type type, boolean ignoreCase, String property,
		Iterator<Comparable<?>> iterator) {

	if (ignoreCase && type != Type.SIMPLE_PROPERTY) {
		throw new InvalidDataAccessApiUsageException(String.format("Ignore case not supported for '%s'", type));
	}

	switch (type) {

		case GREATER_THAN:
			return Predicates.greaterThan(property, iterator.next());
		case GREATER_THAN_EQUAL:
			return Predicates.greaterEqual(property, iterator.next());
		case LESS_THAN:
			return Predicates.lessThan(property, iterator.next());
		case LESS_THAN_EQUAL:
			return Predicates.lessEqual(property, iterator.next());

		default:
			throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
	}
}
 
开发者ID:hazelcast,项目名称:spring-data-hazelcast,代码行数:23,代码来源:HazelcastQueryCreator.java

示例11: fromEqualityVariant

import com.hazelcast.query.Predicate; //导入依赖的package包/类
private Predicate<?, ?> fromEqualityVariant(Type type, boolean ignoreCase, String property,
		Iterator<Comparable<?>> iterator) {

	switch (type) {

		case SIMPLE_PROPERTY:
			if (ignoreCase) {
				return Predicates.ilike(property, iterator.next().toString());
			} else {
				return Predicates.equal(property, iterator.next());
			}

		default:
			throw new InvalidDataAccessApiUsageException(String.format("Logic error for '%s' in query", type));
	}
}
 
开发者ID:hazelcast,项目名称:spring-data-hazelcast,代码行数:17,代码来源:HazelcastQueryCreator.java

示例12: resolve

import com.hazelcast.query.Predicate; //导入依赖的package包/类
/**
 * @param A query in Spring form
 * @return The same in Hazelcast form
 */
public Predicate<?, ?> resolve(KeyValueQuery<?> query) {

	if (query == null || query.getCritieria() == null) {
		return null;
	}

	if (query.getCritieria() instanceof PagingPredicate) {
		PagingPredicate pagingPredicate = (PagingPredicate) query.getCritieria();
		query.limit(pagingPredicate.getPageSize());
		return pagingPredicate.getPredicate();
	}

	if (query.getCritieria() instanceof Predicate) {
		return (Predicate<?, ?>) query.getCritieria();
	}

	throw new UnsupportedOperationException(query.toString());
}
 
开发者ID:hazelcast,项目名称:spring-data-hazelcast,代码行数:23,代码来源:HazelcastCriteriaAccessor.java

示例13: notJavaDuke

import com.hazelcast.query.Predicate; //导入依赖的package包/类
@Test
public void notJavaDuke() {
	String FIRST_NAME_IS_JOHN = "John";
	String LAST_NAME_IS_WAYNE = "Wayne";
	String NINETEEN_SIXTY_NINE = "1969";

	Predicate<?, ?> predicate = Predicates.and(Predicates.equal("firstname", FIRST_NAME_IS_JOHN),
			Predicates.equal("lastname", LAST_NAME_IS_WAYNE));

	// Force operation to server's content, not remote
	Set<String> localKeySet = super.server_personMap.localKeySet(predicate);

	assertThat("Entry exists", localKeySet.size(), equalTo(1));
	String key = localKeySet.iterator().next();

	assertThat("Correct key", key, equalTo(NINETEEN_SIXTY_NINE));

	Person person = super.server_personMap.get(key);
	assertThat("Not invalidated", person, notNullValue());
	assertThat("@Id matches key", person.getId(), equalTo(key));
	assertThat("First name", person.getFirstname(), equalTo(FIRST_NAME_IS_JOHN));
	assertThat("Last name", person.getLastname(), equalTo(LAST_NAME_IS_WAYNE));
}
 
开发者ID:hazelcast,项目名称:spring-data-hazelcast,代码行数:24,代码来源:ClientServerIT.java

示例14: usingPredicates

import com.hazelcast.query.Predicate; //导入依赖的package包/类
@Test
public void usingPredicates() {
    bookRepository.save(Arrays.asList(Book.create("978-1785285332", "Getting Started With Hazelcast", 3848),
            Book.create("978-1782169970", "Infinispan Data Grid Platform Definitive Guide", 4947),
            Book.create("978-1783988181", "Mastering Redis", 6172)));

    Predicate<String, Book> predicate =
            Predicates.and(Predicates.equal("isbn", "978-1785285332"), Predicates.greaterEqual("price", 3000));

    KeyValueQuery<Predicate<String, Book>> query = new KeyValueQuery<>(predicate);

    Iterable<Book> books = keyValueOperations.find(query, Book.class);

    assertThat(StreamSupport.stream(books.spliterator(), false).map(Book::getTitle).collect(Collectors.toList()))
            .hasSize(1)
            .containsExactly("Getting Started With Hazelcast");
}
 
开发者ID:kazuhira-r,项目名称:hazelcast-examples,代码行数:18,代码来源:SpringDataHazelcastTest.java

示例15: usingPredicateBuilder

import com.hazelcast.query.Predicate; //导入依赖的package包/类
@Test
public void usingPredicateBuilder() {
    bookRepository.save(Arrays.asList(Book.create("978-1785285332", "Getting Started With Hazelcast", 3848),
            Book.create("978-1782169970", "Infinispan Data Grid Platform Definitive Guide", 4947),
            Book.create("978-1783988181", "Mastering Redis", 6172)));

    EntryObject e = new PredicateBuilder().getEntryObject();
    Predicate<String, Book> predicate =
            e.get("isbn").equal("978-1785285332").and(e.get("price").greaterEqual(3000));

    KeyValueQuery<Predicate<String, Book>> query = new KeyValueQuery<>(predicate);

    Iterable<Book> books = keyValueOperations.find(query, Book.class);

    assertThat(StreamSupport.stream(books.spliterator(), false).map(Book::getTitle).collect(Collectors.toList()))
            .hasSize(1)
            .containsExactly("Getting Started With Hazelcast");
}
 
开发者ID:kazuhira-r,项目名称:hazelcast-examples,代码行数:19,代码来源:SpringDataHazelcastTest.java


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