• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Predicates类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: findByFilters

import com.hazelcast.query.Predicates; //导入依赖的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.Predicates; //导入依赖的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: when_readRemoteMap_withNativePredicateAndProjection

import com.hazelcast.query.Predicates; //导入依赖的package包/类
@Test
public void when_readRemoteMap_withNativePredicateAndProjection()
        throws Exception {
    populateMap(hz.getMap(SOURCE_NAME));

    DAG dag = new DAG();
    Vertex source = dag.newVertex("source",
            readRemoteMapP(SOURCE_NAME, clientConfig,
                    Predicates.greaterThan("this", "0"),
                    Projections.singleAttribute("value")
            )
    ).localParallelism(4);
    Vertex sink = dag.newVertex(SINK_NAME, writeListP(SINK_NAME)).localParallelism(1);
    dag.edge(between(source, sink));

    executeAndWait(dag);
    IStreamList<Object> list = jet.getList(SINK_NAME);
    assertEquals(ITEM_COUNT - 1, list.size());
    assertFalse(list.contains(0));
    assertTrue(list.contains(1));
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:22,代码来源:HazelcastRemoteConnectorTest.java


示例4: when_readMap_withNativePredicateAndProjection

import com.hazelcast.query.Predicates; //导入依赖的package包/类
@Test
public void when_readMap_withNativePredicateAndProjection() {
    IStreamMap<Integer, Integer> sourceMap = jetInstance.getMap(sourceName);
    range(0, ENTRY_COUNT).forEach(i -> sourceMap.put(i, i));

    DAG dag = new DAG();
    Vertex source = dag.newVertex("source",
            readMapP(sourceName,
                    Predicates.greaterThan("this", "0"),
                    Projections.singleAttribute("value")
            )
    );
    Vertex sink = dag.newVertex("sink", writeListP(sinkName));
    dag.edge(between(source, sink));

    jetInstance.newJob(dag).join();

    IStreamList<Object> list = jetInstance.getList(sinkName);
    assertEquals(ENTRY_COUNT - 1, list.size());
    for (int i = 0; i < ENTRY_COUNT; i++) {
        assertEquals(i != 0, list.contains(i));
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-jet,代码行数:24,代码来源:HazelcastConnectorTest.java


示例5: getQuery

import com.hazelcast.query.Predicates; //导入依赖的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


示例6: getLastDocumentForUri

import com.hazelcast.query.Predicates; //导入依赖的package包/类
public Document getLastDocumentForUri(String uri) {
	MapService svc = nodeEngine.getService(MapService.SERVICE_NAME);
	MapServiceContext mapCtx = svc.getMapServiceContext();
	Query query = new Query(CN_XDM_DOCUMENT, Predicates.equal("uri", uri), IterationType.VALUE, null, null);
	try {
		Document last = null;
		QueryResult rs = (QueryResult) mapCtx.getMapQueryRunner(CN_XDM_DOCUMENT).runIndexOrPartitionScanQueryOnOwnedPartitions(query);
		for (QueryResultRow row: rs.getRows()) {
			Document doc = nodeEngine.toObject(row.getValue());
			if (last == null) {
				last = doc;
			} else {
				if (doc.getVersion() > last.getVersion()) {
					last = doc;
				}
			}
		}
		logger.trace("getLastDocumentForUri; uri: {}; returning: {}", uri, last);
		return last;
	} catch (ExecutionException | InterruptedException ex) {
		logger.error("getLastDocumentForUri.error: ", ex);
	}
	return null;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:25,代码来源:DataDistributionService.java


示例7: getElementKeys

import com.hazelcast.query.Predicates; //导入依赖的package包/类
public Collection<DataKey> getElementKeys(long docId) {
	MapService svc = nodeEngine.getService(MapService.SERVICE_NAME);
	MapServiceContext mapCtx = svc.getMapServiceContext();
	Query query = new Query(CN_XDM_ELEMENT, Predicates.equal("__key#documentKey", docId), IterationType.KEY, null, null);
	Collection<DataKey> result = null;
	try {
		QueryResult rs = (QueryResult) mapCtx.getMapQueryRunner(CN_XDM_ELEMENT).runIndexOrPartitionScanQueryOnOwnedPartitions(query);
		result = new ArrayList<>(rs.size());
		for (QueryResultRow row: rs.getRows()) {
			result.add((DataKey) nodeEngine.toObject(row.getKey()));
		}
		return result;
	} catch (ExecutionException | InterruptedException ex) {
		logger.error("getElementKeys.error", ex);
	}
	return result;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:18,代码来源:DataDistributionService.java


示例8: getElements

import com.hazelcast.query.Predicates; //导入依赖的package包/类
public Map<DataKey, Elements> getElements(long docId) {
	MapService svc = nodeEngine.getService(MapService.SERVICE_NAME);
	MapServiceContext mapCtx = svc.getMapServiceContext();
	Query query = new Query(CN_XDM_ELEMENT, Predicates.equal("__key#documentKey", docId), IterationType.ENTRY, null, null);
	Map<DataKey, Elements> result = null;
	try {
		QueryResult rs = (QueryResult) mapCtx.getMapQueryRunner(CN_XDM_ELEMENT).runIndexOrPartitionScanQueryOnOwnedPartitions(query);
		result = new HashMap<>(rs.size());
		for (QueryResultRow row: rs.getRows()) {
			result.put((DataKey) nodeEngine.toObject(row.getKey()), (Elements) nodeEngine.toObject(row.getValue()));
		}
		return result;
	} catch (ExecutionException | InterruptedException ex) {
		logger.error("getElementKeys.error", ex);
	}
	return result;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:18,代码来源:DataDistributionService.java


示例9: fromInequalityVariant

import com.hazelcast.query.Predicates; //导入依赖的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


示例10: fromEqualityVariant

import com.hazelcast.query.Predicates; //导入依赖的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


示例11: notJavaDuke

import com.hazelcast.query.Predicates; //导入依赖的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


示例12: usingPredicates

import com.hazelcast.query.Predicates; //导入依赖的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


示例13: query

import com.hazelcast.query.Predicates; //导入依赖的package包/类
@TimeStep(prob = -1)
public void query(ThreadState state, Probe probe, @StartNanos long startNanos) {
    int key = state.getRandomKey();
    Predicate predicate = Predicates.equal("payloadField[any]", key);
    Collection<Object> result = null;
    try {
        result = map.values(predicate);
    } finally {
        probe.done(startNanos);
    }

    if (throttlingLogger.requestLogSlot()) {
        throttlingLogger.logInSlot(Level.INFO,
                format("Query 'payloadField[any]= %d' returned %d results.", key, result.size()));
    }

    for (Object resultSillySequence : result) {
        state.assertValidSequence(resultSillySequence);
    }
}
 
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:21,代码来源:MultiValueMapTest.java


示例14: pagePredicate

import com.hazelcast.query.Predicates; //导入依赖的package包/类
@TimeStep(prob = 0.2)
public void pagePredicate(ThreadState state) {
    double maxSalary = state.randomDouble() * Employee.MAX_SALARY;
    Predicate predicate = Predicates.lessThan("salary", maxSalary);
    SalaryComparator salaryComparator = new SalaryComparator();
    PagingPredicate pagingPredicate = new PagingPredicate(predicate, salaryComparator, pageSize);

    Collection<Employee> employees;
    List<Employee> employeeList;
    do {
        employees = map.values(pagingPredicate);
        employeeList = fillListWithQueryResultSet(employees);
        Employee nextEmployee;
        Employee currentEmployee;
        for (int i = 0; i < employeeList.size() - 1; i++) {
            currentEmployee = employeeList.get(i);
            nextEmployee = employeeList.get(i + 1);
            // check the order & max salary
            assertTrue(format(baseAssertMessage, currentEmployee.getSalary(), predicate),
                    currentEmployee.getSalary() <= nextEmployee.getSalary() && nextEmployee.getSalary() < maxSalary);
        }
        pagingPredicate.nextPage();
    } while (!employees.isEmpty());

    state.operationCounter.pagePredicateCount++;
}
 
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:27,代码来源:MapPredicateTest.java


示例15: clean

import com.hazelcast.query.Predicates; //导入依赖的package包/类
@Override
public void clean()
{
    final long oldest = System.currentTimeMillis() - kfkaCfg.getTtl(TimeUnit.MILLISECONDS);
    final Predicate<?, ?> p = Predicates.lessThan("timestamp", oldest); 
    this.messages.executeOnEntries(cleanProcessor, p);
}
 
开发者ID:ethlo,项目名称:kfka,代码行数:8,代码来源:KfkaManagerImpl.java


示例16: toHazelcastPredicate

import com.hazelcast.query.Predicates; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public Predicate<Long, KfkaMessage> toHazelcastPredicate()
{
    final List<Predicate<?,?>> predicates = new LinkedList<>();
    
    // Message ID
    if (messageId != null)
    {
        predicates.add(Predicates.greaterEqual("id", messageId));
    }
    
    // Topic
    if (topic != null)
    {
        predicates.add(Predicates.equal("topic", topic));
    }
    
    if (! propertyMatch.isEmpty())
    {
        for (Entry<String, Comparable> e : propertyMatch.entrySet())
        {
            predicates.add(Predicates.equal(e.getKey(), e.getValue()));
        }
    }
    
    return Predicates.and(predicates.toArray(new Predicate[predicates.size()]));
}
 
开发者ID:ethlo,项目名称:kfka,代码行数:28,代码来源:KfkaPredicate.java


示例17: toPredicate

import com.hazelcast.query.Predicates; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static Predicate<DocumentKey, Document> toPredicate(SchemaRepository repo, String query) {
	if (query.startsWith("collections.contains")) {
		String clName = query.substring(21, query.length() - 1);
		Collection cln = repo.getSchema().getCollection(clName);
		if (cln == null) {
			return null;
		}
		return new CollectionPredicate(cln.getId());
	}
	
	int pos = query.indexOf(" ");
	if (pos > 0) {
		String attr = query.substring(0, pos); 
		int pos2 = query.indexOf(" ", pos + 1);
		if (pos2 > 0) {
			Comparison comp = toComparison(query.substring(pos, pos2).trim());
			if (comp != null) {
				String val = query.substring(pos2);
				Comparable<?> value = toValue(attr, val.trim());
				//logger.trace("toPredicate; got predicate parts: {} {} {}", attr, comp, value);
				switch (comp) {
					case EQ: return Predicates.equal(attr, value);
					case NE: return Predicates.notEqual(attr, value);
					case GT: return Predicates.greaterThan(attr, value);
					case GE: return Predicates.greaterEqual(attr, value);
					case LT: return Predicates.lessThan(attr, value);
					case LE: return Predicates.lessEqual(attr, value);
					case LIKE: return Predicates.like(attr, value.toString());
				}
			}
		}
	}
	return null;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:36,代码来源:DocumentPredicateBuilder.java


示例18: getPathsForRoot

import com.hazelcast.query.Predicates; //导入依赖的package包/类
@ManagedOperation(description="Return all unique paths for the document type provided")
@ManagedOperationParameters({
	@ManagedOperationParameter(name = "root", description = "A document type root")})
public String[] getPathsForRoot(String root) {
    IMap<String, Path> xpCache = hzClient.getMap(CN_XDM_PATH_DICT);
	Collection<Path> paths = xpCache.values(Predicates.equal("root", root)); 
	logger.debug("getPathsForRoot; got paths {} for root {}", paths, root);
	String[] result = new String[paths.size()];
	int idx = 0;
	for (Path path: paths) {
		result[idx++] = "" + path.getPathId() + ": " + path.getPath() + 
				" (" + path.getNodeKind() + ":" + getTypeName(path.getDataType()) + ")";
	}
	return result;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:16,代码来源:ModelManagement.java


示例19: aggregatePath

import com.hazelcast.query.Predicates; //导入依赖的package包/类
@ManagedOperation(description="Calculates the number of unique values on the path specified")
@ManagedOperationParameters({
	@ManagedOperationParameter(name = "pathId", description = "The path identifier to aggregate on")})
public int aggregatePath(int pathId) {

	IMap<DataKey, Elements> elts = hzClient.getMap(CN_XDM_ELEMENT);
	Predicate<DataKey, Elements> q = Predicates.equal("pathId", pathId);
	Set<DataKey> keys = elts.keySet(q);
	if (keys.size() > 0) {
		q = Predicates.and(Predicates.equal("pathId", pathId), new GroupCountPredicate());
		elts.keySet(q);
	}
	return keys.size();
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:15,代码来源:ModelManagement.java


示例20: getLastKeyForUri

import com.hazelcast.query.Predicates; //导入依赖的package包/类
public DocumentKey getLastKeyForUri(String uri) {
	MapService svc = nodeEngine.getService(MapService.SERVICE_NAME);
	MapServiceContext mapCtx = svc.getMapServiceContext();
	Query query = new Query(CN_XDM_DOCUMENT, Predicates.equal("uri", uri), IterationType.KEY, null, null);
	try {
		DocumentKey last = null;
		QueryResult rs = (QueryResult) mapCtx.getMapQueryRunner(CN_XDM_DOCUMENT).runIndexOrPartitionScanQueryOnOwnedPartitions(query);
		for (QueryResultRow row: rs.getRows()) {
			DocumentKey key = nodeEngine.toObject(row.getKey());
			if (last == null) {
				last = key;
			} else {
				if (key.getVersion() > last.getVersion()) {
					last = key;
				}
			}
		}
		logger.trace("getLastKeyForUri; uri: {}; returning: {}", uri, last);
		return last;
	} catch (ExecutionException | InterruptedException ex) {
		logger.error("getLastKeyForUri.error: ", ex);
	}
	return null;
	//List<DocumentKey> keys = getCachedObject(CN_XDM_KEY, new UrlHashKey(uri), true);
	//if (keys != null) {
	//	return keys.get(keys.size() - 1);
	//}
	//return null;
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:30,代码来源:DataDistributionService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StreamCloser类代码示例发布时间:2022-05-21
下一篇:
Java SqlCommandType类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap