本文整理汇总了Java中org.apache.pig.impl.util.UDFContext.getUDFProperties方法的典型用法代码示例。如果您正苦于以下问题:Java UDFContext.getUDFProperties方法的具体用法?Java UDFContext.getUDFProperties怎么用?Java UDFContext.getUDFProperties使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.pig.impl.util.UDFContext
的用法示例。
在下文中一共展示了UDFContext.getUDFProperties方法的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: prepareToWrite
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
@Override
public void prepareToWrite(RecordWriter writer) throws IOException {
// Store writer to use in putNext()
this.writer = writer;
// Get the schema string from the UDFContext object.
UDFContext udfc = UDFContext.getUDFContext();
Properties p = udfc.getUDFProperties(this.getClass(), new String[]{ udfContextSignature });
String strSchema = p.getProperty(SCHEMA_SIGNATURE);
if (strSchema == null) {
throw new IOException("Could not find schema in UDF context");
}
schema = new ResourceSchema(Utils.getSchemaFromString(strSchema));
fields = schema.getFields();
}
示例4: setLocation
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
@Override
public void setLocation(String location, Job job) throws IOException {
UDFContext udfContext = UDFContext.getUDFContext();
Properties properties = udfContext.getUDFProperties(RegisteredJarVisibilityLoader.class);
if (!properties.containsKey(REGISTERED_JAR_VISIBILITY_SCHEMA)) {
LOG.info("Storing " + RegisteredJarVisibilitySchema.class.getName() + " in UDFContext.");
properties.put(REGISTERED_JAR_VISIBILITY_SCHEMA, new RegisteredJarVisibilitySchema());
LOG.info("Stored " + RegisteredJarVisibilitySchema.class.getName() + " in UDFContext.");
} else {
LOG.info("Retrieving " + REGISTERED_JAR_VISIBILITY_SCHEMA + " from UDFContext.");
RegisteredJarVisibilitySchema registeredJarVisibilitySchema =
(RegisteredJarVisibilitySchema) properties.get(REGISTERED_JAR_VISIBILITY_SCHEMA);
LOG.info("Retrieved " + REGISTERED_JAR_VISIBILITY_SCHEMA + " from UDFContext.");
}
super.setLocation(location, job);
}
示例5: 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();
}
示例6: prepareToWrite
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void prepareToWrite(RecordWriter writer) throws IOException {
this.writer = (DocumentDBRecordWriter) writer;
// Parse the schema from the string stored in the properties object.
UDFContext udfc = UDFContext.getUDFContext();
Properties p = udfc.getUDFProperties(this.getClass(), new String[]{udfContextSignature});
String strSchema = p.getProperty(PIG_OUTPUT_SCHEMA_UDF_CONTEXT);
if (strSchema == null) {
throw new IOException("Could not find schema in UDF context");
}
try {
// Parse the schema from the string stored in the properties object.
this.schema = new ResourceSchema(SchemaHelper.getSchemaFromString(strSchema));
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}
示例7: getSchema
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
public ResourceSchema getSchema(String location, Job job)
throws IOException {
ResourceSchema s;
if (schema!=null) {
s = schema;
} else {
// Parse the schema
s = (new JsonMetadata()).getSchema(location, job, true);
if (s == null) {
throw new IOException("Unable to parse schema found in file in " + location);
}
}
// Now that we have determined the schema, 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());
return s;
}
示例8: 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);
}
示例9: 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;
}
示例10: 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)));
}
示例11: 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;
}
示例12: 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));
}
示例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: getProperties
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
/**
* Internal function for getting the Properties object associated with
* this UDF instance.
* @param c Class of this UDF
* @param signature Signature string
* @return The Properties object associated with this UDF instance
*/
@SuppressWarnings("rawtypes")
protected final Properties getProperties(final Class c,
final String signature) {
UDFContext context = UDFContext.getUDFContext();
if (signature == null) {
return context.getUDFProperties(c);
} else {
return context.getUDFProperties(c, new String[] {signature});
}
}
示例15: checkSchema
import org.apache.pig.impl.util.UDFContext; //导入方法依赖的package包/类
@Override
public void checkSchema(ResourceSchema s) throws IOException {
checkPigSchemaForDynamo(s);
UDFContext udfc = UDFContext.getUDFContext();
Properties p = udfc.getUDFProperties(this.getClass(),
new String[] { this.udfContextSignature });
p.setProperty(SCHEMA_PROPERTY, s.toString());
}