%AbstractKeyValueSink
% Interface for classes that act as a key-value pairs sink.

% Copyright 2014-2016 The MathWorks, Inc.

classdef (Abstract, Hidden) AbstractKeyValueSink < handle
methods (Abstract)
% Add the given <key, value> pairs to the underlying data storage.
% The keys and values input must be vectors of the same length.
add(this, keys, values);

% Commit any output to the final location. This is only called if
% the task is successful. If a task is not successful, the sink
% is expected to cleanup all side-effects when destroyed.
commit(this);

% Provide any data that is to be returned to the driver code for
% MapReduce. This can be an arbitrary serializable value and will
% be called once at the end of a Map or Reduce task to obtain the
% return value of the run method.
results = getTaskOutputMetadata(this);
end

methods
% Create a key/value processor that ensures keys and values have the
% correct type and size for this given sink.
function processor = createKeyValueProcessor(~)
import matlab.mapreduce.internal.KeyValueProcessor;
processor = KeyValueProcessor();
end
end
end