gpAux/extensions/gps3ext/src/gpwriter.cpp
// invoked by s3_export(), need to be exception safe
invoked by s3_export(), need to be exception safe
invoked by s3_export () need to be exception safe
GPWriter* writer_init(const char* url_with_options, const char* format) {
    GPWriter* writer = NULL;
    s3extErrorMessage.clear();
    try {
        if (!url_with_options) {
            return NULL;
        }
        string urlWithOptions(url_with_options);
        string url = truncate_options(urlWithOptions);
        if (url.empty()) {
            return NULL;
        }
        string config_path = get_opt_s3(urlWithOptions, "config");
        if (config_path.empty()) {
            S3ERROR("The 'config' parameter is not provided, use default value 's3/s3.conf'.");
            config_path = "s3/s3.conf";
        }
        if (!InitConfig(config_path, "default")) {
            return NULL;
        }
        CheckEssentialConfig();
        InitRemoteLog();
        string extName = s3ext_autocompress ? string(format) + ".gz" : format;
        writer = new GPWriter(url, extName);
        if (writer == NULL) {
            return NULL;
        }
        WriterParams params;
        writer->open(params);
        return writer;
    } catch (std::exception& e) {
        if (writer != NULL) {
            delete writer;
        }
        S3ERROR("writer_init caught an exception: %s", e.what());
        s3extErrorMessage = e.what();
        return NULL;
    }
}
GPWriter * writer_init ( const char * url_with_options , const char * format ) { GPWriter * writer = NULL ; s3extErrorMessage . clear ( ) ; try { if ( ! url_with_options ) { return NULL ; } string urlWithOptions ( url_with_options ) ; string url = truncate_options ( urlWithOptions ) ; if ( url . empty ( ) ) { return NULL ; } string config_path = get_opt_s3 ( urlWithOptions , " " ) ; if ( config_path . empty ( ) ) { S3ERROR ( " " ) ; config_path = " " ; } if ( ! InitConfig ( config_path , " " ) ) { return NULL ; } CheckEssentialConfig ( ) ; InitRemoteLog ( ) ; string extName = s3ext_autocompress ? string ( format ) + " " : format ; writer = new GPWriter ( url , extName ) ; if ( writer == NULL ) { return NULL ; } WriterParams params ; writer -> open ( params ) ; return writer ; } catch ( std :: exception & e ) { if ( writer != NULL ) { delete writer ; } S3ERROR ( " " , e . what ( ) ) ; s3extErrorMessage = e . what ( ) ; return NULL ; } }
invoked by s3_export(), need to be exception safe
invoked by s3_export () need to be exception safe