Merge pull request #2062 from nosqlbench/jshook/nosqlbench-2044-spaces

jshook/nosqlbench-2044-spaces
This commit is contained in:
Jonathan Shook 2024-10-31 12:09:03 -05:00 committed by GitHub
commit 41abcbd891
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1884 changed files with 4086 additions and 2703 deletions

View File

@ -1,5 +1,5 @@
<!--
~ Copyright (c) 2022 nosqlbench
~ Copyright (c) nosqlbench
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--
- Copyright (c) 2022 nosqlbench
- Copyright (c) nosqlbench
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--
- Copyright (c) 2022 nosqlbench
- Copyright (c) nosqlbench
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--
- Copyright (c) 2022 nosqlbench
- Copyright (c) nosqlbench
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
- Copyright (c) 2022 nosqlbench
- Copyright (c) nosqlbench
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -398,29 +398,6 @@
<version>2.24.1</version>
</dependency>
<dependency>
<groupId>io.weaviate</groupId>
<artifactId>client</artifactId>
<version>4.8.2</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-search-documents</artifactId>
<version>11.7.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.13.2</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-spanner</artifactId>
<version>6.77.0</version>
</dependency>
</dependencies>
</dependencyManagement>
@ -730,7 +707,7 @@
<exclude>**/generated-sources/**</exclude>
</excludes>
<addLicenseHeaders>true</addLicenseHeaders>
<copyrightMessage>Copyright (c) 2022 nosqlbench</copyrightMessage>
<copyrightMessage>Copyright (c) nosqlbench</copyrightMessage>
</configuration>
</plugin>

View File

@ -22,7 +22,6 @@ import io.nosqlbench.nb.api.config.standard.NBConfiguration;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.BaseDriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverSpaceCache;
import io.nosqlbench.nb.api.labels.NBLabels;
import io.nosqlbench.nb.api.components.core.NBComponent;
import io.nosqlbench.nb.annotations.Service;
@ -30,6 +29,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.function.Function;
import java.util.function.LongFunction;
@Service(value = DriverAdapter.class, selector = "amqp")
public class AmqpDriverAdapter extends BaseDriverAdapter<AmqpTimeTrackOp, AmqpSpace> {
@ -40,15 +40,13 @@ public class AmqpDriverAdapter extends BaseDriverAdapter<AmqpTimeTrackOp, AmqpSp
}
@Override
public OpMapper<AmqpTimeTrackOp> getOpMapper() {
DriverSpaceCache<? extends AmqpSpace> spaceCache = getSpaceCache();
NBConfiguration adapterConfig = getConfiguration();
return new AmqpOpMapper(this, adapterConfig, spaceCache);
public OpMapper<AmqpTimeTrackOp, AmqpSpace> getOpMapper() {
return new AmqpOpMapper(this, getConfiguration(), getSpaceCache());
}
@Override
public Function<String, ? extends AmqpSpace> getSpaceInitializer(NBConfiguration cfg) {
return (s) -> new AmqpSpace(s, cfg);
public LongFunction<AmqpSpace> getSpaceInitializer(NBConfiguration cfg) {
return (s) -> new AmqpSpace(this,s, cfg);
}
@Override

View File

@ -1,7 +1,7 @@
package io.nosqlbench.adapter.amqp;
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -19,33 +19,37 @@ package io.nosqlbench.adapter.amqp;
import io.nosqlbench.adapter.amqp.dispensers.AmqpMsgRecvOpDispenser;
import io.nosqlbench.adapter.amqp.dispensers.AmqpMsgSendOpDispenser;
import io.nosqlbench.adapter.amqp.ops.AmqpTimeTrackOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.ConcurrentSpaceCache;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.nb.api.config.standard.NBConfiguration;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverSpaceCache;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.engine.api.templating.TypeAndTarget;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class AmqpOpMapper implements OpMapper<AmqpTimeTrackOp> {
import java.util.function.LongFunction;
public class AmqpOpMapper implements OpMapper<AmqpTimeTrackOp,AmqpSpace> {
private final static Logger logger = LogManager.getLogger(AmqpOpMapper.class);
private final NBConfiguration cfg;
private final DriverSpaceCache<? extends AmqpSpace> spaceCache;
private final ConcurrentSpaceCache<AmqpSpace> spaceCache;
private final DriverAdapter adapter;
public AmqpOpMapper(DriverAdapter adapter, NBConfiguration cfg, DriverSpaceCache<? extends AmqpSpace> spaceCache) {
public AmqpOpMapper(DriverAdapter adapter, NBConfiguration cfg, ConcurrentSpaceCache<AmqpSpace> spaceCache) {
this.cfg = cfg;
this.spaceCache = spaceCache;
this.adapter = adapter;
}
@Override
public OpDispenser<? extends AmqpTimeTrackOp> apply(ParsedOp op) {
String spaceName = op.getStaticConfigOr("space", "default");
public OpDispenser<AmqpTimeTrackOp> apply(ParsedOp op, LongFunction spaceInitF) {
//public OpDispenser<AmqpTimeTrackOp> apply(ParsedOp op, LongFunction<AmqpTimeTrackOp> spaceInitF) {
int spaceName = op.getStaticConfigOr("space", 0);
AmqpSpace amqpSpace = spaceCache.get(spaceName);
/*
@ -68,4 +72,5 @@ public class AmqpOpMapper implements OpMapper<AmqpTimeTrackOp> {
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,6 +23,7 @@ import io.nosqlbench.adapter.amqp.exception.AmqpAdapterInvalidParamException;
import io.nosqlbench.adapter.amqp.exception.AmqpAdapterUnexpectedException;
import io.nosqlbench.adapter.amqp.util.AmqpAdapterUtil;
import io.nosqlbench.adapter.amqp.util.AmqpClientConf;
import io.nosqlbench.adapters.api.activityimpl.uniform.BaseSpace;
import io.nosqlbench.nb.api.config.standard.ConfigModel;
import io.nosqlbench.nb.api.config.standard.NBConfigModel;
import io.nosqlbench.nb.api.config.standard.NBConfiguration;
@ -44,11 +45,10 @@ import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
public class AmqpSpace implements AutoCloseable {
public class AmqpSpace extends BaseSpace<AmqpSpace> {
private final static Logger logger = LogManager.getLogger(AmqpSpace.class);
private final String spaceName;
private final NBConfiguration cfg;
private final AmqpClientConf amqpClientConf;
@ -117,8 +117,8 @@ public class AmqpSpace implements AutoCloseable {
private long totalCycleNum;
private long totalThreadNum;
public AmqpSpace(String spaceName, NBConfiguration cfg) {
this.spaceName = spaceName;
public AmqpSpace(AmqpDriverAdapter adapter, long idx, NBConfiguration cfg) {
super(adapter,idx);
this.cfg = cfg;
String amqpClientConfFileName = cfg.get("config");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2023 nosqlbench
# Copyright (c) nosqlbench
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -15,45 +15,50 @@
-->
<!--<?xml version="1.0" encoding="UTF-8"?>-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>adapter-azure-aisearch</artifactId>
<packaging>jar</packaging>
<artifactId>adapter-azure-aisearch</artifactId>
<packaging>jar</packaging>
<parent>
<artifactId>mvn-defaults</artifactId>
<groupId>io.nosqlbench</groupId>
<version>${revision}</version>
<relativePath>../../mvn-defaults</relativePath>
</parent>
<parent>
<artifactId>mvn-defaults</artifactId>
<groupId>io.nosqlbench</groupId>
<version>${revision}</version>
<relativePath>../../mvn-defaults</relativePath>
</parent>
<name>${project.artifactId}</name>
<description>
An nosqlbench adapter driver module for the Azure AI Search database.
</description>
<name>${project.artifactId}</name>
<description>
An nosqlbench adapter driver module for the Azure AI Search database.
</description>
<dependencies>
<dependency>
<groupId>io.nosqlbench</groupId>
<artifactId>nb-annotations</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.nosqlbench</groupId>
<artifactId>adapters-api</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-search-documents</artifactId>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
</dependency>
</dependencies>
</project>
<dependencies>
<dependency>
<groupId>io.nosqlbench</groupId>
<artifactId>nb-annotations</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.nosqlbench</groupId>
<artifactId>adapters-api</artifactId>
<version>${revision}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-search-documents</artifactId>
<version>11.7.0</version>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.13.2</version>
</dependency>
</dependencies>
</project>

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@ package io.nosqlbench.adapter.azureaisearch;
import java.util.function.Function;
import java.util.function.LongFunction;
import io.nosqlbench.adapter.azureaisearch.ops.AzureAISearchBaseOp;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
@ -31,20 +32,20 @@ import io.nosqlbench.nb.api.labels.NBLabels;
import static io.nosqlbench.adapter.azureaisearch.AzureAISearchAdapterUtils.AZURE_AI_SEARCH;
@Service(value = DriverAdapter.class, selector = AZURE_AI_SEARCH)
public class AzureAISearchDriverAdapter extends BaseDriverAdapter<AzureAISearchBaseOp<?>, AzureAISearchSpace> {
public class AzureAISearchDriverAdapter extends BaseDriverAdapter<AzureAISearchBaseOp, AzureAISearchSpace> {
public AzureAISearchDriverAdapter(NBComponent parentComponent, NBLabels labels) {
super(parentComponent, labels);
}
@Override
public OpMapper<AzureAISearchBaseOp<?>> getOpMapper() {
public OpMapper<AzureAISearchBaseOp,AzureAISearchSpace> getOpMapper() {
return new AzureAISearchOpMapper(this);
}
@Override
public Function<String, ? extends AzureAISearchSpace> getSpaceInitializer(NBConfiguration cfg) {
return (s) -> new AzureAISearchSpace(s, cfg);
public LongFunction<AzureAISearchSpace> getSpaceInitializer(NBConfiguration cfg) {
return (s) -> new AzureAISearchSpace(this,s, cfg);
}
@Override
@ -52,4 +53,4 @@ public class AzureAISearchDriverAdapter extends BaseDriverAdapter<AzureAISearchB
return super.getConfigModel().add(AzureAISearchSpace.getConfigModel());
}
}
}

View File

@ -32,44 +32,53 @@ import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.engine.api.templating.TypeAndTarget;
public class AzureAISearchOpMapper implements OpMapper<AzureAISearchBaseOp<?>> {
private static final Logger logger = LogManager.getLogger(AzureAISearchOpMapper.class);
private final AzureAISearchDriverAdapter adapter;
import java.util.function.LongFunction;
/**
* Create a new {@code AzureAISearchOpMapper} implementing the {@link OpMapper}.
* interface.
*
* @param adapter The associated {@link AzureAISearchDriverAdapter}
*/
public AzureAISearchOpMapper(AzureAISearchDriverAdapter adapter) {
this.adapter = adapter;
}
public class AzureAISearchOpMapper implements OpMapper<AzureAISearchBaseOp, AzureAISearchSpace> {
private static final Logger logger = LogManager.getLogger(AzureAISearchOpMapper.class);
private final AzureAISearchDriverAdapter adapter;
/**
* Given an instance of a {@link ParsedOp} returns the appropriate
* {@link AzureAISearchBaseOpDispenser} subclass.
*
* @param op The {@link ParsedOp} to be evaluated
* @return The correct {@link AzureAISearchBaseOpDispenser} subclass based on
* the op type
*/
@Override
public OpDispenser<? extends AzureAISearchBaseOp<?>> apply(ParsedOp op) {
TypeAndTarget<AzureAISearchOpType, String> typeAndTarget = op.getTypeAndTarget(AzureAISearchOpType.class,
String.class, "type", "target");
logger.info(() -> "Using '" + typeAndTarget.enumId + "' op type for op template '" + op.getName() + "'");
/**
* Create a new {@code AzureAISearchOpMapper} implementing the {@link OpMapper}.
* interface.
*
* @param adapter
* The associated {@link AzureAISearchDriverAdapter}
*/
public AzureAISearchOpMapper(AzureAISearchDriverAdapter adapter) {
this.adapter = adapter;
}
return switch (typeAndTarget.enumId) {
case delete_index -> new AzureAISearchDeleteIndexOpDispenser(adapter, op, typeAndTarget.targetFunction);
case create_or_update_index ->
new AzureAISearchCreateOrUpdateIndexOpDispenser(adapter, op, typeAndTarget.targetFunction);
case list_indexes -> new AzureAISearchListIndexesOpDispenser(adapter, op, typeAndTarget.targetFunction);
case upload_documents -> new AzureAISearchUploadDocumentsOpDispenser(adapter, op, typeAndTarget.targetFunction);
case search_documents -> new AzureAISearchSearchDocumentsOpDispenser(adapter, op, typeAndTarget.targetFunction);
/**
* Given an instance of a {@link ParsedOp} returns the appropriate
* {@link AzureAISearchBaseOpDispenser} subclass.
*
* @param op
* The {@link ParsedOp} to be evaluated
* @param spaceInitF
* @return The correct {@link AzureAISearchBaseOpDispenser} subclass based on
* the op type
*/
@Override
public OpDispenser<AzureAISearchBaseOp> apply(ParsedOp op, LongFunction<AzureAISearchSpace> spaceInitF) {
TypeAndTarget<AzureAISearchOpType, String> typeAndTarget = op.getTypeAndTarget(AzureAISearchOpType.class,
String.class, "type", "target");
logger.info(() -> "Using '" + typeAndTarget.enumId + "' op type for op template '" + op.getName() + "'");
return switch (typeAndTarget.enumId) {
case delete_index -> new AzureAISearchDeleteIndexOpDispenser(adapter, op, typeAndTarget.targetFunction);
case create_or_update_index ->
new AzureAISearchCreateOrUpdateIndexOpDispenser(adapter, op, typeAndTarget.targetFunction);
case list_indexes -> new AzureAISearchListIndexesOpDispenser(adapter, op, typeAndTarget.targetFunction);
case upload_documents ->
new AzureAISearchUploadDocumentsOpDispenser(adapter, op, typeAndTarget.targetFunction);
case search_documents ->
new AzureAISearchSearchDocumentsOpDispenser(adapter, op, typeAndTarget.targetFunction);
// default -> throw new RuntimeException(
// "Unrecognized op type '" + typeAndTarget.enumId.name() + "' while " + "mapping parsed op " + op);
};
}
};
}
}

