PageRenderTime 38ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/release-0.0.0-rc0/hive/external/ql/src/java/org/apache/hadoop/hive/ql/optimizer/GenMRRedSink2.java

#
Java | 84 lines | 45 code | 11 blank | 28 comment | 3 complexity | 2c0d9df9a0a0e83715075aa065716eaa MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, JSON, CPL-1.0
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. package org.apache.hadoop.hive.ql.optimizer;
  19. import java.io.Serializable;
  20. import java.util.Map;
  21. import java.util.Stack;
  22. import org.apache.hadoop.hive.ql.exec.Operator;
  23. import org.apache.hadoop.hive.ql.exec.ReduceSinkOperator;
  24. import org.apache.hadoop.hive.ql.exec.Task;
  25. import org.apache.hadoop.hive.ql.lib.Node;
  26. import org.apache.hadoop.hive.ql.lib.NodeProcessor;
  27. import org.apache.hadoop.hive.ql.lib.NodeProcessorCtx;
  28. import org.apache.hadoop.hive.ql.optimizer.GenMRProcContext.GenMapRedCtx;
  29. import org.apache.hadoop.hive.ql.parse.SemanticException;
  30. /**
  31. * Processor for the rule - reduce sink followed by reduce sink.
  32. */
  33. public class GenMRRedSink2 implements NodeProcessor {
  34. public GenMRRedSink2() {
  35. }
  36. /**
  37. * Reduce Scan encountered.
  38. *
  39. * @param nd
  40. * the reduce sink operator encountered
  41. * @param opProcCtx
  42. * context
  43. */
  44. public Object process(Node nd, Stack<Node> stack, NodeProcessorCtx opProcCtx,
  45. Object... nodeOutputs) throws SemanticException {
  46. ReduceSinkOperator op = (ReduceSinkOperator) nd;
  47. GenMRProcContext ctx = (GenMRProcContext) opProcCtx;
  48. Map<Operator<? extends Serializable>, GenMapRedCtx> mapCurrCtx = ctx
  49. .getMapCurrCtx();
  50. GenMapRedCtx mapredCtx = mapCurrCtx.get(op.getParentOperators().get(0));
  51. Task<? extends Serializable> currTask = mapredCtx.getCurrTask();
  52. Operator<? extends Serializable> currTopOp = mapredCtx.getCurrTopOp();
  53. String currAliasId = mapredCtx.getCurrAliasId();
  54. Operator<? extends Serializable> reducer = op.getChildOperators().get(0);
  55. Map<Operator<? extends Serializable>, Task<? extends Serializable>> opTaskMap = ctx
  56. .getOpTaskMap();
  57. Task<? extends Serializable> opMapTask = opTaskMap.get(reducer);
  58. ctx.setCurrTopOp(currTopOp);
  59. ctx.setCurrAliasId(currAliasId);
  60. ctx.setCurrTask(currTask);
  61. if (opMapTask == null) {
  62. GenMapRedUtils.splitPlan(op, ctx);
  63. } else {
  64. GenMapRedUtils.joinPlan(op, currTask, opMapTask, ctx, -1, true, false,
  65. false);
  66. currTask = opMapTask;
  67. ctx.setCurrTask(currTask);
  68. }
  69. mapCurrCtx.put(op, new GenMapRedCtx(ctx.getCurrTask(), ctx.getCurrTopOp(),
  70. ctx.getCurrAliasId()));
  71. return null;
  72. }
  73. }