Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs for arrow #35

Merged
merged 17 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions btrdb/conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,67 @@ def list_collections(self, starts_with=""):
"""
return [c for some in self.ep.listCollections(starts_with) for c in some]

def _list_unique_tags_annotations(self, key, collection):
"""
Returns a SQL statement and parameters to get list of tags or annotations.
"""
if key == "annotations":
query = "select distinct({}) as {} from streams".format(
"skeys(annotations)", "annotations"
)
else:
query = "select distinct({}) as {} from streams".format(key, key)
params = []
if isinstance(collection, str):
params.append("{}%".format(collection))
query = " where ".join([query, """collection like $1"""])
return [metadata[key] for metadata in self.query(query, params)]

def list_unique_annotations(self, collection=None):
"""
Returns a list of annotation keys used in a given collection prefix.

Parameters
-------
collection: str
Prefix of the collection to filter.

Returns
-------
annotations: list[str]
"""
return self._list_unique_tags_annotations("annotations", collection)

def list_unique_names(self, collection=None):
"""
Returns a list of names used in a given collection prefix.

Parameters
-------
collection: str
Prefix of the collection to filter.

Returns
-------
names: list[str]
"""
return self._list_unique_tags_annotations("name", collection)

def list_unique_units(self, collection=None):
"""
Returns a list of units used in a given collection prefix.

Parameters
-------
collection: str
Prefix of the collection to filter.

Returns
-------
units: list[str]
"""
return self._list_unique_tags_annotations("unit", collection)

@retry
def streams_in_collection(
self,
Expand Down
Loading