mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
remove ChainingOp
This commit is contained in:
parent
221939657f
commit
0d0efd12d6
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2023 nosqlbench
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* <H2>ChainingOp<I,O>: f(I) -> O<I,O></H2>
|
||||
* <P>
|
||||
* Run a function on the current cached result in the current thread and replace it
|
||||
* with the result of the function. ChainingOps are one way of invoking
|
||||
* logic within a cycle. However, they are not intended to stand alone.
|
||||
* A ChainingOp must always have an input to work on,
|
||||
* provided by either a {@link CycleOp} OR <em>another</em> call to a {@link ChainingOp}</P>
|
||||
*
|
||||
* @param <I> Some input type, as determined by a previous {@link CycleOp} or {@link ChainingOp} on the same thread.
|
||||
* @param <O> Some output type.
|
||||
*/
|
||||
public interface ChainingOp<I, O> extends Op, Function<I, O> {
|
||||
|
||||
/**
|
||||
* Transform a value from a previous action and provide the result for a subsequent action.
|
||||
*
|
||||
* @param lastResult object form a previous operation or action
|
||||
* @return a new result
|
||||
*/
|
||||
@Override
|
||||
O apply(I lastResult);
|
||||
}
|
@ -30,9 +30,6 @@ import java.util.function.LongFunction;
|
||||
* <P>This variant of {@link Op} has the ability to see the cycle
|
||||
* which was previously used to select the op implementation.</p>
|
||||
*
|
||||
* <p>It also has the ability to emit an value which can be seen a subsequent operation, if
|
||||
* and only if it is a {@link ChainingOp}s.</P>
|
||||
*
|
||||
* <h2>Designer Notes</h2>
|
||||
* <p>
|
||||
* If you are using the value in this call to select a specific type of behavior, it is very
|
||||
@ -48,7 +45,7 @@ public interface CycleOp<T> extends Op, LongFunction<T> {
|
||||
* <p>Run an action for the given cycle.</p>
|
||||
*
|
||||
* @param value The cycle value for which an operation is run
|
||||
* @return A result object which <em>may</em> be used by a subsequent {@link ChainingOp}
|
||||
* @return A result object which <em>may</em> be used by result readers or validators
|
||||
*/
|
||||
@Override
|
||||
T apply(long value);
|
||||
|
@ -27,7 +27,7 @@ package io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes;
|
||||
* the result type from your operation. In some cases preparing a result body to
|
||||
* hand down the chain is more costly, so implementing this interface allows the runtime
|
||||
* to be more optimized.</li>
|
||||
* <li>{@link ChainingOp}</li>
|
||||
*
|
||||
* <li>{@link RunnableOp}</li>
|
||||
* </ul>
|
||||
* </p>
|
||||
|
@ -25,9 +25,7 @@ public interface RunnableOp extends Op, Runnable {
|
||||
|
||||
/**
|
||||
* Invoke the operation. If you need to see the value of the current
|
||||
* cycle, then you can use {@link CycleOp} instead. If you need to
|
||||
* use a cached result of a previous operation, then you may need to
|
||||
* use {@link ChainingOp}.
|
||||
* cycle, then you can use {@link CycleOp} instead.
|
||||
*/
|
||||
@Override
|
||||
void run();
|
||||
|
@ -99,11 +99,9 @@ public class StandardAction<A extends StandardActivity<R, ?>, R extends Op> impl
|
||||
runnableOp.run();
|
||||
} else if (op instanceof CycleOp<?> cycleOp) {
|
||||
result = cycleOp.apply(cycle);
|
||||
} else if (op instanceof ChainingOp chainingOp) {
|
||||
result = chainingOp.apply(result);
|
||||
} else {
|
||||
throw new RuntimeException("The op implementation did not implement any active logic. Implement " +
|
||||
"one of [RunnableOp, CycleOp, or ChainingOp]");
|
||||
"one of [RunnableOp, CycleOp]");
|
||||
}
|
||||
// TODO: break out validation timer from execute
|
||||
try (Timer.Context ignored = verifierTimer.time()) {
|
||||
|
Loading…
Reference in New Issue
Block a user