throw new IOException("Invalid input. Please pass in both a list of column names and the columns themselves.");
if (input.isNull(0) || input.isNull(1))
return null;
String columnSelector = input.get(0).toString();
DataBag cassandraBag = (DataBag)input.get(1);
String[] selections = DELIM_PATTERN.split(columnSelector);
Tuple output = TupleFactory.getInstance().newTuple(selections.length);
for (int i = 0; i < selections.length; i++) {
String selection = selections[i];
if (selection.endsWith(GREEDY_OPERATOR)) {
String namePrefix = selection.substring(0,selection.length()-1);
DataBag columnsBag = BagFactory.getInstance().newDefaultBag();
// Find all columns in the input bag that begin with 'namePrefix'
// and add them to the 'columnsBag'
for (Tuple cassandraColumn : cassandraBag) {
String name = cassandraColumn.get(0).toString();
if (name.startsWith(namePrefix)) {
columnsBag.add(cassandraColumn);
}
}
// Sometimes this bag will have no columns in it, this _is_ the desired behavior.
output.set(i, columnsBag);