Skip to content

Comments

CASSANALYTICS-121: Assign data file start offset based on BTI index#173

Open
lukasz-antoniak wants to merge 1 commit intoapache:trunkfrom
lukasz-antoniak:CASSANALYTICS-121
Open

CASSANALYTICS-121: Assign data file start offset based on BTI index#173
lukasz-antoniak wants to merge 1 commit intoapache:trunkfrom
lukasz-antoniak:CASSANALYTICS-121

Conversation

@lukasz-antoniak
Copy link
Member

Copy link
Contributor

@yifan-c yifan-c left a comment

Choose a reason for hiding this comment

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

Thanks for the patch!
Please also update CHANGES.txt

Comment on lines 152 to 155
if (position.size() == 1)
{
offset.set(position.get(0).lowerPosition);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. nit: rename to positions?
  2. When the positions size is not 1, it is simply ignored. It is expected? If so, please make a comment

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

try
{
// Loading data file is required by BtiTableReader.
// Migrate to org.apache.cassandra.io.sstable.format.SSTableReader#getApproximatePositionsForRanges
Copy link
Contributor

Choose a reason for hiding this comment

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

I cannot find the method in Cassandra trunk a9ee34b62d977893380b0b753c25b2b0aa68fa11. Is it from an unmerged patch in Cassandra?
How about filing a JIRA (in Analytics) and comment here to not forget?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is available in DS distribution. Registered CASSANALYTICS-123 and removed the comment.

Comment on lines 145 to 147
Token tokenStart = TokenUtils.bigIntegerToToken(metadata.partitioner, tokenRange.lowerEndpoint());
Token tokenEnd = TokenUtils.bigIntegerToToken(metadata.partitioner, tokenRange.upperEndpoint());
Range<Token> range = new Range<>(tokenStart, tokenEnd);
Copy link
Contributor

Choose a reason for hiding this comment

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

those lines are unlikely to throw, but if it happens, the btiTableReader is not released. Can we ensure the reader is released?

{
// o.a.c.io.util.SimpleChunkReader flips the buffer, so position should be set to the end.
dst.position(read);
dst.position(Math.min(read, dst.limit()));
Copy link
Contributor

Choose a reason for hiding this comment

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

When read can be greater than dst.limit()? A bit concerned the guard masks some true bug, if Math.min is necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

If I think about it again, you might be right. Wanted to be more defensive coding, but this should not happen. This is a NIT outside scope of this PR. I have observed it only when testing with DS Cassandra, not OSS. Reverting.

throw new UnsupportedOperationException("Unexpected token type: " + token.getClass().getName());
}

public static Token bigIntegerToToken(final IPartitioner partitioner, final BigInteger token)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove final.

The method seem to be unused?

Copy link
Member Author

Choose a reason for hiding this comment

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

IntelliJ does not see it at first, because the class is present in cassandra-four-zero-types module. cassandra-five-zero-types is based on cassandra-four-zero-types, but class body does not change. Executing a Gradle build fixes the problem.

Patched by Lukasz Antoniak; Reviewed by Yifan Cai for CASSANALYTICS-121
@lukasz-antoniak
Copy link
Member Author

@yifan-c, thank you for quick review. PR ready for a second round. CI in progress.

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