Skip to content

Commit

Permalink
Fix OperatorRun allocation
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso committed Jan 9, 2025
1 parent f727005 commit f06256f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class OpAccumulatorClosure extends OpClosure {
}

@Override
protected OperatorRun runInstance() {
protected OperatorRun allocateRun() {
return getPreviousRun()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class OpClosure extends Closure implements OpContext {

private final Closure target

private final ThreadLocal<OperatorRun> runPerThread = ThreadLocal.withInitial(()->new OperatorRun())
private final ThreadLocal<OperatorRun> runPerThread = new ThreadLocal<>()

private final Map<String,OperatorRun> holder = new ConcurrentHashMap<>()

Expand Down Expand Up @@ -96,16 +96,17 @@ class OpClosure extends Closure implements OpContext {
target.setProperty(propertyName, newValue)
}

protected OperatorRun runInstance() {
final result = runPerThread.get()
protected OperatorRun allocateRun() {
final result = new OperatorRun()
runPerThread.set(result)
setPreviousRun(result)
return result
}

@Override
Object call(final Object... args) {
// when the accumulator flag true, re-use the previous run object
final OperatorRun run = runInstance()
final OperatorRun run = allocateRun()
// map the inputs
final List<Object> inputs = Prov.getTracker().receiveInputs(run, Arrays.asList(args))
final Object result = InvokerHelper.invokeMethod(target, "call", inputs.toArray())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ProvTest extends Dsl2Spec {
upstream.first.name == 'p1'
}

def 'should branch two process'() {
def 'should track provenance with branch operator'() {

when:
dsl_eval(globalConfig(), '''
Expand Down Expand Up @@ -258,7 +258,7 @@ class ProvTest extends Dsl2Spec {

}

def 'should track provenance two processes and the filter operator'() {
def 'should track provenance with filter operator'() {

when:
dsl_eval(globalConfig(), '''
Expand Down

0 comments on commit f06256f

Please sign in to comment.