Skip to content

Conversation

@justfortaste
Copy link

@justfortaste justfortaste commented Jul 10, 2018

Support secondary clustering key in MyRocks

 Support new syntax
      create table t1(c1 int priamry key, c2 int clustering, c3 int) engine=rocksdb;
      alter table t1 add clustering key idx1(c3);

 New clustering key row layout as follows, PK and SK has not changed
    1) CK (secondary cluster key)
      key: index_id + ck_cols + pk_cols
      value: [TTL] +  NULL-bitmap + unpack_info + other_cols

    2) PK (primary key)
      key: index_id + pk_cols
      value: [TTL] +  NULL-bitmap + unpack_info + other_cols

    3) SK (ordinary sencordary key)
      key: index_id + sk_cols + pk_cols
      value: [unpack_info (TTL is in unpack_info, TTL_FLAG)
@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

Copy link
Contributor

@laurynas-biveinis laurynas-biveinis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The syntax and server parts of the patch appear to be based on the Percona Server TokuDB clustering key support, which appears to be a good idea from future compatibility point of view

bugfix: when add clustring index, we also need call
  convert_ck_record_to_storage_formatto set values

clean ttl relative code, then ttl layout in index as follows

1) PK
  key: index_id + pk_cols
  value: [TTL] +  NULL-bitmap + unpack_info + other_cols

2) CK
  key: index_id + ck_cols + pk_cols
  value: [TTL] +  NULL-bitmap + unpack_info + other_cols

3) SK
  key: index_id + sk_cols + pk_cols
  value: unpack_info (TTL is in unpack_info, TTL_FLAG)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants