當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。