-
Notifications
You must be signed in to change notification settings - Fork 104
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
Support UDF in planner #2995
base: main
Are you sure you want to change the base?
Support UDF in planner #2995
Conversation
This reverts commit 3a5a44b.
Result of fdb-record-layer-pr on Linux CentOS 7
|
Result of fdb-record-layer-pr on Linux CentOS 7
|
fdb-record-layer-core/src/main/java/com/apple/foundationdb/record/metadata/Key.java
Show resolved
Hide resolved
...-core/src/test/java/com/apple/foundationdb/record/query/plan/cascades/MacroFunctionTest.java
Show resolved
Hide resolved
@@ -20,9 +20,9 @@ | |||
|
|||
package com.apple.foundationdb.relational.util; | |||
|
|||
import com.apple.foundationdb.annotation.API; | |||
import static com.apple.foundationdb.record.expressions.RecordKeyExpressionProto.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use static import to make file more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkstyle doesn't allow "*" in imports, reverted the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can static import them separately. Sometimes, IntelliJ is configured to group them into a *
import.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, but unfortunately build still fails because checkStyle doesn't allow * in import lines.
return MacroFunction.fromProto(serializationContext, proto.getMacroFunction()); | ||
} else { | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can add more if
blocks when we have more items in the oneof
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do dynamic dispatch in a follow-up PR
} | ||
|
||
@Nonnull | ||
public static MacroFunction fromProto(@Nonnull final PlanSerializationContext serializationContext, @Nonnull final PMacroFunctionValue functionValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that I can inject serializationContext with @autoservice, but this method is called from RecordMetaDataBuilder
, which doesn't have serializationContext
injected. So it seems that I'll need to create a serializationContext
in RecordMetaDataBuilder
and pass it to MacroFunction.fromProto
anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The context is normally used to do dynamic dispatch among the implementing classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. will do it in a follow-up PR.
*/ | ||
public class MacroFunction implements SerializableFunction { | ||
@Nonnull | ||
private final String functionName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All functions will have this in common:
- function name
- declared parameters (types at least)
- return type
Can you move that up into SerializableFunction
? You can give SerializableFunction
the appropriate getters forcing all implementors to provide methods for them. As a second step, have an abstract base class implementing SerializableFunction
. Let's call that AbstractCatalogedFunction
. All your methods extends from that. It's the same approach Value
, and AbstractValue
(for instance) have taken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, restructured the code.
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public interface SerializableFunction { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be called something that encompasses more than just serialization. I had suggested CatalogedFunction
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discussed offline, renamed.
* limitations under the License. | ||
*/ | ||
|
||
package com.apple.foundationdb.record.metadata; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach you have taken is not what I had in mind:
BuiltInFunction
should give up most of its attributes/functionality, encapsulation to this class. Only the encapsulation lambda should stay that is used to implement theencapsulate()
method.BuiltInFunction
should be THE base for all internal functions that are not domain specific (likelength(string)
or similar).MacroFunction
should be extending this class and adding the functionality that you coded up to expand an arbitrary body
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discussed offline, restructured the code.
} | ||
|
||
@Nonnull | ||
public static MacroFunction fromProto(@Nonnull final PlanSerializationContext serializationContext, @Nonnull final PMacroFunctionValue functionValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The context is normally used to do dynamic dispatch among the implementing classes.
} | ||
|
||
@Nullable | ||
public static UserDefinedFunction fromProto(@Nonnull PlanSerializationContext serializationContext, @Nonnull RecordMetaDataProto.UserDefinedFunction proto) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can autoservice the extends for UserDefinedFunction
and then call the appropriate dispatch routine using the serialization context. We currently do this for Value
, RecordQueryPlan
, and for Type
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do the dispatch in a follow-up PR.
No description provided.