diff --git a/RELEASENOTES.md b/RELEASENOTES.md index e2e130ab7..e69de29bb 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -1,12 +0,0 @@ -- 114aea71b (HEAD -> main) Merge branch 'main' of github.com:nosqlbench/nosqlbench -- 0fd85c09b (origin/main) Merge pull request #728 from nosqlbench/feature/mongodb_baselines2_workloads -- 99f0226fc Merge pull request #729 from nosqlbench/snyk-upgrade-2d988862477c7e76f15ff8b65bcdc3a4 -- d22413259 Merge pull request #727 from nosqlbench/snyk-upgrade-b28610be666fa7e80936b0c2f87df569 -- d49a5087d improved build diagnostics -- e594aab92 (origin/snyk-upgrade-2d988862477c7e76f15ff8b65bcdc3a4) fix: upgrade com.datastax.oss:pulsar-jms from 2.4.4 to 2.4.9 -- 64990c412 (origin/feature/mongodb_baselines2_workloads) Initial working draft of MongoDB timeseries -- 7ebb16a06 (origin/snyk-upgrade-b28610be666fa7e80936b0c2f87df569) fix: upgrade org.postgresql:postgresql from 42.4.2 to 42.5.0 -- 68cdd075b new function, security updates, actions fix -- ec8e6ee71 Merge branch 'main' of github.com:nosqlbench/nosqlbench -- a63fa951c actions fix release -- 0f6bce0b0 fix typo in docker push logic diff --git a/adapter-cqld4/pom.xml b/adapter-cqld4/pom.xml index 4e8c8d41a..bc0c902af 100644 --- a/adapter-cqld4/pom.xml +++ b/adapter-cqld4/pom.xml @@ -20,7 +20,7 @@ io.nosqlbench mvn-defaults - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -38,7 +38,7 @@ io.nosqlbench adapters-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/Cqld4CqlReboundStatement.java b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/Cqld4CqlReboundStatement.java index 0ac61009c..6cf024b36 100644 --- a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/Cqld4CqlReboundStatement.java +++ b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/Cqld4CqlReboundStatement.java @@ -24,8 +24,8 @@ import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp; public class Cqld4CqlReboundStatement extends Cqld4CqlOp { private final BoundStatement stmt; - public Cqld4CqlReboundStatement(CqlSession session, int maxpages, boolean retryreplace, BoundStatement rebound, RSProcessors processors) { - super(session,maxpages,retryreplace,processors); + public Cqld4CqlReboundStatement(CqlSession session, int maxPages, boolean retryReplace, int maxLwtRetries, int lwtRetryCount, BoundStatement rebound, RSProcessors processors) { + super(session,maxPages,retryReplace,maxLwtRetries,lwtRetryCount, processors); this.stmt = rebound; } diff --git a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/exceptions/ExceededRetryReplaceException.java b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/exceptions/ExceededRetryReplaceException.java new file mode 100644 index 000000000..a5e5f1f46 --- /dev/null +++ b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/exceptions/ExceededRetryReplaceException.java @@ -0,0 +1,45 @@ +/* + * 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.adapter.cqld4.exceptions; + + +import com.datastax.oss.driver.api.core.cql.ResultSet; + +/** + * This is a synthetic error generated by the cql driver in NoSQLBench when + * the retryreplace option is used but the number of LWT round-trips from the driver + * is excessive. The number of LWT round trips allowed is controlled by the + * maxlwtretries op field. + */ +public class ExceededRetryReplaceException extends CqlGenericCycleException { + + private final ResultSet resultSet; + private final String queryString; + private final int retries; + + public ExceededRetryReplaceException(ResultSet resultSet, String queryString, int retries) { + super("After " + retries + " retries using the retryreplace option, Operation was not applied:" + queryString); + this.retries = retries; + this.resultSet = resultSet; + this.queryString = queryString; + } + + public ResultSet getResultSet() { + return resultSet; + } + public String getQueryString() { return queryString; } +} diff --git a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/Cqld4BaseOpDispenser.java b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/Cqld4BaseOpDispenser.java index 34200479e..540b34dc1 100644 --- a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/Cqld4BaseOpDispenser.java +++ b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/Cqld4BaseOpDispenser.java @@ -45,12 +45,14 @@ public abstract class Cqld4BaseOpDispenser extends BaseOpDispenser sessionFunc; private final boolean isRetryReplace; + private final int maxLwtRetries; public Cqld4BaseOpDispenser(DriverAdapter adapter, LongFunction sessionFunc, ParsedOp op) { super(adapter, op); this.sessionFunc = sessionFunc; this.maxpages = op.getStaticConfigOr("maxpages", 1); this.isRetryReplace = op.getStaticConfigOr("retryreplace", false); + this.maxLwtRetries = op.getStaticConfigOr("maxlwtretries", 1); } public int getMaxPages() { @@ -61,6 +63,11 @@ public abstract class Cqld4BaseOpDispenser extends BaseOpDispenser getSessionFunc() { return sessionFunc; } diff --git a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/Cqld4PreparedStmtDispenser.java b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/Cqld4PreparedStmtDispenser.java index 497b67b99..83503c9c8 100644 --- a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/Cqld4PreparedStmtDispenser.java +++ b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/Cqld4PreparedStmtDispenser.java @@ -89,6 +89,7 @@ public class Cqld4PreparedStmtDispenser extends Cqld4BaseOpDispenser { boundStatement, getMaxPages(), isRetryReplace(), + getMaxLwtRetries(), processors ); } catch (Exception exception) { diff --git a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/Cqld4RawStmtDispenser.java b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/Cqld4RawStmtDispenser.java index fe986415c..16b999e60 100644 --- a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/Cqld4RawStmtDispenser.java +++ b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/Cqld4RawStmtDispenser.java @@ -49,7 +49,8 @@ public class Cqld4RawStmtDispenser extends Cqld4BaseOpDispenser { getSessionFunc().apply(value), (SimpleStatement) stmtFunc.apply(value), getMaxPages(), - isRetryReplace() + isRetryReplace(), + getMaxLwtRetries() ); } diff --git a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/Cqld4SimpleCqlStmtDispenser.java b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/Cqld4SimpleCqlStmtDispenser.java index a3e85cac5..f58ce6dc3 100644 --- a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/Cqld4SimpleCqlStmtDispenser.java +++ b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/opdispensers/Cqld4SimpleCqlStmtDispenser.java @@ -46,7 +46,8 @@ public class Cqld4SimpleCqlStmtDispenser extends Cqld4BaseOpDispenser { getSessionFunc().apply(value), (SimpleStatement) stmtFunc.apply(value), getMaxPages(), - isRetryReplace() + isRetryReplace(), + getMaxLwtRetries() ); } diff --git a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/optypes/Cqld4CqlBatchStatement.java b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/optypes/Cqld4CqlBatchStatement.java index bf8a64c3b..d122aa2eb 100644 --- a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/optypes/Cqld4CqlBatchStatement.java +++ b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/optypes/Cqld4CqlBatchStatement.java @@ -24,8 +24,8 @@ public class Cqld4CqlBatchStatement extends Cqld4CqlOp { private final BatchStatement stmt; - public Cqld4CqlBatchStatement(CqlSession session, BatchStatement stmt, int maxpages, boolean retryreplace) { - super(session,maxpages,retryreplace,new RSProcessors()); + public Cqld4CqlBatchStatement(CqlSession session, BatchStatement stmt, int maxPage, int maxLwtRetries, boolean retryReplace) { + super(session,maxPage,retryReplace,maxLwtRetries,new RSProcessors()); this.stmt = stmt; } diff --git a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/optypes/Cqld4CqlOp.java b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/optypes/Cqld4CqlOp.java index e72c835c3..67931b83a 100644 --- a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/optypes/Cqld4CqlOp.java +++ b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/optypes/Cqld4CqlOp.java @@ -23,6 +23,7 @@ import com.datastax.oss.driver.api.core.cql.Row; import com.datastax.oss.driver.api.core.cql.Statement; import io.nosqlbench.adapter.cqld4.*; import io.nosqlbench.adapter.cqld4.exceptions.ChangeUnappliedCycleException; +import io.nosqlbench.adapter.cqld4.exceptions.ExceededRetryReplaceException; import io.nosqlbench.adapter.cqld4.exceptions.UndefinedResultSetException; import io.nosqlbench.adapter.cqld4.exceptions.UnexpectedPagingException; import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.*; @@ -44,17 +45,29 @@ import java.util.Map; public abstract class Cqld4CqlOp implements CycleOp, VariableCapture, OpGenerator, OpResultSize { private final CqlSession session; - private final int maxpages; - private final boolean retryreplace; + private final int maxPages; + private final boolean retryReplace; + private final int maxLwtRetries; + private int retryReplaceCount =0; private ResultSet rs; private Cqld4CqlOp nextOp; private final RSProcessors processors; - public Cqld4CqlOp(CqlSession session, int maxpages, boolean retryreplace, RSProcessors processors) { + public Cqld4CqlOp(CqlSession session, int maxPages, boolean retryReplace, int maxLwtRetries, RSProcessors processors) { this.session = session; - this.maxpages = maxpages; - this.retryreplace = retryreplace; + this.maxPages = maxPages; + this.retryReplace = retryReplace; + this.maxLwtRetries =maxLwtRetries; + this.processors = processors; + } + + protected Cqld4CqlOp(CqlSession session, int maxPages, boolean retryReplace, int maxLwtRetries, int retryRplaceCount, RSProcessors processors) { + this.session = session; + this.maxPages = maxPages; + this.retryReplace = retryReplace; + this.maxLwtRetries =maxLwtRetries; + this.retryReplaceCount=retryRplaceCount; this.processors = processors; } @@ -66,9 +79,13 @@ public abstract class Cqld4CqlOp implements CycleOp, VariableCapture, int totalRows = 0; if (!rs.wasApplied()) { - if (!retryreplace) { + if (!retryReplace) { throw new ChangeUnappliedCycleException(rs, getQueryString()); } else { + retryReplaceCount++; + if (retryReplaceCount >maxLwtRetries) { + throw new ExceededRetryReplaceException(rs,getQueryString(), retryReplaceCount); + } Row one = rs.one(); processors.buffer(one); totalRows++; @@ -86,8 +103,8 @@ public abstract class Cqld4CqlOp implements CycleOp, VariableCapture, Row row = reader.next(); processors.buffer(row); } - if (pages++ > maxpages) { - throw new UnexpectedPagingException(rs, getQueryString(), pages, maxpages, stmt.getPageSize()); + if (pages++ > maxPages) { + throw new UnexpectedPagingException(rs, getQueryString(), pages, maxPages, stmt.getPageSize()); } if (rs.isFullyFetched()) { break; @@ -119,7 +136,7 @@ public abstract class Cqld4CqlOp implements CycleOp, VariableCapture, private Cqld4CqlOp rebindLwt(Statement stmt, Row row) { BoundStatement rebound = LWTRebinder.rebindUnappliedStatement(stmt, row); - return new Cqld4CqlReboundStatement(session, maxpages, retryreplace, rebound, processors); + return new Cqld4CqlReboundStatement(session, maxPages, retryReplace, maxLwtRetries, retryReplaceCount, rebound, processors); } } diff --git a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/optypes/Cqld4CqlPreparedStatement.java b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/optypes/Cqld4CqlPreparedStatement.java index 4c8720196..9e6dfcad9 100644 --- a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/optypes/Cqld4CqlPreparedStatement.java +++ b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/optypes/Cqld4CqlPreparedStatement.java @@ -24,8 +24,8 @@ public class Cqld4CqlPreparedStatement extends Cqld4CqlOp { private final BoundStatement stmt; - public Cqld4CqlPreparedStatement(CqlSession session, BoundStatement stmt, int maxpages, boolean retryreplace, RSProcessors processors) { - super(session,maxpages,retryreplace,processors); + public Cqld4CqlPreparedStatement(CqlSession session, BoundStatement stmt, int maxPages, boolean retryReplace, int maxLwtRetries, RSProcessors processors) { + super(session,maxPages,retryReplace,maxLwtRetries,processors); this.stmt = stmt; } diff --git a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/optypes/Cqld4CqlSimpleStatement.java b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/optypes/Cqld4CqlSimpleStatement.java index 19f1a6936..0f119c91d 100644 --- a/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/optypes/Cqld4CqlSimpleStatement.java +++ b/adapter-cqld4/src/main/java/io/nosqlbench/adapter/cqld4/optypes/Cqld4CqlSimpleStatement.java @@ -23,8 +23,8 @@ import io.nosqlbench.adapter.cqld4.RSProcessors; public class Cqld4CqlSimpleStatement extends Cqld4CqlOp { private final SimpleStatement stmt; - public Cqld4CqlSimpleStatement(CqlSession session, SimpleStatement stmt, int maxpages, boolean retryreplace) { - super(session, maxpages,retryreplace, new RSProcessors()); + public Cqld4CqlSimpleStatement(CqlSession session, SimpleStatement stmt, int maxPages, boolean retryReplace, int maxLwtRetries) { + super(session, maxPages,retryReplace, maxLwtRetries, new RSProcessors()); this.stmt = stmt; } diff --git a/adapter-cqld4/src/main/resources/cqld4.md b/adapter-cqld4/src/main/resources/cqld4.md index cb83996ce..473969a14 100644 --- a/adapter-cqld4/src/main/resources/cqld4.md +++ b/adapter-cqld4/src/main/resources/cqld4.md @@ -198,6 +198,11 @@ params: # match the preconditions) in order to test LWT performance. retryreplace: true + # Set the number of retries allowed by the retryreplace option. This is set + # to 1 conservatively, as with the maxpages setting. This means that you will + # see an error if the first LWT retry after an unapplied change was not successful. + maxlwtretries: 1 + ## The following options are meant for advanced testing scenarios only, ## and are not generally meant to be used in typical application-level, ## data mode, performance or scale testing. These expose properties diff --git a/adapter-diag/pom.xml b/adapter-diag/pom.xml index 302538264..55c07a912 100644 --- a/adapter-diag/pom.xml +++ b/adapter-diag/pom.xml @@ -21,7 +21,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -37,13 +37,13 @@ io.nosqlbench nb-annotations - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench engine-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT compile diff --git a/adapter-dynamodb/pom.xml b/adapter-dynamodb/pom.xml index 5d6d2d48e..30c918124 100644 --- a/adapter-dynamodb/pom.xml +++ b/adapter-dynamodb/pom.xml @@ -20,7 +20,7 @@ io.nosqlbench mvn-defaults - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -39,7 +39,7 @@ io.nosqlbench adapters-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/adapter-http/pom.xml b/adapter-http/pom.xml index b6ccd52eb..5db53ca97 100644 --- a/adapter-http/pom.xml +++ b/adapter-http/pom.xml @@ -20,7 +20,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -38,7 +38,7 @@ io.nosqlbench engine-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT compile diff --git a/adapter-mongodb/pom.xml b/adapter-mongodb/pom.xml index e60032009..7cb99c906 100644 --- a/adapter-mongodb/pom.xml +++ b/adapter-mongodb/pom.xml @@ -23,7 +23,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -36,7 +36,7 @@ io.nosqlbench engine-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/adapter-pulsar/pom.xml b/adapter-pulsar/pom.xml index 5ed541f12..732d585c0 100644 --- a/adapter-pulsar/pom.xml +++ b/adapter-pulsar/pom.xml @@ -23,7 +23,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -41,13 +41,13 @@ io.nosqlbench engine-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench adapters-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/adapter-stdout/pom.xml b/adapter-stdout/pom.xml index 285f86353..c094c1509 100644 --- a/adapter-stdout/pom.xml +++ b/adapter-stdout/pom.xml @@ -23,7 +23,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -38,14 +38,14 @@ io.nosqlbench nb-annotations - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT compile io.nosqlbench adapters-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT compile diff --git a/adapter-tcp/pom.xml b/adapter-tcp/pom.xml index 6204a442b..d75a37401 100644 --- a/adapter-tcp/pom.xml +++ b/adapter-tcp/pom.xml @@ -23,7 +23,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -40,7 +40,7 @@ io.nosqlbench engine-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/adapters-api/pom.xml b/adapters-api/pom.xml index ea91c96ca..e17269322 100644 --- a/adapters-api/pom.xml +++ b/adapters-api/pom.xml @@ -21,7 +21,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -39,19 +39,19 @@ io.nosqlbench nb-spectest - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench nb-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench virtdata-userlibs - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/adapters-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/flowtypes/ChainingOp.java b/adapters-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/flowtypes/ChainingOp.java index 0edcfa34c..43c1aeed4 100644 --- a/adapters-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/flowtypes/ChainingOp.java +++ b/adapters-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/flowtypes/ChainingOp.java @@ -19,16 +19,25 @@ package io.nosqlbench.engine.api.activityimpl.uniform.flowtypes; import java.util.function.Function; /** - * Run a function on the current cached result and replace it - * with the result of the function. Functions are one way of invoking + *

