com.amazonaws.services.s3.model.CSVInput Java Examples

The following examples show how to use com.amazonaws.services.s3.model.CSVInput. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: S3QueryUtil.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private static SelectObjectContentRequest generateBaseCSVRequest(String bucket, String key, String query) {
	SelectObjectContentRequest request = new SelectObjectContentRequest();
	request.setBucketName(bucket);
	request.setKey(key);
	request.setExpression(query);
	request.setExpressionType(ExpressionType.SQL);

	InputSerialization inputSerialization = new InputSerialization();
	inputSerialization.setCsv(new CSVInput());
	inputSerialization.setCompressionType(CompressionType.NONE);
	request.setInputSerialization(inputSerialization);

	OutputSerialization outputSerialization = new OutputSerialization();
	outputSerialization.setCsv(new CSVOutput());
	request.setOutputSerialization(outputSerialization);

	return request;
}
 
Example #2
Source File: S3QueryUtil.java    From flink with Apache License 2.0 6 votes vote down vote up
private static SelectObjectContentRequest generateBaseCSVRequest(String bucket, String key, String query) {
	SelectObjectContentRequest request = new SelectObjectContentRequest();
	request.setBucketName(bucket);
	request.setKey(key);
	request.setExpression(query);
	request.setExpressionType(ExpressionType.SQL);

	InputSerialization inputSerialization = new InputSerialization();
	inputSerialization.setCsv(new CSVInput());
	inputSerialization.setCompressionType(CompressionType.NONE);
	request.setInputSerialization(inputSerialization);

	OutputSerialization outputSerialization = new OutputSerialization();
	outputSerialization.setCsv(new CSVOutput());
	request.setOutputSerialization(outputSerialization);

	return request;
}
 
Example #3
Source File: S3SelectCsvRecordReader.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public SelectObjectContentRequest buildSelectObjectRequest(Properties schema, String query, Path path)
{
    SelectObjectContentRequest selectObjectRequest = new SelectObjectContentRequest();
    URI uri = path.toUri();
    selectObjectRequest.setBucketName(PrestoS3FileSystem.extractBucketName(uri));
    selectObjectRequest.setKey(PrestoS3FileSystem.keyFromPath(path));
    selectObjectRequest.setExpression(query);
    selectObjectRequest.setExpressionType(ExpressionType.SQL);

    String fieldDelimiter = getFieldDelimiter(schema);
    String quoteChar = schema.getProperty(QUOTE_CHAR, null);
    String escapeChar = schema.getProperty(ESCAPE_CHAR, null);

    CSVInput selectObjectCSVInputSerialization = new CSVInput();
    selectObjectCSVInputSerialization.setRecordDelimiter(lineDelimiter);
    selectObjectCSVInputSerialization.setFieldDelimiter(fieldDelimiter);
    selectObjectCSVInputSerialization.setComments(COMMENTS_CHAR_STR);
    selectObjectCSVInputSerialization.setQuoteCharacter(quoteChar);
    selectObjectCSVInputSerialization.setQuoteEscapeCharacter(escapeChar);

    InputSerialization selectObjectInputSerialization = new InputSerialization();
    selectObjectInputSerialization.setCompressionType(getCompressionType(path));
    selectObjectInputSerialization.setCsv(selectObjectCSVInputSerialization);
    selectObjectRequest.setInputSerialization(selectObjectInputSerialization);

    OutputSerialization selectObjectOutputSerialization = new OutputSerialization();
    CSVOutput selectObjectCSVOutputSerialization = new CSVOutput();
    selectObjectCSVOutputSerialization.setRecordDelimiter(lineDelimiter);
    selectObjectCSVOutputSerialization.setFieldDelimiter(fieldDelimiter);
    selectObjectCSVOutputSerialization.setQuoteCharacter(quoteChar);
    selectObjectCSVOutputSerialization.setQuoteEscapeCharacter(escapeChar);
    selectObjectOutputSerialization.setCsv(selectObjectCSVOutputSerialization);
    selectObjectRequest.setOutputSerialization(selectObjectOutputSerialization);

    return selectObjectRequest;
}
 
Example #4
Source File: S3SelectAccessor.java    From pxf with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a {@link com.amazonaws.services.s3.model.CSVInput}
 * object with parsed values from the request context.
 *
 * @param context the request context
 * @return a {@link CSVInput}
 */
CSVInput getCSVInput(RequestContext context) {
    CSVInput csvInput = new CSVInput();
    GreenplumCSV csv = context.getGreenplumCSV();

    String fileHeaderInfo = context.getOption(FILE_HEADER_INFO);
    if (fileHeaderInfo != null) {
        LOG.debug("With CSV FileHeaderInfo '{}'", fileHeaderInfo);
        csvInput.setFileHeaderInfo(fileHeaderInfo);
    }

    if (csv.getDelimiter() != null) {
        LOG.debug("With CSV field delimiter '{}'", csv.getDelimiter());
        csvInput.setFieldDelimiter(csv.getDelimiter());
    }

    if (csv.getNewline() != null) {
        LOG.debug("With CSV NEWLINE '{}'", csv.getNewline());
        csvInput.setRecordDelimiter(csv.getNewline());
    }

    if (csv.getEscape() != null) {
        LOG.debug("With CSV quote escape character '{}'", csv.getEscape());
        csvInput.setQuoteEscapeCharacter(csv.getEscape());
    }

    LOG.debug("With CSV quote character '{}'", csv.getQuote());
    csvInput.setQuoteCharacter(csv.getQuote());

    return csvInput;
}