Modified: 
incubator/pig/branches/types/test/org/apache/pig/test/utils/GenPhyOp.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/utils/GenPhyOp.java?rev=644076&r1=644075&r2=644076&view=diff
==============================================================================
--- incubator/pig/branches/types/test/org/apache/pig/test/utils/GenPhyOp.java 
(original)
+++ incubator/pig/branches/types/test/org/apache/pig/test/utils/GenPhyOp.java 
Wed Apr  2 14:23:36 2008
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
 package org.apache.pig.test.utils;
 
 import java.io.IOException;
@@ -24,111 +41,111 @@
 //import 
org.apache.pig.impl.physicalLayer.topLevelOperators.expressionOperators.binaryExprOps.comparators.NotEqualToExpr;
 
 public class GenPhyOp {
-       static Random r = new Random();
-       public static ConstantExpression exprConst(){
-               ConstantExpression ret = new ConstantExpression(new 
OperatorKey("",r.nextLong()));
-               return ret;
-       }
+    static Random r = new Random();
+    public static ConstantExpression exprConst(){
+        ConstantExpression ret = new ConstantExpression(new 
OperatorKey("",r.nextLong()));
+        return ret;
+    }
 
-       public static GreaterThanExpr compGreaterThanExpr(){
-               GreaterThanExpr ret = new GreaterThanExpr(new 
OperatorKey("",r.nextLong()));
-               return ret;
-       }
-       
-       public static POProject exprProject(){
-               POProject ret = new POProject(new OperatorKey("",r.nextLong()));
-               return ret;
-       }
-//     
-//     public static GTOrEqualToExpr compGTOrEqualToExpr(){
-//             GTOrEqualToExpr ret = new GTOrEqualToExpr(new 
OperatorKey("",r.nextLong()));
-//             return ret;
-//     }
-//     
-//     public static EqualToExpr compEqualToExpr(){
-//             EqualToExpr ret = new EqualToExpr(new 
OperatorKey("",r.nextLong()));
-//             return ret;
-//     }
-//     
-//     public static NotEqualToExpr compNotEqualToExpr(){
-//             NotEqualToExpr ret = new NotEqualToExpr(new 
OperatorKey("",r.nextLong()));
-//             return ret;
-//     }
-//     
-//     public static LessThanExpr compLessThanExpr(){
-//             LessThanExpr ret = new LessThanExpr(new 
OperatorKey("",r.nextLong()));
-//             return ret;
-//     }
-//     
-//     public static LTOrEqualToExpr compLTOrEqualToExpr(){
-//             LTOrEqualToExpr ret = new LTOrEqualToExpr(new 
OperatorKey("",r.nextLong()));
-//             return ret;
-//     }
-//     
-//     public static POLocalRearrange topLocalRearrangeOp(){
-//             POLocalRearrange ret = new POLocalRearrange(new 
OperatorKey("",r.nextLong()));
-//             return ret;
-//     }
-//     
-//     public static POGenerate topGenerateOp(){
-//             POGenerate ret = new POGenerate(new 
OperatorKey("",r.nextLong()));
-//             return ret;
-//     }
-//     
-//     public static POLoad topLoadOp(){
-//             POLoad ret = new POLoad(new OperatorKey("",r.nextLong()));
-//             return ret;
-//     }
-//     
-       public static POFilter topFilterOp(){
-               POFilter ret = new POFilter(new OperatorKey("",r.nextLong()));
-               return ret;
-       }
-       
-       public static POFilter topFilterOpWithExPlan(int lhsVal, int rhsVal) 
throws IOException{
-               POFilter ret = new POFilter(new OperatorKey("",r.nextLong()));
-               
-               ConstantExpression ce1 = GenPhyOp.exprConst();
-               ce1.setValue(lhsVal);
-               
-               ConstantExpression ce2 = GenPhyOp.exprConst();
-               ce2.setValue(rhsVal);
-               
-               GreaterThanExpr gr = GenPhyOp.compGreaterThanExpr();
-               gr.setLhs(ce1);
-               gr.setRhs(ce2);
-               gr.setOperandType(DataType.INTEGER);
-               
-               ExprPlan ep = new ExprPlan();
-               ep.add(ce1);
-               ep.add(ce2);
-               ep.add(gr);
-               
-               ep.connect(ce1, gr);
-               ep.connect(ce2, gr);
-               
-               ret.setPlan(ep);
-               
-               return ret;
-       }
-//     
-//     public static POGlobalRearrange topGlobalRearrangeOp(){
-//             POGlobalRearrange ret = new POGlobalRearrange(new 
OperatorKey("",r.nextLong()));
-//             return ret;
-//     }
-//     
-//     public static POPackage topPackageOp(){
-//             POPackage ret = new POPackage(new OperatorKey("",r.nextLong()));
-//             return ret;
-//     }
-//     
-//     public static POStore topStoreOp(){
-//             POStore ret = new POStore(new OperatorKey("",r.nextLong()));
-//             return ret;
-//     }
-//     
-//     public static StartMap topStartMapOp(){
-//             StartMap ret = new StartMap(new OperatorKey("",r.nextLong()));
-//             return ret;
-//     }
+    public static GreaterThanExpr compGreaterThanExpr(){
+        GreaterThanExpr ret = new GreaterThanExpr(new 
OperatorKey("",r.nextLong()));
+        return ret;
+    }
+    
+    public static POProject exprProject(){
+        POProject ret = new POProject(new OperatorKey("",r.nextLong()));
+        return ret;
+    }
+//    
+//    public static GTOrEqualToExpr compGTOrEqualToExpr(){
+//        GTOrEqualToExpr ret = new GTOrEqualToExpr(new 
OperatorKey("",r.nextLong()));
+//        return ret;
+//    }
+//    
+//    public static EqualToExpr compEqualToExpr(){
+//        EqualToExpr ret = new EqualToExpr(new OperatorKey("",r.nextLong()));
+//        return ret;
+//    }
+//    
+//    public static NotEqualToExpr compNotEqualToExpr(){
+//        NotEqualToExpr ret = new NotEqualToExpr(new 
OperatorKey("",r.nextLong()));
+//        return ret;
+//    }
+//    
+//    public static LessThanExpr compLessThanExpr(){
+//        LessThanExpr ret = new LessThanExpr(new 
OperatorKey("",r.nextLong()));
+//        return ret;
+//    }
+//    
+//    public static LTOrEqualToExpr compLTOrEqualToExpr(){
+//        LTOrEqualToExpr ret = new LTOrEqualToExpr(new 
OperatorKey("",r.nextLong()));
+//        return ret;
+//    }
+//    
+//    public static POLocalRearrange topLocalRearrangeOp(){
+//        POLocalRearrange ret = new POLocalRearrange(new 
OperatorKey("",r.nextLong()));
+//        return ret;
+//    }
+//    
+//    public static POGenerate topGenerateOp(){
+//        POGenerate ret = new POGenerate(new OperatorKey("",r.nextLong()));
+//        return ret;
+//    }
+//    
+//    public static POLoad topLoadOp(){
+//        POLoad ret = new POLoad(new OperatorKey("",r.nextLong()));
+//        return ret;
+//    }
+//    
+    public static POFilter topFilterOp(){
+        POFilter ret = new POFilter(new OperatorKey("",r.nextLong()));
+        return ret;
+    }
+    
+    public static POFilter topFilterOpWithExPlan(int lhsVal, int rhsVal) 
throws IOException{
+        POFilter ret = new POFilter(new OperatorKey("",r.nextLong()));
+        
+        ConstantExpression ce1 = GenPhyOp.exprConst();
+        ce1.setValue(lhsVal);
+        
+        ConstantExpression ce2 = GenPhyOp.exprConst();
+        ce2.setValue(rhsVal);
+        
+        GreaterThanExpr gr = GenPhyOp.compGreaterThanExpr();
+        gr.setLhs(ce1);
+        gr.setRhs(ce2);
+        gr.setOperandType(DataType.INTEGER);
+        
+        ExprPlan ep = new ExprPlan();
+        ep.add(ce1);
+        ep.add(ce2);
+        ep.add(gr);
+        
+        ep.connect(ce1, gr);
+        ep.connect(ce2, gr);
+        
+        ret.setPlan(ep);
+        
+        return ret;
+    }
+//    
+//    public static POGlobalRearrange topGlobalRearrangeOp(){
+//        POGlobalRearrange ret = new POGlobalRearrange(new 
OperatorKey("",r.nextLong()));
+//        return ret;
+//    }
+//    
+//    public static POPackage topPackageOp(){
+//        POPackage ret = new POPackage(new OperatorKey("",r.nextLong()));
+//        return ret;
+//    }
+//    
+//    public static POStore topStoreOp(){
+//        POStore ret = new POStore(new OperatorKey("",r.nextLong()));
+//        return ret;
+//    }
+//    
+//    public static StartMap topStartMapOp(){
+//        StartMap ret = new StartMap(new OperatorKey("",r.nextLong()));
+//        return ret;
+//    }
 }

