Package io.nosqlbench.api.content
Class NBIO
java.lang.Object
io.nosqlbench.api.content.NBIO
- All Implemented Interfaces:
NBPathsAPI.DoSearch,NBPathsAPI.Facets,NBPathsAPI.GetExtension,NBPathsAPI.GetName,NBPathsAPI.GetPrefix,NBPathsAPI.GetSource
NBIO is a helper utility packaged as a search builder and fluent API.
It uses value semantics internally, so it is safe to re-use as a
stateful configuration builder for finding files in various ways.
Since this is meant to ease development around a usually over-complicated surface area in the JVM (Files, Paths, URIs, accessing data, knowing where it comes from, searching for it, etc), more emphasis was put on ease of use and clarity than efficiency. This set of classes is not expected to be used much in NoSqlBench after workload initialization, so is not performance oriented
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddGlobalIncludes(String[] globalIncludes) static NBPathsAPI.GetPrefixall()Search for named resources everywhere: URLs, filesystem, classpathReturn 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.static NBPathsAPI.GetPrefixSearch for named resources in the classpathexpandNamesAndSuffixes(List<String> _names, Set<String> _suffixes) Given names and suffixes, expand a list of names which may be valid.provide a list of optional file extensions which should be considered.Only return content from the filesystem, but not remote URLs nor internal bundled resources.findFirstLocalPath(String... potentials) first()Return the result of resolving the resource.static NBPathsAPI.GetPrefixfs()Search for named resources on the filesystemstatic PathgetFirstLocalPath(String... potentials) Only return content from the runtime classpath, internal resources that are bundled, and do not return content on the file system.list()Provide a list of all matching content that was matched by the search qualifiersstatic NBPathsAPI.GetPrefixlocal()Search for named resources locally: filesystem, classpathOnly provide content from the class path and the local filesystem.maybeOne()Provide the names of the resources to be resolved.Content<?>one()Find exactly one source of content under the search parameters given.Each of the prefix paths will be searched if the resource is not found with the exact path given.static CharBufferreadCharBuffer(String fileName, String... searchPaths) static org.apache.commons.csv.CSVParserreadFileCSV(String filename, String... searchPaths) static org.apache.commons.csv.CSVParserreadFileDelimCSV(String filename, char delim, String... searchPaths) static InputStreamreadInputStream(String fromPath, String yaml, String[] searchPaths) relativeTo(String... base) Return a list of paths which are comprised of the relative part once the provided base has been removed from the front.static NBPathsAPI.GetPrefixremote()Search for named resources only in URLsOnly return content from remote URLs.Return the result of resolving each of the resource names given.Provide a combined prefix, name and suffix in a combined form.toString()
-
Method Details
-
addGlobalIncludes
-
readLines
-
readFileCSV
-
readFileDelimCSV
-
readCharBuffer
-
getFirstLocalPath
-
findFirstLocalPath
-
readInputStream
-
localContent
Description copied from interface:NBPathsAPI.GetSourceOnly provide content from the class path and the local filesystem.- Specified by:
localContentin interfaceNBPathsAPI.GetSource- Returns:
- this builder
-
remoteContent
Description copied from interface:NBPathsAPI.GetSourceOnly 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.- Specified by:
remoteContentin interfaceNBPathsAPI.GetSource- Returns:
- this builder
-
internalContent
Description copied from interface:NBPathsAPI.GetSourceOnly return content from the runtime classpath, internal resources that are bundled, and do not return content on the file system.- Specified by:
internalContentin interfaceNBPathsAPI.GetSource- Returns:
- this builder
-
fileContent
Description copied from interface:NBPathsAPI.GetSourceOnly return content from the filesystem, but not remote URLs nor internal bundled resources.- Specified by:
fileContentin interfaceNBPathsAPI.GetSource- Returns:
- this builder
-
allContent
Description copied from interface:NBPathsAPI.GetSourceReturn 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.- Specified by:
allContentin interfaceNBPathsAPI.GetSource- Returns:
- this builder
-
prefix
Description copied from interface:NBPathsAPI.GetPrefixEach of the prefix paths will be searched if the resource is not found with the exact path given. To be specific, if you want to search within a location based on wildcards, you must provide a prefix that provides a boundary for the search.- Specified by:
prefixin interfaceNBPathsAPI.GetPrefix- Parameters:
searchPaths- A list of paths to include in the search- Returns:
- this builder
-
search
Description copied from interface:NBPathsAPI.GetNameProvide a combined prefix, name and suffix in a combined form. For each search template provided, the value is sliced up into the three components (prefix, name, extension) and added as if they were specified separately using the following rules:- Any suffix like
is stripped off as the extension..name - Any literal (non-pattern) path parts are taken as the prefix.
- The remainder is taken as the name.
my/prefix/path/..?/name.txtyields:- prefix:
my/prefix/path/ - name:
..?/name - extension:
.txt
- prefix:
.*.yamlyeilds:- prefix:
./ - name:
.* - extension:
.yaml
- prefix:
- Specified by:
searchin interfaceNBPathsAPI.GetName- Returns:
- Any suffix like
-
name
Description copied from interface:NBPathsAPI.GetNameProvide the names of the resources to be resolved. More than one resource may be provided. If no name is provided, then a wildcard search is assumed.- Specified by:
namein interfaceNBPathsAPI.GetName- Parameters:
searchNames- The name of the resource to load- Returns:
- this builder
-
extension
Description copied from interface:NBPathsAPI.GetExtensionprovide a list of optional file extensions which should be considered. If the content is not found under the provided name, then each of the extension is tried in order. Any provided names are combined with the extensions to create an expanded list of paths to search for. if extensions are provided without a name, then wildcards are created with the extensions as suffix patterns.- Specified by:
extensionin interfaceNBPathsAPI.GetExtension- Parameters:
extensions- The extension names to try- Returns:
- this builder
-
all
Search for named resources everywhere: URLs, filesystem, classpath- Returns:
- a builder
-
classpath
Search for named resources in the classpath- Returns:
- a builder
-
fs
Search for named resources on the filesystem- Returns:
- a builder
-
local
Search for named resources locally: filesystem, classpath- Returns:
- a builder
-
remote
Search for named resources only in URLs- Returns:
- a builder
-
first
Description copied from interface:NBPathsAPI.DoSearchReturn the result of resolving the resource.- Specified by:
firstin interfaceNBPathsAPI.DoSearch- Returns:
- an optional
Content<?>element.
-
maybeOne
-
one
Description copied from interface:NBPathsAPI.DoSearchFind exactly one source of content under the search parameters given. It is an error if you find none, or more than one.- Specified by:
onein interfaceNBPathsAPI.DoSearch- Returns:
- An optional content element.
-
resolveEach
Description copied from interface:NBPathsAPI.DoSearchReturn the result of resolving each of the resource names given. This has the same semantics ofNBPathsAPI.DoSearch.first(), except that it returns a result pair-wise for each name given.- Specified by:
resolveEachin interfaceNBPathsAPI.DoSearch- Returns:
- A list of optional
Content<?>elements.
-
expandNamesAndSuffixes
-
expandNamesAndSuffixes
Given names and suffixes, expand a list of names which may be valid. If no name is given, then
is used. If suffixes are given, then all returned results must include at least one of the suffixes. If the name includes one of the suffixes given, then additional names are expanded to match the additional suffixes..*- Parameters:
_names- base filenames or path fragment, possibly fully-qualified_suffixes- zero or more suffixes, which, if given, imply that one of them must match- Returns:
- Expanded names of valid filename fragments according to the above rules
-
list
Description copied from interface:NBPathsAPI.DoSearchProvide a list of all matching content that was matched by the search qualifiers- Specified by:
listin interfaceNBPathsAPI.DoSearch- Returns:
- a list of content
-
relativeTo
Description copied from interface:NBPathsAPI.DoSearchReturn a list of paths which are comprised of the relative part once the provided base has been removed from the front. This is done per content item within the direct filesystem the path belongs to.- Specified by:
relativeToin interfaceNBPathsAPI.DoSearch- Parameters:
base- The root path elements to remove- Returns:
- Relative paths
-
toString
-