use of org.apache.pig.impl.util.UDFContext in project mongo-hadoop by mongodb.
the class BSONStorage method checkSchema.
@Override
public void checkSchema(final ResourceSchema schema) throws IOException {
this.schema = schema;
UDFContext context = UDFContext.getUDFContext();
Properties p = context.getUDFProperties(getClass(), new String[] { udfcSignature });
p.setProperty(SCHEMA_SIGNATURE, schema.toString());
}
use of org.apache.pig.impl.util.UDFContext in project mongo-hadoop by mongodb.
the class MongoInsertStorage method prepareToWrite.
public void prepareToWrite(final RecordWriter writer) throws IOException {
out = writer;
if (out == null) {
throw new IOException("Invalid Record Writer");
}
UDFContext udfc = UDFContext.getUDFContext();
Properties p = udfc.getUDFProperties(getClass(), new String[] { udfcSignature });
String strSchema = p.getProperty(SCHEMA_SIGNATURE);
if (strSchema == null) {
LOG.warn("Could not find schema in UDF context. Interpreting each tuple as containing a single map.");
} else {
try {
// Parse the schema from the string stored in the properties object.
schema = new ResourceSchema(Utils.getSchemaFromString(strSchema));
} catch (Exception e) {
schema = null;
LOG.warn(e.getMessage());
}
if (LOG.isDebugEnabled()) {
LOG.debug("GOT A SCHEMA " + schema + " " + strSchema);
}
}
}
use of org.apache.pig.impl.util.UDFContext in project phoenix by apache.
the class ReserveNSequence method initConnection.
private void initConnection() throws IOException {
// Create correct configuration to be used to make phoenix connections
UDFContext context = UDFContext.getUDFContext();
configuration = new Configuration(context.getJobConf());
configuration.set(HConstants.ZOOKEEPER_QUORUM, this.zkQuorum);
if (Strings.isNullOrEmpty(tenantId)) {
configuration.unset(PhoenixRuntime.TENANT_ID_ATTRIB);
} else {
configuration.set(PhoenixRuntime.TENANT_ID_ATTRIB, tenantId);
}
try {
connection = ConnectionUtil.getOutputConnection(configuration);
} catch (SQLException e) {
throw new IOException("Caught exception while creating connection", e);
}
}
Aggregations