refactor dryrun for type clarity

This commit is contained in:
Jonathan Shook
2024-10-23 13:40:09 -05:00
parent d5ec597152
commit 05c6b82bba
12 changed files with 339 additions and 34 deletions

View File

@@ -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;
}
}

View File

@@ -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);
}
}

View File

@@ -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() {
}

View File

@@ -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);
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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();
}
}

View File

@@ -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);
}
}