Skip to content

Commit

Permalink
Added javadoc for DeleteColumns. Made delimiter comma or spacing. Fix…
Browse files Browse the repository at this point in the history
…ed a typo in DeleteColumns.
  • Loading branch information
jeromatron committed Jun 13, 2011
1 parent efce7ab commit da33d9b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 12 additions & 3 deletions udf/src/main/java/org/pygmalion/udf/DeleteColumns.java
Expand Up @@ -14,16 +14,25 @@
import java.util.List;
import java.util.Properties;

/**
* EvalFunc to take the given set of column names and convert them
* into a CassandraBag to delete those columns. Works similarly
* to ToCassandraBag.
*
* The first value in the input bag *has* to be the key. For
* the rest of the fields, this UDF will interrogate the values
* that you have named the variables to be the column names.
*/
public class DeleteColumns extends EvalFunc<Tuple> {

private static String UDFCONTEXT_SCHEMA_KEY = "cassandra.input_field_schema";
private static String DELIM = ",";
private static String DELIM = "[\\s,]+";

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);
Properties property = context.getUDFProperties(DeleteColumns.class);
String fieldString = property.getProperty(UDFCONTEXT_SCHEMA_KEY);
String [] fieldnames = fieldString.split(DELIM);

Expand Down Expand Up @@ -63,7 +72,7 @@ public Schema outputSchema(Schema input) {
}

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

return super.outputSchema(input);
Expand Down
2 changes: 1 addition & 1 deletion udf/src/main/java/org/pygmalion/udf/ToCassandraBag.java
Expand Up @@ -27,7 +27,7 @@
public class ToCassandraBag extends EvalFunc<Tuple> {

private static String UDFCONTEXT_SCHEMA_KEY = "cassandra.input_field_schema";
private static String DELIM = ",";
private static String DELIM = "[\\s,]+";

public Tuple exec(Tuple input) throws IOException {
Tuple row = TupleFactory.getInstance().newTuple(2);
Expand Down

0 comments on commit da33d9b

Please sign in to comment.