Vertex data context for complicated result store. A vertex has a single value as results.
| 708 | |
| 709 | |
| 710 | class DynamicVertexDataContext(collections.abc.Mapping): |
| 711 | """Vertex data context for complicated result store. |
| 712 | A vertex has a single value as results. |
| 713 | """ |
| 714 | |
| 715 | def __init__(self, context_node, key): |
| 716 | self._key = key |
| 717 | self._graph = context_node._graph |
| 718 | self._session_id = context_node.session_id |
| 719 | self._saved_signature = self.signature |
| 720 | |
| 721 | @property |
| 722 | def session_id(self): |
| 723 | return self._session_id |
| 724 | |
| 725 | @property |
| 726 | def key(self): |
| 727 | return self._key |
| 728 | |
| 729 | @property |
| 730 | def signature(self): |
| 731 | check_argument( |
| 732 | self._key is not None, |
| 733 | "Context key error, maybe it is not connected to engine.", |
| 734 | ) |
| 735 | return hashlib.sha256( |
| 736 | "{}.{}".format(self._key, self._graph.signature).encode( |
| 737 | "utf-8", errors="ignore" |
| 738 | ) |
| 739 | ) |
| 740 | |
| 741 | def __repr__(self): |
| 742 | return f"graphscope.framework.context.{self.__class__.__name__} from graph {str(self._graph)}" |
| 743 | |
| 744 | def __len__(self): |
| 745 | return self._graph._graph.number_of_nodes() |
| 746 | |
| 747 | def __getitem__(self, key): |
| 748 | if key not in self._graph._graph: |
| 749 | raise KeyError(key) |
| 750 | op = dag_utils.get_context_data(self, json.dumps(key)) |
| 751 | return dict(json.loads(op.eval())) |
| 752 | |
| 753 | def __iter__(self): |
| 754 | return iter(self._graph._graph) |
| 755 | |
| 756 | |
| 757 | def create_context_node(context_type, bound_app, graph, *args, **kwargs): |