本文整理汇总了Java中com.hazelcast.mapreduce.Context类的典型用法代码示例。如果您正苦于以下问题:Java Context类的具体用法?Java Context怎么用?Java Context使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Context类属于com.hazelcast.mapreduce包,在下文中一共展示了Context类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(String key, Person value, Context<String, Integer> context) {
if (state != null) {
if (!state.equals(value.getState())) {
return;
}
}
String name = abbrevationMapping.get(value.getState());
IMap<String, SalaryYear> salariesMap = hazelcastInstance.getMap("salaries");
// Person's partition key is email!
SalaryYear salaryYear = salariesMap.get(value.getEmail());
for (SalaryMonth salaryMonth : salaryYear.getMonths()) {
context.emit(name, salaryMonth.getSalary());
}
}
开发者ID:noctarius,项目名称:hazelcast-mapreduce-presentation,代码行数:20,代码来源:SalaryMapper.java
示例2: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(
final Integer key,
final SpatialPoint value,
final Context<Integer, Integer> collector)
{
final double x = value.point.getX();
final double y = value.point.getY();
m_insidePolygon.setXY(x, y);
final Collection<SpatialPolygon> collection = m_map.values(m_insidePolygon);
if (!collection.isEmpty())
{
collector.emit(collection.iterator().next().id, 1);
}
}
开发者ID:mraad,项目名称:HZSpatial,代码行数:18,代码来源:FeatureMapper.java
示例3: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(String key, String value, Context<String, Integer> context) {
StringTokenizer tokenizer = new StringTokenizer(value);
while (tokenizer.hasMoreTokens()) {
String word = WordCountExample.cleanWord(tokenizer.nextToken());
if (word.length() >= 4) {
context.emit(word.toLowerCase(), ONE);
}
}
}
开发者ID:gAmUssA,项目名称:jpoint-2016-computing-talk,代码行数:11,代码来源:TokenizerMapper.java
示例4: initialize
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void initialize(Context<String, Integer> context) {
super.initialize(context);
IMap<Integer, State> states = hazelcastInstance.getMap("states");
for (State s : states.values()) {
String abbrevation = s.getAbbreviation();
String name = s.getName();
abbrevationMapping.put(abbrevation, name);
}
}
开发者ID:noctarius,项目名称:hazelcast-mapreduce-presentation,代码行数:12,代码来源:SalaryMapper.java
示例5: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(String key, Person value, Context<String, Person> context) {
if (state != null) {
if (!state.equals(value.getState())) {
return;
}
}
context.emit(value.getState(), value);
}
开发者ID:noctarius,项目名称:hazelcast-mapreduce-presentation,代码行数:11,代码来源:StateBasedMapper.java
示例6: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(String key, Crime value, Context<CrimeCategory, Integer> context) {
if (!stateName.equals(value.getState())) {
return;
}
context.emit(value.getCrime(), value.getCount());
}
开发者ID:noctarius,项目名称:hazelcast-mapreduce-presentation,代码行数:9,代码来源:CrimeMapper.java
示例7: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(String key, Person value, Context<String, Integer> context) {
if (state != null) {
if (!state.equals(value.getState())) {
return;
}
}
String name = abbrevationMapping.get(value.getState());
context.emit(name, ONE);
}
开发者ID:noctarius,项目名称:hazelcast-mapreduce-presentation,代码行数:12,代码来源:StateBasedCountMapper.java
示例8: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(String key, String value, Context<String, Integer> context) {
StringTokenizer tokenizer = new StringTokenizer(value);
while (tokenizer.hasMoreTokens()) {
String word = WordCount.cleanWord(tokenizer.nextToken());
context.emit(word.toLowerCase(), ONE);
}
}
开发者ID:noctarius,项目名称:hazelcast-mapreduce-presentation,代码行数:9,代码来源:TokenizerMapper.java
示例9: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(Comparable key, Double value, Context<Feature, Double> context) {
MultiMap<Comparable, FeatureConfidenceTuple> multiMap = hazelcastInstance.getMultiMap("traindata-"+this.mapKey);
Collection<FeatureConfidenceTuple> values = multiMap.get(key);
for (FeatureConfidenceTuple featureConfidenceTuple : values) {
context.emit(featureConfidenceTuple.getFeature(), (featureConfidenceTuple.getConfidenceCoefficient() * value.doubleValue()));
}
}
开发者ID:bgokden,项目名称:predictblty,代码行数:12,代码来源:RecommendationMethodMapper.java
示例10: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(String key, Double value, Context<String, Double> context) {
MultiMap<String, KeyValueTuple> multiMap = hazelcastInstance.getMultiMap("keyValueTuples");
Collection<KeyValueTuple> values = multiMap.get(key);
for (KeyValueTuple keyValueTuple : values) {
context.emit(keyValueTuple.getKey(), (keyValueTuple.getValue()*value.doubleValue()) );
}
}
开发者ID:bgokden,项目名称:predictblty,代码行数:12,代码来源:InvertedMapper.java
示例11: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(ByteHolder key, ClassifiedFeature value, Context<Map<String, Serializable>, Classification> context) {
for (UnclassifiedFeature unclassifiedFeature : this.data) {
List<Pair<Map<String, Serializable>, Classification>> list = new LinkedList<Pair<Map<String, Serializable>, Classification>>();
Double coef = unclassifiedFeature.getConfidence() * value.getClassification().getConfidence();
boolean similar = false;
for (Map.Entry<String, Serializable> stringSerializableEntry : unclassifiedFeature.getFeatureMap().entrySet()) {
for (Map.Entry<String, Serializable> stringSerializableEntryInner : value.getFeatureMap().entrySet()) {
if (stringSerializableEntry.getValue().equals(stringSerializableEntryInner.getValue())) {
similar = true;
} else {
Map<String, Serializable> otherKey = new HashMap<String, Serializable>();
otherKey.put("key", stringSerializableEntryInner.getValue());
list.add(new Pair<Map<String, Serializable>, Classification>(otherKey, new Classification(stringSerializableEntryInner.getValue(), coef)));
}
}
}
if (similar) {
for (Pair<Map<String, Serializable>, Classification> pair : list) {
context.emit(pair.fst, pair.snd);
}
}
//System.out.println("New map:"+value.getClassification().toString());
}
}
开发者ID:bgokden,项目名称:predictblty,代码行数:28,代码来源:UserBasedCollaborativeFilteringRecommendationAlgorithmMapper.java
示例12: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(Map<String, Serializable> key, Classification value, Context<Map<String, Serializable>, Classification> context) {
for (UnclassifiedFeature unclassifiedFeature : this.data) {
//double distance = unclassifiedFeature.getFeature().distanceTo(key);
double distance = this.comparator.compare(unclassifiedFeature.getFeatureMap(), key);
double weight = Double.MAX_VALUE;
if (distance != 0) {
weight = value.getConfidence() * unclassifiedFeature.getConfidence() / distance;
}
context.emit(unclassifiedFeature.getFeatureMap(), new Classification(value.getClassification(), weight));
//System.out.println("New map:"+value.getClassification().toString());
}
}
开发者ID:bgokden,项目名称:predictblty,代码行数:15,代码来源:DistanceBasedClassificationAlgorithmMapper.java
示例13: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(String key, String numbersString, Context<Integer, Integer> context) {
StringTokenizer tokenizer = new StringTokenizer(numbersString);
while (tokenizer.hasMoreTokens()) {
Integer number = Integer.valueOf(tokenizer.nextToken());
context.emit(number, ONE);
}
}
开发者ID:FutureProcessing,项目名称:HazelcastShowAndTell,代码行数:10,代码来源:TokenizerMapper.java
示例14: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(String key, String document, Context<String, Long> context) {
// Just splitting the text by whitespaces
StringTokenizer tokenizer = new StringTokenizer(document.toLowerCase());
// For every token in the text (=> per word)
while (tokenizer.hasMoreTokens()) {
// Emit a new value in the mapped results
context.emit(tokenizer.nextToken(), ONE);
}
}
开发者ID:noctarius,项目名称:hz-map-reduce,代码行数:13,代码来源:TokenizerMapper.java
示例15: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(String key, Integer value, Context<String, Integer> context) {
AbstractMap.SimpleEntry entry = new AbstractMap.SimpleEntry(key, value);
Integer valueOut = (Integer) supplier.apply((Map.Entry) entry);
if (valueOut != null) {
context.emit(key, valueOut);
}
}
开发者ID:kazuhira-r,项目名称:hazelcast-examples,代码行数:10,代码来源:SupplierDelegateMapper.java
示例16: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(String key, Person value, Context<String, Person> context) {
if (firstName.equalsIgnoreCase(value.getFirstName())) {
context.emit(value.getEmail(), value);
}
}
开发者ID:noctarius,项目名称:hazelcast-mapreduce-presentation,代码行数:7,代码来源:PersonMapper.java
示例17: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(String key, SalaryYear value, Context<String, Integer> context) {
context.emit("sum", value.getAnnualSalary());
}
开发者ID:noctarius,项目名称:hazelcast-mapreduce-presentation,代码行数:5,代码来源:SalarySumMapper.java
示例18: initialize
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void initialize(final Context<Integer, Integer> context)
{
m_insidePolygon = new InsidePolygon();
}
开发者ID:mraad,项目名称:HZSpatial,代码行数:6,代码来源:FeatureMapper.java
示例19: finalized
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void finalized(final Context<Integer, Integer> context)
{
}
开发者ID:mraad,项目名称:HZSpatial,代码行数:5,代码来源:FeatureMapper.java
示例20: map
import com.hazelcast.mapreduce.Context; //导入依赖的package包/类
@Override
public void map(Integer key, Employee employee, Context<Integer, Employee> context) {
if (employee.getId() % mod == 0) {
context.emit(key, employee);
}
}
开发者ID:hazelcast,项目名称:hazelcast-simulator,代码行数:7,代码来源:MapReduceTest.java
注:本文中的com.hazelcast.mapreduce.Context类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论