本文整理了Java中org.elasticsearch.common.collect.Maps.newHashMapWithExpectedSize()
方法的一些代码示例,展示了Maps.newHashMapWithExpectedSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Maps.newHashMapWithExpectedSize()
方法的具体详情如下:
包路径:org.elasticsearch.common.collect.Maps
类名称:Maps
方法名:newHashMapWithExpectedSize
暂无
代码示例来源:origin: com.bazaarvoice.elasticsearch.client/es-client-java-core
@Override public GetResponse fromXContent(final Map<String, Object> map) {
final Map<String, GetField> fields;
if (map.containsKey("fields")) {
Map<String, Object> incoming = nodeMapValue(map.get("fields"), String.class, Object.class);
fields = Maps.newHashMapWithExpectedSize(incoming.size());
for (Map.Entry<String, Object> entry : incoming.entrySet()) {
if (entry.getValue() instanceof List) {
fields.put(entry.getKey(), new GetField(entry.getKey(), nodeListValue(entry.getValue(), Object.class)));
} else {
fields.put(entry.getKey(), new GetField(entry.getKey(), ImmutableList.of(entry.getValue())));
}
}
} else {
fields = ImmutableMap.of();
}
return new GetResponse(new GetResult(
nodeStringValue(map.get("_index")),
nodeStringValue(map.get("_type")),
nodeStringValue(map.get("_id")),
nodeLongValue(map.get("_version"), -1),
nodeBooleanValue(map.get("found"), true),
nodeBytesReferenceValue(map.get("_source")),
fields
));
}
}
代码示例来源:origin: com.bazaarvoice.elasticsearch.client/es-rest-client-core-1.4
@Override public GetResponse fromXContent(final Map<String, Object> map) {
final Map<String, GetField> fields;
if (map.containsKey("fields")) {
Map<String, Object> incoming = nodeMapValue(map.get("fields"), String.class, Object.class);
fields = Maps.newHashMapWithExpectedSize(incoming.size());
for (Map.Entry<String, Object> entry : incoming.entrySet()) {
if (entry.getValue() instanceof List) {
fields.put(entry.getKey(), new GetField(entry.getKey(), nodeListValue(entry.getValue(), Object.class)));
} else {
fields.put(entry.getKey(), new GetField(entry.getKey(), ImmutableList.of(entry.getValue())));
}
}
} else {
fields = ImmutableMap.of();
}
//noinspection unchecked
return new GetResponse(new GetResult(
nodeStringValue(map.get("_index")),
nodeStringValue(map.get("_type")),
nodeStringValue(map.get("_id")),
nodeLongValue(map.get("_version"), -1),
nodeBooleanValue(map.get("found"), true),
nodeBytesReferenceForMapValue((Map<String, ?>) map.get("_source")),
fields
));
}
}
内容来源于网络,如有侵权,请联系作者删除!