【问题标题】:How to set TTL with Cassandra COPY command如何使用 Cassandra COPY 命令设置 TTL
【发布时间】:2017-09-12 13:48:36
【问题描述】:

我可以使用COPY 命令将一大块数据导入Cassandra 表,例如:

COPY my_table (name, address) FROM my_file.csv WITH option='value' ... ;

但是当我使用COPY 命令创建表时,我希望它们具有有限的TTL 集(例如,1 天或 86400 秒)。我该怎么做?

【问题讨论】:

    标签: cassandra copy cql ttl


    【解决方案1】:

    目前没有办法做到这一点,但这将是一个有用的功能要求,因此您应该创建一个 JIRA。

    来自 cqlsh 工具的来源:

    COPY <table_name> [ ( column [, ...] ) ]
                 TO ( '<filename>' | STDOUT )
                 [ WITH <option>='value' [AND ...] ];
    
            Available options and defaults:
    
              DELIMITER=','    - character that appears between records
              QUOTE='"'        - quoting character to be used to quote fields
              ESCAPE='\'       - character to appear before the QUOTE char when quoted
              HEADER=false     - whether to ignore the first line
              NULL=''          - string that represents a null value
              ENCODING='utf8'  - encoding for CSV output (COPY TO only)
    

    bulk-loader 允许使用 TTL 进行插入,但这会增加必须为批量加载生成 sstable 的开销。

    【讨论】:

    • 谢谢。我们可以在哪里为新功能创建 Cassandra JIRA?
    • @genesco Apache jira 要求您登录。确保选择 cassandra 项目。万事如意!
    【解决方案2】:

    通过 COPY FROM 命令的 TTL 选项可以解决问题。 (注意 - 此选项仅在 Cassandra 3.2 及更高版本中可用)

    https://www.datastax.com/dev/blog/new-features-in-cqlsh-copy

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-25
      • 1970-01-01
      • 2017-11-14
      • 2015-10-10
      • 1970-01-01
      • 2014-07-02
      • 2017-02-12
      相关资源
      最近更新 更多