| #------------------------------------------------------------- |
| # |
| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| # |
| #------------------------------------------------------------- |
| |
| |
| source("./scripts/staging/pipelines/utils.dml") as utils; |
| |
| |
| # The below functions will generate the all possible |
| # physical pipelines for a given logical pipeline |
| ################################################### |
| |
| getPermutations = function(Frame[String] opt) |
| return(Frame[String] output) |
| { |
| idx = seq(1, ncol(opt)) |
| # get the indexes of columns for recode transformation |
| index = utils::vectorToCsv(idx) |
| # recode logical pipelines for easy handling |
| jspecR = "{ids:true, recode:["+index+"]}"; |
| [X, M] = transformencode(target=opt, spec=jspecR); |
| # initialize output matrix |
| n = nrow(opt) |
| d = ncol(opt) |
| outC = matrix(0, n^d, d) |
| |
| parfor(i in 1 : d) { |
| # matrix for storing rows of ith columns |
| outR = matrix(0, 0, 1) |
| j = n^i |
| rowIdx = 1 |
| for(k in 1:j) { |
| valDup = matrix(as.scalar(X[rowIdx, i]), n^(d-i), 1) |
| outR = rbind(outR, valDup) |
| rowIdx = rowIdx + 1 |
| rowIdx = ifelse(((rowIdx)%%(n+1)) == 0, 1, rowIdx) |
| } |
| outC[,i] = outR |
| } |
| output = transformdecode(target=outC, spec=jspecR, meta=M); |
| } |