mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-11-25 18:20:33 -06:00
minor updates to branch
This commit is contained in:
parent
4abf54a3a7
commit
d8b3e6214c
@ -272,7 +272,7 @@ public class NBCLIScenarioParser {
|
||||
|
||||
List<Content<?>> activities = NBIO.all()
|
||||
.prefix(SEARCH_IN)
|
||||
.name(".*\\.yaml")
|
||||
.extension("yaml")
|
||||
.list();
|
||||
|
||||
List<Path> yamlPathList = activities.stream().map(Content::asPath).collect(Collectors.toList());
|
||||
|
@ -45,51 +45,51 @@ public class NBIO implements NBPathsAPI.Facets {
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBPathsAPI.ForPrefix localContent() {
|
||||
public NBPathsAPI.GetPrefix localContent() {
|
||||
this.resolver = URIResolvers.inFS().inCP();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBPathsAPI.ForPrefix remoteContent() {
|
||||
public NBPathsAPI.GetPrefix remoteContent() {
|
||||
this.resolver = URIResolvers.inURLs();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBPathsAPI.ForPrefix internalContent() {
|
||||
public NBPathsAPI.GetPrefix internalContent() {
|
||||
this.resolver = URIResolvers.inClasspath();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBPathsAPI.ForPrefix fileContent() {
|
||||
public NBPathsAPI.GetPrefix fileContent() {
|
||||
this.resolver = URIResolvers.inFS();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBPathsAPI.ForPrefix allContent() {
|
||||
public NBPathsAPI.GetPrefix allContent() {
|
||||
this.resolver = URIResolvers.inFS().inCP().inURLs();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBPathsAPI.ForPrefix prefix(String... searchPaths) {
|
||||
public NBPathsAPI.GetPrefix prefix(String... searchPaths) {
|
||||
ArrayList<String> addingPaths = new ArrayList<>(this.prefixes);
|
||||
addingPaths.addAll(Arrays.asList(searchPaths));
|
||||
return new NBIO(resolver, addingPaths, names, extensions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBPathsAPI.ForName name(String... searchNames) {
|
||||
public NBPathsAPI.GetExtension name(String... searchNames) {
|
||||
ArrayList<String> addingNames = new ArrayList<>(this.names);
|
||||
addingNames.addAll(Arrays.asList(searchNames));
|
||||
return new NBIO(resolver, prefixes, addingNames, extensions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBPathsAPI.ForExtension extension(String... extensions) {
|
||||
public NBPathsAPI.DoSearch extension(String... extensions) {
|
||||
ArrayList<String> addingExtensions = new ArrayList<>(this.extensions);
|
||||
for (String addingExtension : extensions) {
|
||||
addingExtensions.add(dotExtension(addingExtension));
|
||||
@ -102,7 +102,7 @@ public class NBIO implements NBPathsAPI.Facets {
|
||||
*
|
||||
* @return a builder
|
||||
*/
|
||||
public static NBPathsAPI.ForPrefix all() {
|
||||
public static NBPathsAPI.GetPrefix all() {
|
||||
return new NBIO().allContent();
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ public class NBIO implements NBPathsAPI.Facets {
|
||||
*
|
||||
* @return a builder
|
||||
*/
|
||||
public static NBPathsAPI.ForPrefix classpath() {
|
||||
public static NBPathsAPI.GetPrefix classpath() {
|
||||
return new NBIO().internalContent();
|
||||
}
|
||||
|
||||
@ -120,7 +120,7 @@ public class NBIO implements NBPathsAPI.Facets {
|
||||
*
|
||||
* @return a builder
|
||||
*/
|
||||
public static NBPathsAPI.ForPrefix fs() {
|
||||
public static NBPathsAPI.GetPrefix fs() {
|
||||
return new NBIO().fileContent();
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ public class NBIO implements NBPathsAPI.Facets {
|
||||
*
|
||||
* @return a builder
|
||||
*/
|
||||
public static NBPathsAPI.ForPrefix local() {
|
||||
public static NBPathsAPI.GetPrefix local() {
|
||||
return new NBIO().localContent();
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ public class NBIO implements NBPathsAPI.Facets {
|
||||
*
|
||||
* @return a builder
|
||||
*/
|
||||
public static NBPathsAPI.ForPrefix remote() {
|
||||
public static NBPathsAPI.GetPrefix remote() {
|
||||
return new NBIO().remoteContent();
|
||||
}
|
||||
|
||||
|
@ -2,81 +2,80 @@ package io.nosqlbench.nb.api.content.fluent;
|
||||
|
||||
import io.nosqlbench.nb.api.content.Content;
|
||||
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface NBPathsAPI {
|
||||
|
||||
public static interface Facets extends
|
||||
WantsSpaces, ForPrefix, WantsContentName, ForName, ForExtension {}
|
||||
GetSource, GetPrefix, GetName, GetExtension, DoSearch {}
|
||||
|
||||
public static interface WantsSpaces {
|
||||
public static interface GetSource {
|
||||
/**
|
||||
* Only provide content from the class path and the local filesystem.
|
||||
* @return this builder
|
||||
*/
|
||||
ForPrefix localContent();
|
||||
GetPrefix localContent();
|
||||
|
||||
/**
|
||||
* Only return content from remote URLs. If the user is providing non-URL content
|
||||
* in this context, it is an error. Throw an error in that case.
|
||||
* @return this builder
|
||||
*/
|
||||
ForPrefix remoteContent();
|
||||
GetPrefix remoteContent();
|
||||
|
||||
/**
|
||||
* Only return content from the runtime classpath, internal resources that are bundled,
|
||||
* and do not return content on the file system.
|
||||
* @return this builder
|
||||
*/
|
||||
ForPrefix internalContent();
|
||||
GetPrefix internalContent();
|
||||
|
||||
/**
|
||||
* Only return content from the filesystem, but not remote URLs nor internal bundled resources.
|
||||
* @return this builder
|
||||
*/
|
||||
ForPrefix fileContent();
|
||||
GetPrefix fileContent();
|
||||
|
||||
/**
|
||||
* Return content from everywhere, from remote URls, or from the file system and then the internal
|
||||
* bundled content if not found in the file system first.
|
||||
* @return this builder
|
||||
*/
|
||||
ForPrefix allContent();
|
||||
GetPrefix allContent();
|
||||
}
|
||||
|
||||
public static interface ForPrefix extends WantsContentName {
|
||||
public static interface GetPrefix extends GetName {
|
||||
/**
|
||||
* Each of the prefix paths will be searched if the resource is not found with the exact
|
||||
* path given.
|
||||
* @param prefixPaths A list of paths to include in the search
|
||||
* @return this builder
|
||||
*/
|
||||
WantsContentName prefix(String... prefixPaths);
|
||||
GetName prefix(String... prefixPaths);
|
||||
}
|
||||
|
||||
public static interface WantsContentName {
|
||||
public static interface GetName extends GetExtension {
|
||||
/**
|
||||
* Provide the names of the resources to be resolved. More than one resource may be provided.
|
||||
* @param name The name of the resource to load
|
||||
* @return this builder
|
||||
*/
|
||||
ForName name(String... name);
|
||||
GetExtension name(String... name);
|
||||
}
|
||||
|
||||
public static interface ForName extends ForExtension {
|
||||
public static interface GetExtension extends DoSearch {
|
||||
/**
|
||||
* provide a list of optional file extensions which should be considered. If the content is
|
||||
* not found under the provided name, then each of the extensios is tried in order.
|
||||
* @param extensions The extension names to try
|
||||
* @return this builder
|
||||
*/
|
||||
ForExtension extension(String... extensions);
|
||||
DoSearch extension(String... extensions);
|
||||
|
||||
}
|
||||
|
||||
public static interface ForExtension {
|
||||
public static interface DoSearch {
|
||||
/**
|
||||
* Return the result of resolving the resource.
|
||||
* @return an optional {@code Content<?>} element.
|
||||
@ -92,8 +91,6 @@ public interface NBPathsAPI {
|
||||
|
||||
List<Content<?>> list();
|
||||
|
||||
Optional<Content<?>> maybeOne();
|
||||
|
||||
/**
|
||||
* Find exactly one source of content under the search parameters given.
|
||||
* It is an error if you find none, or more than one.
|
||||
|
@ -69,10 +69,10 @@ public class NBIOTest {
|
||||
|
||||
@Test
|
||||
public void testLoadCsv1Classpath() {
|
||||
NBPathsAPI.ForPrefix forSourceType = NBIO.classpath();
|
||||
NBPathsAPI.WantsContentName nesteddir1 = forSourceType.prefix("nesteddir1");
|
||||
NBPathsAPI.ForName forName = nesteddir1.name("nesteddir2/testcsv1");
|
||||
NBPathsAPI.ForExtension forCsvExtension = forName.extension(".csv");
|
||||
NBPathsAPI.GetPrefix forSourceType = NBIO.classpath();
|
||||
NBPathsAPI.GetName nesteddir1 = forSourceType.prefix("nesteddir1");
|
||||
NBPathsAPI.GetExtension getExtension = nesteddir1.name("nesteddir2/testcsv1");
|
||||
NBPathsAPI.DoSearch forCsvExtension = getExtension.extension(".csv");
|
||||
Optional<Content<?>> testcsv1 = forCsvExtension.first();
|
||||
|
||||
assertThat(testcsv1).isNotPresent();
|
||||
@ -80,10 +80,10 @@ public class NBIOTest {
|
||||
|
||||
@Test
|
||||
public void testLoadCsv1Filesystem() {
|
||||
NBPathsAPI.ForPrefix forSourceType = NBIO.fs();
|
||||
NBPathsAPI.WantsContentName nesteddir1 = forSourceType.prefix("target/test-classes/nesteddir1");
|
||||
NBPathsAPI.ForName forName = nesteddir1.name("nesteddir2/testcsv1");
|
||||
NBPathsAPI.ForExtension forCsvExtension = forName.extension(".csv");
|
||||
NBPathsAPI.GetPrefix forSourceType = NBIO.fs();
|
||||
NBPathsAPI.GetName nesteddir1 = forSourceType.prefix("target/test-classes/nesteddir1");
|
||||
NBPathsAPI.GetExtension getExtension = nesteddir1.name("nesteddir2/testcsv1");
|
||||
NBPathsAPI.DoSearch forCsvExtension = getExtension.extension(".csv");
|
||||
Optional<Content<?>> testcsv1 = forCsvExtension.first();
|
||||
|
||||
assertThat(testcsv1).isNotPresent();
|
||||
|
Loading…
Reference in New Issue
Block a user