本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}