PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/release-0.1-rc2/hive/external/ql/src/java/org/apache/hadoop/hive/ql/parse/GenMapRedWalker.java

#
Java | 73 lines | 27 code | 10 blank | 36 comment | 5 complexity | 59085630b9926a4545ce4f1201d9448a 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.parse;
  19. import java.util.List;
  20. import org.apache.hadoop.hive.ql.exec.ReduceSinkOperator;
  21. import org.apache.hadoop.hive.ql.lib.DefaultGraphWalker;
  22. import org.apache.hadoop.hive.ql.lib.Dispatcher;
  23. import org.apache.hadoop.hive.ql.lib.Node;
  24. /**
  25. * Walks the operator tree in pre order fashion.
  26. */
  27. public class GenMapRedWalker extends DefaultGraphWalker {
  28. /**
  29. * constructor of the walker - the dispatcher is passed.
  30. *
  31. * @param disp
  32. * the dispatcher to be called for each node visited
  33. */
  34. public GenMapRedWalker(Dispatcher disp) {
  35. super(disp);
  36. }
  37. /**
  38. * Walk the given operator.
  39. *
  40. * @param nd
  41. * operator being walked
  42. */
  43. @Override
  44. public void walk(Node nd) throws SemanticException {
  45. List<? extends Node> children = nd.getChildren();
  46. // maintain the stack of operators encountered
  47. opStack.push(nd);
  48. dispatch(nd, opStack);
  49. // kids of reduce sink operator need not be traversed again
  50. if ((children == null)
  51. || ((nd instanceof ReduceSinkOperator) && (getDispatchedList()
  52. .containsAll(children)))) {
  53. opStack.pop();
  54. return;
  55. }
  56. // move all the children to the front of queue
  57. for (Node ch : children) {
  58. walk(ch);
  59. }
  60. // done with this operator
  61. opStack.pop();
  62. }
  63. }