Skip to content

Commit d87b441

Browse files
committed
Addressed review comments
Signed-off-by: aurobindoc <aurobindoc1991@gmail.com>
1 parent 0a9a0cd commit d87b441

File tree

7 files changed

+48
-19
lines changed

7 files changed

+48
-19
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
# Created by aurobindo.m on 18/04/22

sdk/python/feast/infra/online_stores/contrib/hbase_online_store/README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# Hbase Online Store
2-
Hbase is not included in current [Feast](https://github.com/feast-dev/feast) roadmap, this project intends to add Hbase
3-
support for Online Store.
4-
1+
# HBase Online Store
2+
HBase is not included in current [Feast](https://github.com/feast-dev/feast) roadmap, this project intends to add HBase support for Online Store.
53
We create a table <project_name>_<feature_view_name> which gets updated with data on every materialize call
64

75

@@ -14,7 +12,7 @@ cd feature_repo
1412

1513
#### Edit `feature_store.yaml`
1614

17-
set `online_store` type to be `feast_hbase.hbase.HbaseOnlineStore`
15+
set `online_store` type to be `hbase`
1816

1917
```yaml
2018
project: feature_repo
@@ -38,7 +36,7 @@ Registered feature view driver_hourly_stats_view
3836
Deploying infrastructure for driver_hourly_stats_view
3937
```
4038
41-
### Migrate Latest Data to Online Feature Store (Hbase)
39+
### Migrate Latest Data to Online Feature Store (HBase)
4240
```
4341
$ CURRENT_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S")
4442
$ feast -c feature_repo materialize-incremental $CURRENT_TIME
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
# Created by aurobindo.m on 18/04/22

sdk/python/feast/infra/online_stores/contrib/hbase_online_store/hbase.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Created by aurobindo.m on 18/04/22
21
import calendar
32
import struct
43
from datetime import datetime
@@ -150,12 +149,15 @@ def online_read(
150149

151150
result: List[Tuple[Optional[datetime], Optional[Dict[str, ValueProto]]]] = []
152151

153-
for entity_key in entity_keys:
154-
row_key = serialize_entity_key(entity_key).hex()
155-
val = hbase.row(table_name, row_key=row_key)
152+
row_keys = [
153+
serialize_entity_key(entity_key).hex() for entity_key in entity_keys
154+
]
155+
rows = hbase.rows(table_name, row_keys=row_keys)
156+
157+
for _, row in rows:
156158
res = {}
157159
res_ts = None
158-
for feature_name, feature_value in val.items():
160+
for feature_name, feature_value in row.items():
159161
f_name = HbaseConstants.get_feature_from_col(feature_name)
160162
if requested_features is not None and f_name in requested_features:
161163
v = ValueProto()

sdk/python/feast/infra/online_stores/contrib/contrib_repo_configuration.py renamed to sdk/python/feast/infra/online_stores/contrib/hbase_repo_configuration.py

File renamed without changes.

sdk/python/feast/infra/utils/hbase_utils.py

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# Created by aurobindo.m on 18/04/22
21
from typing import List
32

43
from happybase import Connection
54

5+
from feast.infra.key_encoding_utils import serialize_entity_key
6+
from feast.protos.feast.types.EntityKey_pb2 import EntityKey
7+
68

79
class HbaseConstants:
810
"""Constants to be used by the Hbase Online Store."""
@@ -80,7 +82,7 @@ def check_if_table_exist(self, table_name: str):
8082

8183
def batch(self, table_name: str):
8284
"""
83-
Returns a 'Batch' instance that can be used for mass data manipulation in the habse table.
85+
Returns a 'Batch' instance that can be used for mass data manipulation in the hbase table.
8486
8587
Arguments:
8688
table_name: Name of the Hbase table.
@@ -93,7 +95,7 @@ def put(self, table_name: str, row_key: str, data: dict):
9395
9496
Arguments:
9597
table_name: Name of the Hbase table.
96-
row_key: Row key of the row to be inserted to habse table.
98+
row_key: Row key of the row to be inserted to hbase table.
9799
data: Mapping of column family name:column name to column values
98100
"""
99101
table = self.conn.table(table_name)
@@ -112,7 +114,7 @@ def row(
112114
113115
Arguments:
114116
table_name: Name of the Hbase table.
115-
row_key: Row key of the row to be inserted to habse table.
117+
row_key: Row key of the row to be inserted to hbase table.
116118
columns: the name of columns that needs to be fetched.
117119
timestamp: timestamp specifies the maximum version the cells can have.
118120
include_timestamp: specifies if (column, timestamp) to be return instead of only column.
@@ -133,7 +135,7 @@ def rows(
133135
134136
Arguments:
135137
table_name: Name of the Hbase table.
136-
row_keys: List of row key of the row to be inserted to habse table.
138+
row_keys: List of row key of the row to be inserted to hbase table.
137139
columns: the name of columns that needs to be fetched.
138140
timestamp: timestamp specifies the maximum version the cells can have.
139141
include_timestamp: specifies if (column, timestamp) to be return instead of only column.
@@ -156,3 +158,32 @@ def delete_table(self, table: str):
156158
def close_conn(self):
157159
"""Closes the happybase connection."""
158160
self.conn.close()
161+
162+
163+
def main():
164+
from feast.protos.feast.types.Value_pb2 import Value
165+
166+
connection = Connection(host="localhost", port=9090)
167+
table = connection.table("test_hbase_driver_hourly_stats")
168+
row_keys = [
169+
serialize_entity_key(
170+
EntityKey(join_keys=["driver_id"], entity_values=[Value(int64_val=1004)])
171+
).hex(),
172+
serialize_entity_key(
173+
EntityKey(join_keys=["driver_id"], entity_values=[Value(int64_val=1005)])
174+
).hex(),
175+
serialize_entity_key(
176+
EntityKey(join_keys=["driver_id"], entity_values=[Value(int64_val=1024)])
177+
).hex(),
178+
]
179+
rows = table.rows(row_keys)
180+
181+
for row_key, row in rows:
182+
for key, value in row.items():
183+
col_name = bytes.decode(key, "utf-8").split(":")[1]
184+
print(col_name, value)
185+
print()
186+
187+
188+
if __name__ == "__main__":
189+
main()

sdk/python/feast/templates/hbase/feature_store.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ provider: local
44
online_store:
55
type: hbase
66
host: 127.0.0.1
7-
port: 9090
7+
port: 9090

0 commit comments

Comments
 (0)