AWS Big Data - Athena presto和hive适用场景

presto和hive的一些对比   

1.本质区别
Hive是把一个查询转化成多个MapReduce任务,然后一个接一个执行。执行的中间结果通过对磁盘的读写来同步。然而,Presto没有使用MapReduce,它是通过一个定制的查询和执行引擎来完成的。它的所有的查询处理是在内存中,这也是它的性能很高的一个主要原因。
2.执行速度
presto由于是基于内存的,而hive是在磁盘上读写的,因此presto比hive快很多,但是由于是基于内存的当多张大表关联操作时易引起内存溢出错误
3.处理json类型的数据
presto处理如下:
        select 
                json_extract_scalar(xx['custom'],'$.position')
        from table

hive处理如下:
        select 
               get_json_object(xx['custom'],'$.position')
        from table

此外Presto还有一个函数json_extract是直接返回一个json串,根据需要自己需要选择函数

4.列转行
Hive
        select student, score from tests lateral view explode(split(scores, ',')) t as score;

Presto
       select student, score from tests cross json unnest(split(scores, ',') as t (score)
 

presto和hive适用场景

snail_knight关注

0.122017.05.08 22:08:12字数 593阅读 4,046

经过评测:presto的平均性能是hive的10倍

presto优点:数据源具有完全解耦,高性能,以及对ansi sql的支持特性,使得presto在etl,实时数据计算、ad-hoc查询和实时数据流分析等多个场景中能够发挥重要的作用。

 

hive和presto可以作为互补适用:

presto适合在单次扫描级别gb tb级别的数据

hive适合海量级别的数据的计算

presto分成两种场景:

基于数据快照的实时计算:

1、完成时间通常在200ms-20min

完全实时计算:

要完成实时计算,需要满足:

(1)适用的基准数据需要实时更新,时刻保持与线上的数据保持一直

(2)计算速度要够快速完成

presto基于t+1数据的计算,

在这种业务场景中,并不要求基准数据的实时更新,但要求数据查询要够快相应。

因此采用 Treasure Data 提供的基于 Presto-gres 中的 ODBC 驱动改造之后的 ODBC 驱动连接到 Presto 集群。

实时数据流分析:presto-kafka使用sql对kafka的数据进行清洗,分析和计算,在实际场景中两种使用场景:

1、保留历史数据

真实的测试过程中,Greenplum 表现并不理想,和 MySQL 对比,查询效率差了两个数量级。

为此,我们做了查询效率低效的分析,如下:

查询期间 Segment 节点 CPU 平均使用率峰值 14.67%,IO until 100%,内存使用率峰值 3.05%,网络流量峰值 0.03 Mbit/s,问题在于单机 IO 上;

导入数据时间间隔为 4 月 1 号到 4 月 25 号,而查询时间间隔同样为为 4 月 1 号到 4 月 25 号,手动做了分区消除;

分布键分布数据集中在单机,无法发挥 Greenplum 性能。

于是,我们放弃了 Greenplum 方案,原因如下:

导入数据慢;

查询执行效率低;

机器成本高,部署维护较复

 

https://dbarobin.com/2016/09/24/bi-scheme/

http://tech.dianwoda.com/2016/10/20/unt/

http://hualong.iteye.com/blog/2102798

以下是使用 aws-sdk-s3 和 Minio C++ 库在 Visual Studio 中上传和下载文件的示例代码: ```c++ #include <aws/core/Aws.h> #include <aws/s3/S3Client.h> #include <aws/s3/model/PutObjectRequest.h> #include <aws/s3/model/GetObjectRequest.h> #include <iostream> #include <fstream> #include <minio/minio.h> #include <minio/minio_io.h> using namespace Aws::S3; using namespace Aws::S3::Model; int main() { // 初始化 AWS SDK Aws::SDKOptions options; Aws::InitAPI(options); // 建立 S3 客户端 Aws::Client::ClientConfiguration config; config.scheme = Aws::Http::Scheme::HTTP; config.endpointOverride = "localhost:9000"; // Minio 服务器地址和端口 config.verifySSL = false; // 关闭 SSL 验证 S3Client s3_client(config); // 上传文件到 Minio const std::string bucket_name = "my-bucket"; const std::string object_name = "my-object"; const std::string file_path = "path/to/my/file"; std::shared_ptr<std::iostream> file_stream = std::make_shared<std::fstream>(file_path.c_str(), std::ios_base::in | std::ios_base::binary); PutObjectRequest put_request; put_request.SetBucket(bucket_name); put_request.SetKey(object_name); put_request.SetBody(file_stream); auto put_outcome = s3_client.PutObject(put_request); if (put_outcome.IsSuccess()) { std::cout << "File uploaded successfully!" << std::endl; } else { std::cout << "File upload failed: " << put_outcome.GetError().GetMessage() << std::endl; } // 下载文件从 Minio const std::string downloaded_file_path = "path/to/my/downloaded/file"; GetObjectRequest get_request; get_request.SetBucket(bucket_name); get_request.SetKey(object_name); auto get_outcome = s3_client.GetObject(get_request); if (get_outcome.IsSuccess()) { std::shared_ptr<Aws::IOStream> body_stream = get_outcome.GetResult().GetBody(); Minio::ObjectReadStream object_stream(body_stream); std::ofstream downloaded_file(downloaded_file_path, std::ios_base::out | std::ios_base::binary); downloaded_file << object_stream.rdbuf(); std::cout << "File downloaded successfully!" << std::endl; } else { std::cout << "File download failed: " << get_outcome.GetError().GetMessage() << std::endl; } // 关闭 AWS SDK Aws::ShutdownAPI(options); return 0; } ``` 请注意,此示例代码假设你已经在 Minio 上创建了一个名为 "my-bucket" 的存储桶,并且已经在本地计算机上安装了 Minio 服务器。你需要根据你的实际情况进行修改。 此外,请不要忘记在代码中包含必要的头文件,并将 AWS SDK 和 Minio C++ 库添加到项目中,并在项目属性中设置正确的库和头文件路径。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值