public class Fluid extends java.lang.Object
AssemblyBuilder.Start builder = Fluid.assembly();Next a branch must be started:
Pipe pipe = builder.startBranch( "rhs" ) .groupBy( Fields.ALL ) .every( Fields.ALL ).aggregator( new Count() ).outgoing( Fields.ALL ) .completeGroupBy() .each( Fields.ALL ).filter( new RegexFilter( "" ) ) .coerce().coerceFields( Fields.fields( "foo", int.class ) ).end() .completeBranch();Note
completeBranch()
is a factory, it will return a Pipe
instance. Also note
the assembly builder is stateful, and will keep the return Pipe as a known assembly tail.
fields(Comparable[])
is a convenience for new Fields("...")
. Type Fields itself also has many fluent helper
methods, for example Fluid.fields( "average").applyTypes(long.class);
Calling:
Pipe[] tails = assembly.completeAssembly();Will return a
Pipe[]
with a single entry, the same called from the completeBranch()
call
previously.
To begin a join, two or more pipes will need to be created prior to the next call:
Pipe lhsUpperLower = assembly .startHashJoin() .lhs( pipeLhs ).lhsJoinFields( fields( "num" ) ) .rhs( upperLower ).rhsJoinFields( fields( "numUpperLower" ) ) .declaredFields( fields( "numLhs", "charLhs", "numUpperLower", "charUpperLower", "num2UpperLower", "char2UpperLower" ) ) .createHashJoin();This is a factory and must be added to the assembly via:
lhsUpperLower = assembly .continueBranch( lhsUpperLower ) .each( Fields.ALL ).function ( function().Identity().fieldDeclaration( Fields.ALL ).end() ) .outgoing( Fields.RESULTS ) .completeBranch();If the two given pipes (
pipeLhs
and pipeRhs
) were previously tails
in the assembly, they will be no longer tails within the assembly, replaced by the result of completeBranch()
.
Finally notice in the above code, function()
is used to create a new Function
for use in the assembly.
In the first example at the top, new Count()
was called. This call could have
been replaced with function().Count().end()
.
AggregateBy sub-classes also have factory helpers than can be used when adding a base
AggregateBy
to the pipe assembly.
Pipe rhs = builder .startBranch( "rhs" ) .aggregateBy() .groupingFields( fields( "grouping" ) ) .assemblies ( Fluid.aggregateBy().AverageBy().valueField( fields( "value" ) ).averageField( fields( "average" ) ).end(), Fluid.aggregateBy().SumBy().valueField( fields( "value" ) ).sumField( fields( "sum", long.class ) ).end() ) .end() // end aggregateBy builder .completeBranch();
Modifier and Type | Method and Description |
---|---|
static AggregateByBuilder<java.lang.Void> |
aggregateBy()
Method aggregateBy returns a new
AggregateBy factory builder. |
static AggregatorBuilder<java.lang.Void> |
aggregator()
Method aggregator returns a new
Aggregator factory builder. |
static AssemblyBuilder.Start |
assembly()
Method assembly returns a new assembly builder.
|
static BufferBuilder<java.lang.Void> |
buffer()
Method buffer returns a new
Aggregator factory builder. |
static Fields |
fields(java.lang.Comparable... fields)
Method fields is a convenience helper factory for creating a new
Fields instance. |
static Fields |
fields(java.lang.Comparable field,
java.lang.reflect.Type type)
Method fields is a convenience helper factory for creating a new
Fields instance. |
static FilterBuilder<java.lang.Void> |
filter()
Method filter returns a new
Filter factory builder. |
static FunctionBuilder<java.lang.Void> |
function()
Method function returns a new
Function factory builder. |
static GroupAssertionBuilder<java.lang.Void> |
groupAssertion()
Method groupAssertion returns a new
GroupAssertion factory builder. |
static ValueAssertionBuilder<java.lang.Void> |
valueAssertion()
Method valueAssertion returns a new
ValueAssertion factory builder. |
public static Fields fields(java.lang.Comparable... fields)
Fields
instance.
The Fields class is also fluent, so adding types to the result is as simple as calling
Fields.applyTypes(java.lang.reflect.Type...)
.fields
- is a set of integer ordinals or field names.Fields
public static Fields fields(java.lang.Comparable field, java.lang.reflect.Type type)
Fields
instance.field
- is a an integer ordinal or field name.type
- is the Type of the given fieldFields
public static AssemblyBuilder.Start assembly()
S053a82dabe5b75f103bff8687568d2d4.startBranch(String)
.
To complete the current branch, call completeBranch()
on the builder.
To complete the assembly, call S053a82dabe5b75f103bff8687568d2d4.completeAssembly()
.public static FunctionBuilder<java.lang.Void> function()
Function
factory builder.
Unlike the assembly builder, a Function factory builder provides a simple api for constructing
known Function types, that should ba added after an each()
builder method is called.
Factory builders retain no internal state, and can be shared and re-used across assembly builders.Function
public static FilterBuilder<java.lang.Void> filter()
Filter
factory builder.
Unlike the assembly builder, a Filter factory builder provides a simple api for constructing
known Filter types, that should ba added after an each()
builder method is called.
Factory builders retain no internal state, and can be shared and re-used across assembly builders.Filter
public static AggregatorBuilder<java.lang.Void> aggregator()
Aggregator
factory builder.
Unlike the assembly builder, a Aggregator factory builder provides a simple api for constructing
known Aggregator types, that should ba added after an every()
builder method is called.
Factory builders retain no internal state, and can be shared and re-used across assembly builders.Aggregator
public static BufferBuilder<java.lang.Void> buffer()
Aggregator
factory builder.
Unlike the assembly builder, a Buffer factory builder provides a simple api for constructing
known Buffer types, that should ba added after an every()
builder method is called.
Factory builders retain no internal state, and can be shared and re-used across assembly builders.Buffer
public static ValueAssertionBuilder<java.lang.Void> valueAssertion()
ValueAssertion
factory builder.
Unlike the assembly builder, a ValueAssertion factory builder provides a simple api for constructing
known ValueAssertion types, that should ba added after an each()
builder method is called.
Factory builders retain no internal state, and can be shared and re-used across assembly builders.ValueAssertion
public static GroupAssertionBuilder<java.lang.Void> groupAssertion()
GroupAssertion
factory builder.
Unlike the assembly builder, a GroupAssertion factory builder provides a simple api for constructing
known GroupAssertion types, that should ba added after an every()
builder method is called.
Factory builders retain no internal state, and can be shared and re-used across assembly builders.GroupAssertion
public static AggregateByBuilder<java.lang.Void> aggregateBy()
AggregateBy
factory builder.
Unlike the assembly builder, an AggregateBy factory builder provides a simple api for constructing
known AggregateBy sub-types that should be passed to a parent AggregateBy
for
concurrent aggregation of multiple values.
Factory builders retain no internal state, and can be shared and re-used across assembly builders.AggregateBy
Copyright © 2007-2017 Xplenty, Inc. All Rights Reserved.