use of com.google.common.base.MoreObjects.toStringHelper in project presto by prestodb.
the class ExternalBodyReference method toString.
@Override
public String toString() {
ToStringHelper helper = toStringHelper(this);
identifier.ifPresent(value -> helper.add("identifier", value));
return helper.toString();
}
use of com.google.common.base.MoreObjects.toStringHelper in project presto by prestodb.
the class PageFunctionCompiler method defineFilterClass.
private ClassDefinition defineFilterClass(SqlFunctionProperties sqlFunctionProperties, Map<SqlFunctionId, SqlInvokedFunction> sessionFunctions, RowExpression filter, InputChannels inputChannels, CallSiteBinder callSiteBinder, boolean isOptimizeCommonSubExpression, Optional<String> classNameSuffix) {
ClassDefinition classDefinition = new ClassDefinition(a(PUBLIC, FINAL), generateFilterClassName(classNameSuffix), type(Object.class), type(PageFilter.class));
CachedInstanceBinder cachedInstanceBinder = new CachedInstanceBinder(classDefinition, callSiteBinder);
Map<LambdaDefinitionExpression, CompiledLambda> compiledLambdaMap = generateMethodsForLambda(classDefinition, callSiteBinder, cachedInstanceBinder, filter, metadata, sqlFunctionProperties, sessionFunctions);
// cse
Map<VariableReferenceExpression, CommonSubExpressionFields> cseFields = ImmutableMap.of();
RowExpressionCompiler compiler = new RowExpressionCompiler(classDefinition, callSiteBinder, cachedInstanceBinder, new FieldAndVariableReferenceCompiler(callSiteBinder, cseFields), metadata, sqlFunctionProperties, sessionFunctions, compiledLambdaMap);
if (isOptimizeCommonSubExpression) {
Map<Integer, Map<RowExpression, VariableReferenceExpression>> commonSubExpressionsByLevel = collectCSEByLevel(filter);
if (!commonSubExpressionsByLevel.isEmpty()) {
cseFields = declareCommonSubExpressionFields(classDefinition, commonSubExpressionsByLevel);
compiler = new RowExpressionCompiler(classDefinition, callSiteBinder, cachedInstanceBinder, new FieldAndVariableReferenceCompiler(callSiteBinder, cseFields), metadata, sqlFunctionProperties, sessionFunctions, compiledLambdaMap);
generateCommonSubExpressionMethods(classDefinition, compiler, commonSubExpressionsByLevel, cseFields);
Map<RowExpression, VariableReferenceExpression> commonSubExpressions = commonSubExpressionsByLevel.values().stream().flatMap(m -> m.entrySet().stream()).collect(toImmutableMap(Map.Entry::getKey, Map.Entry::getValue));
filter = rewriteExpressionWithCSE(filter, commonSubExpressions);
if (log.isDebugEnabled()) {
log.debug("Extracted %d common sub-expressions", commonSubExpressions.size());
commonSubExpressions.entrySet().forEach(entry -> log.debug("\t%s = %s", entry.getValue(), entry.getKey()));
log.debug("Rewrote filter: %s", filter);
}
}
}
generateFilterMethod(classDefinition, compiler, filter, cseFields);
FieldDefinition selectedPositions = classDefinition.declareField(a(PRIVATE), "selectedPositions", boolean[].class);
generatePageFilterMethod(classDefinition, selectedPositions);
// isDeterministic
classDefinition.declareMethod(a(PUBLIC), "isDeterministic", type(boolean.class)).getBody().append(constantBoolean(determinismEvaluator.isDeterministic(filter))).retBoolean();
// getInputChannels
classDefinition.declareMethod(a(PUBLIC), "getInputChannels", type(InputChannels.class)).getBody().append(invoke(callSiteBinder.bind(inputChannels, InputChannels.class), "getInputChannels")).retObject();
// toString
String toStringResult = toStringHelper(classDefinition.getType().getJavaClassName()).add("filter", filter).toString();
classDefinition.declareMethod(a(PUBLIC), "toString", type(String.class)).getBody().append(invoke(callSiteBinder.bind(toStringResult, String.class), "toString")).retObject();
// constructor
MethodDefinition constructorDefinition = classDefinition.declareConstructor(a(PUBLIC));
BytecodeBlock body = constructorDefinition.getBody();
Variable thisVariable = constructorDefinition.getThis();
body.comment("super();").append(thisVariable).invokeConstructor(Object.class).append(thisVariable.setField(selectedPositions, newArray(type(boolean[].class), 0)));
initializeCommonSubExpressionFields(cseFields.values(), thisVariable, body);
cachedInstanceBinder.generateInitializations(thisVariable, body);
body.ret();
return classDefinition;
}
use of com.google.common.base.MoreObjects.toStringHelper in project presto by prestodb.
the class ShardMetadata method toString.
@Override
public String toString() {
ToStringHelper stringHelper = toStringHelper(this).add("tableId", tableId).add("shardId", shardId).add("shardUuid", shardUuid).add("isDelta", isDelta).add("rowCount", rowCount).add("compressedSize", DataSize.succinctBytes(compressedSize)).add("uncompressedSize", DataSize.succinctBytes(uncompressedSize));
deltaUuid.ifPresent(uuid -> stringHelper.add("deltaUuid", uuid));
if (bucketNumber.isPresent()) {
stringHelper.add("bucketNumber", bucketNumber.getAsInt());
}
if (xxhash64.isPresent()) {
stringHelper.add("xxhash64", format("%16x", xxhash64.getAsLong()));
}
if (rangeStart.isPresent()) {
stringHelper.add("rangeStart", rangeStart.getAsLong());
}
if (rangeEnd.isPresent()) {
stringHelper.add("rangeEnd", rangeEnd.getAsLong());
}
return stringHelper.toString();
}
use of com.google.common.base.MoreObjects.toStringHelper in project gerrit by GerritCodeReview.
the class CommitInfo method toString.
@Override
public String toString() {
ToStringHelper helper = MoreObjects.toStringHelper(this).addValue(commit);
if (parents != null) {
helper.add("parents", parents.stream().map(p -> p.commit).collect(joining(", ")));
}
helper.add("author", author).add("committer", committer).add("subject", subject).add("message", message);
if (webLinks != null) {
helper.add("webLinks", webLinks);
}
if (resolveConflictsWebLinks != null) {
helper.add("resolveConflictsWebLinks", resolveConflictsWebLinks);
}
return helper.toString();
}
Aggregations