use of edu.uci.ics.texera.workflow.common.tuple.schema.Schema in project textdb by TextDB.
the class PythonUDFOpExec method sendArgs.
private void sendArgs() {
// Send user args to Server.
List<String> userArgs = new ArrayList<>();
if (inputColumns != null)
userArgs.addAll(inputColumns);
if (arguments != null)
userArgs.addAll(arguments);
if (outputColumns != null) {
for (Attribute a : outputColumns) userArgs.add(a.getName());
}
if (outerFilePaths != null)
userArgs.addAll(outerFilePaths);
Schema argsSchema = new Schema(Collections.singletonList(new Attribute("args", AttributeType.STRING)));
Queue<Tuple> argsTuples = new LinkedList<>();
for (String arg : userArgs) {
argsTuples.add(new Tuple(argsSchema, Collections.singletonList(arg)));
}
writeArrowStream(flightClient, argsTuples, ArrowUtils.fromTexeraSchema(argsSchema), Channel.ARGS, batchSize);
}
use of edu.uci.ics.texera.workflow.common.tuple.schema.Schema in project textdb by TextDB.
the class PieChartOpPartialExec method processTexeraTuple.
@Override
public Iterator<Tuple> processTexeraTuple(Either<Tuple, InputExhausted> tuple, LinkIdentity input) {
if (tuple.isLeft()) {
Tuple inputTuple = tuple.left().get();
String name = inputTuple.getField(nameColumn);
Double data;
if (inputTuple.getSchema().getAttribute(dataColumn).getType() == AttributeType.STRING) {
data = Double.parseDouble(inputTuple.getField(dataColumn));
} else if (inputTuple.getSchema().getAttribute(dataColumn).getType() == AttributeType.INTEGER) {
data = Double.parseDouble(Integer.toString(inputTuple.getField(dataColumn)));
} else {
data = inputTuple.getField(dataColumn);
}
Schema oldSchema = tuple.left().get().getSchema();
Attribute dataAttribute = new Attribute(oldSchema.getAttribute(dataColumn).getName(), oldSchema.getAttribute(dataColumn).getType());
Schema newSchema = new Schema(Arrays.asList(oldSchema.getAttribute(nameColumn), dataAttribute));
if (noDataCol) {
result.add(Tuple.newBuilder(newSchema).addSequentially(new Object[] { name, data.intValue() }).build());
} else {
result.add(Tuple.newBuilder(newSchema).addSequentially(new Object[] { name, data }).build());
}
return JavaConverters.asScalaIterator(Collections.emptyIterator());
} else {
result.sort((left, right) -> {
double leftValue;
double rightValue;
if (noDataCol) {
leftValue = left.getInt(1);
rightValue = right.getInt(1);
} else {
leftValue = left.getDouble(1);
rightValue = right.getDouble(1);
}
return Double.compare(rightValue, leftValue);
});
return JavaConverters.asScalaIterator(result.iterator());
}
}