本文整理汇总了Java中org.apache.pig.impl.util.UDFContext.getUDFContext方法的典型用法代码示例。如果您正苦于以下问题:Java UDFContext.getUDFContext方法的具体用法?Java UDFContext.getUDFContext怎么用?Java UDFContext.getUDFContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pig.impl.util.UDFContext
的用法示例。
在下文中一共展示了UDFContext.getUDFContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSchema
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
public ResourceSchema getSchema(String location, Job job)
throws IOException {
if (schema != null) {
// Send schema to backend
// Schema should have been passed as an argument (-> constructor)
// or provided in the default constructor
UDFContext udfc = UDFContext.getUDFContext();
Properties p = udfc.getUDFProperties(this.getClass(), new String[]{ udfContextSignature });
p.setProperty(SCHEMA_SIGNATURE, schema.toString());
return schema;
} else {
// Should never get here
throw new IllegalArgumentException(
"No schema found: default schema was never created and no user-specified schema was found."
);
}
}
示例2: pushProjection
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
@Override
public RequiredFieldResponse pushProjection(RequiredFieldList requiredFieldList) throws FrontendException {
if (requiredFieldList == null)
return null;
if (!useDefaultSchema && requiredFieldList.getFields() != null)
{
requiredFields = new boolean[fields.length];
for (RequiredField f : requiredFieldList.getFields()) {
requiredFields[f.getIndex()] = true;
}
UDFContext udfc = UDFContext.getUDFContext();
Properties p = udfc.getUDFProperties(this.getClass(), new String[]{ udfContextSignature });
try {
p.setProperty(REQUIRED_FIELDS_SIGNATURE, ObjectSerializer.serialize(requiredFields));
} catch (Exception e) {
throw new RuntimeException("Cannot serialize requiredFields for pushProjection");
}
}
return new RequiredFieldResponse(true);
}
示例3: prepareToRead
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void prepareToRead(RecordReader reader, PigSplit split)
throws IOException {
this.reader = reader;
// Get the schema string from the UDFContext object.
UDFContext udfc = UDFContext.getUDFContext();
Properties p =
udfc.getUDFProperties(this.getClass(), new String[]{udfcSignature});
String strSchema = p.getProperty(SCHEMA_SIGNATURE);
if (strSchema == null) {
throw new IOException("Could not find schema in UDF context");
}
// Parse the schema from the string stored in the properties object.
schema = new ResourceSchema(Utils.getSchemaFromString(strSchema));
jsonFactory = new JsonFactory();
}
示例4: prepareToWrite
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
@Override
public void prepareToWrite(RecordWriter writer) throws IOException {
// Store the record writer reference so we can use it when it's time
// to write tuples
this.writer = writer;
// Get the schema string from the UDFContext object.
UDFContext udfc = UDFContext.getUDFContext();
Properties p =
udfc.getUDFProperties(this.getClass(), new String[]{udfcSignature});
String strSchema = p.getProperty(SCHEMA_SIGNATURE);
if (strSchema == null) {
throw new IOException("Could not find schema in UDF context");
}
// Parse the schema from the string stored in the properties object.
schema = new ResourceSchema(Utils.getSchemaFromString(strSchema));
// Build a Json factory
jsonFactory = new JsonFactory();
}
示例5: pushProjection
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
@Override
public RequiredFieldResponse pushProjection(RequiredFieldList requiredFieldList) throws FrontendException {
if (requiredFieldList == null)
return null;
if (fields != null && requiredFieldList.getFields() != null)
{
requiredFields = new boolean[fields.length];
for (RequiredField f : requiredFieldList.getFields()) {
requiredFields[f.getIndex()] = true;
}
UDFContext udfc = UDFContext.getUDFContext();
Properties p = udfc.getUDFProperties(this.getClass(), new String[]{ udfContextSignature });
try {
p.setProperty(REQUIRED_FIELDS_SIGNATURE, ObjectSerializer.serialize(requiredFields));
} catch (Exception e) {
throw new RuntimeException("Cannot serialize requiredFields for pushProjection");
}
}
return new RequiredFieldResponse(true);
}
示例6: getWhereClauseForPartitionFilter
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
/** retrieve where clause for partition filter */
private String getWhereClauseForPartitionFilter()
{
UDFContext context = UDFContext.getUDFContext();
Properties property = context.getUDFProperties(AbstractCassandraStorage.class);
return property.getProperty(PARTITION_FILTER_SIGNATURE);
}
示例7: getCfInfo
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
/** get the columnfamily definition for the signature */
protected CfInfo getCfInfo(String signature) throws IOException
{
UDFContext context = UDFContext.getUDFContext();
Properties property = context.getUDFProperties(AbstractCassandraStorage.class);
String prop = property.getProperty(signature);
CfInfo cfInfo = new CfInfo();
cfInfo.cfDef = cfdefFromString(prop.substring(2));
cfInfo.compactCqlTable = prop.charAt(0) == '1' ? true : false;
cfInfo.cql3Table = prop.charAt(1) == '1' ? true : false;
return cfInfo;
}
示例8: setPartitionFilter
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
/** set partition filter */
public void setPartitionFilter(Expression partitionFilter) throws IOException
{
UDFContext context = UDFContext.getUDFContext();
Properties property = context.getUDFProperties(AbstractCassandraStorage.class);
property.setProperty(PARTITION_FILTER_SIGNATURE, indexExpressionsToString(filterToIndexExpressions(partitionFilter)));
}
示例9: getIndexExpressions
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
/** get a list of index expression */
private List<IndexExpression> getIndexExpressions() throws IOException
{
UDFContext context = UDFContext.getUDFContext();
Properties property = context.getUDFProperties(AbstractCassandraStorage.class);
if (property.getProperty(PARTITION_FILTER_SIGNATURE) != null)
return indexExpressionsFromString(property.getProperty(PARTITION_FILTER_SIGNATURE));
else
return null;
}
示例10: getCfDef
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
/** get the columnfamily definition for the signature */
protected CfDef getCfDef(String signature) throws IOException
{
UDFContext context = UDFContext.getUDFContext();
Properties property = context.getUDFProperties(AbstractCassandraStorage.class);
return cfdefFromString(property.getProperty(signature));
}
示例11: checkSchema
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
public void checkSchema(ResourceSchema s) throws IOException {
// Not actually checking schema
// Actually, just storing it to use in the backend
UDFContext udfc = UDFContext.getUDFContext();
Properties p =
udfc.getUDFProperties(this.getClass(), new String[]{ udfContextSignature });
p.setProperty(SCHEMA_SIGNATURE, s.toString());
}
示例12: checkSchema
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
@Override
public void checkSchema(ResourceSchema s) throws IOException {
// Not actually checking schema
// Just storing it to use in the backend
UDFContext udfc = UDFContext.getUDFContext();
Properties p =
udfc.getUDFProperties(this.getClass(), new String[]{ udfContextSignature });
p.setProperty(SCHEMA_SIGNATURE, s.toString());
}
示例13: checkSchema
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
@Override
public void checkSchema(ResourceSchema s) throws IOException {
// We won't really check the schema here, we'll store it in our
// UDFContext properties object so we have it when we need it on the
// backend
UDFContext udfc = UDFContext.getUDFContext();
Properties p =
udfc.getUDFProperties(this.getClass(), new String[]{udfcSignature});
p.setProperty(SCHEMA_SIGNATURE, s.toString());
}
示例14: prepareToWrite
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
/** BACKEND **/
@SuppressWarnings("rawtypes")
@Override
public void prepareToWrite(RecordWriter writer) throws IOException {
// Get the schema string from the UDFContext object.
UDFContext udfc = UDFContext.getUDFContext();
Properties p = udfc.getUDFProperties(this.getClass(),
new String[] { this.udfContextSignature });
String strSchema = p.getProperty(SCHEMA_PROPERTY);
if (strSchema == null) {
throw new IOException(
"Could not find schema in UDF context at property "
+ SCHEMA_PROPERTY);
}
// Parse the schema from the string stored in the properties object.
this.schema = new ResourceSchema(
Utils.getSchemaFromString(strSchema));
// connect to dynamo
this.dynamo = loadDynamoDB();
// fetch capacity we are allowed to use
this.maxWriteCapacity = getMaxWriteCapacity();
this.currentWriteCapacity = this.maxWriteCapacity;
this.queue = new DynamoWriteRequestBlockingQueue();
// create and start the stopwatch
this.stopwatch = new Stopwatch().start();
}
示例15: setupUDFContext
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
public static void setupUDFContext(Configuration job) throws IOException {
UDFContext udfc = UDFContext.getUDFContext();
udfc.addJobConf(job);
// don't deserialize in front-end
if (udfc.isUDFConfEmpty()) {
udfc.deserialize();
}
}