CRZbulabula commented on code in PR #15686:
URL: https://github.com/apache/iotdb/pull/15686#discussion_r2136813443
##########
iotdb-core/ainode/ainode/core/config.py:
##########
@@ -52,6 +52,8 @@ def __init__(self):
# log directory
self._ain_logs_dir: str = AINODE_LOG_DIR
+ self._ain_data_cache_size = 50
Review Comment:
Add unit to this variable, plz check the other variables by the way~
##########
iotdb-core/ainode/ainode/core/ingress/iotdb.py:
##########
@@ -0,0 +1,307 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+import torch
+from iotdb.Session import Session
+from iotdb.table_session import TableSession, TableSessionConfig
+from iotdb.utils.Field import Field
+from iotdb.utils.IoTDBConstants import TSDataType
+from util.cache import MemoryLRUCache
+
+from ainode.core.config import AINodeDescriptor
+from ainode.core.ingress.dataset import BasicDatabaseForecastDataset
+from ainode.core.log import Logger
+
+logger = Logger()
+
+
+def get_field_value(field: Field):
+ data_type = field.get_data_type()
+ if data_type == TSDataType.INT32:
+ return field.get_int_value()
+ elif data_type == TSDataType.INT64:
+ return field.get_long_value()
+ elif data_type == TSDataType.FLOAT:
+ return field.get_float_value()
+ elif data_type == TSDataType.DOUBLE:
+ return field.get_double_value()
+ else:
+ return field.get_string_value()
+
+
+def _cache_enable() -> bool:
+ return AINodeDescriptor().get_config().get_ain_data_storage_cache_size()
!= 0
Review Comment:
```suggestion
return AINodeDescriptor().get_config().get_ain_data_storage_cache_size()
> 0
```
##########
iotdb-core/ainode/ainode/core/util/cache.py:
##########
@@ -0,0 +1,85 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+import sys
+from collections import OrderedDict
+
+from ainode.core.config import AINodeDescriptor
+from ainode.core.util.decorator import singleton
+
+
+def _estimate_size(obj):
+ if isinstance(obj, str):
+ return len(obj) + 49
+ elif isinstance(obj, int):
+ return 28
+ elif isinstance(obj, list):
+ return 64 + sum(_estimate_size(x) for x in obj)
+ elif isinstance(obj, dict):
+ return 280 + sum(_estimate_size(k) + _estimate_size(v) for k, v in
obj.items())
Review Comment:
plz rename this function to '_estimate_size_in_byte', and I wonder is there
has any builtin interfaces of python to calculate the size of a specific
objects?
##########
iotdb-core/ainode/ainode/core/ingress/iotdb.py:
##########
@@ -0,0 +1,307 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+import torch
+from iotdb.Session import Session
+from iotdb.table_session import TableSession, TableSessionConfig
+from iotdb.utils.Field import Field
+from iotdb.utils.IoTDBConstants import TSDataType
+from util.cache import MemoryLRUCache
+
+from ainode.core.config import AINodeDescriptor
+from ainode.core.ingress.dataset import BasicDatabaseForecastDataset
+from ainode.core.log import Logger
+
+logger = Logger()
+
+
+def get_field_value(field: Field):
+ data_type = field.get_data_type()
+ if data_type == TSDataType.INT32:
+ return field.get_int_value()
+ elif data_type == TSDataType.INT64:
+ return field.get_long_value()
+ elif data_type == TSDataType.FLOAT:
+ return field.get_float_value()
+ elif data_type == TSDataType.DOUBLE:
+ return field.get_double_value()
+ else:
+ return field.get_string_value()
+
+
+def _cache_enable() -> bool:
+ return AINodeDescriptor().get_config().get_ain_data_storage_cache_size()
!= 0
+
+
+class IoTDBTreeModelDataset(BasicDatabaseForecastDataset):
Review Comment:
It is cratical to explain how ur classes will interact with the caller. Plz
add some annotations to the provided interfaces of these classes. BTW, the name
`iotdb.py` seems conflict with our main project, I think the `iotdb_dataset.py`
is better.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]