Search in sources :

Example 1 with KeyValueWriterWithBasePath

use of org.apache.tez.runtime.library.api.KeyValueWriterWithBasePath in project tez by apache.

the class MultiMROutput method getWriter.

@Override
public KeyValueWriterWithBasePath getWriter() throws IOException {
    return new KeyValueWriterWithBasePath() {

        @SuppressWarnings("unchecked")
        @Override
        public void write(Object key, Object value) throws IOException {
            throw new UnsupportedOperationException("Write without basePath isn't supported.");
        }

        @SuppressWarnings("unchecked")
        @Override
        public void write(Object key, Object value, String basePath) throws IOException {
            if (basePath == null) {
                throw new UnsupportedOperationException("Write without basePath isn't supported.");
            }
            if (basePath.length() > 0 && basePath.charAt(0) == '/') {
                // written outside the output committer's task work path.
                throw new UnsupportedOperationException("Write with absolute basePath isn't supported.");
            }
            if (useNewApi) {
                try {
                    getNewRecordWriter(newApiTaskAttemptContext, basePath).write(key, value);
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                    throw new IOInterruptedException("Interrupted while writing next key-value", e);
                }
            } else {
                getOldRecordWriter(basePath).write(key, value);
            }
            outputRecordCounter.increment(1);
            getContext().notifyProgress();
        }
    };
}
Also used : KeyValueWriterWithBasePath(org.apache.tez.runtime.library.api.KeyValueWriterWithBasePath) IOInterruptedException(org.apache.tez.runtime.library.api.IOInterruptedException) IOInterruptedException(org.apache.tez.runtime.library.api.IOInterruptedException)

Aggregations

IOInterruptedException (org.apache.tez.runtime.library.api.IOInterruptedException)1 KeyValueWriterWithBasePath (org.apache.tez.runtime.library.api.KeyValueWriterWithBasePath)1