use of org.apache.hyracks.algebricks.core.algebra.properties.RandomPartitioningProperty in project asterixdb by apache.
the class AbstractHashJoinPOperator method getRequiredPropertiesForChildren.
@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
// In a cost-based optimizer, we would also try to propagate the
// parent's partitioning requirements.
IPartitioningProperty pp1;
IPartitioningProperty pp2;
switch(partitioningType) {
case PAIRWISE:
pp1 = new UnorderedPartitionedProperty(new ListSet<>(keysLeftBranch), context.getComputationNodeDomain());
pp2 = new UnorderedPartitionedProperty(new ListSet<>(keysRightBranch), context.getComputationNodeDomain());
break;
case BROADCAST:
pp1 = new RandomPartitioningProperty(context.getComputationNodeDomain());
pp2 = new BroadcastPartitioningProperty(context.getComputationNodeDomain());
break;
default:
throw new IllegalStateException();
}
StructuralPropertiesVector[] pv = new StructuralPropertiesVector[2];
pv[0] = OperatorPropertiesUtil.checkUnpartitionedAndGetPropertiesVector(op, new StructuralPropertiesVector(pp1, null));
pv[1] = OperatorPropertiesUtil.checkUnpartitionedAndGetPropertiesVector(op, new StructuralPropertiesVector(pp2, null));
IPartitioningRequirementsCoordinator prc;
switch(kind) {
case INNER:
{
prc = IPartitioningRequirementsCoordinator.EQCLASS_PARTITIONING_COORDINATOR;
break;
}
case LEFT_OUTER:
{
prc = new IPartitioningRequirementsCoordinator() {
@Override
public Pair<Boolean, IPartitioningProperty> coordinateRequirements(IPartitioningProperty requirements, IPartitioningProperty firstDeliveredPartitioning, ILogicalOperator op, IOptimizationContext context) throws AlgebricksException {
if (firstDeliveredPartitioning != null && requirements != null && firstDeliveredPartitioning.getPartitioningType() == requirements.getPartitioningType()) {
switch(requirements.getPartitioningType()) {
case UNORDERED_PARTITIONED:
{
UnorderedPartitionedProperty upp1 = (UnorderedPartitionedProperty) firstDeliveredPartitioning;
Set<LogicalVariable> set1 = upp1.getColumnSet();
UnorderedPartitionedProperty uppreq = (UnorderedPartitionedProperty) requirements;
Set<LogicalVariable> modifuppreq = new ListSet<LogicalVariable>();
Map<LogicalVariable, EquivalenceClass> eqmap = context.getEquivalenceClassMap(op);
Set<LogicalVariable> covered = new ListSet<LogicalVariable>();
Set<LogicalVariable> keysCurrent = uppreq.getColumnSet();
List<LogicalVariable> keysFirst = (keysRightBranch.containsAll(keysCurrent)) ? keysRightBranch : keysLeftBranch;
List<LogicalVariable> keysSecond = keysFirst == keysRightBranch ? keysLeftBranch : keysRightBranch;
for (LogicalVariable r : uppreq.getColumnSet()) {
EquivalenceClass ecSnd = eqmap.get(r);
boolean found = false;
int j = 0;
for (LogicalVariable rvar : keysFirst) {
if (rvar == r || ecSnd != null && eqmap.get(rvar) == ecSnd) {
found = true;
break;
}
j++;
}
if (!found) {
throw new IllegalStateException("Did not find a variable equivalent to " + r + " among " + keysFirst);
}
LogicalVariable v2 = keysSecond.get(j);
EquivalenceClass ecFst = eqmap.get(v2);
for (LogicalVariable vset1 : set1) {
if (vset1 == v2 || ecFst != null && eqmap.get(vset1) == ecFst) {
covered.add(vset1);
modifuppreq.add(r);
break;
}
}
if (covered.equals(set1)) {
break;
}
}
if (!covered.equals(set1)) {
throw new AlgebricksException("Could not modify " + requirements + " to agree with partitioning property " + firstDeliveredPartitioning + " delivered by previous input operator.");
}
UnorderedPartitionedProperty upp2 = new UnorderedPartitionedProperty(modifuppreq, requirements.getNodeDomain());
return new Pair<>(false, upp2);
}
case ORDERED_PARTITIONED:
{
throw new NotImplementedException();
}
}
}
return new Pair<>(true, requirements);
}
};
break;
}
default:
{
throw new IllegalStateException();
}
}
return new PhysicalRequirements(pv, prc);
}
use of org.apache.hyracks.algebricks.core.algebra.properties.RandomPartitioningProperty in project asterixdb by apache.
the class DataSourcePartitioningProvider method getFeedPartitioningProperty.
public static IPartitioningProperty getFeedPartitioningProperty(DataSource ds, INodeDomain domain, List<LogicalVariable> scanVariables) {
IPartitioningProperty pp;
if (scanVariables.size() < 2) {
pp = new RandomPartitioningProperty(domain);
} else {
Set<LogicalVariable> pvars = new ListSet<>();
pvars.addAll(ds.getPrimaryKeyVariables(scanVariables));
pp = new UnorderedPartitionedProperty(pvars, domain);
}
return pp;
}
use of org.apache.hyracks.algebricks.core.algebra.properties.RandomPartitioningProperty in project asterixdb by apache.
the class NestedLoopJoinPOperator method getRequiredPropertiesForChildren.
@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
if (partitioningType != JoinPartitioningType.BROADCAST) {
throw new NotImplementedException(partitioningType + " nested loop joins are not implemented.");
}
StructuralPropertiesVector[] pv = new StructuralPropertiesVector[2];
// TODO: leverage statistics to make better decisions.
pv[0] = OperatorPropertiesUtil.checkUnpartitionedAndGetPropertiesVector(op, new StructuralPropertiesVector(new RandomPartitioningProperty(context.getComputationNodeDomain()), null));
pv[1] = OperatorPropertiesUtil.checkUnpartitionedAndGetPropertiesVector(op, new StructuralPropertiesVector(new BroadcastPartitioningProperty(context.getComputationNodeDomain()), null));
return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION);
}
use of org.apache.hyracks.algebricks.core.algebra.properties.RandomPartitioningProperty in project asterixdb by apache.
the class UnionAllPOperator method getRequiredPropertiesForChildren.
@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
StructuralPropertiesVector pv0 = OperatorPropertiesUtil.checkUnpartitionedAndGetPropertiesVector(op, new StructuralPropertiesVector(new RandomPartitioningProperty(context.getComputationNodeDomain()), null));
StructuralPropertiesVector pv1 = OperatorPropertiesUtil.checkUnpartitionedAndGetPropertiesVector(op, new StructuralPropertiesVector(new RandomPartitioningProperty(context.getComputationNodeDomain()), null));
return new PhysicalRequirements(new StructuralPropertiesVector[] { pv0, pv1 }, IPartitioningRequirementsCoordinator.NO_COORDINATION);
}
use of org.apache.hyracks.algebricks.core.algebra.properties.RandomPartitioningProperty in project asterixdb by apache.
the class DataSourcePartitioningProvider method computePropertiesVector.
@Override
public IPhysicalPropertiesVector computePropertiesVector(List<LogicalVariable> scanVariables) {
IPhysicalPropertiesVector propsVector;
IPartitioningProperty pp;
List<ILocalStructuralProperty> propsLocal = new ArrayList<>();
switch(ds.getDatasourceType()) {
case DataSource.Type.LOADABLE:
case DataSource.Type.EXTERNAL_DATASET:
pp = new RandomPartitioningProperty(domain);
ds.computeLocalStructuralProperties(propsLocal, scanVariables);
break;
case DataSource.Type.FEED:
pp = getFeedPartitioningProperty(ds, domain, scanVariables);
break;
case DataSource.Type.INTERNAL_DATASET:
Set<LogicalVariable> pvars = new ListSet<>();
pp = getInternalDatasetPartitioningProperty(ds, domain, scanVariables, pvars);
propsLocal.add(new LocalOrderProperty(getOrderColumns(pvars)));
break;
default:
throw new IllegalArgumentException();
}
propsVector = new StructuralPropertiesVector(pp, propsLocal);
return propsVector;
}
Aggregations