use of org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements in project asterixdb by apache.
the class BTreeSearchPOperator method getRequiredPropertiesForChildren.
@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
if (requiresBroadcast) {
// For primary indexes optimizing an equality condition we can reduce the broadcast requirement to hash partitioning.
if (isPrimaryIndex && isEqCondition) {
// If this is a composite primary index, then all of the keys should be provided.
Index searchIndex = ((DataSourceIndex) idx).getIndex();
int numberOfKeyFields = searchIndex.getKeyFieldNames().size();
if (numberOfKeyFields < 2 || (lowKeyVarList.size() == numberOfKeyFields && highKeyVarList.size() == numberOfKeyFields)) {
StructuralPropertiesVector[] pv = new StructuralPropertiesVector[1];
ListSet<LogicalVariable> searchKeyVars = new ListSet<>();
searchKeyVars.addAll(lowKeyVarList);
searchKeyVars.addAll(highKeyVarList);
// Also, add a local sorting property to enforce a sort before the primary-index operator.
List<ILocalStructuralProperty> propsLocal = new ArrayList<>();
List<OrderColumn> orderColumns = new ArrayList<>();
for (LogicalVariable orderVar : searchKeyVars) {
orderColumns.add(new OrderColumn(orderVar, OrderKind.ASC));
}
propsLocal.add(new LocalOrderProperty(orderColumns));
pv[0] = new StructuralPropertiesVector(new UnorderedPartitionedProperty(searchKeyVars, domain), propsLocal);
return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION);
}
}
StructuralPropertiesVector[] pv = new StructuralPropertiesVector[1];
pv[0] = new StructuralPropertiesVector(new BroadcastPartitioningProperty(domain), null);
return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION);
} else {
return super.getRequiredPropertiesForChildren(op, reqdByParent, context);
}
}
use of org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements in project asterixdb by apache.
the class HashPartitionMergeExchangePOperator method getRequiredPropertiesForChildren.
@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
List<ILocalStructuralProperty> orderProps = new LinkedList<ILocalStructuralProperty>();
List<OrderColumn> columns = new ArrayList<OrderColumn>();
for (OrderColumn oc : orderColumns) {
LogicalVariable var = oc.getColumn();
columns.add(new OrderColumn(var, oc.getOrder()));
}
orderProps.add(new LocalOrderProperty(columns));
StructuralPropertiesVector[] r = new StructuralPropertiesVector[] { new StructuralPropertiesVector(null, orderProps) };
return new PhysicalRequirements(r, IPartitioningRequirementsCoordinator.NO_COORDINATION);
}
use of org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements in project asterixdb by apache.
the class IndexBulkloadPOperator method getRequiredPropertiesForChildren.
@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
//skVarMap is used to remove duplicated variable references for order operator
Map<Integer, Object> skVarMap = new HashMap<Integer, Object>();
List<LogicalVariable> scanVariables = new ArrayList<>();
scanVariables.addAll(primaryKeys);
scanVariables.add(new LogicalVariable(-1));
IPhysicalPropertiesVector physicalProps = dataSourceIndex.getDataSource().getPropertiesProvider().computePropertiesVector(scanVariables);
List<ILocalStructuralProperty> localProperties = new ArrayList<>();
List<OrderColumn> orderColumns = new ArrayList<OrderColumn>();
// OR [token, PK] if the index is not partitioned
for (LogicalVariable skVar : secondaryKeys) {
if (!skVarMap.containsKey(skVar.getId())) {
orderColumns.add(new OrderColumn(skVar, OrderKind.ASC));
skVarMap.put(skVar.getId(), null);
}
}
for (LogicalVariable pkVar : primaryKeys) {
orderColumns.add(new OrderColumn(pkVar, OrderKind.ASC));
}
localProperties.add(new LocalOrderProperty(orderColumns));
StructuralPropertiesVector spv = new StructuralPropertiesVector(physicalProps.getPartitioningProperty(), localProperties);
return new PhysicalRequirements(new IPhysicalPropertiesVector[] { spv }, IPartitioningRequirementsCoordinator.NO_COORDINATION);
}
use of org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements in project asterixdb by apache.
the class IndexInsertDeleteUpsertPOperator method getRequiredPropertiesForChildren.
@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator op, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
List<LogicalVariable> scanVariables = new ArrayList<LogicalVariable>();
scanVariables.addAll(primaryKeys);
scanVariables.add(new LogicalVariable(-1));
for (int i = 0; i < numOfAdditionalNonFilteringFields; i++) {
scanVariables.add(new LogicalVariable(-1));
}
IPhysicalPropertiesVector r = dataSourceIndex.getDataSource().getPropertiesProvider().computePropertiesVector(scanVariables);
r.getLocalProperties().clear();
IPhysicalPropertiesVector[] requirements = new IPhysicalPropertiesVector[1];
requirements[0] = r;
return new PhysicalRequirements(requirements, IPartitioningRequirementsCoordinator.NO_COORDINATION);
}
Aggregations