Skip to content

Commit

Permalink
Minor renaming of compiler hint
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabian Hueske authored and StephanEwen committed Feb 27, 2014
1 parent eaaaeea commit 908cba5
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ protected List<OperatorDescriptorSingle> getPossibleProperties() {
}

/**
* Computes the estimates for the Map operator. Map takes one value and transforms it into another value.
* Computes the estimates for the Map operator.
* We assume that by default, Map takes one value and transforms it into another value.
* The cardinality consequently stays the same.
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,13 +654,13 @@ else if (this instanceof SingleInputNode) {
}

// use the width to infer the cardinality (given size) and vice versa
if (hints.getAvgBytesPerOutputRecord() >= 1) {
if (hints.getAvgOutputRecordSize() >= 1) {
// the estimated number of rows based on size
if (this.estimatedNumRecords == -1 && this.estimatedOutputSize >= 0) {
this.estimatedNumRecords = (long) (this.estimatedOutputSize / hints.getAvgBytesPerOutputRecord());
this.estimatedNumRecords = (long) (this.estimatedOutputSize / hints.getAvgOutputRecordSize());
}
else if (this.estimatedOutputSize == -1 && this.estimatedNumRecords >= 0) {
this.estimatedOutputSize = (long) (this.estimatedNumRecords * hints.getAvgBytesPerOutputRecord());
this.estimatedOutputSize = (long) (this.estimatedNumRecords * hints.getAvgOutputRecordSize());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,14 +538,14 @@ private void visit(DumpableNode<?> node, PrintWriter writer, boolean first) {

String size = hints.getOutputSize() == defaults.getOutputSize() ? "(none)" : String.valueOf(hints.getOutputSize());
String card = hints.getOutputCardinality() == defaults.getOutputCardinality() ? "(none)" : String.valueOf(hints.getOutputCardinality());
String width = hints.getAvgBytesPerOutputRecord() == defaults.getAvgBytesPerOutputRecord() ? "(none)" : String.valueOf(hints.getAvgBytesPerOutputRecord());
String width = hints.getAvgOutputRecordSize() == defaults.getAvgOutputRecordSize() ? "(none)" : String.valueOf(hints.getAvgOutputRecordSize());
String filter = hints.getFilterFactor() == defaults.getFilterFactor() ? "(none)" : String.valueOf(hints.getFilterFactor());

writer.print(",\n\t\t\"compiler_hints\": [\n");

addProperty(writer, "Output Size", size, true);
addProperty(writer, "Output Size (bytes)", size, true);
addProperty(writer, "Output Cardinality", card, false);
addProperty(writer, "Output avg. width (bytes)", width, false);
addProperty(writer, "Avg. Output Record Size (bytes)", width, false);
addProperty(writer, "Filter Factor", filter, false);

writer.print("\t\t]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* A class encapsulating compiler hints describing the behavior of the user function.
* If set, the optimizer will use them to estimate the sizes of the intermediate results.
* Not that these values are optional hints, the optimizer will always generate a valid plan without
* Note that these values are optional hints, the optimizer will always generate a valid plan without
* them as well. The hints may help, however, to improve the plan choice.
*/
public class CompilerHints {
Expand All @@ -30,7 +30,7 @@ public class CompilerHints {

private long outputCardinality = -1;

private float avgBytesPerOutputRecord = -1.0f;
private float avgOutputRecordSize = -1.0f;

private float filterFactor = -1.0f;

Expand Down Expand Up @@ -62,15 +62,15 @@ public void setOutputCardinality(long outputCardinality) {
this.outputCardinality = outputCardinality;
}

public float getAvgBytesPerOutputRecord() {
return this.avgBytesPerOutputRecord;
public float getAvgOutputRecordSize() {
return this.avgOutputRecordSize;
}

public void setAvgBytesPerOutputRecord(float avgBytesPerOutputRecord) {
if (avgBytesPerOutputRecord <= 0)
public void setAvgOutputRecordSize(float avgOutputRecordSize) {
if (avgOutputRecordSize <= 0)
throw new IllegalArgumentException("The size of produced records must be positive.");

this.avgBytesPerOutputRecord = avgBytesPerOutputRecord;
this.avgOutputRecordSize = avgOutputRecordSize;
}

public float getFilterFactor() {
Expand Down Expand Up @@ -146,7 +146,7 @@ public void clearUniqueFields() {
protected void copyFrom(CompilerHints source) {
this.outputSize = source.outputSize;
this.outputCardinality = source.outputCardinality;
this.avgBytesPerOutputRecord = source.avgBytesPerOutputRecord;
this.avgOutputRecordSize = source.avgOutputRecordSize;
this.filterFactor = source.filterFactor;

if (source.uniqueFields != null && source.uniqueFields.size() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,14 @@ public Plan getPlan(String... args) {
.input(ranks)
.name("Filter Ranks")
.build();
filterRanks.getCompilerHints().setFilterFactor(0.25f);

// Create MapOperator for filtering the entries from the visits relation
MapOperator filterVisits = MapOperator.builder(new FilterVisits())
.input(visits)
.name("Filter Visits")
.build();
filterVisits.getCompilerHints().setFilterFactor(0.2f);

// Create JoinOperator to join the filtered documents and ranks
// relation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ private RecordFormatCompilerHints(CompilerHints parent) {
}

@Override
public float getAvgBytesPerOutputRecord() {
float superWidth = super.getAvgBytesPerOutputRecord();
public float getAvgOutputRecordSize() {
float superWidth = super.getAvgOutputRecordSize();
if (superWidth > 0.0f || this.width <= 0.0f) {
return superWidth;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ trait OutputHintable[Out] { this: DataSet[Out] =>
def outputCardinality_=(value: Long) = contract.getCompilerHints().setOutputCardinality(value)
def outputCardinality(value: Long): this.type = { contract.getCompilerHints().setOutputCardinality(value); this }

def avgBytesPerRecord = contract.getCompilerHints().getAvgBytesPerOutputRecord()
def avgBytesPerRecord_=(value: Float) = contract.getCompilerHints().setAvgBytesPerOutputRecord(value)
def avgBytesPerRecord(value: Float): this.type = { contract.getCompilerHints().setAvgBytesPerOutputRecord(value); this }
def avgBytesPerRecord = contract.getCompilerHints().getAvgOutputRecordSize()
def avgBytesPerRecord_=(value: Float) = contract.getCompilerHints().setAvgOutputRecordSize(value)
def avgBytesPerRecord(value: Float): this.type = { contract.getCompilerHints().setAvgOutputRecordSize(value); this }

def filterFactor = contract.getCompilerHints().getFilterFactor()
def filterFactor_=(value: Float) = contract.getCompilerHints().setFilterFactor(value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ object CopyOperator {
.filter( z => z._1 == z._2).map { _._1}))
persistHints = { () =>
this.setName("Copy " + source.getName())
if (source.getCompilerHints().getAvgBytesPerOutputRecord() >= 0)
this.getCompilerHints().setAvgBytesPerOutputRecord(source.getCompilerHints().getAvgBytesPerOutputRecord())
if (source.getCompilerHints().getAvgOutputRecordSize() >= 0)
this.getCompilerHints().setAvgOutputRecordSize(source.getCompilerHints().getAvgOutputRecordSize())
}
}
new DataSet[Nothing](ret)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private void testQueryGeneric(Plan p, long orderSize, long lineitemSize,
JoinOperator joiner = cr.getNode(JOIN_NAME);
setSourceStatistics(ordersSource, orderSize, 100f);
setSourceStatistics(lineItemSource, lineitemSize, 140f);
mapper.getCompilerHints().setAvgBytesPerOutputRecord(16f);
mapper.getCompilerHints().setAvgOutputRecordSize(16f);
mapper.getCompilerHints().setFilterFactor(orderSelectivity);
joiner.getCompilerHints().setFilterFactor(joinSelectivity);

Expand Down

0 comments on commit 908cba5

Please sign in to comment.