如何在具有相同架构的GCS中附加文件? [英] How to append files in GCS with the same schema?

查看:37
本文介绍了如何在具有相同架构的GCS中附加文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以在GCS中附加两个文件,假设一个文件已满加载,第二个文件是增量加载.那我们可以追加什么方式这两个吗?
其次,使用gsutil compose将追加两个文件,包括属性以及名字.因此,在最终文件中,我需要两个文件的数据.

Is there any way one can append two files in GCS, suppose file one is a full load and second file is an incremental load. Then what's the way we can append the two?
Secondly, using gsutil compose will append the two files including the attributes names as well. So, in the final file I want the data of the two files.

推荐答案

您可以附加两个单独的文件在Google Cloud Shell中使用 compose 并将输出文件重命名为第一个文件,如下所示:

You can append two separate files using compose in the Google Cloud Shell and rename the output file as the first file, like this:

gsutil compose gs://bucket/obj1 [gs://bucket/obj2 ...] gs://bucket/obj1

此命令用于并行上传,在并行上传中,您将较大的对象文件划分为较小的对象.它们被上传到Google Cloud Storage,然后您可以附加它们以获取原始文件.您可以在复合对象和并行上传中找到更多信息.

This command is meant for parallel uploads in which you divide a large object file in smaller objects. They get uploaded to Google Cloud Storage and then you can append them to get the original file. You can find more information on Composite Objects and Parallel Uploads.

我提出了两种可能的解决方案:

I've come up with two possible solutions:

我要使用的选项是使用Cloud Function.进行如下操作:

The option I would go for is using a Cloud Function. Doing something like the following:

  1. 创建一个空的存储桶,例如append_bucket.
  2. 上传第一个文件.
  3. 将Cloud Function创建为由新触发器触发上传的文件在桶.
  4. 上传第二个文件.
  5. 读取第一个和第二个文件(您必须

    Google Dataflow解决方案

    您也可以使用

    Google Dataflow solution

    You can also do it with Dataflow for BigQuery (keep in mind it’s still in beta).

    1. 创建BigQuery数据集和表.
    2. 创建一个数据流实例,从模板云存储文本"到BigQuery.
    3. 使用用于转换文本的逻辑来创建Javascript文件.
    4. 将Json格式的文件上传到存储桶中.
    5. 数据流将读取Json文件,执行Java代码并将新数据附加到BigQuery数据集.
    6. 最后,将BigQuery查询结果导出到Cloud Storage.

    这篇关于如何在具有相同架构的GCS中附加文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