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

Rocks condition expr rebase #19

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

stevelorddremio
Copy link
Owner

This is equivalent to the external PR that will be posted to project-nessie with RocksDB rebase and condition expression handling.

@@ -35,12 +35,6 @@
<artifactId>nessie-versioned-tiered-impl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>

Choose a reason for hiding this comment

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

Do you know why this was done? Given that this is a Rocks patch, we should probably only change Rocks related items unless it's clearly denoted.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm really not sure where this crept in. I have reverted this change.

*/
@Immutable
abstract class Function {
static final String EQUALS = "equals";

Choose a reason for hiding this comment

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

I thought @tifflhl changed this into an enum?

Copy link
Owner Author

Choose a reason for hiding this comment

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

She did but that patch didn't get in before I did the refactor. Should I apply her change to this branch?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I'm applying this change.

final ExpressionPath.PathSegment pathSegment = function.getPath().getRoot().getChild().orElse(null);
if (pathSegment == null) {
return toEntity(stream).equals(function.getValue());
} else { // compare complete list

Choose a reason for hiding this comment

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

Can collapse this into an else if

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes, collapsed.

* @param function the condition to check
* @return true if the condition is met
*/
public abstract boolean evaluateFunction(Function function);

Choose a reason for hiding this comment

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

Any reason not to just call this evaluate() ?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Agreed to just have an overloaded method name.

* @param function the function to evaluate against id.
* @return true if the id meets the function condition
*/
boolean idEvaluates(Function function) {

Choose a reason for hiding this comment

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

You'll probably get a comment about the name here, but I don't know a better name.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Maybe to swap the name around evaluatesId ?

Choose a reason for hiding this comment

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

Sure, please do so.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done

}

@Override
public Function visit(ExpressionFunction value) {

Choose a reason for hiding this comment

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

I bet we'll get comments on the fact that the visitors really only have a single case for both. It does make me wonder if we should use the visitors at all, since you already know what you're dealing with?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I think it is worth waiting then refactoring if there are comments, and there will be comments.

if (function.getRootPathAsNameSegment().getChild().isPresent()) {
return false;
}
if (function.getOperator().equals(Function.EQUALS)) {

Choose a reason for hiding this comment

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

Why not using else if here, like below?

Copy link
Owner Author

Choose a reason for hiding this comment

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

I see your point. else if it is.

} else if (identifier.equals("t")) {
return TAG;
} else {
throw new IllegalArgumentException(String.format("Unknown identifier name [%s].", identifier));

Choose a reason for hiding this comment

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

Should this say: Unknown Type name?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Yes, except I'll keep Type lowercase.

throw new IllegalStateException("branch()/tag() has already been called");
}
type = Type.TAG;
// TODO: Do we need to serialize ref type?

Choose a reason for hiding this comment

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

@stevelorddremio should this still be here?

Copy link
Owner Author

@stevelorddremio stevelorddremio Feb 14, 2021

Choose a reason for hiding this comment

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

No. Removed.

return random.ints('a', 'z' + 1)
.limit(numChars)
.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
.toString();
}

Choose a reason for hiding this comment

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

Can you revert the move of createStringEntity?

Copy link
Owner Author

Choose a reason for hiding this comment

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

Done.

@codecov-io
Copy link

Codecov Report

Merging #19 (47c23bb) into main (bf8994c) will decrease coverage by 14.83%.
The diff coverage is 75.91%.

Impacted file tree graph

@@              Coverage Diff              @@
##               main      #19       +/-   ##
=============================================
- Coverage     84.73%   69.89%   -14.84%     
- Complexity        0      294      +294     
=============================================
  Files            11      229      +218     
  Lines           871     9047     +8176     
  Branches        124      878      +754     
=============================================
+ Hits            738     6323     +5585     
- Misses           93     2261     +2168     
- Partials         40      463      +423     
Flag Coverage Δ Complexity Δ
java 68.30% <75.91%> (?) 0.00 <171.00> (?)
python 84.73% <ø> (ø) 0.00 <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ Complexity Δ
...rojectnessie/versioned/mongodb/MongoBaseValue.java 88.63% <ø> (ø) 15.00 <0.00> (?)
.../org/projectnessie/versioned/rocksdb/Function.java 37.50% <37.50%> (ø) 4.00 <4.00> (?)
...rg/projectnessie/versioned/rocksdb/RocksValue.java 44.44% <44.44%> (ø) 3.00 <3.00> (?)
...ctnessie/versioned/rocksdb/RocksDBStoreConfig.java 50.00% <50.00%> (ø) 1.00 <1.00> (?)
...tnessie/versioned/rocksdb/RocksCommitMetadata.java 66.66% <66.66%> (ø) 5.00 <5.00> (?)
...projectnessie/versioned/rocksdb/RocksFragment.java 68.96% <68.96%> (ø) 8.00 <8.00> (?)
...tnessie/versioned/rocksdb/RocksDBValueVisitor.java 70.83% <70.83%> (ø) 8.00 <8.00> (?)
...rojectnessie/versioned/rocksdb/RocksBaseValue.java 73.58% <73.58%> (ø) 24.00 <24.00> (?)
.../projectnessie/versioned/rocksdb/RocksDBStore.java 74.17% <74.17%> (ø) 41.00 <41.00> (?)
...a/org/projectnessie/versioned/rocksdb/RocksL1.java 78.26% <78.26%> (ø) 17.00 <17.00> (?)
... and 224 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf8994c...47c23bb. Read the comment docs.

assertEquals("list_append(p0, :v0)", v0p.asString());
assertEquals(AttributeValueUtil.fromEntity(av0), c.getAttributesValues().get(":v0").l().get(0));
}

@Test

Choose a reason for hiding this comment

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

Finally figured out why this is removed. It's odd that this is removed here when AddClause isn't removed in this patch but by a different one, I think you should revert changes to this file.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Reverted back to main version

@@ -28,4 +30,144 @@
protected long getRandomSeed() {
return 8612341233543L;
}

@Test

Choose a reason for hiding this comment

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

Do you know why these are here when nothing has changed for MongoDB Store? I think the changes to this file should all be removed.

Copy link
Owner Author

@stevelorddremio stevelorddremio Feb 15, 2021

Choose a reason for hiding this comment

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

This is because I merged in the putConditional and deleteConditional tests to AbstractTestStore in the Rocks ConditionExpression branches. As mongo does not have this implemented in my branch I update TestMongoDBStore to disable these test. I see you the AbstractTestStore patch merged to main subsequently nested the AbstractTestStore tests and disabled the parent tests for mongo. So reverting this change in my branch brings it in line with that design approach.

* @param function the function to evaluate against id.
* @return true if the id meets the function condition
*/
boolean idEvaluates(Function function) {

Choose a reason for hiding this comment

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

Sure, please do so.

final byte[] value = getAndCheckValue(transaction, columnFamilyHandle, id, operation);
final RocksBaseValue<C> consumer = RocksSerDe.getConsumer(type);
RocksSerDe.deserializeToConsumer(type, value, consumer);
if (!(consumer.evaluate(translate(condition.get())))) {

Choose a reason for hiding this comment

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

Nit: remove the extra braces here.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Removed

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.

4 participants