use of org.apache.hyracks.algebricks.core.algebra.base.IPhysicalOperator in project asterixdb by apache.
the class RequiredCapacityVisitor method calculateMemoryUsageForExchange.
// Calculates the memory usage for exchange operators.
private void calculateMemoryUsageForExchange(ExchangeOperator op) throws AlgebricksException {
visitInternal(op, false);
IPhysicalOperator physicalOperator = op.getPhysicalOperator();
PhysicalOperatorTag physicalOperatorTag = physicalOperator.getOperatorTag();
if (physicalOperatorTag == PhysicalOperatorTag.ONE_TO_ONE_EXCHANGE || physicalOperatorTag == PhysicalOperatorTag.SORT_MERGE_EXCHANGE) {
addOutputBuffer(op);
return;
}
stageMemorySoFar += 2L * MAX_BUFFER_PER_CONNECTION * numComputationPartitions * numComputationPartitions * frameSize;
clusterCapacity.setAggregatedMemoryByteSize(stageMemorySoFar);
}
use of org.apache.hyracks.algebricks.core.algebra.base.IPhysicalOperator in project asterixdb by apache.
the class EnforceStructuralPropertiesRule method addPartitioningEnforcers.
private void addPartitioningEnforcers(ILogicalOperator op, int i, IPartitioningProperty pp, IPhysicalPropertiesVector required, IPhysicalPropertiesVector deliveredByChild, INodeDomain domain, IOptimizationContext context) throws AlgebricksException {
if (pp != null) {
IPhysicalOperator pop;
switch(pp.getPartitioningType()) {
case UNPARTITIONED:
{
List<OrderColumn> ordCols = computeOrderColumns(deliveredByChild);
if (ordCols.isEmpty()) {
pop = new RandomMergeExchangePOperator();
} else {
if (op.getAnnotations().containsKey(OperatorAnnotations.USE_RANGE_CONNECTOR)) {
IRangeMap rangeMap = (IRangeMap) op.getAnnotations().get(OperatorAnnotations.USE_RANGE_CONNECTOR);
pop = new RangePartitionMergeExchangePOperator(ordCols, domain, rangeMap);
} else {
OrderColumn[] sortColumns = new OrderColumn[ordCols.size()];
sortColumns = ordCols.toArray(sortColumns);
pop = new SortMergeExchangePOperator(sortColumns);
}
}
break;
}
case UNORDERED_PARTITIONED:
{
List<LogicalVariable> varList = new ArrayList<>(((UnorderedPartitionedProperty) pp).getColumnSet());
String hashMergeHint = context.getMetadataProvider().getConfig().get(HASH_MERGE);
if (hashMergeHint == null || !hashMergeHint.equalsIgnoreCase(TRUE_CONSTANT)) {
pop = new HashPartitionExchangePOperator(varList, domain);
break;
}
List<ILocalStructuralProperty> cldLocals = deliveredByChild.getLocalProperties();
List<ILocalStructuralProperty> reqdLocals = required.getLocalProperties();
boolean propWasSet = false;
pop = null;
if (reqdLocals != null && cldLocals != null && allAreOrderProps(cldLocals)) {
AbstractLogicalOperator c = (AbstractLogicalOperator) op.getInputs().get(i).getValue();
Map<LogicalVariable, EquivalenceClass> ecs = context.getEquivalenceClassMap(c);
List<FunctionalDependency> fds = context.getFDList(c);
if (PropertiesUtil.matchLocalProperties(reqdLocals, cldLocals, ecs, fds)) {
List<OrderColumn> orderColumns = getOrderColumnsFromGroupingProperties(reqdLocals, cldLocals);
pop = new HashPartitionMergeExchangePOperator(orderColumns, varList, domain);
propWasSet = true;
}
}
if (!propWasSet) {
pop = new HashPartitionExchangePOperator(varList, domain);
}
break;
}
case ORDERED_PARTITIONED:
{
pop = new RangePartitionExchangePOperator(((OrderedPartitionedProperty) pp).getOrderColumns(), domain, null);
break;
}
case BROADCAST:
{
pop = new BroadcastExchangePOperator(domain);
break;
}
case RANDOM:
{
RandomPartitioningProperty rpp = (RandomPartitioningProperty) pp;
INodeDomain nd = rpp.getNodeDomain();
pop = new RandomPartitionExchangePOperator(nd);
break;
}
default:
{
throw new NotImplementedException("Enforcer for " + pp.getPartitioningType() + " partitioning type has not been implemented.");
}
}
Mutable<ILogicalOperator> ci = op.getInputs().get(i);
ExchangeOperator exchg = new ExchangeOperator();
exchg.setPhysicalOperator(pop);
setNewOp(ci, exchg, context);
exchg.setExecutionMode(AbstractLogicalOperator.ExecutionMode.PARTITIONED);
OperatorPropertiesUtil.computeSchemaAndPropertiesRecIfNull(exchg, context);
context.computeAndSetTypeEnvironmentForOperator(exchg);
if (AlgebricksConfig.DEBUG) {
AlgebricksConfig.ALGEBRICKS_LOGGER.fine(">>>> Added partitioning enforcer " + exchg.getPhysicalOperator() + ".\n");
printOp((AbstractLogicalOperator) op);
}
}
}
use of org.apache.hyracks.algebricks.core.algebra.base.IPhysicalOperator in project asterixdb by apache.
the class IsolateHyracksOperatorsRule method testIfExchangeAbove.
private boolean testIfExchangeAbove(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException {
AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
if (op.getOperatorTag() == LogicalOperatorTag.EXCHANGE) {
return false;
}
boolean exchInserted = false;
for (Mutable<ILogicalOperator> i : op.getInputs()) {
AbstractLogicalOperator c = (AbstractLogicalOperator) i.getValue();
IPhysicalOperator cpop = c.getPhysicalOperator();
if (c.getOperatorTag() == LogicalOperatorTag.EXCHANGE || cpop == null) {
continue;
}
if (!cpop.isMicroOperator()) {
insertOneToOneExchange(i, context);
exchInserted = true;
}
}
return exchInserted;
}
use of org.apache.hyracks.algebricks.core.algebra.base.IPhysicalOperator in project asterixdb by apache.
the class IsolateHyracksOperatorsRule method testIfExchangeBelow.
private boolean testIfExchangeBelow(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException {
AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
boolean exchInserted = false;
for (Mutable<ILogicalOperator> i : op.getInputs()) {
AbstractLogicalOperator c = (AbstractLogicalOperator) i.getValue();
if (c.getOperatorTag() != LogicalOperatorTag.EXCHANGE) {
if (c.getPhysicalOperator() == null) {
return false;
}
insertOneToOneExchange(i, context);
exchInserted = true;
}
}
IPhysicalOperator pt = op.getPhysicalOperator();
if (pt.isJobGenDisabledBelowMe() || arrayContains(operatorsBelowWhichJobGenIsDisabled, pt.getOperatorTag())) {
for (Mutable<ILogicalOperator> i : op.getInputs()) {
disableJobGenRec(i.getValue());
}
}
return exchInserted;
}
Aggregations