@Override
    public void write(final NullWritable key, final VertexWritable vertex) throws IOException {
        if (null != vertex) {
            try {
                final Bindings bindings = this.engine.createBindings();
                bindings.put(VERTEX, vertex.get());
                final String line = (String) engine.eval(WRITE_CALL, bindings);
                if (line != null) {
                    this.out.write(line.getBytes(UTF8));
                    this.out.write(NEWLINE);
                }
            } catch (final ScriptException e) {
                throw new IOException(e.getMessage(), e);
            }
        }
    }
@author Daniel Kuppitz (http://gremlin.guru)
hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/script/ScriptRecordWriter.java