Skip to content

CASSANDRA-20349 Accord: Serialization Improvements#3910

Merged
belliottsmith merged 1 commit intoapache:cep-15-accordfrom
belliottsmith:cleanup-14feb25
Feb 22, 2025
Merged

CASSANDRA-20349 Accord: Serialization Improvements#3910
belliottsmith merged 1 commit intoapache:cep-15-accordfrom
belliottsmith:cleanup-14feb25

Conversation

@belliottsmith
Copy link
Copy Markdown
Contributor

Thanks for sending a pull request! Here are some tips if you're new here:

  • Ensure you have added or run the appropriate tests for your PR.
  • Be sure to keep the PR description updated to reflect all changes.
  • Write your PR title to summarize what this PR proposes.
  • If possible, provide a concise example to reproduce the issue for a faster review.
  • Read our contributor guidelines
  • If you're making a documentation change, see our guide to documentation contribution

Commit messages should follow the following format:

<One sentence description, usually Jira title or CHANGES.txt summary>

<Optional lengthier description (context on patch)>

patch by <Authors>; reviewed by <Reviewers> for CASSANDRA-#####

Co-authored-by: Name1 <email1>
Co-authored-by: Name2 <email2>

The Cassandra Jira

@belliottsmith belliottsmith force-pushed the cleanup-14feb25 branch 3 times, most recently from ef15c8e to a79e262 Compare February 19, 2025 09:26
@ifesdjeen ifesdjeen self-requested a review February 19, 2025 14:33
if (buffer.remaining() < 8)
return super.readLeastSignificantBytes(bytes);

long retval = buffer.getLong(buffer.position());
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.

nit: should we add an assert it is exactly 8 bytes only?

serialize(flags, out, userVersion);
}

private void serialize(int flags, DataOutputPlus out, int userVersion) throws IOException
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.

Should we maybe use this one instead of serialize(Command command, int flags, DataOutputPlus out, int userVersion) too so that we do not have this logic twice? Essentially apply command to builder, and then serialize.

storeId = accessor.getStoreId(partitionKeyComponents);
partitionKey = accessor.getKey(partitionKeyComponents);
ByteBuffer key = partition.partitionKey().getKey();
storeId = accessor.getStoreId(key);
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.

nit: this is a static method now

else
{
int pos = dst.position() + offset;
dst.putLong(pos, register << (64 - (bytes * 8)));
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.

nit: add invariant for number of bytes?

else
{
int pos = dst.position() + offset;
return dst.getLong(pos) >>> (64 - (bytes * 8));
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.

nit: add invariant for a maximum number of bytes?

case 2: return accessor.getShort(dst, offset);
case 3:
return ((long)accessor.getShort(dst, offset) << 8)
| (long)accessor.getByte(dst, offset + 1);
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.

I think we should have + 2 here.

AccordRoutingKey end = end();
Token left = start instanceof SentinelKey ? partitioner.getMinimumToken() : start.token();
Token right = end instanceof SentinelKey ? partitioner.getMinimumToken() : end.token();
TokenKey start = start();
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.

Oh, nice. This has bothered me quite a bit, but I was not sure what SentinelKey was at that moment.

@Test
public void serde()
{
qt().withSeed(0L).forAll(fromQT(partitioners().assuming(IPartitioner::accordSupported)).flatMap(partitioner -> routingKeyGen(fromQT(CassandraGenerators.TABLE_ID_GEN), fromQT(token(partitioner)), partitioner)))
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.

nit:unhardcode seed?

}

public abstract static class AbstractRangesSerializer<RS extends AbstractRanges> implements IVersionedSerializer<RS>
// this serializer is designed to permits using the collection in its serialized form with minimal in-memory state.
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.

nit: "to permit"

final IntFunction<K[]> allocate;

public AbstractKeysSerializer(IVersionedSerializer<K> keySerializer, IntFunction<K[]> allocate)
public AbstractKeysSerializer(AccordKeySerializer<K> keySerializer, IntFunction<K[]> allocate)
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.

nit: on L553, we can use skip instead of deserialize now that skip is available

@belliottsmith belliottsmith force-pushed the cleanup-14feb25 branch 4 times, most recently from aa95eee to 568a578 Compare February 22, 2025 11:48
Improve:
 - Introduce pre/accept fast execution flags
 - Introduce searchable Deps serialization
 - Flatten AccordRoutingKey(s) into single type, using sentinel bits
 - Introduce new fast byte-comparable serialization methods for Token and TableId to support above
Fix:
 - Fix journal re-serialization logic
 - Enable RandomPartitioner for Accord by supporting fixed-width serialization for RouteIndex
@belliottsmith belliottsmith merged this pull request into apache:cep-15-accord Feb 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants