2 * Copyright (c) 2007 Yahoo! Inc. All rights reserved.
3 * See accompanying LICENSE file.
5 package com
.yahoo
.pig
.impl
.logicalLayer
;
7 import java
.util
.LinkedList
;
10 import com
.yahoo
.pig
.impl
.PigContext
;
13 public class LogicalPlan
{
16 PigContext pigContext
;
18 public LogicalPlan(LogicalOperator rootIn
, PigContext pigContext
) {
19 this.pigContext
= pigContext
;
24 public LogicalOperator
root() {
28 public void setRoot(LogicalOperator newRoot
) {
32 public PigContext
getPigContext() {
36 public List
<String
> getFuncs() {
37 if (root
== null) return new LinkedList
<String
>();
38 else return root
.getFuncs();
41 // indentation for root is 0
42 public String
toString() {
43 StringBuffer sb
= new StringBuffer();
44 sb
.append(root
.name() +"(" + root
.arguments() +")\n");
45 sb
.append(appendChildren(root
, 1));
48 public String
appendChildren(LogicalOperator parent
, int indentation
) {
49 StringBuffer sb
= new StringBuffer();
50 LogicalOperator
[] children
= parent
.children();
51 for(int i
=0; i
!= children
.length
; i
++) {
52 for(int j
=0; j
!= indentation
; j
++) {
55 sb
.append(children
[i
].name() + "(" + children
[i
].arguments()+ ")\n");
56 sb
.append(appendChildren(children
[i
], indentation
+1));
61 public int getOutputType(){
62 return root
.getOutputType();