Skip to content

Commit

Permalink
Added compiler for aggregation functions.
Browse files Browse the repository at this point in the history
Added the necessary parts for compiling a user-defined aggregation function
from a java class.
  • Loading branch information
pontusmelke committed Dec 12, 2016
1 parent e2a5175 commit 207ff6a
Show file tree
Hide file tree
Showing 8 changed files with 1,206 additions and 44 deletions.
Expand Up @@ -24,13 +24,13 @@
public interface CallableUserAggregationFunction public interface CallableUserAggregationFunction
{ {
UserFunctionSignature signature(); UserFunctionSignature signature();
Aggregator create( Context ctx ); Aggregator create( Context ctx ) throws ProcedureException;


interface Aggregator interface Aggregator
{ {
void update( Object[] input ) throws ProcedureException; void update( Object[] input ) throws ProcedureException;


Object result(); Object result() throws ProcedureException;
} }




Expand Down
Expand Up @@ -33,25 +33,25 @@
/** /**
* Injects annotated fields with appropriate values. * Injects annotated fields with appropriate values.
*/ */
public class FieldInjections class FieldInjections
{ {
private final ComponentRegistry components; private final ComponentRegistry components;


public FieldInjections( ComponentRegistry components ) FieldInjections( ComponentRegistry components )
{ {
this.components = components; this.components = components;
} }


/** /**
* On calling apply, injects the `value` for the field `field` on the provided `object`. * On calling apply, injects the `value` for the field `field` on the provided `object`.
*/ */
public static class FieldSetter static class FieldSetter
{ {
private final Field field; private final Field field;
private final MethodHandle setter; private final MethodHandle setter;
private final ComponentRegistry.Provider<?> provider; private final ComponentRegistry.Provider<?> provider;


public FieldSetter( Field field, MethodHandle setter, ComponentRegistry.Provider<?> provider ) FieldSetter( Field field, MethodHandle setter, ComponentRegistry.Provider<?> provider )
{ {
this.field = field; this.field = field;
this.setter = setter; this.setter = setter;
Expand Down Expand Up @@ -79,7 +79,7 @@ void apply( org.neo4j.kernel.api.proc.Context ctx, Object object ) throws Proced
* @return A list of `FieldSetters` * @return A list of `FieldSetters`
* @throws ProcedureException if the type of the injected field does not match what has been registered. * @throws ProcedureException if the type of the injected field does not match what has been registered.
*/ */
public List<FieldSetter> setters( Class<?> cls ) throws ProcedureException List<FieldSetter> setters( Class<?> cls ) throws ProcedureException
{ {
List<FieldSetter> setters = new LinkedList<>(); List<FieldSetter> setters = new LinkedList<>();
Class<?> currentClass = cls; Class<?> currentClass = cls;
Expand Down

0 comments on commit 207ff6a

Please sign in to comment.