forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extended and reworked optimizer tests.
- Loading branch information
sewen
committed
Apr 9, 2013
1 parent
f0ff109
commit 15feaff
Showing
20 changed files
with
640 additions
and
423 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,8 @@ | |
|
||
package eu.stratosphere.pact.common.contract; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
|
@@ -46,9 +46,6 @@ | |
* unknown.</li> | ||
* <li>The average number of bytes per record. <code>-1.0</code> by default, indicating that this value is unknown.</li> | ||
* </ul> | ||
* | ||
* @author Matthias Ringwald | ||
* @author Fabian Hueske ([email protected]) | ||
*/ | ||
public class CompilerHints { | ||
|
||
|
@@ -60,15 +57,62 @@ public class CompilerHints { | |
|
||
private Map<FieldSet, Float> avgNumRecordsPerDistinctFields = new HashMap<FieldSet, Float>(); | ||
|
||
private Set<FieldSet> uniqueFields = null; | ||
private Set<FieldSet> uniqueFields; | ||
|
||
// -------------------------------------------------------------------------------------------- | ||
// Basic Record Statistics | ||
// -------------------------------------------------------------------------------------------- | ||
|
||
/** | ||
* Gets the average number of bytes per record (key/value pair) for the | ||
* contract containing these hints. | ||
* | ||
* @return The average number of bytes per record, or -1.0, if unknown. | ||
*/ | ||
public float getAvgBytesPerRecord() { | ||
return avgBytesPerRecord; | ||
} | ||
|
||
/** | ||
* Sets the average number of bytes per record (key/value pair) for the | ||
* contract containing these hints. | ||
* | ||
* @param avgBytes | ||
* The average number of bytes per record. | ||
*/ | ||
public void setAvgBytesPerRecord(float avgBytes) { | ||
if(avgBytes < 0) { | ||
throw new IllegalArgumentException("Average Bytes per Record must be >= 0!"); | ||
} | ||
this.avgBytesPerRecord = avgBytes; | ||
} | ||
|
||
/** | ||
* Default constructor. Creates a new <tt>CompilerHints</tt> object | ||
* with the default values for the encapsulated fields. | ||
* Gets the average number of emitted records per stub call. | ||
* | ||
* @return The average number of emitted records per stub call. | ||
*/ | ||
public CompilerHints() { | ||
public float getAvgRecordsEmittedPerStubCall() { | ||
return avgRecordsEmittedPerStubCall; | ||
} | ||
|
||
/** | ||
* Sets the average number of emitted records per stub call. | ||
* | ||
* @param avgRecordsEmittedPerStubCall | ||
* The average number of emitted records per stub call to set. | ||
*/ | ||
public void setAvgRecordsEmittedPerStubCall(float avgRecordsEmittedPerStubCall) { | ||
if(avgRecordsEmittedPerStubCall < 0) { | ||
throw new IllegalArgumentException("Average Number of Emitted Records per Stub Call must be >= 0!"); | ||
} | ||
this.avgRecordsEmittedPerStubCall = avgRecordsEmittedPerStubCall; | ||
} | ||
|
||
// -------------------------------------------------------------------------------------------- | ||
// Column (Group) Statistics | ||
// -------------------------------------------------------------------------------------------- | ||
|
||
/** | ||
* Gets the count of distinct values for the given set of fields. | ||
* | ||
|
@@ -139,78 +183,77 @@ public void setAvgNumRecordsPerDistinctFields(FieldSet fieldSet, float avgNumRec | |
} | ||
this.avgNumRecordsPerDistinctFields.put(fieldSet, avgNumRecords); | ||
} | ||
|
||
// -------------------------------------------------------------------------------------------- | ||
// Uniqueness | ||
// -------------------------------------------------------------------------------------------- | ||
|
||
/** | ||
* Gets the average number of bytes per record (key/value pair) for the | ||
* contract containing these hints. | ||
* Gets the FieldSets that are unique | ||
* | ||
* @return The average number of bytes per record, or -1.0, if unknown. | ||
* @return List of FieldSet that are unique | ||
*/ | ||
public float getAvgBytesPerRecord() { | ||
return avgBytesPerRecord; | ||
public Set<FieldSet> getUniqueFields() { | ||
return this.uniqueFields; | ||
} | ||
|
||
/** | ||
* Sets the average number of bytes per record (key/value pair) for the | ||
* contract containing these hints. | ||
* Adds a FieldSet to be unique | ||
* | ||
* @param avgBytes | ||
* The average number of bytes per record. | ||
* @param uniqueFieldSet The unique FieldSet | ||
*/ | ||
public void setAvgBytesPerRecord(float avgBytes) { | ||
if(avgBytes < 0) { | ||
throw new IllegalArgumentException("Average Bytes per Record must be >= 0!"); | ||
public void addUniqueField(FieldSet uniqueFieldSet) { | ||
if (this.uniqueFields == null) { | ||
this.uniqueFields = new HashSet<FieldSet>(); | ||
} | ||
this.avgBytesPerRecord = avgBytes; | ||
} | ||
|
||
/** | ||
* Gets the average number of emitted records per stub call. | ||
* | ||
* @return The average number of emitted records per stub call. | ||
*/ | ||
public float getAvgRecordsEmittedPerStubCall() { | ||
return avgRecordsEmittedPerStubCall; | ||
this.uniqueFields.add(uniqueFieldSet); | ||
} | ||
|
||
/** | ||
* Sets the average number of emitted records per stub call. | ||
* Adds a field as having only unique values. | ||
* | ||
* @param avgRecordsEmittedPerStubCall | ||
* The average number of emitted records per stub call to set. | ||
* @param field The field with unique values. | ||
*/ | ||
public void setAvgRecordsEmittedPerStubCall(float avgRecordsEmittedPerStubCall) { | ||
if(avgRecordsEmittedPerStubCall < 0) { | ||
throw new IllegalArgumentException("Average Number of Emitted Records per Stub Call must be >= 0!"); | ||
public void addUniqueField(int field) { | ||
if (this.uniqueFields == null) { | ||
this.uniqueFields = new HashSet<FieldSet>(); | ||
} | ||
this.avgRecordsEmittedPerStubCall = avgRecordsEmittedPerStubCall; | ||
this.uniqueFields.add(new FieldSet(field)); | ||
} | ||
|
||
|
||
/** | ||
* Gets the FieldSets that are unique | ||
* Adds multiple FieldSets to be unique | ||
* | ||
* @return List of FieldSet that are unique | ||
* @param uniqueFieldSets A set of unique FieldSet | ||
*/ | ||
public Set<FieldSet> getUniqueFields() { | ||
return this.uniqueFields; | ||
public void addUniqueFields(Set<FieldSet> uniqueFieldSets) { | ||
if (this.uniqueFields == null) { | ||
this.uniqueFields = new HashSet<FieldSet>(); | ||
} | ||
this.uniqueFields.addAll(uniqueFieldSets); | ||
} | ||
|
||
/** | ||
* Sets a FieldSet to be unique | ||
* | ||
* @param uniqueFieldSet The unique FieldSet | ||
*/ | ||
public void setUniqueField(FieldSet uniqueFieldSet) { | ||
this.uniqueFields = Collections.singleton(uniqueFieldSet); | ||
public void clearUniqueFields() { | ||
this.uniqueFields = null; | ||
} | ||
|
||
/** | ||
* Sets multiple FieldSets to be unique | ||
* | ||
* @param uniqueFieldSets A set of unique FieldSet | ||
*/ | ||
public void setUniqueField(Set<FieldSet> uniqueFieldSets) { | ||
this.uniqueFields = uniqueFieldSets; | ||
// -------------------------------------------------------------------------------------------- | ||
// Miscellaneous | ||
// -------------------------------------------------------------------------------------------- | ||
|
||
protected void copyFrom(CompilerHints source) { | ||
this.avgRecordsEmittedPerStubCall = source.avgRecordsEmittedPerStubCall; | ||
this.avgBytesPerRecord = source.avgBytesPerRecord; | ||
this.distinctCounts.putAll(source.distinctCounts); | ||
this.avgNumRecordsPerDistinctFields.putAll(source.avgNumRecordsPerDistinctFields); | ||
|
||
if (source.uniqueFields != null && source.uniqueFields.size() > 0) { | ||
if (this.uniqueFields == null) { | ||
this.uniqueFields = new HashSet<FieldSet>(); | ||
} else { | ||
this.uniqueFields.clear(); | ||
} | ||
this.uniqueFields.addAll(source.uniqueFields); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 0 additions & 37 deletions
37
pact/pact-common/src/main/java/eu/stratosphere/pact/common/io/OutputSchemaProvider.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.