-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1950 from nosqlbench/ms/dapi
Additional APIs, upgraded client
- Loading branch information
Showing
14 changed files
with
284 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
.../io/nosqlbench/adapter/dataapi/opdispensers/DataApiEstimatedDocumentCountOpDispenser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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 KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.nosqlbench.adapter.dataapi.opdispensers; | ||
|
||
import io.nosqlbench.adapter.dataapi.DataApiDriverAdapter; | ||
import io.nosqlbench.adapter.dataapi.ops.DataApiBaseOp; | ||
import io.nosqlbench.adapter.dataapi.ops.DataApiEstimatedDocumentCountOp; | ||
import io.nosqlbench.adapters.api.templating.ParsedOp; | ||
|
||
import java.util.function.LongFunction; | ||
|
||
public class DataApiEstimatedDocumentCountOpDispenser extends DataApiOpDispenser { | ||
private final LongFunction<DataApiEstimatedDocumentCountOp> opFunction; | ||
public DataApiEstimatedDocumentCountOpDispenser( | ||
DataApiDriverAdapter adapter, ParsedOp op, LongFunction<String> targetFunction) { | ||
super(adapter, op, targetFunction); | ||
this.opFunction = createOpFunction(op); | ||
} | ||
|
||
private LongFunction<DataApiEstimatedDocumentCountOp> createOpFunction(ParsedOp op) { | ||
return (l) -> { | ||
return new DataApiEstimatedDocumentCountOp( | ||
spaceFunction.apply(l).getDatabase(), | ||
targetFunction.apply(l) | ||
); | ||
}; | ||
} | ||
|
||
@Override | ||
public DataApiBaseOp getOp(long value) { | ||
return opFunction.apply(value); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...ava/io/nosqlbench/adapter/dataapi/opdispensers/DataApiListCollectionNamesOpDispenser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* 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 KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.nosqlbench.adapter.dataapi.opdispensers; | ||
|
||
import io.nosqlbench.adapter.dataapi.DataApiDriverAdapter; | ||
import io.nosqlbench.adapter.dataapi.ops.DataApiBaseOp; | ||
import io.nosqlbench.adapter.dataapi.ops.DataApiListCollectionNamesOp; | ||
import io.nosqlbench.adapters.api.templating.ParsedOp; | ||
|
||
import java.util.function.LongFunction; | ||
|
||
public class DataApiListCollectionNamesOpDispenser extends DataApiOpDispenser { | ||
private final LongFunction<DataApiListCollectionNamesOp> opFunction; | ||
public DataApiListCollectionNamesOpDispenser(DataApiDriverAdapter adapter, ParsedOp op, LongFunction<String> targetFunction) { | ||
super(adapter, op, targetFunction); | ||
this.opFunction = createOpFunction(op); | ||
} | ||
|
||
private LongFunction<DataApiListCollectionNamesOp> createOpFunction(ParsedOp op) { | ||
return l -> { | ||
return new DataApiListCollectionNamesOp(spaceFunction.apply(l).getDatabase()); | ||
}; | ||
} | ||
|
||
@Override | ||
public DataApiBaseOp getOp(long value) { | ||
return opFunction.apply(value); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...in/java/io/nosqlbench/adapter/dataapi/opdispensers/DataApiListCollectionsOpDispenser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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 KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.nosqlbench.adapter.dataapi.opdispensers; | ||
|
||
import io.nosqlbench.adapter.dataapi.DataApiDriverAdapter; | ||
import io.nosqlbench.adapter.dataapi.ops.DataApiBaseOp; | ||
import io.nosqlbench.adapter.dataapi.ops.DataApiListCollectionsOp; | ||
import io.nosqlbench.adapters.api.templating.ParsedOp; | ||
|
||
import java.util.function.LongFunction; | ||
|
||
public class DataApiListCollectionsOpDispenser extends DataApiOpDispenser { | ||
private final LongFunction<DataApiListCollectionsOp> opFunction; | ||
public DataApiListCollectionsOpDispenser(DataApiDriverAdapter adapter, ParsedOp op, LongFunction<String> targetFunction) { | ||
super(adapter, op, targetFunction); | ||
this.opFunction = createOpFunction(op); | ||
} | ||
|
||
private LongFunction<DataApiListCollectionsOp> createOpFunction(ParsedOp op) { | ||
return l -> { | ||
DataApiListCollectionsOp dataApiListCollectionsOp = | ||
new DataApiListCollectionsOp( | ||
spaceFunction.apply(l).getDatabase()); | ||
return dataApiListCollectionsOp; | ||
}; | ||
} | ||
|
||
@Override | ||
public DataApiBaseOp getOp(long value) { | ||
return opFunction.apply(value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...aapi/src/main/java/io/nosqlbench/adapter/dataapi/ops/DataApiEstimatedDocumentCountOp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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 KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.nosqlbench.adapter.dataapi.ops; | ||
|
||
import com.datastax.astra.client.Collection; | ||
import com.datastax.astra.client.Database; | ||
import com.datastax.astra.client.model.Document; | ||
|
||
public class DataApiEstimatedDocumentCountOp extends DataApiBaseOp { | ||
private final String collectionName; | ||
public DataApiEstimatedDocumentCountOp(Database db, String collectionName) { | ||
super(db); | ||
this.collectionName = collectionName; | ||
} | ||
|
||
@Override | ||
public Object apply(long value) { | ||
long response; | ||
Collection<Document> collection = db.getCollection(collectionName); | ||
response = collection.estimatedDocumentCount(); | ||
return response; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
...dataapi/src/main/java/io/nosqlbench/adapter/dataapi/ops/DataApiListCollectionNamesOp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* 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 KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.nosqlbench.adapter.dataapi.ops; | ||
|
||
import com.datastax.astra.client.Database; | ||
|
||
import java.util.stream.Stream; | ||
|
||
public class DataApiListCollectionNamesOp extends DataApiBaseOp { | ||
|
||
public DataApiListCollectionNamesOp(Database db) { | ||
super(db); | ||
} | ||
|
||
@Override | ||
public Object apply(long value) { | ||
Stream<String> response; | ||
response = db.listCollectionNames(); | ||
if(logger.isDebugEnabled()) response.forEach(logger::debug); | ||
return response; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...ter-dataapi/src/main/java/io/nosqlbench/adapter/dataapi/ops/DataApiListCollectionsOp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* 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 KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.nosqlbench.adapter.dataapi.ops; | ||
|
||
import com.datastax.astra.client.Database; | ||
|
||
public class DataApiListCollectionsOp extends DataApiBaseOp { | ||
|
||
public DataApiListCollectionsOp(Database db) { | ||
super(db); | ||
} | ||
|
||
@Override | ||
public Object apply(long value) { | ||
return db.listCollections(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
nb-adapters/adapter-dataapi/src/main/resources/activities/estimated_document_count.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
scenarios: | ||
default: | ||
estimated_document_count: run driver=dataapi tags==blocks:estimated_document_count cycles=1 | ||
|
||
blocks: | ||
estimated_document_count: | ||
ops: | ||
op1: | ||
estimated_document_count: "collectionName" |
9 changes: 9 additions & 0 deletions
9
nb-adapters/adapter-dataapi/src/main/resources/activities/list_collection_names.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
scenarios: | ||
default: | ||
list_collection_names: run driver=dataapi tags==blocks:list_collection_names cycles=1 | ||
|
||
blocks: | ||
list_collection_names: | ||
ops: | ||
op1: | ||
list_collection_names: |
9 changes: 9 additions & 0 deletions
9
nb-adapters/adapter-dataapi/src/main/resources/activities/list_collections.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
scenarios: | ||
default: | ||
list_collections: run driver=dataapi tags==blocks:list_collections cycles=1 | ||
|
||
blocks: | ||
list_collections: | ||
ops: | ||
op1: | ||
list_collections: |