You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ch...@apache.org on 2013/09/27 05:36:39 UTC
svn commit: r1526784 - in /pig/trunk: ./ src/org/apache/pig/
src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/
src/org/apache/pig/backend/hadoop/hbase/ src/org/apache/pig/builtin/
src/org/apache/pig/impl/util/ test/or...
Author: cheolsoo
Date: Fri Sep 27 03:36:39 2013
New Revision: 1526784
URL: http://svn.apache.org/r1526784
Log:
PIG-3485: Remove CastUtils.bytesToMap(byte[] b) method from LoadCaster interface (cheolsoo)
Modified:
pig/trunk/CHANGES.txt
pig/trunk/src/org/apache/pig/LoadCaster.java
pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POCast.java
pig/trunk/src/org/apache/pig/backend/hadoop/hbase/HBaseBinaryConverter.java
pig/trunk/src/org/apache/pig/builtin/BinStorage.java
pig/trunk/src/org/apache/pig/builtin/TextLoader.java
pig/trunk/src/org/apache/pig/builtin/Utf8StorageConverter.java
pig/trunk/src/org/apache/pig/impl/util/CastUtils.java
pig/trunk/test/org/apache/pig/test/TestConversions.java
pig/trunk/test/org/apache/pig/test/TestPOCast.java
pig/trunk/test/org/apache/pig/test/TestStore.java
pig/trunk/test/org/apache/pig/test/TestTextDataParser.java
pig/trunk/test/org/apache/pig/test/utils/GenRandomData.java
Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1526784&r1=1526783&r2=1526784&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Fri Sep 27 03:36:39 2013
@@ -21,7 +21,9 @@ Pig Change Log
Trunk (unreleased changes)
INCOMPATIBLE CHANGES
-
+
+PIG-3485: Remove CastUtils.bytesToMap(byte[] b) method from LoadCaster interface (cheolsoo)
+
IMPROVEMENTS
PIG-3484: Make the size of pig.script property configurable (cheolsoo)
Modified: pig/trunk/src/org/apache/pig/LoadCaster.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/LoadCaster.java?rev=1526784&r1=1526783&r2=1526784&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/LoadCaster.java (original)
+++ pig/trunk/src/org/apache/pig/LoadCaster.java Fri Sep 27 03:36:39 2013
@@ -100,15 +100,6 @@ public interface LoadCaster {
/**
* Cast data from bytearray to map value.
* @param b bytearray to be cast.
- * @return Map value.
- * @throws IOException if the value cannot be cast.
- */
- @Deprecated
- public Map<String, Object> bytesToMap(byte[] b) throws IOException;
-
- /**
- * Cast data from bytearray to map value.
- * @param b bytearray to be cast.
* @param fieldSchema field schema for the output map
* @return Map value.
* @throws IOException if the value cannot be cast.
Modified: pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POCast.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POCast.java?rev=1526784&r1=1526783&r2=1526784&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POCast.java (original)
+++ pig/trunk/src/org/apache/pig/backend/hadoop/executionengine/physicalLayer/expressionOperators/POCast.java Fri Sep 27 03:36:39 2013
@@ -1384,14 +1384,7 @@ public class POCast extends ExpressionOp
result = obj;
} else if (obj instanceof DataByteArray) {
if (null != caster) {
- try {
- result = caster.bytesToMap(((DataByteArray)obj).get(), fs);
- } catch(AbstractMethodError e) {
- // this is for backward compatibility wherein some old LoadCaster
- // which does not implement bytesToMap(byte[] b, ResourceFieldSchema fieldSchema)
- // In this case, we only cast bytes to map, but leave the value as bytearray
- result = caster.bytesToMap(((DataByteArray)obj).get());
- }
+ result = caster.bytesToMap(((DataByteArray)obj).get(), fs);
} else {
int errCode = 1075;
String msg = "Received a bytearray from the UDF. Cannot determine how to convert the bytearray to tuple.";
@@ -1955,14 +1948,7 @@ public class POCast extends ExpressionOp
}
try {
if (null != caster) {
- try {
- res.result = caster.bytesToMap(dba.get(), fieldSchema);
- } catch(AbstractMethodError e) {
- // this is for backward compatibility wherein some old LoadCaster
- // which does not implement bytesToMap(byte[] b, ResourceFieldSchema fieldSchema)
- // In this case, we only cast bytes to map, but leave the value as bytearray
- res.result = caster.bytesToMap(dba.get());
- }
+ res.result = caster.bytesToMap(dba.get(), fieldSchema);
} else {
int errCode = 1075;
String msg = "Received a bytearray from the UDF. Cannot determine how to convert the bytearray to map.";
Modified: pig/trunk/src/org/apache/pig/backend/hadoop/hbase/HBaseBinaryConverter.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/backend/hadoop/hbase/HBaseBinaryConverter.java?rev=1526784&r1=1526783&r2=1526784&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/backend/hadoop/hbase/HBaseBinaryConverter.java (original)
+++ pig/trunk/src/org/apache/pig/backend/hadoop/hbase/HBaseBinaryConverter.java Fri Sep 27 03:36:39 2013
@@ -92,15 +92,8 @@ public class HBaseBinaryConverter implem
}
@Override
- public Map<String, Object> bytesToMap(byte[] b) throws IOException {
- return bytesToMap(b, null);
- }
- /**
- * NOT IMPLEMENTED
- */
- @Override
public Map<String, Object> bytesToMap(byte[] b, ResourceFieldSchema fieldSchema) throws IOException {
- throw new ExecException("Can't generate a Map from byte[]");
+ return bytesToMap(b, fieldSchema);
}
/**
Modified: pig/trunk/src/org/apache/pig/builtin/BinStorage.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/builtin/BinStorage.java?rev=1526784&r1=1526783&r2=1526784&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/builtin/BinStorage.java (original)
+++ pig/trunk/src/org/apache/pig/builtin/BinStorage.java Fri Sep 27 03:36:39 2013
@@ -118,11 +118,6 @@ implements StoreFuncInterface, LoadMetad
}
@Override
- public Map<String, Object> bytesToMap(byte[] b) throws IOException {
- return bytesToMap(b, null);
- }
-
- @Override
public Map<String, Object> bytesToMap(byte[] b, ResourceFieldSchema fieldSchema) throws IOException {
throw new ExecException(unImplementedErrorMessage, 1118);
}
Modified: pig/trunk/src/org/apache/pig/builtin/TextLoader.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/builtin/TextLoader.java?rev=1526784&r1=1526783&r2=1526784&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/builtin/TextLoader.java (original)
+++ pig/trunk/src/org/apache/pig/builtin/TextLoader.java Fri Sep 27 03:36:39 2013
@@ -147,19 +147,8 @@ public class TextLoader extends LoadFunc
}
@Override
- public Map<String, Object> bytesToMap(byte[] b) throws IOException {
- return bytesToMap(b, null);
- }
-
- /**
- * TextLoader does not support conversion to Map
- * @throws IOException if the value cannot be cast.
- */
- @Override
public Map<String, Object> bytesToMap(byte[] b, ResourceFieldSchema schema) throws IOException {
- int errCode = 2109;
- String msg = "TextLoader does not support conversion to Map.";
- throw new ExecException(msg, errCode, PigException.BUG);
+ return bytesToMap(b, schema);
}
/**
Modified: pig/trunk/src/org/apache/pig/builtin/Utf8StorageConverter.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/builtin/Utf8StorageConverter.java?rev=1526784&r1=1526783&r2=1526784&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/builtin/Utf8StorageConverter.java (original)
+++ pig/trunk/src/org/apache/pig/builtin/Utf8StorageConverter.java Fri Sep 27 03:36:39 2013
@@ -553,11 +553,6 @@ public class Utf8StorageConverter implem
}
@Override
- public Map<String, Object> bytesToMap(byte[] b) throws IOException {
- return bytesToMap(b, null);
- }
-
- @Override
public Tuple bytesToTuple(byte[] b, ResourceFieldSchema fieldSchema) throws IOException {
if(b == null)
return null;
Modified: pig/trunk/src/org/apache/pig/impl/util/CastUtils.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/impl/util/CastUtils.java?rev=1526784&r1=1526783&r2=1526784&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/impl/util/CastUtils.java (original)
+++ pig/trunk/src/org/apache/pig/impl/util/CastUtils.java Fri Sep 27 03:36:39 2013
@@ -59,7 +59,7 @@ public class CastUtils {
case (DataType.LONG): return caster.bytesToLong(bytes);
case (DataType.BOOLEAN): return caster.bytesToBoolean(bytes);
case (DataType.DATETIME): return caster.bytesToDateTime(bytes);
- case (DataType.MAP): return caster.bytesToMap(bytes);
+ case (DataType.MAP): return caster.bytesToMap(bytes, fieldSchema);
case (DataType.TUPLE): return caster.bytesToTuple(bytes, fieldSchema);
default: throw new IOException("Unknown type " + dataType);
}
Modified: pig/trunk/test/org/apache/pig/test/TestConversions.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestConversions.java?rev=1526784&r1=1526783&r2=1526784&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestConversions.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestConversions.java Fri Sep 27 03:36:39 2013
@@ -215,11 +215,12 @@ public class TestConversions {
@Test
public void testBytesToMap() throws IOException
{
+ ResourceFieldSchema fs = GenRandomData.getRandMapFieldSchema();
for (int i = 0; i < MAX; i++) {
Map<String, Object> m = GenRandomData.genRandMap(r,5);
String expectedMapString = DataType.mapToString(m);
- Map<String, Object> convertedMap = ps.getLoadCaster().bytesToMap(expectedMapString.getBytes());
+ Map<String, Object> convertedMap = ps.getLoadCaster().bytesToMap(expectedMapString.getBytes(), fs);
assertTrue(TestHelper.mapEquals(m, convertedMap));
}
@@ -365,29 +366,31 @@ public class TestConversions {
assertNull(b);
s = "[ab]";
- Map<String, Object> m = ps.getLoadCaster().bytesToMap(s.getBytes());
+ schema = Utils.getSchemaFromString("m:map[chararray]");
+ rfs = new ResourceSchema(schema).getFields()[0];
+ Map<String, Object> m = ps.getLoadCaster().bytesToMap(s.getBytes(), rfs);
assertNull(m);
s = "[a#b";
- m = ps.getLoadCaster().bytesToMap(s.getBytes());
+ m = ps.getLoadCaster().bytesToMap(s.getBytes(), rfs);
assertNull(m);
s = "[a#]";
- m = ps.getLoadCaster().bytesToMap(s.getBytes());
+ m = ps.getLoadCaster().bytesToMap(s.getBytes(), rfs);
Map.Entry<String, Object> entry = m.entrySet().iterator().next();
assertEquals("a", entry.getKey());
assertNull(entry.getValue());
s = "[#]";
- m = ps.getLoadCaster().bytesToMap(s.getBytes());
+ m = ps.getLoadCaster().bytesToMap(s.getBytes(), rfs);
assertNull(m);
s = "[a#}";
- m = ps.getLoadCaster().bytesToMap(s.getBytes());
+ m = ps.getLoadCaster().bytesToMap(s.getBytes(), rfs);
assertNull(m);
s = "[a#)";
- m = ps.getLoadCaster().bytesToMap(s.getBytes());
+ m = ps.getLoadCaster().bytesToMap(s.getBytes(), rfs);
assertNull(m);
s = "(a,b)";
@@ -401,7 +404,9 @@ public class TestConversions {
assertEquals("b", t.get(1).toString());
s = "[a#(1,2,3)]";
- m = ps.getLoadCaster().bytesToMap(s.getBytes());
+ schema = Utils.getSchemaFromString("m:map[]");
+ rfs = new ResourceSchema(schema).getFields()[0];
+ m = ps.getLoadCaster().bytesToMap(s.getBytes(), rfs);
entry = m.entrySet().iterator().next();
assertEquals("a", entry.getKey());
assertTrue(entry.getValue() instanceof DataByteArray);
Modified: pig/trunk/test/org/apache/pig/test/TestPOCast.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestPOCast.java?rev=1526784&r1=1526783&r2=1526784&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestPOCast.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestPOCast.java Fri Sep 27 03:36:39 2013
@@ -1534,11 +1534,6 @@ public class TestPOCast {
}
@Override
- public Map<String, Object> bytesToMap(byte[] b) throws IOException {
- return null;
- }
-
- @Override
public Map<String, Object> bytesToMap(byte[] b, ResourceFieldSchema s) throws IOException {
return null;
}
Modified: pig/trunk/test/org/apache/pig/test/TestStore.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestStore.java?rev=1526784&r1=1526783&r2=1526784&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestStore.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestStore.java Fri Sep 27 03:36:39 2013
@@ -251,6 +251,7 @@ public class TestStore {
String[] flds = line.split("\t",-1);
Tuple t = new DefaultTuple();
+ ResourceFieldSchema mapfs = GenRandomData.getRandMapFieldSchema();
ResourceFieldSchema bagfs = GenRandomData.getSmallTupDataBagFieldSchema();
ResourceFieldSchema tuplefs = GenRandomData.getSmallTupleFieldSchema();
@@ -261,7 +262,7 @@ public class TestStore {
t.append(flds[4].compareTo("")!=0 ? ps.getLoadCaster().bytesToFloat(flds[4].getBytes()) : null);
t.append(flds[5].compareTo("")!=0 ? ps.getLoadCaster().bytesToInteger(flds[5].getBytes()) : null);
t.append(flds[6].compareTo("")!=0 ? ps.getLoadCaster().bytesToLong(flds[6].getBytes()) : null);
- t.append(flds[7].compareTo("")!=0 ? ps.getLoadCaster().bytesToMap(flds[7].getBytes()) : null);
+ t.append(flds[7].compareTo("")!=0 ? ps.getLoadCaster().bytesToMap(flds[7].getBytes(), mapfs) : null);
t.append(flds[8].compareTo("")!=0 ? ps.getLoadCaster().bytesToTuple(flds[8].getBytes(), tuplefs) : null);
t.append(flds[9].compareTo("")!=0 ? ps.getLoadCaster().bytesToBoolean(flds[9].getBytes()) : null);
t.append(flds[10].compareTo("")!=0 ? ps.getLoadCaster().bytesToDateTime(flds[10].getBytes()) : null);
@@ -289,6 +290,8 @@ public class TestStore {
stringfs.setType(DataType.CHARARRAY);
ResourceFieldSchema intfs = new ResourceFieldSchema();
intfs.setType(DataType.INTEGER);
+ ResourceFieldSchema bytefs = new ResourceFieldSchema();
+ bytefs.setType(DataType.BYTEARRAY);
ResourceSchema tupleSchema = new ResourceSchema();
tupleSchema.setFields(new ResourceFieldSchema[]{stringfs, intfs});
@@ -302,6 +305,12 @@ public class TestStore {
bagfs.setSchema(bagSchema);
bagfs.setType(DataType.BAG);
+ ResourceSchema mapSchema = new ResourceSchema();
+ mapSchema.setFields(new ResourceFieldSchema[]{bytefs});
+ ResourceFieldSchema mapfs = new ResourceFieldSchema();
+ mapfs.setSchema(mapSchema);
+ mapfs.setType(DataType.MAP);
+
t.append(flds[0].compareTo("")!=0 ? ps.getLoadCaster().bytesToBag(flds[0].getBytes(), bagfs) : null);
t.append(flds[1].compareTo("")!=0 ? new DataByteArray(flds[1].getBytes()) : null);
t.append(flds[2].compareTo("")!=0 ? ps.getLoadCaster().bytesToCharArray(flds[2].getBytes()) : null);
@@ -309,7 +318,7 @@ public class TestStore {
t.append(flds[4].compareTo("")!=0 ? ps.getLoadCaster().bytesToFloat(flds[4].getBytes()) : null);
t.append(flds[5].compareTo("")!=0 ? ps.getLoadCaster().bytesToInteger(flds[5].getBytes()) : null);
t.append(flds[6].compareTo("")!=0 ? ps.getLoadCaster().bytesToLong(flds[6].getBytes()) : null);
- t.append(flds[7].compareTo("")!=0 ? ps.getLoadCaster().bytesToMap(flds[7].getBytes()) : null);
+ t.append(flds[7].compareTo("")!=0 ? ps.getLoadCaster().bytesToMap(flds[7].getBytes(), mapfs) : null);
t.append(flds[8].compareTo("")!=0 ? ps.getLoadCaster().bytesToTuple(flds[8].getBytes(), tuplefs) : null);
t.append(flds[9].compareTo("")!=0 ? ps.getLoadCaster().bytesToBoolean(flds[9].getBytes()) : null);
t.append(flds[10].compareTo("")!=0 ? ps.getLoadCaster().bytesToDateTime(flds[10].getBytes()) : null);
Modified: pig/trunk/test/org/apache/pig/test/TestTextDataParser.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestTextDataParser.java?rev=1526784&r1=1526783&r2=1526784&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestTextDataParser.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestTextDataParser.java Fri Sep 27 03:36:39 2013
@@ -35,6 +35,8 @@ import org.apache.pig.data.DataType;
import org.apache.pig.data.DefaultBagFactory;
import org.apache.pig.data.Tuple;
import org.apache.pig.data.TupleFactory;
+import org.apache.pig.impl.logicalLayer.schema.Schema;
+import org.apache.pig.impl.util.Utils;
import org.joda.time.DateTime;
import org.joda.time.DateTimeZone;
import org.junit.Test;
@@ -129,79 +131,73 @@ public class TestTextDataParser {
assertEquals(myString, s);
}
-
- //the value types of a map should always be a byte array
- //irrespective of the actual type
- @SuppressWarnings("unchecked")
@Test
public void testMapStringValueType() throws Exception{
String myMap = "[key1#value1]";
- Map<String, Object> map = ps.getLoadCaster().bytesToMap(myMap.getBytes());
+ Schema schema = Utils.getSchemaFromString("m:map[chararray]");
+ ResourceFieldSchema rfs = new ResourceSchema(schema).getFields()[0];
+ Map<String, Object> map = ps.getLoadCaster().bytesToMap(myMap.getBytes(), rfs);
String key = map.keySet().iterator().next();
Object v = map.get("key1");
assertEquals("key1", key);
- assertTrue(v instanceof DataByteArray);
- String value = new String(((DataByteArray)v).get());
+ assertTrue(v instanceof String);
+ String value = String.valueOf(v);
assertEquals("value1", value);
}
- //the value types of a map should always be a byte array
- //irrespective of the actual type
- @SuppressWarnings("unchecked")
@Test
public void testMapIntegerValueType() throws Exception{
String myMap = "[key1#1]";
- Map<String, Object> map = ps.getLoadCaster().bytesToMap(myMap.getBytes());
+ Schema schema = Utils.getSchemaFromString("m:map[int]");
+ ResourceFieldSchema rfs = new ResourceSchema(schema).getFields()[0];
+ Map<String, Object> map = ps.getLoadCaster().bytesToMap(myMap.getBytes(), rfs);
String key = map.keySet().iterator().next();
Object v = map.get("key1");
assertEquals("key1", key);
- assertTrue(v instanceof DataByteArray);
- String value = new String(((DataByteArray)v).get());
+ assertTrue(v instanceof Integer);
+ String value = String.valueOf(v);
assertEquals("1", value);
}
- //the value types of a map should always be a byte array
- //irrespective of the actual type
- @SuppressWarnings("unchecked")
@Test
public void testMapLongValueType() throws Exception{
String myMap = "[key1#1l]";
- Map<String, Object> map = ps.getLoadCaster().bytesToMap(myMap.getBytes());
+ Schema schema = Utils.getSchemaFromString("m:map[long]");
+ ResourceFieldSchema rfs = new ResourceSchema(schema).getFields()[0];
+ Map<String, Object> map = ps.getLoadCaster().bytesToMap(myMap.getBytes(), rfs);
String key = map.keySet().iterator().next();
Object v = map.get("key1");
assertEquals("key1", key);
- assertTrue(v instanceof DataByteArray);
- String value = new String(((DataByteArray)v).get());
- assertEquals("1l", value);
+ assertTrue(v instanceof Long);
+ String value = String.valueOf(v);
+ assertEquals("1", value);
}
- //the value types of a map should always be a byte array
- //irrespective of the actual type
- @SuppressWarnings("unchecked")
@Test
public void testMapFloatValueType() throws Exception{
String myMap = "[key1#0.1f]";
- Map<String, Object> map = ps.getLoadCaster().bytesToMap(myMap.getBytes());
+ Schema schema = Utils.getSchemaFromString("m:map[float]");
+ ResourceFieldSchema rfs = new ResourceSchema(schema).getFields()[0];
+ Map<String, Object> map = ps.getLoadCaster().bytesToMap(myMap.getBytes(), rfs);
String key = map.keySet().iterator().next();
Object v = map.get("key1");
assertEquals("key1", key);
- assertTrue(v instanceof DataByteArray);
- String value = new String(((DataByteArray)v).get());
- assertEquals("0.1f", value);
+ assertTrue(v instanceof Float);
+ String value = String.valueOf(v);
+ assertEquals("0.1", value);
}
- //the value types of a map should always be a byte array
- //irrespective of the actual type
- @SuppressWarnings("unchecked")
@Test
public void testMapDoubleValueType() throws Exception{
String myMap = "[key1#0.1]";
- Map<String, Object> map = ps.getLoadCaster().bytesToMap(myMap.getBytes());
+ Schema schema = Utils.getSchemaFromString("m:map[double]");
+ ResourceFieldSchema rfs = new ResourceSchema(schema).getFields()[0];
+ Map<String, Object> map = ps.getLoadCaster().bytesToMap(myMap.getBytes(), rfs);
String key = map.keySet().iterator().next();
Object v = map.get("key1");
assertEquals("key1", key);
- assertTrue(v instanceof DataByteArray);
- String value = new String(((DataByteArray)v).get());
+ assertTrue(v instanceof Double);
+ String value = String.valueOf(v);
assertEquals("0.1", value);
}
Modified: pig/trunk/test/org/apache/pig/test/utils/GenRandomData.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/utils/GenRandomData.java?rev=1526784&r1=1526783&r2=1526784&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/utils/GenRandomData.java (original)
+++ pig/trunk/test/org/apache/pig/test/utils/GenRandomData.java Fri Sep 27 03:36:39 2013
@@ -35,8 +35,19 @@ import org.apache.pig.data.TupleFactory;
import org.apache.pig.data.Tuple;
public class GenRandomData {
-
-
+
+ public static ResourceFieldSchema getRandMapFieldSchema() throws IOException {
+ ResourceFieldSchema bytefs = new ResourceFieldSchema();
+ bytefs.setType(DataType.BYTEARRAY);
+ ResourceSchema mapSchema = new ResourceSchema();
+ mapSchema.setFields(new ResourceFieldSchema[]{bytefs});
+ ResourceFieldSchema mapfs = new ResourceFieldSchema();
+ mapfs.setSchema(mapSchema);
+ mapfs.setType(DataType.MAP);
+
+ return mapfs;
+ }
+
public static Map<String, Object> genRandMap(Random r, int numEnt) {
Map<String,Object> ret = new HashMap<String, Object>();
if(r==null){