remove ChainingOp

This commit is contained in:
Jonathan Shook 2024-03-15 12:08:49 -05:00
parent 221939657f
commit 0d0efd12d6
5 changed files with 4 additions and 54 deletions

View File

@ -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&lt;I,O&gt;: f(I) -> O&lt;I,O&gt;</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);
}

View File

@ -30,9 +30,6 @@ import java.util.function.LongFunction;
* <P>This variant of {@link Op} has the ability to see the cycle * <P>This variant of {@link Op} has the ability to see the cycle
* which was previously used to select the op implementation.</p> * 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> * <h2>Designer Notes</h2>
* <p> * <p>
* If you are using the value in this call to select a specific type of behavior, it is very * 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> * <p>Run an action for the given cycle.</p>
* *
* @param value The cycle value for which an operation is run * @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 @Override
T apply(long value); T apply(long value);

View File

@ -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 * 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 * hand down the chain is more costly, so implementing this interface allows the runtime
* to be more optimized.</li> * to be more optimized.</li>
* <li>{@link ChainingOp}</li> *
* <li>{@link RunnableOp}</li> * <li>{@link RunnableOp}</li>
* </ul> * </ul>
* </p> * </p>

View File

@ -25,9 +25,7 @@ public interface RunnableOp extends Op, Runnable {
/** /**
* Invoke the operation. If you need to see the value of the current * 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 * cycle, then you can use {@link CycleOp} instead.
* use a cached result of a previous operation, then you may need to
* use {@link ChainingOp}.
*/ */
@Override @Override
void run(); void run();

View File

@ -99,11 +99,9 @@ public class StandardAction<A extends StandardActivity<R, ?>, R extends Op> impl
runnableOp.run(); runnableOp.run();
} else if (op instanceof CycleOp<?> cycleOp) { } else if (op instanceof CycleOp<?> cycleOp) {
result = cycleOp.apply(cycle); result = cycleOp.apply(cycle);
} else if (op instanceof ChainingOp chainingOp) {
result = chainingOp.apply(result);
} else { } else {
throw new RuntimeException("The op implementation did not implement any active logic. Implement " + 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 // TODO: break out validation timer from execute
try (Timer.Context ignored = verifierTimer.time()) { try (Timer.Context ignored = verifierTimer.time()) {