View File

@ -20,6 +20,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import io.nosqlbench.adapters.api.activityimpl.uniform.BaseSpace;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -50,9 +51,8 @@ import io.nosqlbench.nb.api.config.standard.Param;
* "https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/search/azure-search-documents/">Azure
* AI Search Java searchIndexClient</a>
*/
public class AzureAISearchSpace implements AutoCloseable {
public class AzureAISearchSpace extends BaseSpace<AzureAISearchSpace> {
private final static Logger logger = LogManager.getLogger(AzureAISearchSpace.class);
private final String name;
private final NBConfiguration cfg;
protected SearchIndexClient searchIndexClient;
@ -62,11 +62,11 @@ public class AzureAISearchSpace implements AutoCloseable {
* contextual information needed to interact with the <b>Azure AI Search</b>
* database instance.
*
* @param name The name of this space
* @param idx The name of this space
* @param cfg The configuration ({@link NBConfiguration}) for this nb run
*/
public AzureAISearchSpace(String name, NBConfiguration cfg) {
this.name = name;
public AzureAISearchSpace(AzureAISearchDriverAdapter adapter, long idx, NBConfiguration cfg) {
super(adapter,idx);
this.cfg = cfg;
}

View File

@ -26,33 +26,32 @@ import com.azure.search.documents.indexes.SearchIndexClient;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
public abstract class AzureAISearchBaseOp<T> implements CycleOp<Object> {
public abstract class AzureAISearchBaseOp<REQUEST, RESULT> implements CycleOp<RESULT> {
protected final static Logger logger = LogManager.getLogger(AzureAISearchBaseOp.class);
protected final SearchIndexClient searchIndexClient;
protected final T request;
protected final LongFunction<Object> apiCall;
protected final REQUEST request;
protected final LongFunction<RESULT> apiCall;
public AzureAISearchBaseOp(SearchIndexClient searchIndexClient, T requestParam) {
public AzureAISearchBaseOp(SearchIndexClient searchIndexClient, REQUEST requestParam) {
this.searchIndexClient = searchIndexClient;
this.request = requestParam;
this.apiCall = this::applyOp;
}
public AzureAISearchBaseOp(SearchIndexClient searchIndexClient, T requestParam, LongFunction<Object> call) {
public AzureAISearchBaseOp(SearchIndexClient searchIndexClient, REQUEST requestParam, LongFunction<RESULT> call) {
this.searchIndexClient = searchIndexClient;
this.request = requestParam;
this.apiCall = call;
}
@Override
public final Object apply(long value) {
public final RESULT apply(long value) {
logger.trace(() -> "applying op: " + this);
try {
Object result = applyOp(value);
RESULT result = applyOp(value);
return result;
} catch (Exception e) {
if (e instanceof RuntimeException rte) {
@ -63,7 +62,7 @@ public abstract class AzureAISearchBaseOp<T> implements CycleOp<Object> {
}
};
public abstract Object applyOp(long value);
public abstract RESULT applyOp(long value);
@Override
public String toString() {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -17,12 +17,14 @@ package io.nosqlbench.adapter.azureaisearch.ops;
import com.azure.search.documents.SearchClient;
import com.azure.search.documents.indexes.SearchIndexClient;
import com.azure.search.documents.util.AutocompletePagedIterable;
import com.azure.search.documents.util.SearchPagedIterable;
public abstract class AzureAISearchClientBaseOp<T> extends AzureAISearchBaseOp<T> {
public abstract class AzureAISearchClientBaseOp<REQUEST, RESULT> extends AzureAISearchBaseOp<REQUEST, RESULT> {
protected final SearchClient searchClient;
public AzureAISearchClientBaseOp(SearchIndexClient searchIdxClient, SearchClient searchClnt, T requestParam) {
public AzureAISearchClientBaseOp(SearchIndexClient searchIdxClient, SearchClient searchClnt, REQUEST requestParam) {
super(searchIdxClient, requestParam);
this.searchClient = searchClnt;
}
}
}

View File

@ -18,14 +18,14 @@ package io.nosqlbench.adapter.azureaisearch.ops;
import com.azure.search.documents.indexes.SearchIndexClient;
import com.azure.search.documents.indexes.models.SearchIndex;
public class AzureAISearchCreateOrUpdateIndexOp extends AzureAISearchBaseOp<SearchIndex> {
public class AzureAISearchCreateOrUpdateIndexOp extends AzureAISearchBaseOp<SearchIndex,SearchIndex> {
public AzureAISearchCreateOrUpdateIndexOp(SearchIndexClient client, SearchIndex request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
public SearchIndex applyOp(long value) {
SearchIndex createResponse = null;
try {
createResponse = searchIndexClient.createOrUpdateIndex(request);

View File

@ -17,14 +17,14 @@ package io.nosqlbench.adapter.azureaisearch.ops;
import com.azure.search.documents.indexes.SearchIndexClient;
public class AzureAISearchDeleteIndexOp extends AzureAISearchBaseOp<String> {
public class AzureAISearchDeleteIndexOp extends AzureAISearchBaseOp<String,String> {
public AzureAISearchDeleteIndexOp(SearchIndexClient client, String request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
public String applyOp(long value) {
try {
searchIndexClient.deleteIndex(request);
logger.debug("Successfully deleted the index: {}", request);
@ -34,4 +34,4 @@ public class AzureAISearchDeleteIndexOp extends AzureAISearchBaseOp<String> {
return "Deleted";
}
}
}

View File

@ -19,14 +19,14 @@ import com.azure.core.http.rest.PagedIterable;
import com.azure.search.documents.indexes.SearchIndexClient;
import com.azure.search.documents.indexes.models.SearchIndex;
public class AzureAISearchListIndexesOp extends AzureAISearchBaseOp<String> {
public class AzureAISearchListIndexesOp extends AzureAISearchBaseOp<String,String> {
public AzureAISearchListIndexesOp(SearchIndexClient client, String request) {
super(client, request);
}
@Override
public Object applyOp(long value) {
public String applyOp(long value) {
try {
PagedIterable<SearchIndex> response = searchIndexClient.listIndexes();
response.forEach((index) -> {

View File

@ -19,9 +19,10 @@ import com.azure.core.util.Context;
import com.azure.search.documents.SearchClient;
import com.azure.search.documents.indexes.SearchIndexClient;
import com.azure.search.documents.models.SearchOptions;
import com.azure.search.documents.util.AutocompletePagedIterable;
import com.azure.search.documents.util.SearchPagedIterable;
public class AzureAISearchSearchDocumentsOp extends AzureAISearchClientBaseOp<SearchOptions> {
public class AzureAISearchSearchDocumentsOp extends AzureAISearchClientBaseOp<SearchOptions,SearchPagedIterable> {
public AzureAISearchSearchDocumentsOp(SearchIndexClient searchIndexClient, SearchClient searchClient,
SearchOptions request) {
@ -29,7 +30,7 @@ public class AzureAISearchSearchDocumentsOp extends AzureAISearchClientBaseOp<Se
}
@Override
public Object applyOp(long value) {
public SearchPagedIterable applyOp(long value) {
SearchPagedIterable searchDocsResponse = null;
try {
searchDocsResponse = searchClient.search(null, // we've not implemented other complex searches yet here.

View File

@ -22,7 +22,7 @@ import com.azure.search.documents.SearchDocument;
import com.azure.search.documents.indexes.SearchIndexClient;
import com.azure.search.documents.models.IndexDocumentsResult;
public class AzureAISearchUploadDocumentsOp extends AzureAISearchClientBaseOp<SearchDocument> {
public class AzureAISearchUploadDocumentsOp extends AzureAISearchClientBaseOp<SearchDocument,IndexDocumentsResult> {
public AzureAISearchUploadDocumentsOp(SearchIndexClient searchIndexClient, SearchClient searchClient,
SearchDocument request) {
@ -30,7 +30,7 @@ public class AzureAISearchUploadDocumentsOp extends AzureAISearchClientBaseOp<Se
}
@Override
public Object applyOp(long value) {
public IndexDocumentsResult applyOp(long value) {
IndexDocumentsResult uploadDocsResponse = null;
try {
uploadDocsResponse = searchClient.uploadDocuments(List.of(request));

View File

@ -1,12 +1,12 @@
/*
* Copyright (c) 2020-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
@ -28,13 +28,13 @@ import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.templating.ParsedOp;
public abstract class AzureAISearchBaseOpDispenser<T>
extends BaseOpDispenser<AzureAISearchBaseOp<T>, AzureAISearchSpace> {
public abstract class AzureAISearchBaseOpDispenser<REQUEST,RESULT>
extends BaseOpDispenser<AzureAISearchBaseOp, AzureAISearchSpace> {
protected final LongFunction<AzureAISearchSpace> azureAISearchSpaceFunction;
protected final LongFunction<SearchIndexClient> clientFunction;
private final LongFunction<? extends AzureAISearchBaseOp<T>> opF;
private final LongFunction<T> paramF;
private final LongFunction<? extends AzureAISearchBaseOp<REQUEST,RESULT>> opF;
private final LongFunction<REQUEST> paramF;
@SuppressWarnings("rawtypes")
protected AzureAISearchBaseOpDispenser(AzureAISearchDriverAdapter adapter, ParsedOp op,
@ -57,14 +57,14 @@ public abstract class AzureAISearchBaseOpDispenser<T>
return (AzureAISearchDriverAdapter) adapter;
}
public abstract LongFunction<T> getParamFunc(LongFunction<SearchIndexClient> clientF, ParsedOp op,
public abstract LongFunction<REQUEST> getParamFunc(LongFunction<SearchIndexClient> clientF, ParsedOp op,
LongFunction<String> targetF);
public abstract LongFunction<AzureAISearchBaseOp<T>> createOpFunc(LongFunction<T> paramF,
public abstract LongFunction<AzureAISearchBaseOp<REQUEST,RESULT>> createOpFunc(LongFunction<REQUEST> paramF,
LongFunction<SearchIndexClient> clientF, ParsedOp op, LongFunction<String> targetF);
@Override
public AzureAISearchBaseOp<T> getOp(long value) {
public AzureAISearchBaseOp<REQUEST,RESULT> getOp(long value) {
return opF.apply(value);
}

View File

@ -53,7 +53,7 @@ import io.nosqlbench.nb.api.errors.OpConfigError;
* "https://learn.microsoft.com/en-us/java/api/com.azure.search.documents?view=azure-java-stable">Index
* docs</a>
*/
public class AzureAISearchCreateOrUpdateIndexOpDispenser extends AzureAISearchBaseOpDispenser<SearchIndex> {
public class AzureAISearchCreateOrUpdateIndexOpDispenser extends AzureAISearchBaseOpDispenser<SearchIndex,SearchIndex> {
private SearchField searchField;
private VectorSearchProfile vsProfile;
@ -290,7 +290,7 @@ public class AzureAISearchCreateOrUpdateIndexOpDispenser extends AzureAISearchBa
}
@Override
public LongFunction<AzureAISearchBaseOp<SearchIndex>> createOpFunc(LongFunction<SearchIndex> paramF,
public LongFunction<AzureAISearchBaseOp<SearchIndex,SearchIndex>> createOpFunc(LongFunction<SearchIndex> paramF,
LongFunction<SearchIndexClient> clientF, ParsedOp op, LongFunction<String> targetF) {
return l -> new AzureAISearchCreateOrUpdateIndexOp(clientF.apply(l), paramF.apply(l));
}

View File

@ -26,7 +26,7 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
/**
* Delete an Azure AI Search index.
*
*
* @see <a href=
* "https://learn.microsoft.com/en-us/rest/api/searchservice/indexes/delete?view=rest-searchservice-2024-07-01&tabs=HTTP">Delete
* Index docs</a>.
@ -34,7 +34,7 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
* "https://learn.microsoft.com/en-us/rest/api/searchservice/">REST
* API</a>.
*/
public class AzureAISearchDeleteIndexOpDispenser extends AzureAISearchBaseOpDispenser<String> {
public class AzureAISearchDeleteIndexOpDispenser extends AzureAISearchBaseOpDispenser<String,String> {
public AzureAISearchDeleteIndexOpDispenser(AzureAISearchDriverAdapter adapter, ParsedOp op,
LongFunction<String> targetF) {
@ -48,7 +48,7 @@ public class AzureAISearchDeleteIndexOpDispenser extends AzureAISearchBaseOpDisp
}
@Override
public LongFunction<AzureAISearchBaseOp<String>> createOpFunc(LongFunction<String> paramF,
public LongFunction<AzureAISearchBaseOp<String,String>> createOpFunc(LongFunction<String> paramF,
LongFunction<SearchIndexClient> clientF, ParsedOp op, LongFunction<String> targetF) {
return l -> new AzureAISearchDeleteIndexOp(clientF.apply(l), paramF.apply(l));
}

View File

@ -27,7 +27,7 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
/**
* Lists the indexes available.
*/
public class AzureAISearchListIndexesOpDispenser extends AzureAISearchBaseOpDispenser<String> {
public class AzureAISearchListIndexesOpDispenser extends AzureAISearchBaseOpDispenser<String,String> {
public AzureAISearchListIndexesOpDispenser(AzureAISearchDriverAdapter adapter, ParsedOp op,
LongFunction<String> targetF) {
super(adapter, op, targetF);
@ -40,8 +40,8 @@ public class AzureAISearchListIndexesOpDispenser extends AzureAISearchBaseOpDisp
}
@Override
public LongFunction<AzureAISearchBaseOp<String>> createOpFunc(LongFunction<String> paramF,
public LongFunction<AzureAISearchBaseOp<String,String>> createOpFunc(LongFunction<String> paramF,
LongFunction<SearchIndexClient> clientF, ParsedOp op, LongFunction<String> targetF) {
return l -> new AzureAISearchListIndexesOp(clientF.apply(l), paramF.apply(l));
}
}
}

View File

@ -26,6 +26,7 @@ import com.azure.search.documents.models.VectorQuery;
import com.azure.search.documents.models.VectorSearchOptions;
import com.azure.search.documents.models.VectorizedQuery;
import com.azure.search.documents.util.SearchPagedIterable;
import io.nosqlbench.adapter.azureaisearch.AzureAISearchDriverAdapter;
import io.nosqlbench.adapter.azureaisearch.ops.AzureAISearchBaseOp;
import io.nosqlbench.adapter.azureaisearch.ops.AzureAISearchSearchDocumentsOp;
@ -40,7 +41,7 @@ import io.nosqlbench.nb.api.errors.OpConfigError;
* "https://learn.microsoft.com/en-us/azure/search/vector-search-how-to-query?tabs=query-2024-07-01%2Cfilter-2024-07-01%2Cbuiltin-portal#vector-query-request">How
* to query/vector search</a>
*/
public class AzureAISearchSearchDocumentsOpDispenser extends AzureAISearchBaseOpDispenser<SearchOptions> {
public class AzureAISearchSearchDocumentsOpDispenser extends AzureAISearchBaseOpDispenser<SearchOptions, SearchPagedIterable> {
public AzureAISearchSearchDocumentsOpDispenser(AzureAISearchDriverAdapter adapter, ParsedOp op,
LongFunction<String> targetF) {
super(adapter, op, targetF);
@ -70,7 +71,7 @@ public class AzureAISearchSearchDocumentsOpDispenser extends AzureAISearchBaseOp
}
@Override
public LongFunction<AzureAISearchBaseOp<SearchOptions>> createOpFunc(LongFunction<SearchOptions> paramF,
public LongFunction<AzureAISearchBaseOp<SearchOptions,SearchPagedIterable>> createOpFunc(LongFunction<SearchOptions> paramF,
LongFunction<SearchIndexClient> clientF, ParsedOp op, LongFunction<String> targetF) {
return l -> new AzureAISearchSearchDocumentsOp(clientF.apply(l),
clientF.apply(l).getSearchClient(targetF.apply(l)), paramF.apply(l));

View File

@ -21,6 +21,7 @@ import java.util.function.LongFunction;
import com.azure.search.documents.SearchDocument;
import com.azure.search.documents.indexes.SearchIndexClient;
import com.azure.search.documents.models.IndexDocumentsResult;
import io.nosqlbench.adapter.azureaisearch.AzureAISearchDriverAdapter;
import io.nosqlbench.adapter.azureaisearch.ops.AzureAISearchBaseOp;
import io.nosqlbench.adapter.azureaisearch.ops.AzureAISearchUploadDocumentsOp;
@ -34,7 +35,7 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
* "https://learn.microsoft.com/en-us/java/api/com.azure.search.documents?view=azure-java-stable">Index
* docs</a>
*/
public class AzureAISearchUploadDocumentsOpDispenser extends AzureAISearchBaseOpDispenser<SearchDocument> {
public class AzureAISearchUploadDocumentsOpDispenser extends AzureAISearchBaseOpDispenser<SearchDocument, IndexDocumentsResult> {
public AzureAISearchUploadDocumentsOpDispenser(AzureAISearchDriverAdapter adapter, ParsedOp op,
LongFunction<String> targetF) {
super(adapter, op, targetF);
@ -55,7 +56,7 @@ public class AzureAISearchUploadDocumentsOpDispenser extends AzureAISearchBaseOp
}
@Override
public LongFunction<AzureAISearchBaseOp<SearchDocument>> createOpFunc(LongFunction<SearchDocument> paramF,
public LongFunction<AzureAISearchBaseOp<SearchDocument,IndexDocumentsResult>> createOpFunc(LongFunction<SearchDocument> paramF,
LongFunction<SearchIndexClient> clientF, ParsedOp op, LongFunction<String> targetF) {
return l -> new AzureAISearchUploadDocumentsOp(clientF.apply(l),
clientF.apply(l).getSearchClient(targetF.apply(l)), paramF.apply(l));

View File

@ -1,7 +1,7 @@
package io.nosqlbench.adapter.cqld4;
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -17,12 +17,13 @@
package io.nosqlbench.adapter.cqld4;
import io.nosqlbench.adapter.cqld4.opmappers.Cqld4CoreOpMapper;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4BaseOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.nb.api.config.standard.NBConfigModel;
import io.nosqlbench.nb.api.config.standard.NBConfiguration;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.BaseDriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverSpaceCache;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.nb.api.labels.NBLabels;
import io.nosqlbench.nb.api.components.core.NBComponent;
@ -35,9 +36,10 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.function.LongFunction;
@Service(value = DriverAdapter.class, selector = "cqld4")
public class Cqld4DriverAdapter extends BaseDriverAdapter<Op, Cqld4Space> {
public class Cqld4DriverAdapter extends BaseDriverAdapter<Cqld4BaseOp, Cqld4Space> {
private final static Logger logger = LogManager.getLogger(Cqld4DriverAdapter.class);
public Cqld4DriverAdapter(NBComponent parentComponent, NBLabels labels) {
@ -45,15 +47,14 @@ public class Cqld4DriverAdapter extends BaseDriverAdapter<Op, Cqld4Space> {
}
@Override
public OpMapper<Op> getOpMapper() {
DriverSpaceCache<? extends Cqld4Space> spaceCache = getSpaceCache();
public OpMapper<Cqld4BaseOp,Cqld4Space> getOpMapper() {
NBConfiguration config = getConfiguration();
return new Cqld4CoreOpMapper(this, config, spaceCache);
return new Cqld4CoreOpMapper(this, config);
}
@Override
public Function<String, ? extends Cqld4Space> getSpaceInitializer(NBConfiguration cfg) {
return s -> new Cqld4Space(s,cfg);
public LongFunction<Cqld4Space> getSpaceInitializer(NBConfiguration cfg) {
return s -> new Cqld4Space(this,s,cfg);
}
@Override

View File

@ -1,7 +1,7 @@
package io.nosqlbench.adapter.cqld4;
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -19,6 +19,7 @@ package io.nosqlbench.adapter.cqld4;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.CqlSessionBuilder;
import com.datastax.oss.driver.api.core.config.*;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import com.datastax.oss.driver.api.core.session.SessionBuilder;
import com.datastax.oss.driver.internal.core.config.composite.CompositeDriverConfigLoader;
import com.datastax.oss.driver.internal.core.loadbalancing.helper.NodeFilterToDistanceEvaluatorAdapter;
@ -28,6 +29,8 @@ import io.nosqlbench.adapter.cqld4.optionhelpers.OptionHelpers;
import io.nosqlbench.adapter.cqld4.wrapper.Cqld4LoadBalancerObserver;
import io.nosqlbench.adapter.cqld4.wrapper.Cqld4SessionBuilder;
import io.nosqlbench.adapter.cqld4.wrapper.NodeSummary;
import io.nosqlbench.adapters.api.activityimpl.uniform.BaseSpace;
import io.nosqlbench.adapters.api.activityimpl.uniform.ConcurrentIndexCache;
import io.nosqlbench.nb.api.config.standard.*;
import io.nosqlbench.nb.api.errors.OpConfigError;
import io.nosqlbench.nb.api.nbio.Content;
@ -45,16 +48,17 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.function.LongFunction;
import java.util.stream.Collectors;
public class Cqld4Space implements AutoCloseable {
public class Cqld4Space extends BaseSpace<Cqld4Space> {
private final static Logger logger = LogManager.getLogger(Cqld4Space.class);
private final String space;
CqlSession session;
private CqlSession session;
private ConcurrentIndexCache<PreparedStatement> preparedStmtCache = new ConcurrentIndexCache<>("pstmts");
public Cqld4Space(String space, NBConfiguration cfg) {
this.space = space;
public Cqld4Space(Cqld4DriverAdapter adapter, long spaceidx, NBConfiguration cfg) {
super(adapter,spaceidx);
session = createSession(cfg);
}
@ -301,7 +305,6 @@ public class Cqld4Space implements AutoCloseable {
}
return Optional.of(mainloader);
}
}
public CqlSession getSession() {
@ -338,10 +341,19 @@ public class Cqld4Space implements AutoCloseable {
@Override
public void close() {
try {
this.preparedStmtCache.clear();
this.getSession().close();
} catch (Exception e) {
logger.warn("auto-closeable cql session threw exception in cql space(" + this.space + "): " + e);
logger.warn("auto-closeable cql session threw exception in cql space(" + getName() + "): " + e);
throw e;
}
}
public PreparedStatement getOrCreatePreparedStatement(
int refkey,
LongFunction<PreparedStatement> psF
) {
PreparedStatement ps = preparedStmtCache.get(refkey, psF);
return ps;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -30,6 +30,7 @@ import com.datastax.oss.driver.api.core.type.VectorType;
import com.datastax.oss.driver.api.core.type.codec.ExtraTypeCodecs;
import com.datastax.oss.driver.api.core.type.codec.TypeCodec;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlPreparedStatement;
import io.nosqlbench.nb.api.errors.OpConfigError;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@ -130,7 +131,7 @@ public class CQLD4PreparedStmtDiagnostics {
};
}
public static Cqld4CqlOp rebindWithDiagnostics(
public static Cqld4CqlPreparedStatement rebindWithDiagnostics(
PreparedStatement preparedStmt,
LongFunction<Object[]> fieldsF,
long cycle,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -18,41 +18,43 @@ package io.nosqlbench.adapter.cqld4.opdispensers;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.*;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.optionhelpers.BatchTypeEnum;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlBatchStatement;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.BaseSpace;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import org.jetbrains.annotations.NotNull;
import java.util.function.LongFunction;
public class CqlD4BatchStmtDispenser extends Cqld4BaseOpDispenser {
public class CqlD4BatchStmtDispenser extends Cqld4CqlBaseOpDispenser<Cqld4CqlBatchStatement> {
private final int repeat;
private final ParsedOp subop;
private final OpMapper submapper;
private LongFunction<Statement> opfunc;
private LongFunction<BatchStatement> opfunc;
public CqlD4BatchStmtDispenser(
DriverAdapter adapter,
LongFunction<CqlSession> sessionFunc,
Cqld4DriverAdapter adapter,
ParsedOp op,
int repeat,
ParsedOp subop,
OpDispenser<? extends Cqld4CqlOp> subopDispenser
OpDispenser<Cqld4CqlOp> subopDispenser
) {
super(adapter, sessionFunc, op);
super(adapter, op);
this.repeat = repeat;
this.subop = subop;
this.opfunc = createStmtFunc(op, subopDispenser);
this.submapper = adapter.getOpMapper();
subopDispenser = submapper.apply(subop);
subopDispenser = submapper.apply(subop, adapter.getSpaceFunc(op));
}
private LongFunction<Statement> createStmtFunc(ParsedOp topOp, OpDispenser<? extends Cqld4CqlOp> subopDispenser) {
private LongFunction<BatchStatement> createStmtFunc(ParsedOp topOp, OpDispenser<? extends Cqld4CqlOp> subopDispenser) {
Cqld4CqlOp exampleOp = subopDispenser.apply(0L);
Statement<?> example = exampleOp.getStmt();
if (!(example instanceof BatchableStatement<?> b)) {
@ -61,33 +63,34 @@ public class CqlD4BatchStmtDispenser extends Cqld4BaseOpDispenser {
}
BatchTypeEnum bte = topOp.getEnumFromFieldOr(BatchTypeEnum.class, BatchTypeEnum.unlogged, "batchtype");
LongFunction<BatchStatementBuilder> bsbf = l -> new BatchStatementBuilder(bte.batchtype);
LongFunction<Statement> bsf = getBatchAccumulator(bsbf, subopDispenser);
bsf = getEnhancedStmtFunc(bsf,topOp);
LongFunction<BatchStatement> bsf = getBatchAccumulator(bsbf, subopDispenser);
bsf = getEnhancedStmtFunc(bsf, topOp);
return bsf;
}
@NotNull
private LongFunction<Statement> getBatchAccumulator(LongFunction<BatchStatementBuilder> bsb, OpDispenser<? extends Cqld4CqlOp> subopDispenser) {
private LongFunction<BatchStatement> getBatchAccumulator(LongFunction<BatchStatementBuilder> bsb, OpDispenser<?
extends Cqld4CqlOp> subopDispenser) {
LongFunction<BatchStatementBuilder> f = l -> {
long base=l*repeat;
long base = l * repeat;
BatchStatementBuilder bsa = bsb.apply(l);
for (int i = 0; i < repeat; i++) {
Cqld4CqlOp op = subopDispenser.apply(base+i);
Cqld4CqlOp op = subopDispenser.apply(base + i);
BatchableStatement<?> stmt = (BatchableStatement<?>) op.getStmt();
bsa= bsa.addStatement(stmt);
bsa = bsa.addStatement(stmt);
}
return bsa;
};
LongFunction<Statement> bsf = (long l) -> f.apply(l).build();
LongFunction<BatchStatement> bsf = (long l) -> f.apply(l).build();
return bsf;
}
@Override
public Cqld4CqlOp getOp(long value) {
public Cqld4CqlBatchStatement getOp(long value) {
Statement bstmt = opfunc.apply(value);
return new Cqld4CqlBatchStatement(
getSessionFunc().apply(value),
sessionF.apply(value),
(BatchStatement) bstmt,
getMaxPages(),
getMaxLwtRetries(),

View File

@ -17,25 +17,28 @@
package io.nosqlbench.adapter.cqld4.opdispensers;
import com.datastax.oss.driver.api.core.CqlSession;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4RainbowTableOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class CqlD4RainbowTableDispenser extends Cqld4BaseOpDispenser {
public class CqlD4RainbowTableDispenser extends Cqld4BaseOpDispenser<Cqld4RainbowTableOp> {
// private final LongFunction<Statement> stmtFunc;
private final LongFunction<String> targetFunction;
public CqlD4RainbowTableDispenser(DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, LongFunction<String> targetFunction, ParsedOp cmd) {
super(adapter, sessionFunc,cmd);
public CqlD4RainbowTableDispenser(Cqld4DriverAdapter adapter, LongFunction<String> targetFunction, ParsedOp cmd) {
super(adapter, cmd);
this.targetFunction=targetFunction;
// this.tableFunc =createTableFunc(cmd);
}
@Override
public Cqld4CqlOp getOp(long cycle) {
public Cqld4RainbowTableOp getOp(long cycle) {
throw new RuntimeException("implement me");
// return new Cqld4RainbowTableOp(
// getSessionFunc().apply(value),

View File

@ -24,8 +24,10 @@ import com.datastax.oss.driver.api.core.config.DriverExecutionProfile;
import com.datastax.oss.driver.api.core.cql.*;
import com.datastax.oss.driver.api.core.metadata.Node;
import com.datastax.oss.driver.api.core.metadata.token.Token;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.instruments.CqlOpMetrics;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4BaseOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
@ -38,23 +40,25 @@ import org.apache.logging.log4j.Logger;
import java.nio.ByteBuffer;
import java.time.Duration;
import java.util.Map;
import java.util.function.IntFunction;
import java.util.function.LongFunction;
public abstract class Cqld4BaseOpDispenser extends BaseOpDispenser<Cqld4CqlOp, Cqld4Space> implements CqlOpMetrics {
public abstract class Cqld4BaseOpDispenser<T extends Cqld4BaseOp> extends BaseOpDispenser<T, Cqld4Space> implements CqlOpMetrics {
private final static Logger logger = LogManager.getLogger("CQLD4");
private final int maxpages;
private final LongFunction<CqlSession> sessionFunc;
private final boolean isRetryReplace;
private final int maxLwtRetries;
private final Histogram rowsHistogram;
private final Histogram pagesHistogram;
private final Histogram payloadBytesHistogram;
protected final LongFunction<CqlSession> sessionF;
public Cqld4BaseOpDispenser(DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, ParsedOp op) {
super(adapter, op);
this.sessionFunc = sessionFunc;
public Cqld4BaseOpDispenser(Cqld4DriverAdapter adapter,
ParsedOp op) {
super((DriverAdapter<? extends T, ? extends Cqld4Space>) adapter, op);
this.sessionF = l -> adapter.getSpaceCache().get(l).getSession();
this.maxpages = op.getStaticConfigOr("maxpages", 1);
this.isRetryReplace = op.getStaticConfigOr("retryreplace", false);
this.maxLwtRetries = op.getStaticConfigOr("maxlwtretries", 1);
@ -90,11 +94,6 @@ public abstract class Cqld4BaseOpDispenser extends BaseOpDispenser<Cqld4CqlOp, C
return maxLwtRetries;
}
public LongFunction<CqlSession> getSessionFunc() {
return sessionFunc;
}
/**
* All implementations of a CQL Statement Dispenser should be using the method
* provided by this function. This ensures that {@link Statement}-level attributes
@ -106,27 +105,50 @@ public abstract class Cqld4BaseOpDispenser extends BaseOpDispenser<Cqld4CqlOp, C
* overhead for implicit attributes. This should be called when the stmt function is
* initialized within each dispenser, not for each time dispensing occurs.
*/
protected LongFunction<Statement> getEnhancedStmtFunc(LongFunction<Statement> basefunc, ParsedOp op) {
protected <S extends Statement> LongFunction<S> getEnhancedStmtFunc(
LongFunction<S> basefunc,
ParsedOp op
) {
LongFunction<S> partial = basefunc;
LongFunction<Statement> partial = basefunc;
partial = op.enhanceEnumOptionally(partial, "cl", DefaultConsistencyLevel.class, Statement::setConsistencyLevel);
partial = op.enhanceEnumOptionally(partial, "consistency_level", DefaultConsistencyLevel.class, Statement::setConsistencyLevel);
partial = op.enhanceEnumOptionally(partial, "scl", DefaultConsistencyLevel.class, Statement::setSerialConsistencyLevel);
partial = op.enhanceEnumOptionally(partial, "serial_consistency_level", DefaultConsistencyLevel.class, Statement::setSerialConsistencyLevel);
partial = op.enhanceFuncOptionally(partial, "idempotent", Boolean.class, Statement::setIdempotent);
partial = op.enhanceFuncOptionally(partial, "timeout", double.class, (statement, l) -> statement.setTimeout(Duration.ofMillis((long) (l * 1000L))));
partial = op.enhanceFuncOptionally(partial, "custom_payload", Map.class, Statement::setCustomPayload);
partial = op.enhanceFuncOptionally(partial, "execution_profile", DriverExecutionProfile.class, Statement::setExecutionProfile);
partial = op.enhanceFuncOptionally(partial, "execution_profile_name", String.class, Statement::setExecutionProfileName);
partial = op.enhanceFuncOptionally(partial, "node", Node.class, Statement::setNode);
partial = op.enhanceFuncOptionally(partial, "now_in_seconds", int.class, Statement::setNowInSeconds);
partial = op.enhanceFuncOptionally(partial, "page_size", int.class, Statement::setPageSize);
partial = op.enhanceFuncOptionally(partial, "query_timestamp", long.class, Statement::setQueryTimestamp);
partial = op.enhanceFuncOptionally(partial, "routing_key", ByteBuffer.class, Statement::setRoutingKey);
partial = op.enhanceFuncOptionally(partial, "routing_keys", ByteBuffer[].class, Statement::setRoutingKey);
partial = op.enhanceFuncOptionally(partial, "routing_token", Token.class, Statement::setRoutingToken);
partial = op.enhanceFuncOptionally(partial, "tracing", boolean.class, Statement::setTracing);
partial = op.enhanceFuncOptionally(partial, "showstmt", boolean.class, this::showstmt);
// This form is need to overcome limitations in covariant type-checking with method references
partial = op.enhanceEnumOptionally(partial, "cl", DefaultConsistencyLevel.class,
(s, cl) -> (S) s.setConsistencyLevel(cl));
partial = op.enhanceEnumOptionally(partial, "consistency_level", DefaultConsistencyLevel.class,
(s,v) -> (S) s.setConsistencyLevel(v));
partial = op.enhanceEnumOptionally(partial, "scl", DefaultConsistencyLevel.class,
(s,v) -> (S) s.setSerialConsistencyLevel(v));
partial = op.enhanceEnumOptionally(partial, "serial_consistency_level", DefaultConsistencyLevel.class,
(s,v) -> (S) s.setSerialConsistencyLevel(v));
partial = op.enhanceFuncOptionally(partial, "idempotent", Boolean.class,
(s,v) -> (S) s.setIdempotent(v));
partial = op.enhanceFuncOptionally(partial, "custom_payload", Map.class,
(s,v) -> (S) s.setCustomPayload(v));
partial = op.enhanceFuncOptionally(partial, "execution_profile", DriverExecutionProfile.class,
(s,v) -> (S) s.setExecutionProfile(v));
partial = op.enhanceFuncOptionally(partial, "execution_profile_name", String.class,
(s,v) -> (S) s.setExecutionProfileName(v));
partial = op.enhanceFuncOptionally(partial, "node", Node.class,
(s,v) -> (S) s.setNode(v));
partial = op.enhanceFuncOptionally(partial, "now_in_seconds", int.class,
(s,v) -> (S) s.setNowInSeconds(v));
partial = op.enhanceFuncOptionally(partial, "page_size", int.class,
(s,v) -> (S) s.setPageSize(v));
partial = op.enhanceFuncOptionally(partial, "query_timestamp", long.class,
(s,v) -> (S) s.setQueryTimestamp(v));
partial = op.enhanceFuncOptionally(partial, "routing_key", ByteBuffer.class,
(s,v) -> (S) s.setRoutingKey(v));
partial = op.enhanceFuncOptionally(partial, "routing_keys", ByteBuffer[].class,
(s,v) -> (S) s.setRoutingKey(v));
partial = op.enhanceFuncOptionally(partial, "routing_token", Token.class,
(s,v) -> (S) s.setRoutingToken(v));
partial = op.enhanceFuncOptionally(partial, "tracing", boolean.class,
(s,v) -> (S) s.setTracing(v));
partial = op.enhanceFuncOptionally(partial, "timeout", double.class,
(statement, l) -> (S) statement.setTimeout(Duration.ofMillis((long) ((l * 1000L)))));
partial = op.enhanceFuncOptionally(partial, "showstmt", boolean.class, (s,v) -> (S) this.showstmt(s,v));
return partial;
}

View File

@ -0,0 +1,34 @@
package io.nosqlbench.adapter.cqld4.opdispensers;
/*
* Copyright (c) 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.
*/
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4BaseOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapters.api.templating.ParsedOp;
public abstract class Cqld4CqlBaseOpDispenser<T extends Cqld4CqlOp> extends Cqld4BaseOpDispenser<T> {
public Cqld4CqlBaseOpDispenser(Cqld4DriverAdapter adapter, ParsedOp op) {
super(adapter, op);
}
@Override
public abstract T getOp(long value);
}

View File

@ -20,11 +20,12 @@ import com.datastax.dse.driver.api.core.graph.FluentGraphStatement;
import com.datastax.dse.driver.api.core.graph.FluentGraphStatementBuilder;
import com.datastax.oss.driver.api.core.CqlSession;
import groovy.lang.Script;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4BaseOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4FluentGraphOp;
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.virtdata.core.bindings.Bindings;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal;
@ -34,37 +35,34 @@ import java.util.Map;
import java.util.function.LongFunction;
import java.util.function.Supplier;
public class Cqld4FluentGraphOpDispenser extends BaseOpDispenser<Op, Cqld4Space> {
public class Cqld4FluentGraphOpDispenser extends Cqld4BaseOpDispenser<Cqld4FluentGraphOp> {
private final LongFunction<? extends String> graphnameFunc;
private final LongFunction<CqlSession> sessionFunc;
private final Bindings virtdataBindings;
private final ThreadLocal<Script> tlScript;
public Cqld4FluentGraphOpDispenser(
DriverAdapter adapter,
ParsedOp optpl,
Cqld4DriverAdapter adapter,
ParsedOp op,
LongFunction<? extends String> graphnameFunc,
LongFunction<CqlSession> sessionFunc,
Bindings virtdataBindings,
Supplier<Script> scriptSource
Supplier<Script> scriptSupplier
) {
super(adapter, optpl);
super(adapter, op);
this.graphnameFunc = graphnameFunc;
this.sessionFunc = sessionFunc;
this.virtdataBindings = virtdataBindings;
this.tlScript = ThreadLocal.withInitial(scriptSource);
this.tlScript = ThreadLocal.withInitial(scriptSupplier);
}
@Override
public Op getOp(long value) {
public Cqld4FluentGraphOp getOp(long value) {
String graphname = graphnameFunc.apply(value);
Script script = tlScript.get();
Map<String, Object> allMap = virtdataBindings.getAllMap(value);
allMap.forEach((k,v) -> script.getBinding().setVariable(k,v));
GraphTraversal<Vertex,Vertex> v = (GraphTraversal<Vertex, Vertex>) script.run();
FluentGraphStatement fgs = new FluentGraphStatementBuilder(v).setGraphName(graphname).build();
return new Cqld4FluentGraphOp(sessionFunc.apply(value),fgs);
return new Cqld4FluentGraphOp(sessionF.apply(value),fgs);
}

View File

@ -19,7 +19,10 @@ package io.nosqlbench.adapter.cqld4.opdispensers;
import com.datastax.dse.driver.api.core.graph.ScriptGraphStatement;
import com.datastax.dse.driver.api.core.graph.ScriptGraphStatementBuilder;
import com.datastax.oss.driver.api.core.CqlSession;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4BaseOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4ScriptGraphOp;
import io.nosqlbench.adapters.api.activityimpl.BaseOpDispenser;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
@ -28,13 +31,14 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.Optional;
import java.util.function.LongFunction;
public class Cqld4GremlinOpDispenser extends BaseOpDispenser<Cqld4ScriptGraphOp, Cqld4Space> {
public class Cqld4GremlinOpDispenser extends BaseOpDispenser<Cqld4BaseOp, Cqld4Space> {
private final LongFunction<? extends ScriptGraphStatement> stmtFunc;
private final LongFunction<CqlSession> sessionFunc;
private final LongFunction<Long> diagFunc;
public Cqld4GremlinOpDispenser(DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, LongFunction<String> targetFunction, ParsedOp cmd) {
public Cqld4GremlinOpDispenser(Cqld4DriverAdapter adapter,
LongFunction<CqlSession> sessionFunc, LongFunction<String> targetFunction, ParsedOp cmd) {
super(adapter,cmd);
this.sessionFunc = sessionFunc;
this.diagFunc = cmd.getAsFunctionOr("diag", 0L);

View File

@ -20,6 +20,8 @@ import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.BoundStatement;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import com.datastax.oss.driver.api.core.cql.Statement;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.RSProcessors;
import io.nosqlbench.adapter.cqld4.diagnostics.CQLD4PreparedStmtDiagnostics;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
@ -33,7 +35,7 @@ import org.apache.logging.log4j.Logger;
import java.util.function.LongFunction;
public class Cqld4PreparedStmtDispenser extends Cqld4BaseOpDispenser {
public class Cqld4PreparedStmtDispenser extends Cqld4BaseOpDispenser<Cqld4CqlPreparedStatement> {
private final static Logger logger = LogManager.getLogger(Cqld4PreparedStmtDispenser.class);
private final RSProcessors processors;
@ -41,15 +43,16 @@ public class Cqld4PreparedStmtDispenser extends Cqld4BaseOpDispenser {
private final ParsedTemplateString stmtTpl;
private final LongFunction<Object[]> fieldsF;
private PreparedStatement preparedStmt;
private CqlSession boundSession;
// This is a stable enum for the op template from the workload, bounded by cardinality of all op templates
private int refkey;
public Cqld4PreparedStmtDispenser(
DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, ParsedOp op, ParsedTemplateString stmtTpl, RSProcessors processors) {
super(adapter, sessionFunc, op);
if (op.isDynamic("space")) {
throw new RuntimeException("Prepared statements and dynamic space values are not supported." +
" This would churn the prepared statement cache, defeating the purpose of prepared statements.");
}
Cqld4DriverAdapter adapter,
ParsedOp op,
ParsedTemplateString stmtTpl,
RSProcessors processors
) {
super(adapter, op);
this.processors = processors;
this.stmtTpl = stmtTpl;
this.fieldsF = getFieldsFunction(op);
@ -59,40 +62,45 @@ public class Cqld4PreparedStmtDispenser extends Cqld4BaseOpDispenser {
private LongFunction<Object[]> getFieldsFunction(ParsedOp op) {
LongFunction<Object[]> varbinder;
varbinder = op.newArrayBinderFromBindPoints(stmtTpl.getBindPoints());
this.refkey = op.getRefKey();
return varbinder;
}
@Override
public LongFunction<CqlSession> getSessionFunc() {
return super.getSessionFunc();
}
protected LongFunction<Statement> createStmtFunc(LongFunction<Object[]> fieldsF, ParsedOp op) {
String preparedQueryString = stmtTpl.getPositionalStatement(s -> "?");
boundSession = getSessionFunc().apply(0);
try {
preparedStmt = boundSession.prepare(preparedQueryString);
String preparedQueryString = stmtTpl.getPositionalStatement(s -> "?");
LongFunction<PreparedStatement> prepareStatementF =
(long l) -> (sessionF.apply(l)).prepare(preparedQueryString);
LongFunction<? extends Cqld4Space> lookupSpaceF =
(long l) -> adapter.getSpaceCache().get(l);
int refKey = op.getRefKey();
LongFunction<PreparedStatement> cachedStatementF =
(long l) -> lookupSpaceF.apply(l).getOrCreatePreparedStatement(refKey,prepareStatementF);
LongFunction<Statement> boundStatementF =
(long l) -> cachedStatementF.apply(l).bind(fieldsF.apply(l));
return super.getEnhancedStmtFunc(boundStatementF, op);
} catch (Exception e) {
throw new OpConfigError(e + "( for statement '" + stmtTpl + "')");
}
LongFunction<Statement> boundStmtFunc = c -> {
Object[] apply = fieldsF.apply(c);
return preparedStmt.bind(apply);
};
return super.getEnhancedStmtFunc(boundStmtFunc, op);
}
@Override
public Cqld4CqlOp getOp(long cycle) {
BoundStatement boundStatement;
public Cqld4CqlPreparedStatement getOp(long cycle) {
BoundStatement stmt = (BoundStatement) stmtFunc.apply(cycle);
try {
boundStatement = (BoundStatement) stmtFunc.apply(cycle);
CqlSession session = (CqlSession) sessionF.apply(cycle);
return new Cqld4CqlPreparedStatement(
boundSession,
boundStatement,
sessionF.apply(cycle),
stmt,
getMaxPages(),
isRetryReplace(),
getMaxLwtRetries(),

View File

@ -20,6 +20,8 @@ import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import com.datastax.oss.driver.api.core.cql.SimpleStatementBuilder;
import com.datastax.oss.driver.api.core.cql.Statement;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlSimpleStatement;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
@ -27,13 +29,14 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class Cqld4RawStmtDispenser extends Cqld4BaseOpDispenser {
public class Cqld4RawStmtDispenser extends Cqld4CqlBaseOpDispenser<Cqld4CqlSimpleStatement> {
private final LongFunction<Statement> stmtFunc;
private final LongFunction<String> targetFunction;
public Cqld4RawStmtDispenser(DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, LongFunction<String> targetFunction, ParsedOp cmd) {
super(adapter, sessionFunc, cmd);
public Cqld4RawStmtDispenser(Cqld4DriverAdapter adapter,
LongFunction<String> targetFunction, ParsedOp cmd) {
super(adapter, cmd);
this.targetFunction=targetFunction;
this.stmtFunc = createStmtFunc(cmd);
}
@ -44,9 +47,9 @@ public class Cqld4RawStmtDispenser extends Cqld4BaseOpDispenser {
}
@Override
public Cqld4CqlOp getOp(long value) {
public Cqld4CqlSimpleStatement getOp(long value) {
return new Cqld4CqlSimpleStatement(
getSessionFunc().apply(value),
sessionF.apply(value),
(SimpleStatement) stmtFunc.apply(value),
getMaxPages(),
isRetryReplace(),

View File

@ -19,19 +19,22 @@ package io.nosqlbench.adapter.cqld4.opdispensers;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import com.datastax.oss.driver.api.core.cql.Statement;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlSimpleStatement;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class Cqld4SimpleCqlStmtDispenser extends Cqld4BaseOpDispenser {
public class Cqld4SimpleCqlStmtDispenser extends Cqld4CqlBaseOpDispenser<Cqld4CqlSimpleStatement> {
private final LongFunction<Statement> stmtFunc;
private final LongFunction<String> targetFunction;
public Cqld4SimpleCqlStmtDispenser(DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, LongFunction<String> targetFunction, ParsedOp cmd) {
super(adapter, sessionFunc,cmd);
public Cqld4SimpleCqlStmtDispenser(Cqld4DriverAdapter adapter, LongFunction<String> targetFunction, ParsedOp cmd) {
super(adapter, cmd);
this.targetFunction=targetFunction;
this.stmtFunc =createStmtFunc(cmd);
}
@ -43,7 +46,7 @@ public class Cqld4SimpleCqlStmtDispenser extends Cqld4BaseOpDispenser {
@Override
public Cqld4CqlSimpleStatement getOp(long value) {
return new Cqld4CqlSimpleStatement(
getSessionFunc().apply(value),
this.sessionF.apply(value),
(SimpleStatement) stmtFunc.apply(value),
getMaxPages(),
isRetryReplace(),

View File

@ -24,13 +24,13 @@ import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class Cqld4SsTableDispenser extends Cqld4BaseOpDispenser {
public class Cqld4SsTableDispenser extends Cqld4BaseOpDispenser<Cqld4CqlOp> {
// private final LongFunction<Statement> stmtFunc;
// private final LongFunction<String> targetFunction;
public Cqld4SsTableDispenser(Cqld4DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, LongFunction<String> targetFunction, ParsedOp cmd) {
super(adapter,sessionFunc,cmd);
public Cqld4SsTableDispenser(Cqld4DriverAdapter adapter, LongFunction<String> targetFunction, ParsedOp cmd) {
super(adapter,cmd);
// this.targetFunction=targetFunction;
// this.tableFunc =createTableFunc(cmd);
}

View File

@ -16,44 +16,33 @@
package io.nosqlbench.adapter.cqld4.opmappers;
import com.datastax.oss.driver.api.core.CqlSession;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.opdispensers.CqlD4BatchStmtDispenser;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlBatchStatement;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.engine.api.templating.TypeAndTarget;
import java.util.function.LongFunction;
public class CqlD4BatchStmtMapper implements OpMapper<Cqld4CqlOp> {
public class CqlD4BatchStmtMapper extends Cqld4CqlBaseOpMapper<Cqld4CqlBatchStatement> {
private final LongFunction<CqlSession> sessionFunc;
private final TypeAndTarget<CqlD4OpType, String> target;
private final DriverAdapter adapter;
public CqlD4BatchStmtMapper(DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, TypeAndTarget<CqlD4OpType,String> target) {
this.sessionFunc=sessionFunc;
public CqlD4BatchStmtMapper(Cqld4DriverAdapter adapter,
TypeAndTarget<CqlD4OpType, String> target) {
super(adapter);
this.target = target;
this.adapter = adapter;
}
/**
* TODO: Make this not require a sub-op element for "uniform batches",
* but allow a sub-op sequence for custom batches.
* @param op the function argument
* @return
*/
public OpDispenser<Cqld4CqlOp> apply(ParsedOp op) {
@Override
public OpDispenser<Cqld4CqlBatchStatement> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF) {
ParsedOp subop = op.getAsSubOp("op_template", ParsedOp.SubOpNaming.ParentAndSubKey);
int repeat = op.getStaticValue("repeat");
OpMapper<Cqld4CqlOp> subopMapper = adapter.getOpMapper();
OpDispenser<? extends Cqld4CqlOp> subopDispenser = subopMapper.apply(subop);
return new CqlD4BatchStmtDispenser(adapter, sessionFunc, op,repeat, subop, subopDispenser);
OpDispenser<Cqld4CqlOp> od = new Cqld4CqlOpMapper(adapter).apply(op, spaceInitF);
return new CqlD4BatchStmtDispenser(adapter, op, repeat, subop, od);
}
}

View File

@ -16,29 +16,28 @@
package io.nosqlbench.adapter.cqld4.opmappers;
import com.datastax.oss.driver.api.core.CqlSession;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.opdispensers.Cqld4SimpleCqlStmtDispenser;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlSimpleStatement;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class CqlD4CqlSimpleStmtMapper implements OpMapper<Cqld4CqlOp> {
private final LongFunction<CqlSession> sessionFunc;
public class CqlD4CqlSimpleStmtMapper extends Cqld4CqlBaseOpMapper<Cqld4CqlSimpleStatement> {
private final LongFunction<String> targetFunction;
private final DriverAdapter adapter;
public CqlD4CqlSimpleStmtMapper(DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, LongFunction<String> targetFunction) {
this.sessionFunc = sessionFunc;
public CqlD4CqlSimpleStmtMapper(Cqld4DriverAdapter adapter,
LongFunction<String> targetFunction) {
super(adapter);
this.targetFunction = targetFunction;
this.adapter = adapter;
}
@Override
public OpDispenser<? extends Cqld4CqlOp> apply(ParsedOp op) {
return new Cqld4SimpleCqlStmtDispenser(adapter, sessionFunc,targetFunction, op);
public OpDispenser<Cqld4CqlSimpleStatement> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF) {
return new Cqld4SimpleCqlStmtDispenser(adapter, targetFunction, op);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -17,15 +17,16 @@
package io.nosqlbench.adapter.cqld4.opmappers;
import com.datastax.oss.driver.api.core.CqlSession;
import io.nosqlbench.adapter.cqld4.Cqld4Processors;
import io.nosqlbench.adapter.cqld4.RSProcessors;
import io.nosqlbench.adapter.cqld4.ResultSetProcessor;
import io.nosqlbench.adapter.cqld4.*;
import io.nosqlbench.adapter.cqld4.opdispensers.Cqld4PreparedStmtDispenser;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4BaseOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlPreparedStatement;
import io.nosqlbench.adapter.cqld4.processors.CqlFieldCaptureProcessor;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.engine.api.templating.TypeAndTarget;
import io.nosqlbench.nb.api.config.params.ParamsParser;
@ -37,20 +38,18 @@ import java.util.Map;
import java.util.Optional;
import java.util.function.LongFunction;
public class CqlD4PreparedStmtMapper implements OpMapper<Cqld4CqlOp> {
public class CqlD4PreparedStmtMapper extends Cqld4CqlBaseOpMapper<Cqld4CqlPreparedStatement> {
private final LongFunction<CqlSession> sessionFunc;
private final TypeAndTarget<CqlD4OpType, String> target;
private final DriverAdapter adapter;
public CqlD4PreparedStmtMapper(DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, TypeAndTarget<CqlD4OpType,String> target) {
this.sessionFunc=sessionFunc;
public CqlD4PreparedStmtMapper(Cqld4DriverAdapter adapter,
TypeAndTarget<CqlD4OpType, String> target) {
super(adapter);
this.target = target;
this.adapter = adapter;
}
public OpDispenser<Cqld4CqlOp> apply(ParsedOp op) {
@Override
public OpDispenser<Cqld4CqlPreparedStatement> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF) {
ParsedTemplateString stmtTpl = op.getAsTemplate(target.field).orElseThrow(() -> new BasicError(
"No statement was found in the op template:" + op
));
@ -70,7 +69,7 @@ public class CqlD4PreparedStmtMapper implements OpMapper<Cqld4CqlOp> {
});
});
return new Cqld4PreparedStmtDispenser(adapter, sessionFunc, op, stmtTpl, processors);
return new Cqld4PreparedStmtDispenser(adapter, op, stmtTpl, processors);
}
}

View File

@ -17,27 +17,34 @@
package io.nosqlbench.adapter.cqld4.opmappers;
import com.datastax.oss.driver.api.core.CqlSession;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4RainbowTableOp;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class CqlD4RainbowTableMapper implements OpMapper<Cqld4RainbowTableOp> {
private final LongFunction<CqlSession> sessionFunc;
public class CqlD4RainbowTableMapper<CO extends Cqld4RainbowTableOp> extends Cqld4BaseOpMapper<Cqld4RainbowTableOp> {
private final LongFunction<String> targetFunction;
private final DriverAdapter adapter;
public CqlD4RainbowTableMapper(DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, LongFunction<String> targetFunction) {
this.sessionFunc = sessionFunc;
public CqlD4RainbowTableMapper(
Cqld4DriverAdapter adapter,
LongFunction<CqlSession> sessionFunc,
LongFunction<String> targetFunction
) {
super(adapter);
this.targetFunction = targetFunction;
this.adapter = adapter;
}
@Override
public OpDispenser<? extends Cqld4RainbowTableOp> apply(ParsedOp op) {
public OpDispenser<Cqld4RainbowTableOp> apply(ParsedOp op, LongFunction spaceInitF) {
return null;
// return new CqlD4RainbowTableDispenser(adapter, sessionFunc,targetFunction, op);
}

View File

@ -16,30 +16,36 @@
package io.nosqlbench.adapter.cqld4.opmappers;
import com.datastax.oss.driver.api.core.CqlSession;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.opdispensers.Cqld4RawStmtDispenser;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4BaseOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlSimpleStatement;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class CqlD4RawStmtMapper implements OpMapper<Cqld4CqlOp> {
public class CqlD4RawStmtMapper extends Cqld4CqlBaseOpMapper<Cqld4CqlSimpleStatement> {
private final LongFunction<CqlSession> sessionFunc;
private final LongFunction<String> targetFunction;
private final DriverAdapter adapter;
public CqlD4RawStmtMapper(DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, LongFunction<String> targetFunction) {
this.sessionFunc = sessionFunc;
public CqlD4RawStmtMapper(Cqld4DriverAdapter adapter,LongFunction<String> targetFunction) {
super(adapter);
this.targetFunction = targetFunction;
this.adapter = adapter;
}
@Override
public OpDispenser<? extends Cqld4CqlOp> apply(ParsedOp op) {
return new Cqld4RawStmtDispenser(adapter, sessionFunc, targetFunction, op);
public OpDispenser<Cqld4CqlSimpleStatement> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF) {
return new Cqld4RawStmtDispenser(adapter, targetFunction,op);
}
// @Override
// public OpDispenser<Cqld4CqlOp> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF) {
// return new Cqld4RawStmtDispenser(adapter, sessionFunc, targetFunction, op);
// }
// @Override
// public OpDispenser<Cqld4CqlOp> apply(ParsedOp parsedOp, LongFunction<Cqld4Space> longFunction) {
// return new Cqld4RawStmtDispenser(adapter, sessionFunc, targetFunction, parsedOp);
// }
}

View File

@ -0,0 +1,52 @@
/*
* 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.adapter.cqld4.opmappers;
import com.datastax.oss.driver.api.core.CqlSession;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4BaseOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.BaseSpace;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.engine.api.templating.TypeAndTarget;
import io.nosqlbench.nb.api.config.standard.NBConfiguration;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.function.LongFunction;
public abstract class Cqld4BaseOpMapper<T extends Cqld4BaseOp> implements OpMapper<T,Cqld4Space> {
protected final static Logger logger = LogManager.getLogger(Cqld4BaseOpMapper.class);
protected final Cqld4DriverAdapter adapter;
protected final LongFunction<Cqld4Space> spaceFunc;
protected final LongFunction<CqlSession> sessionFunc;
public Cqld4BaseOpMapper(Cqld4DriverAdapter adapter) {
this.adapter = adapter;
spaceFunc = l -> adapter.getSpaceCache().get(l);
sessionFunc = l -> spaceFunc.apply(l).getSession();
}
@Override
public abstract OpDispenser<T> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF);
}

View File

@ -16,33 +16,28 @@
package io.nosqlbench.adapter.cqld4.opmappers;
import com.datastax.oss.driver.api.core.CqlSession;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4BaseOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.nb.api.config.standard.NBConfiguration;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverSpaceCache;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.engine.api.templating.TypeAndTarget;
import io.nosqlbench.nb.api.errors.OpConfigError;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.function.LongFunction;
public class Cqld4CoreOpMapper implements OpMapper<Op> {
public class Cqld4CoreOpMapper extends Cqld4BaseOpMapper<Cqld4BaseOp> {
private final static Logger logger = LogManager.getLogger(Cqld4CoreOpMapper.class);
private final DriverSpaceCache<? extends Cqld4Space> cache;
private final NBConfiguration cfg;
private final DriverAdapter adapter;
public Cqld4CoreOpMapper(DriverAdapter adapter, NBConfiguration config, DriverSpaceCache<? extends Cqld4Space> cache) {
this.cfg = config;
this.cache = cache;
this.adapter = adapter;
public Cqld4CoreOpMapper(Cqld4DriverAdapter adapter,
NBConfiguration config) {
super(adapter);
}
/**
@ -50,35 +45,27 @@ public class Cqld4CoreOpMapper implements OpMapper<Op> {
* for it. Since the operations under the CQL driver 4.* do not follow a common type structure, we use the
* base types in the NoSQLBench APIs and treat them somewhat more generically than with other drivers.
*
* @param op The {@link ParsedOp} which is the parsed version of the user-provided op template.
* This contains all the fields provided by the user, as well as explicit knowledge of
* which ones are static and dynamic.
* @param op
* The {@link ParsedOp} which is the parsed version of the user-provided op template.
* This contains all the fields provided by the user, as well as explicit knowledge of
* which ones are static and dynamic.
* @return An op dispenser for each provided op command
*/
public OpDispenser<? extends Op> apply(ParsedOp op) {
LongFunction<String> spaceName = op.getAsFunctionOr("space", "default");
// Since the only needed thing in the Cqld4Space is the session, we can short-circuit
// to it here instead of stepping down from the cycle to the space to the session
LongFunction<CqlSession> sessionFunc = l -> cache.get(spaceName.apply(l)).getSession();
@Override
public OpDispenser<Cqld4BaseOp> apply(ParsedOp op, LongFunction<Cqld4Space> cqld4SpaceLongFunction) {
CqlD4OpType opType = CqlD4OpType.prepared;
TypeAndTarget<CqlD4OpType, String> target = op.getTypeAndTarget(CqlD4OpType.class, String.class, "type", "stmt");
logger.info(() -> "Using " + target.enumId + " statement form for '" + op.getName()+"'");
return switch (target.enumId) {
case raw -> new CqlD4RawStmtMapper(adapter, sessionFunc, target.targetFunction).apply(op);
case simple -> new CqlD4CqlSimpleStmtMapper(adapter, sessionFunc, target.targetFunction).apply(op);
case prepared -> new CqlD4PreparedStmtMapper(adapter, sessionFunc, target).apply(op);
case batch -> new CqlD4BatchStmtMapper(adapter, sessionFunc, target).apply(op);
case gremlin -> new Cqld4GremlinOpMapper(adapter, sessionFunc, target.targetFunction).apply(op);
case fluent -> new Cqld4FluentGraphOpMapper(adapter, sessionFunc, target).apply(op);
case rainbow -> new CqlD4RainbowTableMapper(adapter, sessionFunc, target.targetFunction).apply(op);
return (OpDispenser<Cqld4BaseOp>) switch (target.enumId) {
case raw, simple, prepared, batch -> new Cqld4CqlOpMapper(adapter).apply(op, spaceFunc);
case gremlin -> new Cqld4GremlinOpMapper(adapter, target.targetFunction).apply(op, spaceFunc);
case fluent -> new Cqld4FluentGraphOpMapper(adapter, target).apply(op, spaceFunc);
case rainbow -> new CqlD4RainbowTableMapper(adapter, sessionFunc, target.targetFunction).apply(op, spaceFunc);
default -> throw new OpConfigError("Unsupported op type " + opType);
// case sst -> new Cqld4SsTableMapper(adapter, sessionFunc, target.targetFunction).apply(op);
};
}
}

View File

@ -0,0 +1,37 @@
package io.nosqlbench.adapter.cqld4.opmappers;
/*
* Copyright (c) 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.
*/
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public abstract class Cqld4CqlBaseOpMapper<T extends Cqld4CqlOp> extends Cqld4BaseOpMapper<T> {
public Cqld4CqlBaseOpMapper(Cqld4DriverAdapter adapter) {
super(adapter);
}
@Override
public abstract OpDispenser<T> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF);
}

View File

@ -0,0 +1,62 @@
/*
* 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.adapter.cqld4.opmappers;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlSimpleStatement;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import io.nosqlbench.engine.api.templating.TypeAndTarget;
import io.nosqlbench.nb.api.errors.OpConfigError;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.function.LongFunction;
public class Cqld4CqlOpMapper extends Cqld4CqlBaseOpMapper<Cqld4CqlOp> {
protected final static Logger logger = LogManager.getLogger(Cqld4CqlOpMapper.class);
public Cqld4CqlOpMapper(Cqld4DriverAdapter adapter) {
super(adapter);
}
@Override
public OpDispenser<Cqld4CqlOp> apply(ParsedOp op, LongFunction<Cqld4Space> spaceInitF) {
CqlD4OpType opType = CqlD4OpType.prepared;
TypeAndTarget<CqlD4OpType, String> target = op.getTypeAndTarget(CqlD4OpType.class, String.class, "type", "stmt");
logger.info(() -> "Using " + target.enumId + " statement form for '" + op.getName() + "'");
return (OpDispenser<Cqld4CqlOp>) switch (target.enumId) {
case raw -> {
CqlD4RawStmtMapper cqlD4RawStmtMapper = new CqlD4RawStmtMapper(adapter, target.targetFunction);
OpDispenser<Cqld4CqlSimpleStatement> apply = cqlD4RawStmtMapper.apply(op, spaceFunc);
yield apply;
}
case simple -> new CqlD4CqlSimpleStmtMapper(adapter, target.targetFunction).apply(op, spaceFunc);
case prepared -> new CqlD4PreparedStmtMapper(adapter, target).apply(op, spaceFunc);
case batch -> new CqlD4BatchStmtMapper(adapter, target).apply(op, spaceFunc);
default ->
throw new OpConfigError("Unsupported op type for CQL category of statement forms:" + target.enumId);
};
}
}

View File

@ -21,10 +21,16 @@ import com.datastax.oss.driver.api.core.CqlSession;
import groovy.lang.Binding;
import groovy.lang.GroovyShell;
import groovy.lang.Script;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.opdispensers.Cqld4FluentGraphOpDispenser;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4BaseOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4FluentGraphOp;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
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.templating.ParsedOp;
import io.nosqlbench.engine.api.templating.TypeAndTarget;
@ -45,22 +51,21 @@ import java.util.Map;
import java.util.function.LongFunction;
import java.util.function.Supplier;
public class Cqld4FluentGraphOpMapper implements OpMapper<Op> {
public class Cqld4FluentGraphOpMapper extends Cqld4BaseOpMapper<Cqld4FluentGraphOp> {
private final static Logger logger = LogManager.getLogger(Cqld4FluentGraphOpMapper.class);
private final LongFunction<CqlSession> sessionFunc;
private final TypeAndTarget<CqlD4OpType, String> target;
private final DriverAdapter adapter;
private GraphTraversalSource gtsPlaceHolder;
public Cqld4FluentGraphOpMapper(DriverAdapter adapter, LongFunction<CqlSession> sessionFunc, TypeAndTarget<CqlD4OpType, String> target) {
this.sessionFunc = sessionFunc;
public Cqld4FluentGraphOpMapper(Cqld4DriverAdapter adapter,
TypeAndTarget<CqlD4OpType, String> target) {
super(adapter);
this.target = target;
this.adapter = adapter;
}
@Override
public OpDispenser<? extends Op> apply(ParsedOp op) {
public OpDispenser<Cqld4FluentGraphOp> apply(ParsedOp op, LongFunction<Cqld4Space> cqld4SpaceLongFunction) {
GraphTraversalSource g = DseGraph.g;
ParsedTemplateString fluent = op.getAsTemplate(target.field).orElseThrow();
@ -88,7 +93,13 @@ public class Cqld4FluentGraphOpMapper implements OpMapper<Op> {
LongFunction<? extends String> graphnameFunc = op.getAsRequiredFunction("graphname");
Bindings virtdataBindings = new BindingsTemplate(fluent.getBindPoints()).resolveBindings();
return new Cqld4FluentGraphOpDispenser(adapter, op, graphnameFunc, sessionFunc, virtdataBindings, supplier);
return new Cqld4FluentGraphOpDispenser(
adapter,
op,
graphnameFunc,
virtdataBindings,
supplier
);
}
private String[] expandClassNames(List l) {
@ -110,4 +121,5 @@ public class Cqld4FluentGraphOpMapper implements OpMapper<Op> {
}
return classNames.toArray(new String[0]);
}
}

View File

@ -17,27 +17,30 @@
package io.nosqlbench.adapter.cqld4.opmappers;
import com.datastax.oss.driver.api.core.CqlSession;
import io.nosqlbench.adapter.cqld4.Cqld4DriverAdapter;
import io.nosqlbench.adapter.cqld4.Cqld4Space;
import io.nosqlbench.adapter.cqld4.opdispensers.Cqld4GremlinOpDispenser;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4CqlOp;
import io.nosqlbench.adapter.cqld4.optypes.Cqld4ScriptGraphOp;
import io.nosqlbench.adapters.api.activityimpl.OpDispenser;
import io.nosqlbench.adapters.api.activityimpl.OpMapper;
import io.nosqlbench.adapters.api.activityimpl.uniform.DriverAdapter;
import io.nosqlbench.adapters.api.activityimpl.uniform.Space;
import io.nosqlbench.adapters.api.templating.ParsedOp;
import java.util.function.LongFunction;
public class Cqld4GremlinOpMapper implements OpMapper<Cqld4ScriptGraphOp> {
private final LongFunction<CqlSession> sessionFunc;
public class Cqld4GremlinOpMapper<CO extends Cqld4ScriptGraphOp> extends Cqld4BaseOpMapper<Cqld4ScriptGraphOp> {
private final LongFunction<String> targetFunction;
private final DriverAdapter adapter;
public Cqld4GremlinOpMapper(DriverAdapter adapter, LongFunction<CqlSession> session, LongFunction<String> targetFunction) {
this.sessionFunc = session;
public Cqld4GremlinOpMapper(Cqld4DriverAdapter adapter, LongFunction<String> targetFunction) {
super(adapter);
this.targetFunction = targetFunction;
this.adapter = adapter;
}
public OpDispenser<Cqld4ScriptGraphOp> apply(ParsedOp op) {
@Override
public Cqld4GremlinOpDispenser apply(ParsedOp op, LongFunction spaceInitF) {
return new Cqld4GremlinOpDispenser(adapter, sessionFunc, targetFunction, op);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -0,0 +1,24 @@
package io.nosqlbench.adapter.cqld4.optypes;
/*
* Copyright (c) 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.
*/
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.Op;
public interface Cqld4BaseOp extends Op {
}

View File

@ -49,7 +49,9 @@ import java.util.concurrent.*;
// TODO: add rows histogram resultSetSizeHisto
public abstract class Cqld4CqlOp implements CycleOp<List<Row>>, VariableCapture, OpGenerator, OpResultSize {
public abstract class Cqld4CqlOp
implements Cqld4BaseOp, CycleOp<List<Row>>, VariableCapture, OpGenerator, OpResultSize {
private final static Logger logger = LogManager.getLogger(Cqld4CqlOp.class);
private final CqlSession session;

View File

@ -25,8 +25,15 @@ public class Cqld4CqlPreparedStatement extends Cqld4CqlOp {
private final BoundStatement stmt;
public Cqld4CqlPreparedStatement(CqlSession session, BoundStatement stmt, int maxPages,
boolean retryReplace, int maxLwtRetries, RSProcessors processors, CqlOpMetrics metrics) {
public Cqld4CqlPreparedStatement(
CqlSession session,
BoundStatement stmt,
int maxPages,
boolean retryReplace,
int maxLwtRetries,
RSProcessors processors,
CqlOpMetrics metrics
) {
super(session, maxPages, retryReplace, maxLwtRetries, processors, metrics);
this.stmt = stmt;
}

View File

@ -22,7 +22,7 @@ import com.datastax.oss.driver.api.core.CqlSession;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.CycleOp;
import io.nosqlbench.adapters.api.activityimpl.uniform.flowtypes.OpResultSize;
public class Cqld4FluentGraphOp implements CycleOp<GraphResultSet>, OpResultSize {
public class Cqld4FluentGraphOp implements Cqld4BaseOp, CycleOp<GraphResultSet>, OpResultSize {
private final CqlSession session;
private final FluentGraphStatement stmt;
private int resultSize=0;

Some files were not shown because too many files have changed in this diff Show More