本文整理汇总了Java中com.google.common.collect.ImmutableMap.keySet方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableMap.keySet方法的具体用法?Java ImmutableMap.keySet怎么用?Java ImmutableMap.keySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableMap
的用法示例。
在下文中一共展示了ImmutableMap.keySet方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: finish
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Override
public void finish() throws IOException {
final ImmutableMap<Symbol, Double> scores = this.scores.build();
final ImmutableMap<Symbol, Integer> falsePositives = this.falsePositives.build();
final ImmutableMap<Symbol, Integer> truePositives = this.truePositives.build();
final ImmutableMap<Symbol, Integer> falseNegatives = this.falseNegatives.build();
// see guidelines section 7.3.1.1.3 for aggregating rules:
outputDir.mkdirs();
final double meanScore = scores.isEmpty()?Double.NaN:DoubleMath.mean(scores.values());
Files.asCharSink(new File(outputDir, "linearScore.txt"), Charsets.UTF_8)
.write(Double.toString(meanScore));
for (final Symbol queryId : scores.keySet()) {
final File queryDir = new File(outputDir, queryId.asString());
queryDir.mkdirs();
final File queryScoreFile = new File(queryDir, "score.txt");
// avoid dividing by zero
final double normalizer = Math.max(truePositives.get(queryId) + falseNegatives.get(queryId), 1);
// see guidelines referenced above
// pretends that the corpus is a single document
Files.asCharSink(queryScoreFile, Charsets.UTF_8).write(String
.format(SCORE_PATTERN, truePositives.get(queryId), falsePositives.get(queryId),
falseNegatives.get(queryId), 100 * scores.get(queryId) / normalizer));
}
}
示例2: calculateCycleDeadlockChains
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
private Set<LinkedHashSet<ThreadInfo>> calculateCycleDeadlockChains(ImmutableMap<Long, ThreadInfo> threadInfoMap, Set<LinkedHashSet<ThreadInfo>> cycles) {
ThreadInfo allThreads[] = threadBean.getThreadInfo(threadBean.getAllThreadIds());
Set<LinkedHashSet<ThreadInfo>> deadlockChain = new HashSet<>();
Set<Long> knownDeadlockedThreads = threadInfoMap.keySet();
for (ThreadInfo threadInfo : allThreads) {
Thread.State state = threadInfo.getThreadState();
if (state == Thread.State.BLOCKED && !knownDeadlockedThreads.contains(threadInfo.getThreadId())) {
for (LinkedHashSet cycle : cycles) {
if (cycle.contains(threadInfoMap.get(Long.valueOf(threadInfo.getLockOwnerId())))) {
LinkedHashSet<ThreadInfo> chain = new LinkedHashSet<>();
for (ThreadInfo node = threadInfo; !chain.contains(node); node = threadInfoMap.get(Long.valueOf(node.getLockOwnerId())))
chain.add(node);
deadlockChain.add(chain);
}
}
}
}
return deadlockChain;
}
示例3: defaults
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
public static FiletypeParserFactory defaults(PropertyTreeParserFactory parserFactory) {
ImmutableMap<String, Class<?>> parser=ImmutableMap.<String,Class<?>>builder()
.put("toml", Toml.class)
.put("yaml", Yaml.class)
.build();
return new FiletypeParserFactory() {
@Override
public Maybe<PropertyTreeParser> parserFor(String extension) {
return Maybe.ofNullable(parser.get(extension))
.flatMap(parserFactory::parserFor);
}
@Override
public ImmutableSet<String> supportedExtensions() {
return parser.keySet();
}
};
}
示例4: process
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Override
public MultiLayerModel process(ImmutableMap<String, String> customData)
{
ImmutableMap.Builder<Optional<BlockRenderLayer>, ModelResourceLocation> builder = ImmutableMap.builder();
for(String key : customData.keySet())
{
if("base".equals(key))
{
builder.put(Optional.<BlockRenderLayer>absent(), getLocation(customData.get(key)));
}
for(BlockRenderLayer layer : BlockRenderLayer.values())
{
if(layer.toString().equals(key))
{
builder.put(Optional.of(layer), getLocation(customData.get(key)));
}
}
}
ImmutableMap<Optional<BlockRenderLayer>, ModelResourceLocation> models = builder.build();
if(models.isEmpty()) return INSTANCE;
return new MultiLayerModel(models);
}
示例5: matches
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Override
public boolean matches(IBlockState state) {
ImmutableMap properties = state.getProperties();
for (Object property : properties.keySet()) {
if (((IProperty) property).getName().equalsIgnoreCase(this.propName)) {
String thisPropValue = properties.get(property).toString();
for (String value : this.propValues) {
if (thisPropValue.equalsIgnoreCase(value)) {
return true;
}
}
return false;
}
}
return false;
}
示例6: finish
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Override
public void finish() throws IOException {
final String scorePattern = "TP: %d, FP: %d, FN: %d, Score: %f\n";
// see guidelines section 7.3.1.1.4 for aggregating rules:
// sum over per document contributions, divide by total number of TRFRs in the answer key
// Math.max is to skip division by zero errors.
final double overAllArgScore =
100 * scoreAggregator / Math.max(0.0 + aggregateFNs + aggregateTPs, 1.0);
final String scoreString =
String.format(scorePattern, aggregateTPs, aggregateFPs, aggregateFNs, overAllArgScore);
Files.asCharSink(new File(outputDir, "argScores.txt"), Charsets.UTF_8).write(scoreString);
final File jsonArgScores = new File(outputDir, "argScore.json");
serializer.serializeTo(ArgScoreSummary.of(overAllArgScore,
FMeasureCounts.fromTPFPFN(aggregateTPs, aggregateFPs, aggregateFNs)),
Files.asByteSink(jsonArgScores));
final ImmutableMap<Symbol, Double> scores = this.scores.build();
final ImmutableMap<Symbol, Integer> falsePositives = this.falsePositives.build();
final ImmutableMap<Symbol, Integer> truePositives = this.truePositives.build();
final ImmutableMap<Symbol, Integer> falseNegatives = this.falseNegatives.build();
final File perDocDir = new File(outputDir, "perDocument");
for (final Symbol docid : scores.keySet()) {
final File docDir = new File(perDocDir, docid.asString());
docDir.mkdirs();
final File docScore = new File(docDir, "argScores.txt");
// avoid dividing by zero
final double normalizer = Math.max(truePositives.get(docid) + falseNegatives.get(docid), 1);
// see guidelines referenced above
// pretends that the corpus is a single document
final double normalizedAndScaledArgScore = 100 * scores.get(docid) / normalizer;
Files.asCharSink(docScore, Charsets.UTF_8).write(String
.format(scorePattern, truePositives.get(docid), falsePositives.get(docid),
falseNegatives.get(docid), normalizedAndScaledArgScore));
final File docJsonArgScores = new File(docDir, "argScores.json");
serializer.serializeTo(normalizedAndScaledArgScore, Files.asByteSink(docJsonArgScores));
}
}
示例7: masterOperation
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Override
protected void masterOperation(final ShowUserPropertyRequest request, ClusterState state, final ActionListener<ShowUserPropertyResponse> listener) {
MetaData metaData = clusterService.state().metaData();
String username = request.getUsername();
if (!ALL_USER_NAME.equalsIgnoreCase(username)) {
UserProperty userProperty = metaData.getUserMetadata().getUserPropertyFromLoginUser(request.getUsername(), metaData.getTenantMetadata());
if (userProperty != null) {
username = userProperty.getUsernameWithTenant();
}
}
if (request.getHeader(LoginUserContext.TENANT_FILTER) != null) {
state = AuthService.filterState(state, metaData, (Long) request.getHeader(LoginUserContext.TENANT_FILTER));
}
if (state.metaData().getUserMetadata().getUserProperties().containsKey(username) || ALL_USER_NAME.equalsIgnoreCase(username)) {
ShowUserPropertyResponse response = new ShowUserPropertyResponse();
List<UserProperty> userProperties = new ArrayList<UserProperty>();
if (username.equalsIgnoreCase(ALL_USER_NAME)) {
ImmutableMap<String, UserProperty> allUsers = state.metaData().getUserMetadata().getUserProperties();
for (String specificUsername : allUsers.keySet()) {
userProperties.add(allUsers.get(specificUsername));
}
} else {
userProperties.add(state.metaData().getUserMetadata().getUserProperties().get(username));
}
response.setUserProperty(userProperties);
listener.onResponse(response);
} else {
listener.onFailure(new ElasticsearchException("user not exist: " + username));
}
}
示例8: masterOperation
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Override
protected void masterOperation(final ShowTenantsRequest request, ClusterState state, final ActionListener<ShowTenantsResponse> listener) {
ShowTenantsResponse response = new ShowTenantsResponse();
List<TenantProperty> tenantProperties = new ArrayList<TenantProperty>();
ImmutableMap<Long, TenantProperty> allTenants = state.metaData().getTenantMetadata().tenantProperties();
for (Long tenantId : allTenants.keySet()) {
tenantProperties.add(allTenants.get(tenantId));
}
response.setTenantProperty(tenantProperties);
listener.onResponse(response);
}
示例9: buildTable
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
private Table buildTable(RestRequest req, ClusterStateResponse state, NodesInfoResponse nodesInfo, NodesStatsResponse nodesStats) {
boolean fullId = req.paramAsBoolean("full_id", false);
DiscoveryNodes nodes = state.getState().nodes();
Table table = getTableWithHeader(req);
for (DiscoveryNode node : nodes) {
NodeInfo info = nodesInfo.getNodesMap().get(node.id());
ImmutableMap<String, String> attrs = node.getAttributes();
for(String att : attrs.keySet()) {
table.startRow();
table.addCell(node.name());
table.addCell(fullId ? node.id() : Strings.substring(node.getId(), 0, 4));
table.addCell(info == null ? null : info.getProcess().getId());
table.addCell(node.getHostName());
table.addCell(node.getHostAddress());
if (node.address() instanceof InetSocketTransportAddress) {
table.addCell(((InetSocketTransportAddress) node.address()).address().getPort());
} else {
table.addCell("-");
}
table.addCell(att);
table.addCell(attrs.containsKey(att) ? attrs.get(att) : null);
table.endRow();
}
}
return table;
}
示例10: assertMapContains
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
public static void assertMapContains(Map<NodeId, Set<String>> m1,
ImmutableMap<NodeId, Set<String>> m2) {
for (NodeId k : m2.keySet()) {
Assert.assertTrue(m1.containsKey(k));
assertCollectionEquals(m1.get(k), m2.get(k));
}
}
示例11: buildModels
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
private static ImmutableMap<Optional<BlockRenderLayer>, IBakedModel> buildModels(ImmutableMap<Optional<BlockRenderLayer>, ModelResourceLocation> models, IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter)
{
ImmutableMap.Builder<Optional<BlockRenderLayer>, IBakedModel> builder = ImmutableMap.builder();
for(Optional<BlockRenderLayer> key : models.keySet())
{
IModel model = ModelLoaderRegistry.getModelOrLogError(models.get(key), "Couldn't load MultiLayerModel dependency: " + models.get(key));
builder.put(key, model.bake(new ModelStateComposition(state, model.getDefaultState()), format, bakedTextureGetter));
}
return builder.build();
}
示例12: refreshHostIpWhiteList
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
private void refreshHostIpWhiteList() {
if (clusterService.localNode().isMasterNode()) {
MetaData metaData = clusterService.state().getMetaData();
UserMetadata userMetadata = metaData.getUserMetadata();
final UserMetadata.Builder userMetadataBuilder = new UserMetadata.Builder(userMetadata);
ImmutableMap<String, UserProperty> userPropertyMap = userMetadata.getUserProperties();
boolean changed = false;
for (String user : userPropertyMap.keySet()) {
UserProperty userProperty = userPropertyMap.get(user);
Set<String> hostIpWhiteList = userProperty.getHostIpWhiteList();
Set<String> hostnameWhiteList = userProperty.getHostnameWhiteList();
Set<String> newHostIpWhiteList = new HashSet<>();
boolean errorFlag = false;
for (String hostname : hostnameWhiteList) {
try {
InetAddress[] address = InetAddress.getAllByName(hostname);
for (InetAddress addr : address) {
newHostIpWhiteList.add(addr.getHostAddress());
}
} catch (UnknownHostException e) {
logger.error("Unknown host or BNS name: " + hostname);
errorFlag = true;
break;
}
}
newHostIpWhiteList.addAll(userProperty.getIpWhiteList());
if (!errorFlag && !hostIpWhiteList.equals(newHostIpWhiteList)) {
UserProperty.Builder userPropertyBuilder = new UserProperty.Builder(userProperty);
userPropertyBuilder.cleanHostIpWhiteList().addHostIpListToWhiteList(newHostIpWhiteList);
UserProperty newUserProperty = userPropertyBuilder.build();
userMetadataBuilder.addOrChangeUserProperty(user, newUserProperty);
changed = true;
}
}
if (changed) {
clusterService.submitStateUpdateTask("[refresh user hostIpWhiteList]", new ClusterStateUpdateTask() {
@Override
public boolean runOnlyOnMaster() {
return true;
}
@Override
public ClusterState execute(ClusterState currentState) throws Exception {
MetaData.Builder metaDataBuilder = MetaData.builder(currentState.metaData());
metaDataBuilder.putUserMetadata(userMetadataBuilder);
return ClusterState.builder(currentState).metaData(metaDataBuilder).build();
}
@Override
public void onFailure(String source, Throwable t) {
logger.error("unexpected failure during [{}]", t, source);
}
});
}
}
}