Skip to content

💡 Frame implementation, and backend interface revamping #141

@chaosddp

Description

@chaosddp

Summary

Frame implementation, and backend interface revamping.

Motivation

Current frame implementation uses node and attribute name tuple as key to query attribute, then use it to access value, this is slow as it will create a tuple object every time we access an attribute.

Description

  1. Revamp frame internal implementation to use int instead of string to get/set/query attributes, then we use this as unique key for quick accessing.
  2. Based on 1st option, we need to revamp backend interfaces to support return an ID for new added node and attribute, then access this ID to access value.
  3. Since we are going to use c++ to implement raw backend, we also need to upgrade current np backend and frame layer to use c++ compiler. Ideally we only need replace "class" with "cppclass" at cython part.

Above changes would not affect current frame interfaces for python side.

References

  • Draft code snippets:
# backend layer

cdef cppclass backend:
    IDENTIFIER add_node(str name, UINT number)
    IDENTIFIER add_attr(IDENTIFIER node_id, str name, str dtype, UINT slots)

    object get_attr_value(IDENTIFIER id, UINT slot_index)
    object set_attr_value(IDENTIFIER id, UINT slot_index, object value)

# frame layer

node1_id = backend.add_node("node1", 10)
node2_id = backend.add_node("node2", 5)

attr1_id = backend.add_attr(node1_id, "a1", "i", 2)
attr2_id = backend.add_attr(node1_id, "a2", "i", 3)

val = backend.get_attr_value(attr1_id, 1, 1)
backend.set_attr_value(attr1_id, 0, 12)

Alternatives

No

Additional context

No

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions