@Override public Boolean visitInsertDeleteUpsertOperator(InsertDeleteUpsertOperator op, ILogicalOperator arg) throws AlgebricksException { AbstractLogicalOperator aop = (AbstractLogicalOperator) arg; if (aop.getOperatorTag() != LogicalOperatorTag.INSERT_DELETE_UPSERT) { return Boolean.FALSE; } InsertDeleteUpsertOperator insertOpArg = (InsertDeleteUpsertOperator) copyAndSubstituteVar(op, arg); boolean isomorphic = VariableUtilities.varListEqualUnordered(op.getSchema(), insertOpArg.getSchema()); if (!op.getDataSource().equals(insertOpArg.getDataSource())) { isomorphic = false; } if (!op.getPayloadExpression().equals(insertOpArg.getPayloadExpression())) { isomorphic = false; } return isomorphic; }
@Override public String visitInsertDeleteUpsertOperator(InsertDeleteUpsertOperator op, Boolean showDetails) { stringBuilder.setLength(0); String header = getIndexOpString(op.getOperation()); stringBuilder.append(header).append(str(op.getDataSource())).append(" from record: ") .append(op.getPayloadExpression().getValue().toString()); if (op.getAdditionalNonFilteringExpressions() != null) { stringBuilder.append(", meta: "); printExprList(op.getAdditionalNonFilteringExpressions()); } stringBuilder.append(" partitioned by "); printExprList(op.getPrimaryKeyExpressions()); if (op.getOperation() == Kind.UPSERT) { stringBuilder.append(" out: ([record-before-upsert:").append(op.getBeforeOpRecordVar()); if (op.getBeforeOpAdditionalNonFilteringVars() != null) { stringBuilder.append(", additional-before-upsert: ").append(op.getBeforeOpAdditionalNonFilteringVars()); } stringBuilder.append("]) "); } if (op.isBulkload()) { stringBuilder.append(" [bulkload]"); } appendSchema(op, showDetails); appendAnnotations(op, showDetails); appendPhysicalOperatorInfo(op, showDetails); return stringBuilder.toString(); }
@Override public ILogicalOperator visitInsertDeleteUpsertOperator(InsertDeleteUpsertOperator op, Void arg) throws AlgebricksException { List<Mutable<ILogicalExpression>> newKeyExpressions = new ArrayList<>(); deepCopyExpressionRefs(newKeyExpressions, op.getPrimaryKeyExpressions()); List<Mutable<ILogicalExpression>> newLSMComponentFilterExpressions = new ArrayList<>(); deepCopyExpressionRefs(newKeyExpressions, op.getAdditionalFilteringExpressions()); InsertDeleteUpsertOperator insertDeleteOp = new InsertDeleteUpsertOperator(op.getDataSource(), deepCopyExpressionRef(op.getPayloadExpression()), newKeyExpressions, op.getOperation(), op.isBulkload()); insertDeleteOp.setAdditionalFilteringExpressions(newLSMComponentFilterExpressions); return insertDeleteOp; }
@Override public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException { AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue(); if (op.getOperatorTag() != LogicalOperatorTag.INSERT_DELETE_UPSERT) { return false; } InsertDeleteUpsertOperator insertOp = (InsertDeleteUpsertOperator) op; boolean sameDataset = checkIfInsertAndScanDatasetsSame(op, ((DatasetDataSource) insertOp.getDataSource()).getDataset().getDatasetName()); if (sameDataset) { MaterializeOperator materializeOperator = new MaterializeOperator(); materializeOperator.setSourceLocation(op.getSourceLocation()); MaterializePOperator materializePOperator = new MaterializePOperator(true); materializeOperator.setPhysicalOperator(materializePOperator); materializeOperator.getInputs() .add(new MutableObject<ILogicalOperator>(insertOp.getInputs().get(0).getValue())); context.computeAndSetTypeEnvironmentForOperator(materializeOperator); insertOp.getInputs().clear(); insertOp.getInputs().add(new MutableObject<ILogicalOperator>(materializeOperator)); context.computeAndSetTypeEnvironmentForOperator(insertOp); return true; } else { return false; } }
DataSource dataSource = (DataSource) insertDeleteOperator.getDataSource(); IAType requiredRecordType = dataSource.getItemType();
DataSource dataSource = (DataSource) insertDeleteOperator.getDataSource(); requiredRecordType = (ARecordType) dataSource.getItemType();
if (!insertDeleteUpsertOperator.isBulkload()) { primaryKeyExprs = insertDeleteUpsertOperator.getPrimaryKeyExpressions(); dataset = ((DatasetDataSource) insertDeleteUpsertOperator.getDataSource()).getDataset(); break;
DatasetDataSource dds = (DatasetDataSource) insertOp.getDataSource(); boolean autogenerated = ((InternalDatasetDetails) dds.getDataset().getDatasetDetails()).isAutogenerated(); if (!autogenerated) { if (((DataSource) insertOp.getDataSource()).getDatasourceType() != Type.INTERNAL_DATASET) { return false;
String header = "\"operator\": \"" + getIndexOpString(op.getOperation()) + "\",\n"; addIndent(indent).append(header); addIndent(indent).append(str("\"data-source\": \"" + op.getDataSource() + "\",\n")); addIndent(indent).append("\"from-record\": \"") .append(op.getPayloadExpression().getValue().accept(exprVisitor, indent) + "\"");
@Override public Void visitInsertDeleteUpsertOperator(InsertDeleteUpsertOperator op, Integer indent) throws AlgebricksException { String header = getIndexOpString(op.getOperation()); addIndent(indent).append(header).append(str(op.getDataSource())).append(" from record: ") .append(op.getPayloadExpression().getValue().accept(exprVisitor, indent)); if (op.getAdditionalNonFilteringExpressions() != null) { buffer.append(", meta: "); pprintExprList(op.getAdditionalNonFilteringExpressions(), indent); } buffer.append(" partitioned by "); pprintExprList(op.getPrimaryKeyExpressions(), indent); if (op.getOperation() == Kind.UPSERT) { buffer.append(" out: ([record-before-upsert:" + op.getBeforeOpRecordVar() + ((op.getBeforeOpAdditionalNonFilteringVars() != null) ? (", additional-before-upsert: " + op.getBeforeOpAdditionalNonFilteringVars()) : "") + "]) "); } if (op.isBulkload()) { buffer.append(" [bulkload]"); } return null; }
DataSource datasetSource = (DataSource) primaryIndexModificationOp.getDataSource(); MetadataProvider mp = (MetadataProvider) context.getMetadataProvider(); String dataverseName = datasetSource.getId().getDataverseName();
additionalNonFilterVariables, opLoad.getDataSource())); } else { op.setPhysicalOperator(new InsertDeleteUpsertPOperator(payload, keys, additionalFilteringKeys, opLoad.getDataSource(), opLoad.getOperation(), additionalNonFilterVariables));