本文整理汇总了Java中org.apache.pig.ResourceSchema.ResourceFieldSchema.setType方法的典型用法代码示例。如果您正苦于以下问题:Java ResourceFieldSchema.setType方法的具体用法?Java ResourceFieldSchema.setType怎么用?Java ResourceFieldSchema.setType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pig.ResourceSchema.ResourceFieldSchema
的用法示例。
在下文中一共展示了ResourceFieldSchema.setType方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMixedTupleToConvertFieldSchema
import org.apache.pig.ResourceSchema.ResourceFieldSchema; //导入方法依赖的package包/类
public static ResourceFieldSchema getMixedTupleToConvertFieldSchema() throws IOException {
ResourceFieldSchema stringfs = new ResourceFieldSchema();
stringfs.setType(DataType.CHARARRAY);
ResourceFieldSchema intfs = new ResourceFieldSchema();
intfs.setType(DataType.INTEGER);
ResourceFieldSchema longfs = new ResourceFieldSchema();
longfs.setType(DataType.LONG);
ResourceFieldSchema floatfs = new ResourceFieldSchema();
floatfs.setType(DataType.FLOAT);
ResourceFieldSchema doublefs = new ResourceFieldSchema();
doublefs.setType(DataType.DOUBLE);
ResourceFieldSchema boolfs = new ResourceFieldSchema();
boolfs.setType(DataType.BOOLEAN);
ResourceFieldSchema dtfs = new ResourceFieldSchema();
dtfs.setType(DataType.DATETIME);
ResourceSchema tupleSchema = new ResourceSchema();
tupleSchema.setFields(new ResourceFieldSchema[]{stringfs, longfs, intfs, doublefs, floatfs, stringfs, intfs, doublefs, floatfs, boolfs, dtfs});
ResourceFieldSchema tuplefs = new ResourceFieldSchema();
tuplefs.setSchema(tupleSchema);
tuplefs.setType(DataType.TUPLE);
return tuplefs;
}
示例2: getFloatDataBagFieldSchema
import org.apache.pig.ResourceSchema.ResourceFieldSchema; //导入方法依赖的package包/类
public static ResourceFieldSchema getFloatDataBagFieldSchema(int column) throws IOException {
ResourceFieldSchema intfs = new ResourceFieldSchema();
intfs.setType(DataType.INTEGER);
ResourceSchema tupleSchema = new ResourceSchema();
ResourceFieldSchema[] fss = new ResourceFieldSchema[column];
for (int i=0;i<column;i++) {
fss[i] = intfs;
}
tupleSchema.setFields(fss);
ResourceFieldSchema tuplefs = new ResourceFieldSchema();
tuplefs.setSchema(tupleSchema);
tuplefs.setType(DataType.TUPLE);
ResourceSchema bagSchema = new ResourceSchema();
bagSchema.setFields(new ResourceFieldSchema[]{tuplefs});
ResourceFieldSchema bagfs = new ResourceFieldSchema();
bagfs.setSchema(bagSchema);
bagfs.setType(DataType.BAG);
return bagfs;
}
示例3: setSchema
import org.apache.pig.ResourceSchema.ResourceFieldSchema; //导入方法依赖的package包/类
public void setSchema(ResourceSchema schema) {
schemaField = new ResourceFieldSchema();
schemaField.setType(DataType.TUPLE);
try {
schemaField.setSchema(schema);
} catch (IOException ex) {
throw new EsHadoopIllegalStateException(String.format("Cannot use schema [%s]", schema), ex);
}
}
示例4: getSchema
import org.apache.pig.ResourceSchema.ResourceFieldSchema; //导入方法依赖的package包/类
/** schema: (value, value, value) where keys are in the front. */
public ResourceSchema getSchema(String location, Job job) throws IOException
{
setLocation(location, job);
CfInfo cfInfo = getCfInfo(loadSignature);
CfDef cfDef = cfInfo.cfDef;
// top-level schema, no type
ResourceSchema schema = new ResourceSchema();
// get default marshallers and validators
Map<MarshallerType, AbstractType> marshallers = getDefaultMarshallers(cfDef);
Map<ByteBuffer, AbstractType> validators = getValidatorMap(cfDef);
// will contain all fields for this schema
List<ResourceFieldSchema> allSchemaFields = new ArrayList<ResourceFieldSchema>();
for (ColumnDef cdef : cfDef.column_metadata)
{
ResourceFieldSchema valSchema = new ResourceFieldSchema();
AbstractType validator = validators.get(cdef.name);
if (validator == null)
validator = marshallers.get(MarshallerType.DEFAULT_VALIDATOR);
valSchema.setName(new String(cdef.getName()));
valSchema.setType(getPigType(validator));
allSchemaFields.add(valSchema);
}
// top level schema contains everything
schema.setFields(allSchemaFields.toArray(new ResourceFieldSchema[allSchemaFields.size()]));
return schema;
}
示例5: getSchema
import org.apache.pig.ResourceSchema.ResourceFieldSchema; //导入方法依赖的package包/类
/** schema: (value, value, value) where keys are in the front. */
public ResourceSchema getSchema(String location, Job job) throws IOException
{
setLocation(location, job);
CfDef cfDef = getCfDef(loadSignature);
// top-level schema, no type
ResourceSchema schema = new ResourceSchema();
// get default marshallers and validators
Map<MarshallerType, AbstractType> marshallers = getDefaultMarshallers(cfDef);
Map<ByteBuffer, AbstractType> validators = getValidatorMap(cfDef);
// will contain all fields for this schema
List<ResourceFieldSchema> allSchemaFields = new ArrayList<ResourceFieldSchema>();
for (ColumnDef cdef : cfDef.column_metadata)
{
ResourceFieldSchema valSchema = new ResourceFieldSchema();
AbstractType validator = validators.get(cdef.name);
if (validator == null)
validator = marshallers.get(MarshallerType.DEFAULT_VALIDATOR);
valSchema.setName(new String(cdef.getName()));
valSchema.setType(getPigType(validator));
allSchemaFields.add(valSchema);
}
// top level schema contains everything
schema.setFields(allSchemaFields.toArray(new ResourceFieldSchema[allSchemaFields.size()]));
return schema;
}
示例6: wrapAsTuple
import org.apache.pig.ResourceSchema.ResourceFieldSchema; //导入方法依赖的package包/类
/** wrap a pig schema as tuple */
public static ResourceFieldSchema wrapAsTuple(ResourceFieldSchema subFieldSchema) throws IOException {
ResourceSchema listSchema = new ResourceSchema();
listSchema.setFields(new ResourceFieldSchema[] { subFieldSchema });
ResourceFieldSchema tupleWrapper = new ResourceFieldSchema();
tupleWrapper.setType(DataType.TUPLE);
tupleWrapper.setName(PIG_TUPLE_WRAPPER);
tupleWrapper.setSchema(listSchema);
return tupleWrapper;
}
示例7: getSchema
import org.apache.pig.ResourceSchema.ResourceFieldSchema; //导入方法依赖的package包/类
/** schema: (value, value, value) where keys are in the front. */
public ResourceSchema getSchema(String location, Job job) throws IOException
{
setLocation(location, job);
CfInfo cfInfo = getCfInfo(loadSignature);
CfDef cfDef = cfInfo.cfDef;
// top-level schema, no type
ResourceSchema schema = new ResourceSchema();
// get default marshallers and validators
Map<MarshallerType, AbstractType> marshallers = getDefaultMarshallers(cfDef);
Map<ByteBuffer, AbstractType> validators = getValidatorMap(cfDef);
// will contain all fields for this schema
List<ResourceFieldSchema> allSchemaFields = new ArrayList<ResourceFieldSchema>();
for (ColumnDef cdef : cfDef.column_metadata)
{
ResourceFieldSchema valSchema = new ResourceFieldSchema();
AbstractType validator = validators.get(cdef.name);
if (validator == null)
validator = marshallers.get(MarshallerType.DEFAULT_VALIDATOR);
valSchema.setName(new String(cdef.getName()));
valSchema.setType(getPigType(validator));
allSchemaFields.add(valSchema);
}
// top level schema contains everything
schema.setFields(allSchemaFields.toArray(new ResourceFieldSchema[allSchemaFields.size()]));
return schema;
}
示例8: getFullTupTextDataBagFieldSchema
import org.apache.pig.ResourceSchema.ResourceFieldSchema; //导入方法依赖的package包/类
public static ResourceFieldSchema getFullTupTextDataBagFieldSchema() throws IOException{
ResourceFieldSchema tuplefs = getSmallBagTextTupleFieldSchema();
ResourceSchema outBagSchema = new ResourceSchema();
outBagSchema.setFields(new ResourceFieldSchema[]{tuplefs});
ResourceFieldSchema outBagfs = new ResourceFieldSchema();
outBagfs.setSchema(outBagSchema);
outBagfs.setType(DataType.BAG);
return outBagfs;
}
示例9: getSmallTupDataBagFieldSchema
import org.apache.pig.ResourceSchema.ResourceFieldSchema; //导入方法依赖的package包/类
public static ResourceFieldSchema getSmallTupDataBagFieldSchema() throws IOException {
ResourceFieldSchema tuplefs = getSmallTupleFieldSchema();
ResourceSchema bagSchema = new ResourceSchema();
bagSchema.setFields(new ResourceFieldSchema[]{tuplefs});
ResourceFieldSchema bagfs = new ResourceFieldSchema();
bagfs.setSchema(bagSchema);
bagfs.setType(DataType.BAG);
return bagfs;
}
示例10: getSmallTupleFieldSchema
import org.apache.pig.ResourceSchema.ResourceFieldSchema; //导入方法依赖的package包/类
public static ResourceFieldSchema getSmallTupleFieldSchema() throws IOException{
ResourceFieldSchema stringfs = new ResourceFieldSchema();
stringfs.setType(DataType.CHARARRAY);
ResourceFieldSchema intfs = new ResourceFieldSchema();
intfs.setType(DataType.INTEGER);
ResourceSchema tupleSchema = new ResourceSchema();
tupleSchema.setFields(new ResourceFieldSchema[]{stringfs, intfs});
ResourceFieldSchema tuplefs = new ResourceFieldSchema();
tuplefs.setSchema(tupleSchema);
tuplefs.setType(DataType.TUPLE);
return tuplefs;
}
示例11: getTupleFieldSchema
import org.apache.pig.ResourceSchema.ResourceFieldSchema; //导入方法依赖的package包/类
ResourceFieldSchema getTupleFieldSchema() throws IOException {
ResourceFieldSchema stringfs = new ResourceFieldSchema();
stringfs.setType(DataType.CHARARRAY);
ResourceFieldSchema intfs = new ResourceFieldSchema();
intfs.setType(DataType.INTEGER);
ResourceSchema tupleSchema = new ResourceSchema();
tupleSchema.setFields(new ResourceFieldSchema[]{intfs, stringfs});
ResourceFieldSchema tuplefs = new ResourceFieldSchema();
tuplefs.setSchema(tupleSchema);
tuplefs.setType(DataType.TUPLE);
return tuplefs;
}
示例12: getLongFieldSchema
import org.apache.pig.ResourceSchema.ResourceFieldSchema; //导入方法依赖的package包/类
ResourceFieldSchema getLongFieldSchema() {
ResourceFieldSchema longfs = new ResourceFieldSchema();
longfs.setType(DataType.LONG);
return longfs;
}
示例13: testStoreComplexDataWithNull
import org.apache.pig.ResourceSchema.ResourceFieldSchema; //导入方法依赖的package包/类
@Test
public void testStoreComplexDataWithNull() throws Exception {
Tuple inputTuple = GenRandomData.genRandSmallBagTextTupleWithNulls(new Random(), 10, 100);
inpDB = DefaultBagFactory.getInstance().newDefaultBag();
inpDB.add(inputTuple);
storeAndCopyLocally(inpDB);
PigStorage ps = new PigStorage("\t");
BufferedReader br = new BufferedReader(new FileReader(outputFileName));
for(String line=br.readLine();line!=null;line=br.readLine()){
System.err.println("Complex data: ");
System.err.println(line);
String[] flds = line.split("\t",-1);
Tuple t = new DefaultTuple();
ResourceFieldSchema stringfs = new ResourceFieldSchema();
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});
ResourceFieldSchema tuplefs = new ResourceFieldSchema();
tuplefs.setSchema(tupleSchema);
tuplefs.setType(DataType.TUPLE);
ResourceSchema bagSchema = new ResourceSchema();
bagSchema.setFields(new ResourceFieldSchema[]{tuplefs});
ResourceFieldSchema bagfs = new ResourceFieldSchema();
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);
t.append(flds[3].compareTo("")!=0 ? ps.getLoadCaster().bytesToDouble(flds[3].getBytes()) : null);
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(), 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);
t.append(flds[11].compareTo("")!=0 ? ps.getLoadCaster().bytesToCharArray(flds[10].getBytes()) : null);
assertEquals(inputTuple, t);
}
br.close();
}
示例14: getSmallBagTextTupleFieldSchema
import org.apache.pig.ResourceSchema.ResourceFieldSchema; //导入方法依赖的package包/类
public static ResourceFieldSchema getSmallBagTextTupleFieldSchema() throws IOException{
ResourceFieldSchema dbafs = new ResourceFieldSchema();
dbafs.setType(DataType.BYTEARRAY);
ResourceFieldSchema stringfs = new ResourceFieldSchema();
stringfs.setType(DataType.CHARARRAY);
ResourceFieldSchema intfs = new ResourceFieldSchema();
intfs.setType(DataType.INTEGER);
ResourceFieldSchema bagfs = getSmallTupDataBagFieldSchema();
ResourceFieldSchema floatfs = new ResourceFieldSchema();
floatfs.setType(DataType.FLOAT);
ResourceFieldSchema doublefs = new ResourceFieldSchema();
doublefs.setType(DataType.DOUBLE);
ResourceFieldSchema longfs = new ResourceFieldSchema();
longfs.setType(DataType.LONG);
ResourceFieldSchema mapfs = new ResourceFieldSchema();
mapfs.setType(DataType.MAP);
ResourceFieldSchema tuplefs = getSmallTupleFieldSchema();
ResourceFieldSchema boolfs = new ResourceFieldSchema();
boolfs.setType(DataType.BOOLEAN);
ResourceFieldSchema dtfs = new ResourceFieldSchema();
dtfs.setType(DataType.DATETIME);
ResourceSchema outSchema = new ResourceSchema();
outSchema.setFields(new ResourceFieldSchema[]{bagfs, dbafs, stringfs, doublefs, floatfs,
intfs, longfs, mapfs, tuplefs, boolfs, dtfs});
ResourceFieldSchema outfs = new ResourceFieldSchema();
outfs.setSchema(outSchema);
outfs.setType(DataType.TUPLE);
return outfs;
}