Skip to content
This repository was archived by the owner on Mar 1, 2026. It is now read-only.

[Feature] cluster key#851

Open
justfortaste wants to merge 3 commits into
facebook:fb-mysql-5.6.35from
justfortaste:feature_cluster_key
Open

[Feature] cluster key#851
justfortaste wants to merge 3 commits into
facebook:fb-mysql-5.6.35from
justfortaste:feature_cluster_key

Conversation

@justfortaste

@justfortaste justfortaste commented Jul 10, 2018

Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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

@laurynas-biveinis laurynas-biveinis left a comment

Copy link
Copy Markdown
Contributor

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 subscribe to this conversation on GitHub. Already have an account? Sign in.

3 participants