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


Java GemfireFunction类代码示例

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


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

示例1: countByBrand

import org.springframework.data.gemfire.function.annotation.GemfireFunction; //导入依赖的package包/类
/**
 * Return a count of each Brand
 * @return
 */
@GemfireFunction
public Map<String, AtomicInteger> countByBrand() {
	Map<String,AtomicInteger> results = new HashMap<String,AtomicInteger>();
	Collection<Product> products = productRepository.findAll();
	for (Object objProduct : products) {
		Product product = resolveReference(objProduct);
		if (results.containsKey(product.getBrand())) {
			results.get(product.getBrand()).addAndGet(product.getStockOnHand());
		}
		else {
			results.put(product.getBrand(), new AtomicInteger(product.getStockOnHand()));
		}
	}
	return results;
}
 
开发者ID:Pivotal-Open-Source-Hub,项目名称:geode-demo-application,代码行数:20,代码来源:ProductGroupCounter.java

示例2: countByType

import org.springframework.data.gemfire.function.annotation.GemfireFunction; //导入依赖的package包/类
/**
 * Return a count of all the types
 * @return
 */
@GemfireFunction
public Map<String, AtomicInteger> countByType() {
	Map<String,AtomicInteger> results = new HashMap<String,AtomicInteger>();
	Collection<Product> products = productRepository.findAll();
	for (Object obj : products) {
		Product product = resolveReference(obj);
		if (results.containsKey(product.getType())) {
			results.get(product.getType()).addAndGet(product.getStockOnHand());
		}
		else {
			results.put(product.getType(), new AtomicInteger(product.getStockOnHand()));
		}
	}
	return results;
}
 
开发者ID:Pivotal-Open-Source-Hub,项目名称:geode-demo-application,代码行数:20,代码来源:ProductGroupCounter.java

示例3: getSentiment

import org.springframework.data.gemfire.function.annotation.GemfireFunction; //导入依赖的package包/类
@GemfireFunction(HA=true)
public SentimentResult getSentiment(Region<PostId, Post> localPosts, 
    @Filter Set<String> personNames) throws Exception {
  String personName = personNames.iterator().next();
  Collection<Post> posts = localPosts.query("id.person='" + personName + "'");
  String sentiment = sentimentAnalyzer.analyze(posts);
  return new SentimentResult(sentiment, personName);
}
 
开发者ID:Pivotal-Open-Source-Hub,项目名称:geode-social-demo,代码行数:9,代码来源:Functions.java

示例4: countTransactions

import org.springframework.data.gemfire.function.annotation.GemfireFunction; //导入依赖的package包/类
@GemfireFunction
public int countTransactions(Object customerObj) {
	Customer customer = resolveReferenceCust(customerObj);
	//System.out.println("Counting orders for: " + customer.toString());
	Collection<Transaction> completedTransactions = transactionRepository.findCompletedOrders(customer.getId());
	//System.out.println("Completed Transactions: " + completedTransactions.size());
	Map<Integer, AtomicInteger> dayOfTheYearCount = new HashMap<Integer,AtomicInteger>();
	int count = 0;
	//go through the orders and increment the count
	for (Object txnObj : completedTransactions) {
		Transaction txn = resolveReferenceTxn(txnObj);
		//did it occur this year
		now.setTime(new Date());
		txn_date.setTime(txn.getTransactionDate());
		if (now.get(Calendar.YEAR) == txn_date.get(Calendar.YEAR)) {
			//System.out.println("Transaction Id: " + txn.getId() + " Transaction Date: " + txn.getTransactionDate());
			//System.out.println("Less than a year increment: " + count);
			count++;
			//if its there birthday they get an extra count per order
			if (isBirthday(txn.getTransactionDate(),customer.getBirthday())) {
				//System.out.println("Birthday add one: " + count);
				count++;
			}
			int currentDayOfYear = getDayOfYear(txn.getTransactionDate());
			//build a map of transactions by day of the year
			if (dayOfTheYearCount.containsKey(currentDayOfYear)) {
				dayOfTheYearCount.get(currentDayOfYear).incrementAndGet();
			}
			else {
				dayOfTheYearCount.put(currentDayOfYear, new AtomicInteger());
			}
		}
		
	}
	//go through the map, for days with 5 or more transactions add an extra count
	for (Integer day : dayOfTheYearCount.keySet()) {
		if (dayOfTheYearCount.get(day).intValue() >= 3) {
			//System.out.println("Three on a day - add one: " + count);
			count++;
		}
	}
	return count;
}
 
开发者ID:Pivotal-Open-Source-Hub,项目名称:geode-demo-application,代码行数:44,代码来源:OrderCounter.java


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