本文整理汇总了Java中com.google.common.collect.ImmutableMap.entrySet方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableMap.entrySet方法的具体用法?Java ImmutableMap.entrySet怎么用?Java ImmutableMap.entrySet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.ImmutableMap
的用法示例。
在下文中一共展示了ImmutableMap.entrySet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFirestoreAccess
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Test
public void testFirestoreAccess() throws Exception {
Firestore firestore = FirestoreClient.getFirestore(IntegrationTestUtils.ensureDefaultApp());
DocumentReference reference = firestore.collection("cities").document("Mountain View");
ImmutableMap<String, Object> expected = ImmutableMap.<String, Object>of(
"name", "Mountain View",
"country", "USA",
"population", 77846L,
"capital", false
);
WriteResult result = reference.set(expected).get();
assertNotNull(result);
Map<String, Object> data = reference.get().get().getData();
assertEquals(expected.size(), data.size());
for (Map.Entry<String, Object> entry : expected.entrySet()) {
assertEquals(entry.getValue(), data.get(entry.getKey()));
}
reference.delete().get();
assertFalse(reference.get().get().exists());
}
示例2: process
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
public void process(ImmutableMap<String, String> customData)
{
for (Map.Entry<String, String> e : customData.entrySet())
{
if (e.getKey().equals("ambient"))
this.ambientOcclusion = Boolean.valueOf(e.getValue());
else if (e.getKey().equals("gui3d"))
this.gui3d = Boolean.valueOf(e.getValue());
/*else if (e.getKey().equals("modifyUVs"))
this.modifyUVs = Boolean.valueOf(e.getValue());*/
else if (e.getKey().equals("flip-v"))
this.flipV = Boolean.valueOf(e.getValue());
else if (e.getKey().equals("tintmap")) {
Type type = new TypeToken<Map<String,Integer>>(){}.getType();
this.tintMap = new Gson().fromJson(e.getValue(), type);
}
}
}
示例3: getStringFromMap
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
public static String getStringFromMap(ImmutableMap<String, ImmutableSet<PrivilegeType>> mapSet) {
String result = "";
if (mapSet == null || mapSet.size() == 0) {
return "";
}
boolean isFirst = false;
for(Entry<String, ImmutableSet<PrivilegeType>> ele : mapSet.entrySet()) {
String dbName = ele.getKey();
String privileges = getStringFromArray2(ele.getValue());
if (isFirst) {
result = result + dbName + ": (" + privileges + "); ";
isFirst = false;
} else {
result = result + dbName + ": (" + privileges + "); ";
}
}
return result;
}
示例4: addMatchedQueries
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
private void addMatchedQueries(HitContext hitContext, ImmutableMap<String, Query> namedQueries, List<String> matchedQueries) throws IOException {
for (Map.Entry<String, Query> entry : namedQueries.entrySet()) {
String name = entry.getKey();
Query filter = entry.getValue();
final Weight weight = hitContext.topLevelSearcher().createNormalizedWeight(filter, false);
final Scorer scorer = weight.scorer(hitContext.readerContext());
if (scorer == null) {
continue;
}
final TwoPhaseIterator twoPhase = scorer.twoPhaseIterator();
if (twoPhase == null) {
if (scorer.iterator().advance(hitContext.docId()) == hitContext.docId()) {
matchedQueries.add(name);
}
} else {
if (twoPhase.approximation().advance(hitContext.docId()) == hitContext.docId() && twoPhase.matches()) {
matchedQueries.add(name);
}
}
}
}
示例5: isFieldMappingMissingField
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
/**
* Helper method to find out if the only included fieldmapping metadata is typed NULL, which means
* that type and index exist, but the field did not
*/
private boolean isFieldMappingMissingField(ImmutableMap<String, ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>>> mappingsByIndex) throws IOException {
if (mappingsByIndex.size() != 1) {
return false;
}
for (ImmutableMap<String, ImmutableMap<String, FieldMappingMetaData>> value : mappingsByIndex.values()) {
for (ImmutableMap<String, FieldMappingMetaData> fieldValue : value.values()) {
for (Map.Entry<String, FieldMappingMetaData> fieldMappingMetaDataEntry : fieldValue.entrySet()) {
if (fieldMappingMetaDataEntry.getValue().isNull()) {
return true;
}
}
}
}
return false;
}
示例6: runTests
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
private static void runTests(
AuthorityClassifier p,
ImmutableMap<Classification, ImmutableList<String>> inputs) {
Diagnostic.CollectingReceiver<UrlValue> cr = Diagnostic.CollectingReceiver.from(
TestUtil.STDERR_RECEIVER);
try {
for (Map.Entry<Classification, ImmutableList<String>> e
: inputs.entrySet()) {
Classification want = e.getKey();
ImmutableList<String> inputList = e.getValue();
for (int i = 0; i < inputList.size(); ++i) {
cr.clear();
String url = inputList.get(i);
UrlValue inp = UrlValue.from(TEST_URL_CONTEXT, url);
Classification got = p.apply(inp, cr);
assertEquals(i + ": " + url, want, got);
}
cr.clear();
}
} finally {
cr.flush();
}
}
示例7: getTimestampedValues
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@VisibleForTesting
ImmutableList<MetricPoint<V>> getTimestampedValues(Instant timestamp) {
ImmutableMap<ImmutableList<String>, V> values = valuesSupplier.get();
ImmutableList.Builder<MetricPoint<V>> metricPoints = new ImmutableList.Builder<>();
for (Entry<ImmutableList<String>, V> entry : values.entrySet()) {
metricPoints.add(
MetricPoint.create(this, entry.getKey(), timestamp, timestamp, entry.getValue()));
}
cardinality = values.size();
return metricPoints.build();
}
示例8: shouldNotFindSimilarStyles
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Test
public void shouldNotFindSimilarStyles() {
ImmutableMap<String, String> notEquals = getNotCorrectStyles();
for (Map.Entry<String, String> entry : notEquals.entrySet()) {
assertFalse(instance.checkIfEquals(elementStyles, entry.getKey(), entry.getValue()));
}
}
示例9: shouldFindSimilarStyles
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
@Test
public void shouldFindSimilarStyles() {
ImmutableMap<String, String> equalStyles = getCorrectStyles();
for (Map.Entry<String, String> entry : equalStyles.entrySet()) {
assertTrue(instance.checkIfEquals(elementStyles, entry.getKey(), entry.getValue()));
}
}
示例10: writeBootstrappedOutput
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
private void writeBootstrappedOutput(final List<EALScorer2015Style.Result> perDocResults,
final File baseOutputDir) throws IOException {
if (doBootstrapping) {
// boostrapped result writers are stateful, so we need to get new ones each time
final ImmutableMap.Builder<String, BootstrappedResultWriter> builder = ImmutableMap.builder();
for (final Map.Entry<String, BootstrappedResultWriterSource> source : bootstrappedResultWriterSources
.entrySet()) {
builder.put(source.getKey(), source.getValue().getResultWriter());
}
final ImmutableMap<String, BootstrappedResultWriter> bootstrappedWriters = builder.build();
// this will produce an infinite sequence of bootstrapped samples of the corpus
final Iterator<Collection<EALScorer2015Style.Result>>
bootstrapIt = BootstrapIterator.forData(perDocResults, new Random(bootstrapSeed));
// a bootstrap iterator always has .next()
for (int i = 0; i < numBootstrapSamples; ++i) {
// be sure to use the same sample for all observers
final Collection<EALScorer2015Style.Result> sample = bootstrapIt.next();
for (final KBP2015Scorer.BootstrappedResultWriter bootstrappedResultWriter : bootstrappedWriters
.values()) {
bootstrappedResultWriter.observeSample(sample);
}
}
for (final Map.Entry<String, BootstrappedResultWriter> resultWriterEntry : bootstrappedWriters
.entrySet()) {
final File outputDir = new File(baseOutputDir, resultWriterEntry.getKey());
outputDir.mkdirs();
resultWriterEntry.getValue().writeResult(outputDir);
}
}
}
示例11: dumpPercentilesForMetric
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
private void dumpPercentilesForMetric(String metricName,
ImmutableMap<String, PercentileComputer.Percentiles> percentiles,
Map.Entry<String, Collection<Symbol>> FMeasureSymbol, StringBuilder output) {
output.append(metricName).append(" vs ").append(FMeasureSymbol.getKey()).append("\n\n");
output.append(renderLine("Name", PERCENTILES_TO_PRINT));
output.append(Strings.repeat("*", 70)).append("\n");
for (final Map.Entry<String, PercentileComputer.Percentiles> percentileEntry : percentiles
.entrySet()) {
output.append(renderLine(percentileEntry.getKey(),
Lists.transform(percentileEntry.getValue().percentiles(PERCENTILES_TO_PRINT),
OptionalUtils.deoptionalizeFunction(Double.NaN))));
}
output.append("\n\n\n");
}
示例12: processWaitingShards
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
private ImmutableMap<ShardId, ShardSnapshotStatus> processWaitingShards(ImmutableMap<ShardId, ShardSnapshotStatus> snapshotShards, RoutingTable routingTable) {
boolean snapshotChanged = false;
ImmutableMap.Builder<ShardId, ShardSnapshotStatus> shards = ImmutableMap.builder();
for (ImmutableMap.Entry<ShardId, ShardSnapshotStatus> shardEntry : snapshotShards.entrySet()) {
ShardSnapshotStatus shardStatus = shardEntry.getValue();
if (shardStatus.state() == State.WAITING) {
ShardId shardId = shardEntry.getKey();
IndexRoutingTable indexShardRoutingTable = routingTable.index(shardId.getIndex());
if (indexShardRoutingTable != null) {
IndexShardRoutingTable shardRouting = indexShardRoutingTable.shard(shardId.id());
if (shardRouting != null && shardRouting.primaryShard() != null) {
if (shardRouting.primaryShard().started()) {
// Shard that we were waiting for has started on a node, let's process it
snapshotChanged = true;
logger.trace("starting shard that we were waiting for [{}] on node [{}]", shardEntry.getKey(), shardStatus.nodeId());
shards.put(shardEntry.getKey(), new ShardSnapshotStatus(shardRouting.primaryShard().currentNodeId()));
continue;
} else if (shardRouting.primaryShard().initializing() || shardRouting.primaryShard().relocating()) {
// Shard that we were waiting for hasn't started yet or still relocating - will continue to wait
shards.put(shardEntry);
continue;
}
}
}
// Shard that we were waiting for went into unassigned state or disappeared - giving up
snapshotChanged = true;
logger.warn("failing snapshot of shard [{}] on unassigned shard [{}]", shardEntry.getKey(), shardStatus.nodeId());
shards.put(shardEntry.getKey(), new ShardSnapshotStatus(shardStatus.nodeId(), State.FAILED, "shard is unassigned"));
} else {
shards.put(shardEntry);
}
}
if (snapshotChanged) {
return shards.build();
} else {
return null;
}
}
示例13: indicesWithMissingShards
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
/**
* Returns list of indices with missing shards, and list of indices that are closed
*
* @param shards list of shard statuses
* @return list of failed and closed indices
*/
private Tuple<Set<String>, Set<String>> indicesWithMissingShards(ImmutableMap<ShardId, SnapshotsInProgress.ShardSnapshotStatus> shards, MetaData metaData) {
Set<String> missing = newHashSet();
Set<String> closed = newHashSet();
for (ImmutableMap.Entry<ShardId, SnapshotsInProgress.ShardSnapshotStatus> entry : shards.entrySet()) {
if (entry.getValue().state() == State.MISSING) {
if (metaData.hasIndex(entry.getKey().getIndex()) && metaData.index(entry.getKey().getIndex()).getState() == IndexMetaData.State.CLOSE) {
closed.add(entry.getKey().getIndex());
} else {
missing.add(entry.getKey().getIndex());
}
}
}
return new Tuple<>(missing, closed);
}
示例14: calculateCycles
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
private Set<LinkedHashSet<ThreadInfo>> calculateCycles(ImmutableMap<Long, ThreadInfo> threadInfoMap) {
Set<LinkedHashSet<ThreadInfo>> cycles = new HashSet<>();
for (Map.Entry<Long, ThreadInfo> entry : threadInfoMap.entrySet()) {
LinkedHashSet<ThreadInfo> cycle = new LinkedHashSet<>();
for (ThreadInfo t = entry.getValue(); !cycle.contains(t); t = threadInfoMap.get(Long.valueOf(t.getLockOwnerId())))
cycle.add(t);
if (!cycles.contains(cycle))
cycles.add(cycle);
}
return cycles;
}
示例15: addVictory
import com.google.common.collect.ImmutableMap; //导入方法依赖的package包/类
void addVictory(String userName) {
ImmutableMap<String, Integer> currentScores = scoresRelay.getValue();
ImmutableMap.Builder<String, Integer> newScoreMapBuilder = new ImmutableMap.Builder<>();
for (Map.Entry<String, Integer> entry : currentScores.entrySet()) {
if (entry.getKey().equals(userName)) {
newScoreMapBuilder.put(entry.getKey(), entry.getValue() + 1);
} else {
newScoreMapBuilder.put(entry.getKey(), entry.getValue());
}
}
scoresRelay.accept(newScoreMapBuilder.build());
}