ChainingOp: f(I) -> O

+ *

+ * 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 CycleFunction must always have an input to work on. This input is - * provided by a Supplier as optionally implemented by an Op + * A ChainingOp must always have an input to work on, + * provided by either a {@link CycleOp} OR another call to a {@link ChainingOp}

* - * @param Some input type. + * @param Some input type, as determined by a previous {@link CycleOp} or {@link ChainingOp} on the same thread. * @param Some output type. */ -public interface ChainingOp extends Op, Function { +public interface ChainingOp extends Op, Function { + + /** + * 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 i); + O apply(I lastResult); } diff --git a/adapters-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/flowtypes/CycleOp.java b/adapters-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/flowtypes/CycleOp.java index e6bf71e29..58dfe8e1f 100644 --- a/adapters-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/flowtypes/CycleOp.java +++ b/adapters-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/flowtypes/CycleOp.java @@ -19,32 +19,33 @@ package io.nosqlbench.engine.api.activityimpl.uniform.flowtypes; import java.util.function.LongFunction; /** - * A CycleRunnable is simply a variation of a Runnable type. - * The main difference is that it is supplied with the cycle - * as input. + *

CycleOp: f(cycle) -> T

+ *

A CycleOp of T is an operation which takes a long input value + * and produces a value of type T. It is implemented as + * {@link LongFunction} of T.

+ * + *

This variant of {@link Op} has the ability to see the cycle + * which was previously used to select the op implementation.

+ * + *

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.

+ * + *

Designer Notes

+ *

+ * If you are using the value in this call to select a specific type of behavior, it is very + * likely a candidate for factoring into separate op implementations. + * The {@link io.nosqlbench.engine.api.activityimpl.OpMapper} + * and {@link io.nosqlbench.engine.api.activityimpl.OpDispenser} abstractions are meant to move + * op type selection and scheduling to earlier in the activity. + *

+ * */ public interface CycleOp extends Op, LongFunction { -// /** -// *

Run an action for the given cycle. The cycle is provided for anecdotal -// * usage such as logging and debugging. It is valid to use the cycle value in these places, -// * but you should not use it to determine the logic of what is run. The mechanism -// * for doing this is provided in {@link io.nosqlbench.engine.api.activityimpl.OpMapper} -// * and {@link io.nosqlbench.engine.api.activityimpl.OpDispenser} types.

-// * -// * -// * @param cycle The cycle value for which an operation is run -// */ -//// * This method should do the same thing that {@link #apply(long)} does, except that -//// * there is no need to prepare or return a result. This is the form that will be called -//// * if there is no chaining operation to consume the result of this operation. -// void accept(long cycle); - /** - *

Run an action for the given cycle. The cycle - * value is only to be used for anecdotal presentation. This form is called - * when there is a chaining operation which will do something with this result.

+ *

Run an action for the given cycle.

+ * * @param value The cycle value for which an operation is run - * @return A result which is the native result type for the underlying driver. + * @return A result object which may be used by a subsequent {@link ChainingOp} */ @Override T apply(long value); diff --git a/adapters-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/flowtypes/Op.java b/adapters-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/flowtypes/Op.java index ca50f1a1a..e5ecdf6a2 100644 --- a/adapters-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/flowtypes/Op.java +++ b/adapters-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/flowtypes/Op.java @@ -17,21 +17,20 @@ package io.nosqlbench.engine.api.activityimpl.uniform.flowtypes; /** - * This is the root type of any operation which is used in a NoSQLBench + *

This is the root type of any operation which is used in a NoSQLBench * DriverAdapter. It is a tagging interface for incremental type validation - * in the NB runtime. You probably don't want to use it directly. + * in the NB runtime. You probably don't want to use it directly.

* - * Instead, use these: + *

Instead, use one of these: *

    *
  • {@link CycleOp}
  • - An interface that will called if there is nothing to consume * 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 ... + * hand down the chain is more costly, so implementing this interface allows the runtime + * to be more optimized. + *
  • {@link ChainingOp}
  • *
- * - * either {@link CycleOp} or {@link ChainingOp} (but not both!) - * - * In the standard flow of an activity, either of the above interfaces is called - * so long as an Op implements one of them. + *

*/ +// TODO: optimize the runtime around the specific op type public interface Op extends OpResultSize { } diff --git a/adapters-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/flowtypes/RunnableOp.java b/adapters-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/flowtypes/RunnableOp.java index dd5ba39fc..0cfc2f984 100644 --- a/adapters-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/flowtypes/RunnableOp.java +++ b/adapters-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/flowtypes/RunnableOp.java @@ -16,5 +16,19 @@ package io.nosqlbench.engine.api.activityimpl.uniform.flowtypes; +/** + *

RunnableOp

+ *

This is the simplest form of an executable operation in NoSQLBench. + * It is simply an operation is run for side-effect only.

+ */ 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}. + */ + @Override + void run(); } diff --git a/devdocs/sketches/docs-publishing-flow.svg b/devdocs/sketches/docs-publishing-flow.svg new file mode 100644 index 000000000..ac6f1f7b5 --- /dev/null +++ b/devdocs/sketches/docs-publishing-flow.svg @@ -0,0 +1,743 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + NBmain branch + + + + RELEASEDNB-DOCS + + + + NB-BUILD-DOCS + + + + non-releasebuild + + + + releasebuild + + + + + + + + + + + + + + + edit embededdocs, javadoc,and code + edit docscontent + publish all docscontent to maindocs site + publish embeddeddocs content to maindocs site + publish embeddeddocs content to previewdocs site + on push to mainand change toRELEASENOTES.md + Initially, this doc sitewill be checkpointed manually into the main docs site + on push to mainand NO change toRELEASENOTES.md + + + diff --git a/docsys/pom.xml b/docsys/pom.xml index 1d5147e12..ade6388b4 100644 --- a/docsys/pom.xml +++ b/docsys/pom.xml @@ -28,7 +28,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -37,7 +37,7 @@ io.nosqlbench nb-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT @@ -93,13 +93,13 @@ org.apache.commons commons-compress - 1.21 + 1.22 org.glassfish.jersey.media jersey-media-json-jackson - 3.0.8 + 3.1.0 @@ -133,7 +133,7 @@ io.nosqlbench virtdata-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/engine-api/pom.xml b/engine-api/pom.xml index 9db3bb359..cc8b4087f 100644 --- a/engine-api/pom.xml +++ b/engine-api/pom.xml @@ -21,7 +21,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -39,31 +39,31 @@ io.nosqlbench nb-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench adapters-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench nb-spectest - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench nb-annotations - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench virtdata-userlibs - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/StandardAction.java b/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/StandardAction.java index 0e1612afd..45f8c1826 100644 --- a/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/StandardAction.java +++ b/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/uniform/StandardAction.java @@ -32,11 +32,11 @@ import org.apache.logging.log4j.Logger; import java.util.concurrent.TimeUnit; /** - * This is the generified version of an Action. All activity types should endeavor to use - * this, as the API surface is being consolidated so that the internal machinery of NB - * works in a very consistent and uniform way. - * There will be changes to multiple drivers to support this consolidation, but the bulk - * of this work will be undertaken by the project maintainers. + * This is the generified version of an Action. All driver adapters us this, as opposed + * to previous NB versions where it was implemented for each driver. + * + * This allows the API to be consolidated so that the internal machinery of NB + * works in a very consistent and uniform way for all users and drivers. * * @param The type of activity * @param The type of operation diff --git a/engine-cli/pom.xml b/engine-cli/pom.xml index abccb1e38..8936515c5 100644 --- a/engine-cli/pom.xml +++ b/engine-cli/pom.xml @@ -4,7 +4,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -23,13 +23,13 @@ io.nosqlbench engine-core - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench engine-docker - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/engine-clients/pom.xml b/engine-clients/pom.xml index cc761c986..7fad28143 100644 --- a/engine-clients/pom.xml +++ b/engine-clients/pom.xml @@ -5,7 +5,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -21,7 +21,7 @@ io.nosqlbench engine-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/engine-core/pom.xml b/engine-core/pom.xml index 20caa2538..e21236d2e 100644 --- a/engine-core/pom.xml +++ b/engine-core/pom.xml @@ -21,7 +21,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -38,7 +38,7 @@ io.nosqlbench engine-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT @@ -89,7 +89,7 @@ io.nosqlbench engine-clients - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT compile diff --git a/engine-docker/pom.xml b/engine-docker/pom.xml index bd03836dc..977483fd3 100644 --- a/engine-docker/pom.xml +++ b/engine-docker/pom.xml @@ -4,7 +4,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -56,7 +56,7 @@ io.nosqlbench engine-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/engine-docs/pom.xml b/engine-docs/pom.xml index 8c5838d89..8b7e603dd 100644 --- a/engine-docs/pom.xml +++ b/engine-docs/pom.xml @@ -4,7 +4,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -28,7 +28,7 @@ io.nosqlbench docsys - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/engine-extensions/pom.xml b/engine-extensions/pom.xml index 9a700fb61..74120d0c3 100644 --- a/engine-extensions/pom.xml +++ b/engine-extensions/pom.xml @@ -4,7 +4,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -22,7 +22,7 @@ io.nosqlbench engine-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/engine-rest/pom.xml b/engine-rest/pom.xml index a45106357..a42221e15 100644 --- a/engine-rest/pom.xml +++ b/engine-rest/pom.xml @@ -4,7 +4,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -29,13 +29,13 @@ io.swagger.core.v3 swagger-models - 2.2.4 + 2.2.6 io.nosqlbench engine-cli - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/mvn-defaults/pom.xml b/mvn-defaults/pom.xml index edc8a1f4b..11f90877d 100644 --- a/mvn-defaults/pom.xml +++ b/mvn-defaults/pom.xml @@ -19,7 +19,7 @@ io.nosqlbench mvn-defaults - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT pom @@ -189,7 +189,7 @@ io.netty netty-handler - 4.1.84.Final + 4.1.85.Final diff --git a/nb-annotations/pom.xml b/nb-annotations/pom.xml index 5447fe35e..d2dc538f8 100644 --- a/nb-annotations/pom.xml +++ b/nb-annotations/pom.xml @@ -5,7 +5,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults diff --git a/nb-api/pom.xml b/nb-api/pom.xml index 2e0631a8a..07982e077 100644 --- a/nb-api/pom.xml +++ b/nb-api/pom.xml @@ -21,7 +21,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -58,7 +58,7 @@ io.nosqlbench nb-annotations - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT @@ -97,7 +97,7 @@ com.amazonaws aws-java-sdk-s3 - 1.12.340 + 1.12.341 diff --git a/nb-spectest/pom.xml b/nb-spectest/pom.xml index 274b325f7..55d9a88f6 100644 --- a/nb-spectest/pom.xml +++ b/nb-spectest/pom.xml @@ -20,7 +20,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults diff --git a/nb5/pom.xml b/nb5/pom.xml index 340360d07..9d426e8ab 100644 --- a/nb5/pom.xml +++ b/nb5/pom.xml @@ -21,7 +21,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -40,7 +40,7 @@ io.nosqlbench nbr - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT @@ -49,49 +49,49 @@ io.nosqlbench adapter-tcp - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench adapter-mongodb - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench adapter-stdout - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench adapter-diag - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench adapter-dynamodb - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench adapter-cqld4 - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench adapter-http - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench adapter-pulsar - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT @@ -172,7 +172,7 @@ io.nosqlbench adapter-mongodb - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/nbr-examples/pom.xml b/nbr-examples/pom.xml index 6e8e73730..5613dc4ad 100644 --- a/nbr-examples/pom.xml +++ b/nbr-examples/pom.xml @@ -20,7 +20,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -39,13 +39,13 @@ io.nosqlbench nbr - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench adapter-diag - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/nbr/pom.xml b/nbr/pom.xml index 9dca9b6cf..cc59c9caa 100644 --- a/nbr/pom.xml +++ b/nbr/pom.xml @@ -21,7 +21,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -40,37 +40,37 @@ io.nosqlbench engine-rest - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench engine-cli - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench engine-docs - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench engine-core - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench engine-extensions - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench adapter-diag - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/pom.xml b/pom.xml index 098185117..5cd70137d 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT mvn-defaults diff --git a/virtdata-api/pom.xml b/virtdata-api/pom.xml index 4124f7e4b..f3c2ac971 100644 --- a/virtdata-api/pom.xml +++ b/virtdata-api/pom.xml @@ -7,7 +7,7 @@ io.nosqlbench mvn-defaults - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -23,14 +23,14 @@ io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT nb-api io.nosqlbench virtdata-lang - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/virtdata-lang/pom.xml b/virtdata-lang/pom.xml index 3fbb276f7..f82be7747 100644 --- a/virtdata-lang/pom.xml +++ b/virtdata-lang/pom.xml @@ -23,7 +23,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults diff --git a/virtdata-lib-basics/pom.xml b/virtdata-lib-basics/pom.xml index a84409b13..ca1882850 100644 --- a/virtdata-lib-basics/pom.xml +++ b/virtdata-lib-basics/pom.xml @@ -7,7 +7,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -20,7 +20,7 @@ io.nosqlbench virtdata-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_long/TriangularStepFunction.java b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_long/TriangularStepFunction.java new file mode 100644 index 000000000..9d7d8f8ae --- /dev/null +++ b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_long/TriangularStepFunction.java @@ -0,0 +1,89 @@ +/* + * 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.virtdata.library.basics.shared.from_long.to_long; + +import io.nosqlbench.virtdata.api.annotations.Example; +import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper; + +import java.util.function.LongUnaryOperator; + +/** + *

Compute a value which increases monotonically with respect to the cycle value. + * All values for f(X+(m>=0)) will be equal or greater than f(X). In effect, this + * means that with a sequence of monotonic inputs, the results will be monotonic as + * well as clustered. The values will approximate input/average, but will vary in frequency + * around a simple binomial distribution.

+ * + *

The practical effect of this is to be able to compute a sequence of values + * over inputs which can act as foreign keys, but which are effectively ordered.

+ * + *

Call for Ideas

+ *

Due to the complexity of generalizing this as a pure function over other distributions, + * this is the only function of this type for now. If you are interested in this problem + * domain and have some suggestions for how to extend it to other distributions, please + * join the project or let us know.

+ */ +@ThreadSafeMapper +public class TriangularStepFunction implements LongUnaryOperator { + + private final Hash hasher = new Hash(); + private final long average; + private final LongUnaryOperator sizer; + + private final long variance; + + + @Example({"TriangularStepFunction(100,20)","Create a sequence of values where the average is 100, but the range of values is between 80 and 120."}) + @Example({"TriangularStepFunction(80,10)","Create a sequence of values where the average is 80, but the range of values is between 70 and 90."}) + TriangularStepFunction(long average, long variance) { + if (average<=0 || variance < 0 || variance > average) { + throw new RuntimeException( + "The average must be positive, variance non-negative and the variance must be less than the average. " + + "You provided average=" + average + ", variance=" + variance + "." + ); + } + this.average = average; + this.variance = variance; + this.sizer = new HashRange(average-variance,average+variance); + } + + TriangularStepFunction(long average) { + this(average, average/2); + } + + @Override + public long applyAsLong(long operand) { + // window number + long count = operand / average; + // offset within window + long offset = operand % average; + // base of window + long base = operand - offset; + // variate up to window size + long variance = sizer.applyAsLong(base); + // variate offset from start of window + long slice = base + variance; + // select current or next window + long result = ((slice)>operand) ? count : count + 1; + return result; + } + + @Override + public String toString() { + return this.getClass().getSimpleName()+"{average="+ average +",variance="+variance+"}"; + } +} diff --git a/virtdata-lib-basics/src/test/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_long/TriangularStepFunctionTest.java b/virtdata-lib-basics/src/test/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_long/TriangularStepFunctionTest.java new file mode 100644 index 000000000..a835fa3d5 --- /dev/null +++ b/virtdata-lib-basics/src/test/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_long/TriangularStepFunctionTest.java @@ -0,0 +1,121 @@ +/* + * 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.virtdata.library.basics.shared.from_long.to_long; + +import org.junit.jupiter.api.Test; + +import java.security.InvalidParameterException; +import java.util.Arrays; +import java.util.LongSummaryStatistics; +import java.util.stream.IntStream; + +import static org.assertj.core.api.Assertions.assertThat; + +public class TriangularStepFunctionTest { + + private static final int LABEL=0; + private static final int FREQUENCY=1; + + @Test + public void testExample1() { + TriangularStepFunction e1 = new TriangularStepFunction(100, 20); + int[] runLengths = this.rleStatsFor(e1, 0, 10000); + System.out.println(Arrays.toString(runLengths)); + assertThat(IntStream.of(runLengths).min().orElseThrow()).isEqualTo(80L); + assertThat(IntStream.of(runLengths).max().orElseThrow()).isEqualTo(120L); + } + + @Test + public void testExample2() { + TriangularStepFunction e1 = new TriangularStepFunction(80, 10); + int[] runLengths = this.rleStatsFor(e1, 0, 10000); + System.out.println(Arrays.toString(runLengths)); + assertThat(IntStream.of(runLengths).min().orElseThrow()).isEqualTo(70L); + assertThat(IntStream.of(runLengths).max().orElseThrow()).isEqualTo(90L); + } + + @Test + public void testIncrementalVariance() { + TriangularStepFunction f = new TriangularStepFunction(100, 0); + assertThat(f.applyAsLong(0L)).isEqualTo(0L); + assertThat(f.applyAsLong(1L)).isEqualTo(0L); + assertThat(f.applyAsLong(99L)).isEqualTo(0L); + assertThat(f.applyAsLong(100L)).isEqualTo(1L); + } + + @Test + public void testVariance() { + long first=0; + TriangularStepFunction f = new TriangularStepFunction(100,1); + var rlestats = rleStatsFor(f, 0, 100000); + LongSummaryStatistics stats99to101 = statsForRle((int) f.applyAsLong(first),rlestats); + assertThat(stats99to101.getMin()).isEqualTo(99L); + assertThat(stats99to101.getMax()).isEqualTo(101L); + + int[][] histo = histoFor(rlestats); + LongSummaryStatistics histoStats = new LongSummaryStatistics(); + for (int[] ints : histo) { + histoStats.accept(ints[LABEL]); + } + assertThat(histoStats.getAverage()).isEqualTo(100); + } + + private int[] rleStatsFor(TriangularStepFunction f, long firstTrialIncl, long lastTrialExcl) { + long firstBucket = f.applyAsLong(firstTrialIncl); + long lastBucket = f.applyAsLong(lastTrialExcl); + if (firstBucket>Integer.MAX_VALUE||lastBucket>Integer.MAX_VALUE) { + throw new InvalidParameterException("can't fit result data into range of ints from long [" + firstBucket + ","+lastBucket+"]"); + } + int base = (int) firstBucket; + int[] counts = new int[(((int) lastBucket-(int)firstBucket))+1]; + for (long trial=firstTrialIncl; trial < lastTrialExcl; trial++) { + long result = f.applyAsLong(trial); + counts[(int)(result-base)]++; + } + // remove last partial, as only the front initial partial is compensated + counts= Arrays.copyOfRange(counts,0,counts.length-1); + return counts; + } + + private int[][] histoFor(int[] counts) { + var minval = IntStream.of(counts).min().orElseThrow(); + var maxval = IntStream.of(counts).max().orElseThrow(); + + int[][] histo = new int[(maxval-minval)+1][2]; + for (int i = 0; i <= histo[LABEL].length; i++) { + histo[i][LABEL]=i+minval; + } + + for (int count : counts) { + System.out.println(count); + histo[count-minval][FREQUENCY]++; + } + return histo; + } + + private LongSummaryStatistics statsForRle(int base, int[] counts) { + LongSummaryStatistics stats = new LongSummaryStatistics(); + for (int element = 0; element < counts.length; element++) { + int count = counts[element]; + if (count==0) { + continue; + } + stats.accept(count); + } + return stats; + } +} diff --git a/virtdata-lib-curves4/pom.xml b/virtdata-lib-curves4/pom.xml index 8dcdd827d..744a88b0d 100644 --- a/virtdata-lib-curves4/pom.xml +++ b/virtdata-lib-curves4/pom.xml @@ -4,7 +4,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -22,13 +22,13 @@ io.nosqlbench virtdata-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench virtdata-lib-basics - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/virtdata-lib-random/pom.xml b/virtdata-lib-random/pom.xml index 3ae330a56..6e75f9ccb 100644 --- a/virtdata-lib-random/pom.xml +++ b/virtdata-lib-random/pom.xml @@ -7,7 +7,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -20,13 +20,13 @@ io.nosqlbench virtdata-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench virtdata-lib-basics - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/virtdata-lib-realer/pom.xml b/virtdata-lib-realer/pom.xml index c72acb3ad..83995db65 100644 --- a/virtdata-lib-realer/pom.xml +++ b/virtdata-lib-realer/pom.xml @@ -4,7 +4,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -20,7 +20,7 @@ io.nosqlbench virtdata-lib-basics - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/virtdata-realdata/pom.xml b/virtdata-realdata/pom.xml index d16316af5..3741c45b6 100644 --- a/virtdata-realdata/pom.xml +++ b/virtdata-realdata/pom.xml @@ -7,7 +7,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -18,7 +18,7 @@ io.nosqlbench virtdata-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT diff --git a/virtdata-userlibs/pom.xml b/virtdata-userlibs/pom.xml index 9ae56cc89..b2d8e38ef 100644 --- a/virtdata-userlibs/pom.xml +++ b/virtdata-userlibs/pom.xml @@ -20,7 +20,7 @@ mvn-defaults io.nosqlbench - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT ../mvn-defaults @@ -34,42 +34,42 @@ io.nosqlbench virtdata-realdata - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench virtdata-lib-realer - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench virtdata-api - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench virtdata-lib-random - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench virtdata-lib-basics - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench virtdata-lib-curves4 - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT io.nosqlbench docsys - 4.17.31-SNAPSHOT + 4.17.32-SNAPSHOT compile