Skip to content

Commit 0beef06

Browse files
authored
Update docs for arrow (#35)
* Update docs, add in final enhanced edits.
1 parent 915bf5f commit 0beef06

File tree

6 files changed

+316
-18
lines changed

6 files changed

+316
-18
lines changed

btrdb/conn.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,67 @@ def list_collections(self, starts_with=""):
404404
"""
405405
return [c for some in self.ep.listCollections(starts_with) for c in some]
406406

407+
def _list_unique_tags_annotations(self, key, collection):
408+
"""
409+
Returns a SQL statement and parameters to get list of tags or annotations.
410+
"""
411+
if key == "annotations":
412+
query = "select distinct({}) as {} from streams".format(
413+
"skeys(annotations)", "annotations"
414+
)
415+
else:
416+
query = "select distinct({}) as {} from streams".format(key, key)
417+
params = []
418+
if isinstance(collection, str):
419+
params.append("{}%".format(collection))
420+
query = " where ".join([query, """collection like $1"""])
421+
return [metadata[key] for metadata in self.query(query, params)]
422+
423+
def list_unique_annotations(self, collection=None):
424+
"""
425+
Returns a list of annotation keys used in a given collection prefix.
426+
427+
Parameters
428+
-------
429+
collection: str
430+
Prefix of the collection to filter.
431+
432+
Returns
433+
-------
434+
annotations: list[str]
435+
"""
436+
return self._list_unique_tags_annotations("annotations", collection)
437+
438+
def list_unique_names(self, collection=None):
439+
"""
440+
Returns a list of names used in a given collection prefix.
441+
442+
Parameters
443+
-------
444+
collection: str
445+
Prefix of the collection to filter.
446+
447+
Returns
448+
-------
449+
names: list[str]
450+
"""
451+
return self._list_unique_tags_annotations("name", collection)
452+
453+
def list_unique_units(self, collection=None):
454+
"""
455+
Returns a list of units used in a given collection prefix.
456+
457+
Parameters
458+
-------
459+
collection: str
460+
Prefix of the collection to filter.
461+
462+
Returns
463+
-------
464+
units: list[str]
465+
"""
466+
return self._list_unique_tags_annotations("unit", collection)
467+
407468
@retry
408469
def streams_in_collection(
409470
self,

0 commit comments

Comments
 (0)