本文整理汇总了Java中com.google.common.collect.TreeMultimap.keySet方法的典型用法代码示例。如果您正苦于以下问题:Java TreeMultimap.keySet方法的具体用法?Java TreeMultimap.keySet怎么用?Java TreeMultimap.keySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.TreeMultimap
的用法示例。
在下文中一共展示了TreeMultimap.keySet方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: tag
import com.google.common.collect.TreeMultimap; //导入方法依赖的package包/类
public Map<String, String> tag(Feature feature) {
TreeMultimap<String, Integer> speeds = TreeMultimap.create();
List<SpeedRestriction> restrictions = dbf.getSpeedRestrictions(feature.getLong("ID"));
boolean reversed = isReversed(feature);
for (SpeedRestriction restriction : restrictions) {
switch (restriction.getValidity()) {
case positive:
speeds.put(reversed ? "maxspeed:backward" : "maxspeed:forward", restriction.getSpeed());
break;
case negative:
speeds.put(reversed ? "maxspeed:forward" : "maxspeed:backward", restriction.getSpeed());
break;
case both:
speeds.put("maxspeed", restriction.getSpeed());
break;
}
}
Map<String, String> result = Maps.newHashMap();
for (String key : speeds.keySet()) {
result.put(key, String.valueOf(speeds.get(key).iterator().next()));
}
return result;
}
示例2: forkByClassifier
import com.google.common.collect.TreeMultimap; //导入方法依赖的package包/类
private Map<String, TreeMultimap<Calendar, ItemInfo>> forkByClassifier(
TreeMultimap<Calendar, ItemInfo> cleanupCandidates) {
Map<String, TreeMultimap<Calendar, ItemInfo>> result= Maps.newHashMap();
for (Calendar calendar : cleanupCandidates.keySet()) {
NavigableSet<ItemInfo> itemInfos = cleanupCandidates.get(calendar);
for (ItemInfo itemInfo : itemInfos) {
String classifier=resolveClassifier(itemInfo);
TreeMultimap<Calendar, ItemInfo> classifierMap = result.get(classifier);
if(classifierMap==null){
//classifierMap= TreeMultimap.create(Ordering.natural().reverse(), Ordering.natural().reverse());
classifierMap= TreeMultimap.create(Ordering.natural(), Ordering.natural());;
result.put(classifier,classifierMap);
}
classifierMap.put(calendar,itemInfo);
}
}
return result;
}
示例3: writeIFile
import com.google.common.collect.TreeMultimap; //导入方法依赖的package包/类
static Path writeIFile(int keysPerFile, int repeatCount) throws
IOException {
TreeMultimap<Integer, Long> dataSet = createDataForIFile(keysPerFile, repeatCount);
LOG.info("DataSet size : " + dataSet.size());
Path path = new Path(workDir + "/src", "data_" + System.nanoTime() + ".out");
FSDataOutputStream out = localFs.create(path);
//create IFile with RLE
IFile.Writer writer = new IFile.Writer(defaultConf, out, IntWritable.class
, LongWritable.class, null, null, null, true);
for (Integer key : dataSet.keySet()) {
for (Long value : dataSet.get(key)) {
writer.append(new IntWritable(key), new LongWritable(value));
verificationDataSet.put(key, value);
}
}
writer.close();
out.close();
return path;
}
示例4: getRecommendation
import com.google.common.collect.TreeMultimap; //导入方法依赖的package包/类
/**
* Methods to retrieve Document that is similar to a given document
*
* @param _documentNumber
* @param _resultsType
* @return
* @throws com.google.api.services.datastore.client.DatastoreException
*/
@Override
public RecResponseBean getRecommendation(
final long _documentNumber,
ResultsType _resultsType) throws DatastoreException, DocumentNotFoundException {
DocumentBean baseDocument = dao.getDocument(_documentNumber);
TreeMultimap<BaseContent.ContentType, BaseContent> relevantBeans = baseDocument.getRelevantBeans();
SortedSet<BaseContent> topicRelatedBeans = relevantBeans.removeAll(BaseContent.ContentType.TOPICS);
//TODO: Filter Topics that are the same as that of the base document
Collection<String> entityIds = new ArrayList<String>();
for (BaseContent contentBean : relevantBeans.values()) {
entityIds.add(ContentDictionary.makeKeyFromBean(contentBean));
}
TreeMultimap<BaseContent.ContentType, DocumentMeta> entityResult = dao.getEntityMeta(entityIds, _resultsType);
Collection<DocumentMeta> result = new ArrayList<DocumentMeta>();
for (BaseContent.ContentType contentType : entityResult.keySet()) {
Collection<DocumentMeta> docMetas = new ArrayList<DocumentMeta>(entityResult.get(contentType));
CollectionUtils.filterInverse(docMetas, new Predicate<DocumentMeta>() {
@Override
public boolean evaluate(DocumentMeta documentMeta) {
return (documentMeta.getDocumentNumber() == _documentNumber);
}
});
result.addAll(ResultsType.getResultsForCR(docMetas, _resultsType));
}
// Filter down the result (select randomly from the top results)
result = ResultsType.getResultsForCR(result, ResultsType.RANDOM_10);
result = ResultsType.getResultsForCR(result, _resultsType);
Collection<DocumentBean> recommendedResults = new ArrayList<DocumentBean>();
for (DocumentMeta docMeta : result) {
recommendedResults.add(dao.getDocument(docMeta.getDocumentNumber()));
}
return new RecResponseBean(recommendedResults, "ContentBased");
}