mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
parent
3622d9aee1
commit
8ee9a990cc
5 changed files with 49 additions and 19 deletions
|
@ -75,3 +75,6 @@
|
|||
|
||||
# Entropy source for randomness
|
||||
-Djava.security.egd=file:/dev/urandom
|
||||
-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5006,suspend=y
|
||||
-Dorg.codehaus.janino.source_debugging.dir=/Users/brownbear/src/logstash/logs/debug
|
||||
-Dorg.codehaus.janino.source_debugging.enable=true
|
||||
|
|
|
@ -10,11 +10,9 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
final class ClassFields {
|
||||
|
||||
private final Collection<FieldDefinition> definitions;
|
||||
private final Collection<FieldDefinition> definitions = new ArrayList<>();
|
||||
|
||||
ClassFields() {
|
||||
definitions = new ArrayList<>();
|
||||
}
|
||||
private final Collection<Closure> afterInit = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Add a field of given type that is initialized by the given {@link SyntaxElement} that will
|
||||
|
@ -48,6 +46,14 @@ final class ClassFields {
|
|||
return addField(FieldDefinition.mutableUnassigned(definitions.size(), type));
|
||||
}
|
||||
|
||||
public void addAfterInit(final Closure closure) {
|
||||
afterInit.add(closure);
|
||||
}
|
||||
|
||||
public Closure afterInit() {
|
||||
return Closure.wrap(afterInit.toArray(new Closure[0]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the subset of fields that are assigned in the constructor.
|
||||
* @return Subset of fields to be assigned by the constructor
|
||||
|
|
|
@ -204,7 +204,10 @@ public final class ComputeStepSyntaxElement<T extends Dataset> implements Syntax
|
|||
ctor.add(argVar);
|
||||
}
|
||||
}
|
||||
return combine(ctorFields, MethodSyntaxElement.constructor(name, constructor, ctor));
|
||||
return combine(
|
||||
ctorFields,
|
||||
MethodSyntaxElement.constructor(name, constructor.add(fields.afterInit()), ctor)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -72,9 +72,21 @@ public final class DatasetCompiler {
|
|||
final ValueSyntaxElement elseData = fields.add(RubyArray.class, arrayInit);
|
||||
final ValueSyntaxElement buffer = fields.add(RubyArray.class, arrayInit);
|
||||
final ValueSyntaxElement done = fields.add(boolean.class);
|
||||
final ValueSyntaxElement right = fields.add(DatasetCompiler.Complement.class);
|
||||
final VariableDefinition event =
|
||||
new VariableDefinition(JrubyEventExtLibrary.RubyEvent.class, "event");
|
||||
final ValueSyntaxElement eventVal = event.access();
|
||||
fields.addAfterInit(
|
||||
Closure.wrap(
|
||||
SyntaxFactory.assignment(right,
|
||||
SyntaxFactory.cast(
|
||||
DatasetCompiler.Complement.class, SyntaxFactory.constant(
|
||||
DatasetCompiler.class, DatasetCompiler.Complement.class.getSimpleName()
|
||||
).call("from", SyntaxFactory.THIS, elseData)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
return new ComputeStepSyntaxElement<>(
|
||||
Arrays.asList(
|
||||
MethodSyntaxElement.compute(
|
||||
|
@ -96,10 +108,15 @@ public final class DatasetCompiler {
|
|||
.add(SyntaxFactory.ret(ifData))
|
||||
),
|
||||
MethodSyntaxElement.clear(
|
||||
clearSyntax(parentFields).add(clear(ifData)).add(clear(elseData))
|
||||
.add(SyntaxFactory.assignment(done, SyntaxFactory.FALSE))
|
||||
Closure.wrap(
|
||||
SyntaxFactory.ifCondition(
|
||||
done,
|
||||
clearSyntax(parentFields).add(clear(ifData)).add(clear(elseData))
|
||||
.add(SyntaxFactory.assignment(done, SyntaxFactory.FALSE))
|
||||
)
|
||||
)
|
||||
),
|
||||
MethodSyntaxElement.right(elseData)
|
||||
MethodSyntaxElement.right(right)
|
||||
), fields, SplitDataset.class
|
||||
);
|
||||
}
|
||||
|
@ -150,8 +167,13 @@ public final class DatasetCompiler {
|
|||
body.add(SyntaxFactory.assignment(done, SyntaxFactory.TRUE))
|
||||
.add(SyntaxFactory.ret(outputBuffer)),
|
||||
Closure.wrap(
|
||||
clearSyntax(parentFields), clear(outputBuffer),
|
||||
SyntaxFactory.assignment(done, SyntaxFactory.FALSE)
|
||||
SyntaxFactory.ifCondition(
|
||||
done,
|
||||
Closure.wrap(
|
||||
clearSyntax(parentFields), clear(outputBuffer),
|
||||
SyntaxFactory.assignment(done, SyntaxFactory.FALSE)
|
||||
)
|
||||
)
|
||||
), fields
|
||||
);
|
||||
}
|
||||
|
@ -420,8 +442,10 @@ public final class DatasetCompiler {
|
|||
|
||||
@Override
|
||||
public void clear() {
|
||||
parent.clear();
|
||||
done = false;
|
||||
if (done) {
|
||||
parent.clear();
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,13 +55,7 @@ interface MethodSyntaxElement extends SyntaxElement {
|
|||
*/
|
||||
static MethodSyntaxElement right(final ValueSyntaxElement elseData) {
|
||||
return new MethodSyntaxElement.MethodSyntaxElementImpl(Dataset.class, "right",
|
||||
Closure.wrap(
|
||||
SyntaxFactory.ret(
|
||||
SyntaxFactory.constant(
|
||||
DatasetCompiler.class, DatasetCompiler.Complement.class.getSimpleName()
|
||||
).call("from", SyntaxFactory.THIS, elseData)
|
||||
)
|
||||
)
|
||||
Closure.wrap(SyntaxFactory.ret(elseData))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue