Search in sources :

Example 1 with Serializer

use of org.talend.dataprep.schema.Serializer in project data-prep by Talend.

the class DataSetContentStore method get.

/**
 * Returns the {@link DataSetMetadata data set} content as <b>JSON</b> format. Whether data set content was JSON or
 * not, method is expected to provide a JSON output. It's up to the implementation to:
 * <ul>
 * <li>Convert data content to JSON.</li>
 * <li>Throw an exception if data set is not ready for read (content type missing).</li>
 * </ul>
 * Implementations are also encouraged to implement method with no blocking code.
 *
 * @param dataSetMetadata The {@link DataSetMetadata data set} to read content from.
 * @param limit A limit to pass to content supplier (use -1 for "no limit). Used as parameter for both raw content supplier
 * and JSON serializer.
 * @return A valid <b>JSON</b> stream. It is a JSON array where each element in the array contains a single data set
 * row (it does not mean there's a line in input stream per data set row, a data set row might be split on multiple
 * rows in stream).
 */
protected InputStream get(DataSetMetadata dataSetMetadata, long limit) {
    DataSetContent content = dataSetMetadata.getContent();
    Serializer serializer = factory.getFormatFamily(content.getFormatFamilyId()).getSerializer();
    return serializer.serialize(getAsRaw(dataSetMetadata, limit), dataSetMetadata, limit);
}
Also used : DataSetContent(org.talend.dataprep.api.dataset.DataSetContent) Serializer(org.talend.dataprep.schema.Serializer)

Aggregations

DataSetContent (org.talend.dataprep.api.dataset.DataSetContent)1 Serializer (org.talend.dataprep.schema.Serializer)1