mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
refactor dryrun for type clarity
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2024 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.opwrappers;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
|
||||
|
||||
public class DryCycleOp<T> implements CycleOp<T> {
|
||||
|
||||
private final CycleOp<T> op;
|
||||
|
||||
public DryCycleOp(CycleOp<T> op) {
|
||||
this.op = op;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T apply(long value) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2024 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.opwrappers;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
|
||||
public class DryCycleOpDispenserWrapper<S extends Space, RESULT> extends BaseOpDispenser<CycleOp<RESULT>, S> {
|
||||
|
||||
private final OpDispenser<CycleOp<RESULT>> realDispenser;
|
||||
|
||||
public DryCycleOpDispenserWrapper(
|
||||
DriverAdapter<CycleOp<RESULT>, S> adapter,
|
||||
ParsedOp pop,
|
||||
OpDispenser<CycleOp<RESULT>> realDispenser
|
||||
) {
|
||||
super(adapter, pop);
|
||||
this.realDispenser = realDispenser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CycleOp<RESULT> getOp(long cycle) {
|
||||
CycleOp<RESULT> op = realDispenser.getOp(cycle);
|
||||
return new DryCycleOp<>(op);
|
||||
}
|
||||
}
|
||||
@@ -16,16 +16,16 @@
|
||||
|
||||
package io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
|
||||
|
||||
public class DryRunOp implements RunnableOp {
|
||||
public class DryRunableOp implements RunnableOp {
|
||||
|
||||
private final Op op;
|
||||
private final RunnableOp op;
|
||||
|
||||
public DryRunOp(Op op) {
|
||||
public DryRunableOp(RunnableOp op) {
|
||||
this.op = op;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
}
|
||||
@@ -19,20 +19,26 @@ package io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers;
|
||||
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
|
||||
public class DryRunOpDispenserWrapper extends BaseOpDispenser<Op, Object> {
|
||||
public class DryRunnableOpDispenserWrapper<S extends Space> extends BaseOpDispenser<RunnableOp, S> {
|
||||
|
||||
private final OpDispenser<? extends Op> realDispenser;
|
||||
private final OpDispenser<RunnableOp> realDispenser;
|
||||
|
||||
public DryRunOpDispenserWrapper(DriverAdapter<Op,Object> adapter, ParsedOp pop, OpDispenser<? extends Op> realDispenser) {
|
||||
public DryRunnableOpDispenserWrapper(
|
||||
DriverAdapter<RunnableOp, S> adapter,
|
||||
ParsedOp pop,
|
||||
OpDispenser<RunnableOp> realDispenser
|
||||
) {
|
||||
super(adapter, pop);
|
||||
this.realDispenser = realDispenser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DryRunOp getOp(long cycle) {
|
||||
Op op = realDispenser.getOp(cycle);
|
||||
return new DryRunOp(op);
|
||||
public DryRunableOp getOp(long cycle) {
|
||||
RunnableOp op = realDispenser.getOp(cycle);
|
||||
return new DryRunableOp(op);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2024 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.opwrappers;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
|
||||
|
||||
public class EmitterCycleOp<T> implements CycleOp<T> {
|
||||
|
||||
private final CycleOp<T> cycleOp;
|
||||
public EmitterCycleOp(CycleOp<T> cycleOp) {
|
||||
this.cycleOp = cycleOp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T apply(long value) {
|
||||
T result = cycleOp.apply(value);
|
||||
System.out.println("result from cycle " + value + ":\n"+result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2024 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.opwrappers;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
|
||||
public class EmitterCycleOpDispenserWrapper<O,S extends Space,R> extends BaseOpDispenser<CycleOp<R>, S> {
|
||||
|
||||
private final OpDispenser<CycleOp<R>> realDispenser;
|
||||
|
||||
public EmitterCycleOpDispenserWrapper(
|
||||
DriverAdapter<? extends CycleOp<R>, S> adapter,
|
||||
ParsedOp pop,
|
||||
OpDispenser<CycleOp<R>> realDispenser
|
||||
) {
|
||||
super(adapter, pop);
|
||||
this.realDispenser = realDispenser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmitterCycleOp<R> getOp(long cycle) {
|
||||
CycleOp<R> cycleOp = realDispenser.getOp(cycle);
|
||||
return new EmitterCycleOp(cycleOp);
|
||||
}
|
||||
}
|
||||
@@ -18,16 +18,16 @@ package io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
|
||||
|
||||
public class EmitterOp implements CycleOp<Object> {
|
||||
public class EmitterOp<T> implements CycleOp<T> {
|
||||
|
||||
private final CycleOp<?> cycleOp;
|
||||
public EmitterOp(CycleOp<?> cycleOp) {
|
||||
private final CycleOp<T> cycleOp;
|
||||
public EmitterOp(CycleOp<T> cycleOp) {
|
||||
this.cycleOp = cycleOp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object apply(long value) {
|
||||
Object result = cycleOp.apply(value);
|
||||
public T apply(long value) {
|
||||
T result = cycleOp.apply(value);
|
||||
System.out.println("result from cycle " + value + ":\n"+result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -19,15 +19,16 @@ package io.nosqlbench.adapters.api.activityimpl.uniform.opwrappers;
|
||||
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
|
||||
public class EmitterOpDispenserWrapper extends BaseOpDispenser<Op, Object> {
|
||||
public class EmitterOpDispenserWrapper extends BaseOpDispenser<Op, Space> {
|
||||
|
||||
private final OpDispenser<? extends CycleOp<?>> realDispenser;
|
||||
|
||||
public EmitterOpDispenserWrapper(DriverAdapter<Op,Object> adapter, ParsedOp pop, OpDispenser<? extends CycleOp<?>> realDispenser) {
|
||||
public EmitterOpDispenserWrapper(DriverAdapter<Op,Space> adapter, ParsedOp pop, OpDispenser<? extends CycleOp<?>> realDispenser) {
|
||||
super(adapter, pop);
|
||||
this.realDispenser = realDispenser;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2024 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.opwrappers;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
|
||||
|
||||
public class EmitterRunnableOp implements RunnableOp {
|
||||
|
||||
private final RunnableOp runnableOp;
|
||||
public EmitterRunnableOp(RunnableOp runnableOp) {
|
||||
this.runnableOp = runnableOp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
runnableOp.run();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2022-2024 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.opwrappers;
|
||||
|
||||
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
|
||||
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.RunnableOp;
|
||||
import io.nosqlbench.adapters.api.templating.ParsedOp;
|
||||
|
||||
public class EmitterRunnableOpDispenserWrapper<O,S> extends BaseOpDispenser<RunnableOp, Space> {
|
||||
|
||||
private final OpDispenser<RunnableOp> realDispenser;
|
||||
|
||||
public EmitterRunnableOpDispenserWrapper(
|
||||
DriverAdapter<? extends RunnableOp, ? extends Space> adapter,
|
||||
ParsedOp pop,
|
||||
OpDispenser<RunnableOp> realDispenser
|
||||
) {
|
||||
super(adapter, pop);
|
||||
this.realDispenser = realDispenser;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EmitterRunnableOp getOp(long cycle) {
|
||||
RunnableOp cycleOp = realDispenser.getOp(cycle);
|
||||
return new EmitterRunnableOp(cycleOp);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user