@Override
protected IScalarEvaluator createEvaluator(IHyracksTaskContext ctx, IScalarEvaluator[] args)
throws AlgebricksException {
final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
final UTF8StringPointable stringp = (UTF8StringPointable) UTF8StringPointable.FACTORY.createPointable();
final TaggedValuePointable nodep = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
final ByteBufferInputStream bbis = new ByteBufferInputStream();
final DataInputStream di = new DataInputStream(bbis);
final SequenceBuilder sb = new SequenceBuilder();
final ArrayBackedValueStorage abvsFileNode = new ArrayBackedValueStorage();
final InputSource in = new InputSource();
return new AbstractTaggedValueArgumentScalarEvaluator(args) {
@Override
protected void evaluate(TaggedValuePointable[] args, IPointable result) throws SystemException {
TaggedValuePointable tvp = args[0];
// TODO add support empty sequence and no argument.
if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
throw new SystemException(ErrorCode.FORG0006);
}
tvp.getValue(stringp);
try {
// Get the list of files.
bbis.setByteBuffer(ByteBuffer.wrap(Arrays.copyOfRange(stringp.getByteArray(),
stringp.getStartOffset(), stringp.getLength() + stringp.getStartOffset())), 0);
String collectionName = di.readUTF();
File collectionDirectory = new File(collectionName);
File[] list = collectionDirectory.listFiles();
abvs.reset();