use of com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap in project java-driver by datastax.
the class RelationParser method parseOptions.
protected Map<CqlIdentifier, Object> parseOptions(AdminRow row) {
ImmutableMap.Builder<CqlIdentifier, Object> builder = ImmutableMap.builder();
for (Map.Entry<String, TypeCodec<?>> entry : OPTION_CODECS.entrySet()) {
String name = entry.getKey();
CqlIdentifier id = CqlIdentifier.fromInternal(name);
TypeCodec<?> codec = entry.getValue();
if (name.equals("caching") && row.isString("caching")) {
// C* <=2.2, caching is stored as a string, and also appears as a string in the WITH clause.
builder.put(id, row.getString(name));
} else if (name.equals("compaction_strategy_class")) {
// C* <=2.2, compaction options split in two columns
String strategyClass = row.getString(name);
if (strategyClass != null) {
builder.put(CqlIdentifier.fromInternal("compaction"), ImmutableMap.<String, String>builder().put("class", strategyClass).putAll(SimpleJsonParser.parseStringMap(row.getString("compaction_strategy_options"))).build());
}
} else if (name.equals("compression_parameters")) {
// C* <=2.2, compression stored as a string
String compressionParameters = row.getString(name);
if (compressionParameters != null) {
builder.put(CqlIdentifier.fromInternal("compression"), ImmutableMap.copyOf(SimpleJsonParser.parseStringMap(row.getString(name))));
}
} else if (!isDeprecatedInCassandra4(name)) {
// Default case, read the value in a generic fashion
Object value = row.get(name, codec);
if (value != null) {
builder.put(id, value);
}
}
}
return builder.build();
}
use of com.datastax.oss.driver.shaded.guava.common.collect.ImmutableMap in project java-driver by datastax.
the class DefaultTokenMap method buildReplicationConfigs.
private static Map<CqlIdentifier, Map<String, String>> buildReplicationConfigs(Collection<KeyspaceMetadata> keyspaces, String logPrefix) {
ImmutableMap.Builder<CqlIdentifier, Map<String, String>> builder = ImmutableMap.builder();
for (KeyspaceMetadata keyspace : keyspaces) {
if (!keyspace.isVirtual()) {
builder.put(keyspace.getName(), keyspace.getReplication());
}
}
ImmutableMap<CqlIdentifier, Map<String, String>> result = builder.build();
LOG.debug("[{}] Computing keyspace-level data for {}", logPrefix, result);
return result;
}
Aggregations