use of com.google.common.base.Joiner in project YCSB by brianfrankcooper.
the class CloudSpannerClient method readUsingQuery.
private Status readUsingQuery(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) {
Statement query;
Iterable<String> columns = fields == null ? STANDARD_FIELDS : fields;
if (fields == null || fields.size() == fieldCount) {
query = Statement.newBuilder(standardQuery).bind("key").to(key).build();
} else {
Joiner joiner = Joiner.on(',');
query = Statement.newBuilder("SELECT ").append(joiner.join(fields)).append(" FROM ").append(table).append(" WHERE id=@key").bind("key").to(key).build();
}
try (ResultSet resultSet = dbClient.singleUse(timestampBound).executeQuery(query)) {
resultSet.next();
decodeStruct(columns, resultSet, result);
if (resultSet.next()) {
throw new Exception("Expected exactly one row for each read.");
}
return Status.OK;
} catch (Exception e) {
LOGGER.log(Level.INFO, "readUsingQuery()", e);
return Status.ERROR;
}
}
use of com.google.common.base.Joiner in project YCSB by brianfrankcooper.
the class CloudSpannerClient method scanUsingQuery.
private Status scanUsingQuery(String table, String startKey, int recordCount, Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
Iterable<String> columns = fields == null ? STANDARD_FIELDS : fields;
Statement query;
if (fields == null || fields.size() == fieldCount) {
query = Statement.newBuilder(standardScan).bind("startKey").to(startKey).bind("count").to(recordCount).build();
} else {
Joiner joiner = Joiner.on(',');
query = Statement.newBuilder("SELECT ").append(joiner.join(fields)).append(" FROM ").append(table).append(" WHERE id>=@startKey LIMIT @count").bind("startKey").to(startKey).bind("count").to(recordCount).build();
}
try (ResultSet resultSet = dbClient.singleUse(timestampBound).executeQuery(query)) {
while (resultSet.next()) {
HashMap<String, ByteIterator> row = new HashMap<>();
decodeStruct(columns, resultSet, row);
result.add(row);
}
return Status.OK;
} catch (Exception e) {
LOGGER.log(Level.INFO, "scanUsingQuery()", e);
return Status.ERROR;
}
}
use of com.google.common.base.Joiner in project crate by crate.
the class TreeAssertions method assertListEquals.
private static <T> void assertListEquals(List<T> actual, List<T> expected) {
if (actual.size() != expected.size()) {
Joiner joiner = Joiner.on("\n ");
fail(format("Lists not equal%nActual [%s]:%n %s%nExpected [%s]:%n %s", actual.size(), joiner.join(actual), expected.size(), joiner.join(expected)));
}
assertEquals(actual, expected);
}
use of com.google.common.base.Joiner in project crate by crate.
the class PingTask method buildPingUrl.
private URL buildPingUrl() throws URISyntaxException, IOException, NoSuchAlgorithmException {
URI uri = new URI(this.pingUrl);
Map<String, String> queryMap = new HashMap<>();
// block until clusterId is available
queryMap.put("cluster_id", getClusterId());
queryMap.put("kernel", XContentFactory.jsonBuilder().map(getKernelData()).string());
queryMap.put("master", isMasterNode().toString());
queryMap.put("enterprise", isEnterprise());
queryMap.put("ping_count", XContentFactory.jsonBuilder().map(getCounters()).string());
queryMap.put("hardware_address", getHardwareAddress());
queryMap.put("crate_version", getCrateVersion());
queryMap.put("java_version", getJavaVersion());
if (logger.isDebugEnabled()) {
logger.debug("Sending data: {}", queryMap);
}
final Joiner joiner = Joiner.on('=');
List<String> params = new ArrayList<>(queryMap.size());
for (Map.Entry<String, String> entry : queryMap.entrySet()) {
if (entry.getValue() != null) {
params.add(joiner.join(entry.getKey(), entry.getValue()));
}
}
String query = Joiner.on('&').join(params);
return new URI(uri.getScheme(), uri.getUserInfo(), uri.getHost(), uri.getPort(), uri.getPath(), query, uri.getFragment()).toURL();
}
use of com.google.common.base.Joiner in project gradle by gradle.
the class DefaultLibraryResolutionErrorMessageBuilder method noCompatibleVariantErrorMessage.
@Override
public String noCompatibleVariantErrorMessage(String libraryName, Iterable<? extends Binary> allBinaries) {
HashMultimap<String, String> variantAxisMessages = HashMultimap.create();
for (Binary binary : allBinaries) {
BinarySpec spec = (BinarySpec) binary;
VariantsMetaData md = DefaultVariantsMetaData.extractFrom(spec, schemaStore.getSchema(((BinarySpecInternal) spec).getPublicType()));
Set<String> variantAxesWithIncompatibleTypes = VariantsMetaDataHelper.determineAxesWithIncompatibleTypes(variantsMetaData, md, variantAxesToResolve);
for (String variantAxis : variantAxesToResolve) {
String value = md.getValueAsString(variantAxis);
if (value != null) {
String message = String.format("'%s'", value);
if (variantAxesWithIncompatibleTypes.contains(variantAxis)) {
message = String.format("%s but with an incompatible type (expected '%s' was '%s')", message, variantsMetaData.getVariantAxisType(variantAxis).getConcreteClass().getName(), md.getVariantAxisType(variantAxis).getConcreteClass().getName());
}
variantAxisMessages.put(variantAxis, message);
}
}
}
Joiner joiner = Joiner.on(", ").skipNulls();
StringBuilder error = new StringBuilder(String.format(TextUtil.toPlatformLineSeparators("Cannot find a compatible variant for library '%s'.\n"), libraryName));
for (String variantAxis : variantAxesToResolve) {
String axisName = renderAxisName(variantAxis);
error.append(" Required ").append(axisName).append(" '").append(variantsMetaData.getValueAsString(variantAxis)).append("'");
Set<String> available = new TreeSet<String>(variantAxisMessages.get(variantAxis));
if (!available.isEmpty()) {
error.append(", available: ").append(joiner.join(available)).append("\n");
} else {
error.append(" but no compatible variant was found\n");
}
}
return error.toString();
}
Aggregations