Modified: 
incubator/pig/branches/types/test/org/apache/pig/test/utils/GenRandomData.java
URL: 
http://svn.apache.org/viewvc/incubator/pig/branches/types/test/org/apache/pig/test/utils/GenRandomData.java?rev=644076&r1=644075&r2=644076&view=diff
==============================================================================
--- 
incubator/pig/branches/types/test/org/apache/pig/test/utils/GenRandomData.java 
(original)
+++ 
incubator/pig/branches/types/test/org/apache/pig/test/utils/GenRandomData.java 
Wed Apr  2 14:23:36 2008
@@ -1,3 +1,20 @@
+/*
+ * 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.
+ */
 package org.apache.pig.test.utils;
 
 import java.util.HashMap;
@@ -11,101 +28,101 @@
 import org.apache.pig.data.Tuple;
 
 public class GenRandomData {
-       
-       
-       public static Map<Integer,String> genRandMap(Random r, int numEnt) {
-               Map<Integer,String> ret = new HashMap<Integer, String>();
-               if(r==null){
-                       ret.put(1, "RANDOM");
-                       return ret;
-               }
-               for(int i=0;i<numEnt;i++){
-                       ret.put(r.nextInt(), genRandString(r));
-               }
-               return ret;
-       }
-       
-       public static String genRandString(Random r){
-               if(r==null) return "RANDOM";
-               char[] chars = new char[10];
-               for(int i=0;i<10;i++){
-                       chars[i] = (char)(r.nextInt(26)+65);
-               }
-               return new String(chars);
-       }
-       
-       public static DataByteArray genRandDBA(Random r){
-               if(r==null) return new DataByteArray("RANDOM".getBytes());
-               byte[] bytes = new byte[10];
-               r.nextBytes(bytes);
-               return new DataByteArray(bytes);
-       }
-       
-       public static Tuple genRandSmallTuple(Random r, int limit){
-               if(r==null){
-                       Tuple t = new DefaultTuple();
-                       t.append("RANDOM");
-                       return t;
-               }
-               Tuple t = new DefaultTuple();
-               t.append(genRandString(r));
-               t.append(r.nextInt(limit));
-               return t;
-       }
-       
-       public static Tuple genRandSmallTuple(String s, int value){
-               Tuple t = new DefaultTuple();
-               t.append(s);
-               t.append(value);
-               return t;
-       }
-       
-       public static DataBag genRandSmallTupDataBag(Random r, int num, int 
limit){
-               if(r==null) {
-                       DataBag db = 
DefaultBagFactory.getInstance().newDefaultBag();
-                       Tuple t = new DefaultTuple();
-                       t.append("RANDOM");
-                       db.add(t);
-                       return db;
-               }
-               DataBag db = DefaultBagFactory.getInstance().newDefaultBag();
-               for(int i=0;i<num;i++){
-                       db.add(genRandSmallTuple(r, limit));
-               }
-               return db;
-       }
-       
-       public static Tuple genRandSmallBagTuple(Random r, int num, int limit){
-               if(r==null){
-                       Tuple t = new DefaultTuple();
-                       t.append("RANDOM");
-                       return t;
-               }
-               Tuple t = new DefaultTuple();
-               t.append(genRandSmallTupDataBag(r, num, limit));
-               t.append(r.nextBoolean());
-               t.append(genRandDBA(r));
-               t.append(genRandString(r));
-               t.append(r.nextDouble());
-               t.append(r.nextFloat());
-               t.append(r.nextInt());
-               t.append(r.nextLong());
-               t.append(genRandMap(r, num));
-               return t;
-       }
-       
-       public static DataBag genRandFullTupDataBag(Random r, int num, int 
limit){
-               if(r==null) {
-                       DataBag db = 
DefaultBagFactory.getInstance().newDefaultBag();
-                       Tuple t = new DefaultTuple();
-                       t.append("RANDOM");
-                       db.add(t);
-                       return db;
-               }
-               DataBag db = DefaultBagFactory.getInstance().newDefaultBag();
-               for(int i=0;i<num;i++){
-                       db.add(genRandSmallBagTuple(r, num, limit));
-               }
-               return db;
-       }
+    
+    
+    public static Map<Integer,String> genRandMap(Random r, int numEnt) {
+        Map<Integer,String> ret = new HashMap<Integer, String>();
+        if(r==null){
+            ret.put(1, "RANDOM");
+            return ret;
+        }
+        for(int i=0;i<numEnt;i++){
+            ret.put(r.nextInt(), genRandString(r));
+        }
+        return ret;
+    }
+    
+    public static String genRandString(Random r){
+        if(r==null) return "RANDOM";
+        char[] chars = new char[10];
+        for(int i=0;i<10;i++){
+            chars[i] = (char)(r.nextInt(26)+65);
+        }
+        return new String(chars);
+    }
+    
+    public static DataByteArray genRandDBA(Random r){
+        if(r==null) return new DataByteArray("RANDOM".getBytes());
+        byte[] bytes = new byte[10];
+        r.nextBytes(bytes);
+        return new DataByteArray(bytes);
+    }
+    
+    public static Tuple genRandSmallTuple(Random r, int limit){
+        if(r==null){
+            Tuple t = new DefaultTuple();
+            t.append("RANDOM");
+            return t;
+        }
+        Tuple t = new DefaultTuple();
+        t.append(genRandString(r));
+        t.append(r.nextInt(limit));
+        return t;
+    }
+    
+    public static Tuple genRandSmallTuple(String s, int value){
+        Tuple t = new DefaultTuple();
+        t.append(s);
+        t.append(value);
+        return t;
+    }
+    
+    public static DataBag genRandSmallTupDataBag(Random r, int num, int limit){
+        if(r==null) {
+            DataBag db = DefaultBagFactory.getInstance().newDefaultBag();
+            Tuple t = new DefaultTuple();
+            t.append("RANDOM");
+            db.add(t);
+            return db;
+        }
+        DataBag db = DefaultBagFactory.getInstance().newDefaultBag();
+        for(int i=0;i<num;i++){
+            db.add(genRandSmallTuple(r, limit));
+        }
+        return db;
+    }
+    
+    public static Tuple genRandSmallBagTuple(Random r, int num, int limit){
+        if(r==null){
+            Tuple t = new DefaultTuple();
+            t.append("RANDOM");
+            return t;
+        }
+        Tuple t = new DefaultTuple();
+        t.append(genRandSmallTupDataBag(r, num, limit));
+        t.append(r.nextBoolean());
+        t.append(genRandDBA(r));
+        t.append(genRandString(r));
+        t.append(r.nextDouble());
+        t.append(r.nextFloat());
+        t.append(r.nextInt());
+        t.append(r.nextLong());
+        t.append(genRandMap(r, num));
+        return t;
+    }
+    
+    public static DataBag genRandFullTupDataBag(Random r, int num, int limit){
+        if(r==null) {
+            DataBag db = DefaultBagFactory.getInstance().newDefaultBag();
+            Tuple t = new DefaultTuple();
+            t.append("RANDOM");
+            db.add(t);
+            return db;
+        }
+        DataBag db = DefaultBagFactory.getInstance().newDefaultBag();
+        for(int i=0;i<num;i++){
+            db.add(genRandSmallBagTuple(r, num, limit));
+        }
+        return db;
+    }
 }


Reply via email to