This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 679c8fb Add metaquery in python example (#667)
679c8fb is described below
commit 679c8fb2633ff3cb20053fc3869d295dff0bd35b
Author: Jiang Tian <[email protected]>
AuthorDate: Thu Dec 19 13:31:14 2019 +0800
Add metaquery in python example (#667)
* add metadata query in python example
---
client-py/src/client_example.py | 38 +++++++++++++++++++++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/client-py/src/client_example.py b/client-py/src/client_example.py
index a6a20a2..30e8407 100644
--- a/client-py/src/client_example.py
+++ b/client-py/src/client_example.py
@@ -27,7 +27,7 @@ from iotdb.rpc.TSIService import Client,
TSCreateTimeseriesReq, TSInsertionReq,
TSBatchInsertionReq, TSExecuteStatementReq, TSOpenSessionReq,
TSQueryDataSet, \
TSFetchResultsReq, TSCloseOperationReq, \
TSCloseSessionReq
-from iotdb.rpc.ttypes import TSProtocolVersion
+from iotdb.rpc.ttypes import TSProtocolVersion, TSFetchMetadataReq
TSDataType = {
'BOOLEAN': 0,
@@ -59,6 +59,20 @@ Compressor = {
'PLA': 6
}
+
+class Enum:
+ def __init__(self):
+ pass
+
+
+MetaQueryTypes = Enum()
+MetaQueryTypes.CATALOG_COLUMN = "COLUMN"
+MetaQueryTypes.CATALOG_TIMESERIES = "SHOW_TIMESERIES"
+MetaQueryTypes.CATALOG_STORAGE_GROUP = "SHOW_STORAGE_GROUP"
+MetaQueryTypes.CATALOG_DEVICES = "SHOW_DEVICES"
+MetaQueryTypes.CATALOG_CHILD_PATHS = "SHOW_CHILD_PATHS"
+
+
# used to do `and` operation with bitmap to judge whether the value is null
flag = 0x80
@@ -278,5 +292,27 @@ if __name__ == '__main__':
closeReq.queryId = queryId
client.closeOperation(closeReq)
+ # query metadata
+ metaReq = TSFetchMetadataReq(sessionId=sessionId,
type=MetaQueryTypes.CATALOG_DEVICES)
+ print(client.fetchMetadata(metaReq).devices)
+
+ metaReq = TSFetchMetadataReq(sessionId=sessionId,
+ type=MetaQueryTypes.CATALOG_TIMESERIES,
+ columnPath='root')
+ print(client.fetchMetadata(metaReq).timeseriesList)
+
+ metaReq = TSFetchMetadataReq(sessionId=sessionId,
+ type=MetaQueryTypes.CATALOG_CHILD_PATHS,
+ columnPath='root')
+ print(client.fetchMetadata(metaReq).childPaths)
+
+ metaReq = TSFetchMetadataReq(sessionId=sessionId,
type=MetaQueryTypes.CATALOG_STORAGE_GROUP)
+ print(client.fetchMetadata(metaReq).storageGroups)
+
+ metaReq = TSFetchMetadataReq(sessionId=sessionId,
+ type=MetaQueryTypes.CATALOG_COLUMN,
+ columnPath='root.group1.s1')
+ print(client.fetchMetadata(metaReq).dataType)
+
# and do not forget to close the session before exiting
client.closeSession(TSCloseSessionReq(sessionId))