jiacai2050 commented on code in PR #1418:
URL:
https://github.com/apache/incubator-horaedb/pull/1418#discussion_r1441441634
##########
cluster/src/cluster_impl.rs:
##########
@@ -368,6 +385,13 @@ impl Cluster for ClusterImpl {
self.inner.shard(shard_id)
}
+ fn get_table_status(&self, schema_name: &str, table_name: &str) ->
Option<TableStatus> {
+ match self.inner.get_shard_by_table_name(schema_name, table_name) {
Review Comment:
```
self.inner.get_shard_by_table_name(schema_name, table_name)
.map(|shard| TableStatus::from(shard.get_status()).into())
````
##########
cluster/src/cluster_impl.rs:
##########
@@ -311,6 +311,23 @@ impl Inner {
self.shard_set.get(shard_id)
}
+ /// Get shard by table name.
+ ///
+ /// This method is similar to `route_tables`, but it will not send request
+ /// to meta server, it only load data from local cache.
+ /// If target table is not found in any shards in this cluster, return
None.
+ /// Otherwise, return the shard where this table is exists.
+ fn get_shard_by_table_name(&self, schema_name: &str, table_name: &str) ->
Option<ShardRef> {
+ let shards = self.shard_set.all_shards();
+ for shard in shards {
+ match shard.find_table(schema_name, table_name) {
Review Comment:
```
if shard.find_table(schema_name, table_name).is_some()
```
##########
cluster/src/lib.rs:
##########
@@ -161,6 +165,33 @@ pub enum Error {
define_result!(Error);
+pub enum TableStatus {
+ Ready,
+ Recovering,
+ Frozen,
+}
+
+impl Display for TableStatus {
Review Comment:
We usually don't impl Display for enum, just derive Default is enough.
```rs
#[derive(Default)]
```
##########
cluster/src/shard_set.rs:
##########
@@ -216,6 +231,11 @@ impl ShardData {
self.shard_info.is_opened()
}
+ #[inline]
+ pub fn is_ready(&self) -> bool {
Review Comment:
Is this still used?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]