This has come up before, and I thought ti wasn't, but I'm looking at
POUserFunc and it looks like it should be.

Context:

I want to be able to do:

public Tuple exec(Tuple input) throws IOException {
    input.append(1);
    return input;
}

I was told this wasn't safe, however, looking at POUserFunc

                res.result = TupleFactory.getInstance().newTuple();

                Result temp = null;

                for(PhysicalOperator op : inputs) {
                    temp = op.getNext(getDummy(op.getResultType()),
op.getResultType());
                    if(temp.returnStatus!=POStatus.STATUS_OK) {
                        return temp;
                    }

                    if(op instanceof POProject &&
                            op.getResultType() == DataType.TUPLE){
                        POProject projOp = (POProject)op;
                        if(projOp.isProjectToEnd()){
                            Tuple trslt = (Tuple) temp.result;
                            Tuple rslt = (Tuple) res.result;
                            for(int i=0;i<trslt.size();i++) {
                                rslt.append(trslt.get(i));
                            }
                            continue;
                        }
                    }
                    ((Tuple)res.result).append(temp.result);
                }
                res.returnStatus = temp.returnStatus;

I'm not quite sure in what case doing the above append would be dangerous?
We're being given a new Tuple. Yes, the underling objects are the same as
they are not copied, but as long as you don't .

Perhaps I'm misunderstanding something? I'd love an example where returning
the Tuple you were given in an EvalFunc isn't safe to do?

Thanks
Jon

Reply via email to