Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Put with secondary indices #13289

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ltamasi
Copy link
Contributor

@ltamasi ltamasi commented Jan 10, 2025

Summary: The patch adds support for Put / PutUntracked to the secondary indexing logic. Similarly to PutEntity (see #13180), calling these APIs automatically add or remove secondary index entries as needed in an atomic and transparent fashion.

Differential Revision: D68035089

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68035089

ltamasi added a commit to ltamasi/rocksdb that referenced this pull request Jan 10, 2025
Summary:

The patch adds support for `Put` / `PutUntracked` to the secondary indexing logic. Similarly to `PutEntity` (see facebook#13180), calling these APIs automatically add or remove secondary index entries as needed in an atomic and transparent fashion.

Differential Revision: D68035089
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68035089

Summary:

The patch adds support for `Put` / `PutUntracked` to the secondary indexing logic. Similarly to `PutEntity` (see facebook#13180), calling these APIs automatically add or remove secondary index entries as needed in an atomic and transparent fashion.

Differential Revision: D68035089
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D68035089

ltamasi added a commit to ltamasi/rocksdb that referenced this pull request Jan 10, 2025
Summary:

The patch adds support for `Put` / `PutUntracked` to the secondary indexing logic. Similarly to `PutEntity` (see facebook#13180), calling these APIs automatically add or remove secondary index entries as needed in an atomic and transparent fashion.

Differential Revision: D68035089
typename AddPrimaryEntry>
Status PutlikeWithSecondaryIndices(ColumnFamilyHandle* column_family,
const Slice& key,
const Valuelike& valuelike,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Not sure if there could be a better name. I've seenValueOrWideColumns in another place and wondering if we can be a bit more explicit like the other place.

std::string LDBCommand::PrintKeyValueOrWideColumns(

(And name the function PutWithSecondaryIndicesImpl or something)

@@ -403,11 +411,9 @@ class SecondaryIndexMixin : public Txn {
}
}

auto primary_columns = get_primary_columns(valuelike);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm trying to understand the benefit of using template and combining code for plain value + wide columns.

If the value is a plain text slice, this will be guaranteed to a single column and FindPrimaryColumn won't be really necessary, right? We may just check if column's name is secondary_index->GetPrimaryColumnName().

I'm wondering if it's actually a bit simpler to have two different functions, one for slice value and one for WideColumns. And same for UpdatePrimaryColumnValues() that one takes a single column and the other multiple. Having Valuelike won't be necessary, too.


constexpr bool assume_tracked = true;

return Txn::PutEntity(cfh, primary_key, primary_columns,
Copy link
Contributor

Choose a reason for hiding this comment

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

At this point, I believe that primary_columns are already copied, sorted and updated with the index. IIUC, Tx::PutEntity() uses WriteBatch::PutEntity() and we copy the columns and sort them again. Wondering if we can avoid doing that or I am misunderstanding something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants