io.nosqlbench.engine.api.activityimpl.uniform.DriverAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of adapters-api Show documentation
Show all versions of adapters-api Show documentation
The DriverAdapter API for nosqlbench;
Provides the interfaces needed to build drivers that can be loaded
by nosqlbench core, using a minimal and direct API for op mapping.
/*
* Copyright (c) 2022 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.engine.api.activityimpl.uniform;
import io.nosqlbench.api.docsapi.Docs;
import io.nosqlbench.api.docsapi.DocsBinder;
import io.nosqlbench.engine.api.activityimpl.OpDispenser;
import io.nosqlbench.engine.api.activityimpl.OpMapper;
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.engine.api.templating.ParsedOp;
import io.nosqlbench.nb.annotations.Maturity;
import io.nosqlbench.nb.annotations.Service;
import io.nosqlbench.api.config.standard.NBConfiguration;
import io.nosqlbench.api.content.Content;
import io.nosqlbench.api.content.NBIO;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
/**
* The DriverAdapter interface is expected to be the replacement
* for ActivityTypes. This interface takes a simpler
* approach. Specifically, all of the core logic which was being pasted into each
* driver type is centralized, and only the necessary interfaces
* needed for construction new operations and shared context are exposed.
* This means all drivers can now benefit from cross-cutting enhancements
* in the core implementation.
*
*
* @param The type of Runnable operation which will be used to wrap
* all operations for this driver adapter. This allows you to
* add context or features common to all operations of this
* type.
* @param The type of context space used by this driver to hold
* cached instances of clients, session, or other native driver
* esoterica. This is the shared state which might be needed
* during construction of R type operations, or even for individual
* operations.
*/
public interface DriverAdapter {
/**
*
*
Op Mapping
* An Op Mapper is a function which can look at the parsed
* fields in a {@link ParsedOp} and create an OpDispenser.
* An OpDispenser is a function that will produce a special
* type {@link OPTYPE} that this DriverAdapter implements as its
* op implementation.
*
*
* The function that is returned is responsible for creating another function.
* This might seem counter-intuitive but it is very intentional because
* of these design constraints:
*
* - Mapping op semantics to a type of operation must be very clear
* and flexible. Performance is not important at this layer because this is all done
* during initialization time for an activity.
* - Synthesizing executable operations from a known type of operational template
* must be done very efficiently. This part is done during activity execution, so
* having the details of how you are going to create an op for execution already
* sorted out is important.
*
*
* To clarify the distinction between these two phases, the first is canonically
* called op mapping in the documentation. The second is called
* op synthesis.
*
*
*
*
A note on implementation strategy:
* Generally speaking, implementations of this method should interrogate the op fields
* in the ParsedOp and return an OpDispenser that matches the user's intentions.
* This can be based on something explicit, like the value of a {@code type} field,
* or it can be based on whether certain fields are present or not. Advanced implementations
* might take into account which fields are provided as static values and which are
* specified as bindings. In any case, the op mapping phase is meant to qualify and
* pre-check that the fields provided are valid and specific for a given type of operation.
* What happens within {@link OpDispenser} implementations (the second phase), however, should do
* as little qualification of field values as possible, focusing simply on constructing
* the type of operation for which they are designed.
*
*
* @return a synthesizer function for {@link OPTYPE} op generation
*/
OpMapper getOpMapper();
/**
* The preprocessor function allows the driver adapter to remap
* the fields in the op template before they are interpreted canonically.
* At this level, the transform is applied once to the input map
* (once per op template) to yield the map that is provided to
* {@link io.nosqlbench.engine.api.activityimpl.OpMapper} implementations.
*
* @return A function to pre-process the op template fields.
*/
default Function
© 2015 - 2025 Weber Informatics LLC | Privacy Policy