Package org.apache.pig.impl.util

Examples of org.apache.pig.impl.util.UDFContext


    private String [] fields = {"a", "b", "c", "d", "e", "f", "g", "h", "i"};

    @Test
    public void test() throws Exception {
        ToCassandraBag tcb = new ToCassandraBag();
        UDFContext context = UDFContext.getUDFContext();
        Properties properties = context.getUDFProperties(ToCassandraBag.class);
        Tuple input = new DefaultTuple();
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < fields.length; i++){
            builder.append(fields[i]);
            input.append("foo" + i);
View Full Code Here


    }

    public Tuple exec(Tuple input) throws IOException {
        Tuple row = TupleFactory.getInstance().newTuple(2);
        DataBag columns = BagFactory.getInstance().newDefaultBag();
        UDFContext context = UDFContext.getUDFContext();
        Properties property = context.getUDFProperties(ToCassandraBag.class);
        String fieldString = property.getProperty(getSchemaKey());
        String [] fieldnames = INPUT_DELIM.split(fieldString);
        if (log.isDebugEnabled()) {
            log.debug("Tuple: " + input.toDelimitedString(",") + " Fields: " + fieldString);
        }
View Full Code Here

            if (i != fields.size()-1) {
                builder.append(OUTPUT_DELIM);
            }
        }
       
        UDFContext context = UDFContext.getUDFContext();
        Properties property = context.getUDFProperties(ToCassandraBag.class);
        property.setProperty(getSchemaKey(), builder.toString());

        return super.outputSchema(input);
    }
View Full Code Here

    private static char OUTPUT_DELIM = ',';

    public Tuple exec(Tuple input) throws IOException {
        Tuple row = TupleFactory.getInstance().newTuple(2);
        DataBag columns = BagFactory.getInstance().newDefaultBag();
        UDFContext context = UDFContext.getUDFContext();
        Properties property = context.getUDFProperties(DeleteColumns.class);
        String fieldString = property.getProperty(UDFCONTEXT_SCHEMA_KEY);
        String [] fieldnames = fieldString.split(INPUT_DELIM);

        // IT IS ALWAYS ASSUMED THAT THE OBJECT AT INDEX 0 IS THE ROW KEY
View Full Code Here

            if (i != fields.size()-1) {
                builder.append(OUTPUT_DELIM);
            }
        }

        UDFContext context = UDFContext.getUDFContext();
        Properties property = context.getUDFProperties(DeleteColumns.class);
        property.setProperty(UDFCONTEXT_SCHEMA_KEY, builder.toString());

        return super.outputSchema(input);
    }
View Full Code Here

        return pair;
    }

    private CfDef getCfDef()
    {
        UDFContext context = UDFContext.getUDFContext();
        Properties property = context.getUDFProperties(CassandraStorage.class);
        return cfdefFromString(property.getProperty(getSchemaContextKey()));
    }
View Full Code Here

    /* Methods to get the column family schema from Cassandra */

    private void initSchema()
    {
        UDFContext context = UDFContext.getUDFContext();
        Properties property = context.getUDFProperties(CassandraStorage.class);

        String schemaContextKey = getSchemaContextKey();
        // Only get the schema if we haven't already gotten it
        if (!property.containsKey(schemaContextKey))
        {
View Full Code Here

           pair.set(position, value);
    }

    private CfDef getCfDef(String signature)
    {
        UDFContext context = UDFContext.getUDFContext();
        Properties property = context.getUDFProperties(CassandraStorage.class);
        return cfdefFromString(property.getProperty(signature));
    }
View Full Code Here

    /* Methods to get the column family schema from Cassandra */

    private void initSchema(String signature)
    {
        UDFContext context = UDFContext.getUDFContext();
        Properties property = context.getUDFProperties(CassandraStorage.class);

        // Only get the schema if we haven't already gotten it
        if (!property.containsKey(signature))
        {
            Cassandra.Client client = null;
View Full Code Here

        }
        return reducerMap;
    }
   
    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();
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.pig.impl.util.UDFContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.