Skip to content

Commit

Permalink
Merge pull request #67 from FalkorDB/vector-decoder
Browse files Browse the repository at this point in the history
vector decoder
  • Loading branch information
galshubeli authored Oct 8, 2024
2 parents fb56ead + ef1e169 commit e52c6ac
Showing 1 changed file with 55 additions and 38 deletions.
93 changes: 55 additions & 38 deletions falkordb/query_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,34 @@ class ResultSetScalarTypes(Enum):
Enumeration representing different scalar types in the query result set.
Attributes:
VALUE_UNKNOWN (int): Unknown scalar type (0).
VALUE_NULL (int): Null scalar type (1).
VALUE_STRING (int): String scalar type (2).
VALUE_INTEGER (int): Integer scalar type (3).
VALUE_BOOLEAN (int): Boolean scalar type (4).
VALUE_DOUBLE (int): Double scalar type (5).
VALUE_ARRAY (int): Array scalar type (6).
VALUE_EDGE (int): Edge scalar type (7).
VALUE_NODE (int): Node scalar type (8).
VALUE_PATH (int): Path scalar type (9).
VALUE_MAP (int): Map scalar type (10).
VALUE_POINT (int): Point scalar type (11).
"""

VALUE_UNKNOWN = 0
VALUE_NULL = 1
VALUE_STRING = 2
VALUE_INTEGER = 3
VALUE_BOOLEAN = 4
VALUE_DOUBLE = 5
VALUE_ARRAY = 6
VALUE_EDGE = 7
VALUE_NODE = 8
VALUE_PATH = 9
VALUE_MAP = 10
VALUE_POINT = 11
VALUE_UNKNOWN (int): Unknown scalar type (0)
VALUE_NULL (int): Null scalar type (1)
VALUE_STRING (int): String scalar type (2)
VALUE_INTEGER (int): Integer scalar type (3)
VALUE_BOOLEAN (int): Boolean scalar type (4)
VALUE_DOUBLE (int): Double scalar type (5)
VALUE_ARRAY (int): Array scalar type (6)
VALUE_EDGE (int): Edge scalar type (7)
VALUE_NODE (int): Node scalar type (8)
VALUE_PATH (int): Path scalar type (9)
VALUE_MAP (int): Map scalar type (10)
VALUE_POINT (int): Point scalar type (11)
VALUE_VECTORF32 (int): Vector scalar type (12)
"""

VALUE_UNKNOWN = 0
VALUE_NULL = 1
VALUE_STRING = 2
VALUE_INTEGER = 3
VALUE_BOOLEAN = 4
VALUE_DOUBLE = 5
VALUE_ARRAY = 6
VALUE_EDGE = 7
VALUE_NODE = 8
VALUE_PATH = 9
VALUE_MAP = 10
VALUE_POINT = 11
VALUE_VECTORF32 = 12

def __parse_unknown(value, graph):
"""
Expand Down Expand Up @@ -170,6 +172,20 @@ def __parse_array(value, graph) -> List:
scalar = [parse_scalar(value[i], graph) for i in range(len(value))]
return scalar

def __parse_vectorf32(value, graph) -> List:
"""
Parse a vector32f.
Args:
value: The vector to parse.
graph: The graph instance.
Returns:
list: The parsed vector.
"""

return [float(v) for v in value]

def __parse_entity_properties(props, graph):
"""
Parse node/edge properties.
Expand Down Expand Up @@ -293,18 +309,19 @@ def parse_scalar(value, graph):


PARSE_SCALAR_TYPES = [
__parse_unknown, # VALUE_UNKNOWN
__parse_null, # VALUE_NULL
__parse_string, # VALUE_STRING
__parse_integer, # VALUE_INTEGER
__parse_boolean, # VALUE_BOOLEAN
__parse_double, # VALUE_DOUBLE
__parse_array, # VALUE_ARRAY
__parse_edge, # VALUE_EDGE
__parse_node, # VALUE_NODE
__parse_path, # VALUE_PATH
__parse_map, # VALUE_MAP
__parse_point # VALUE_POINT
__parse_unknown, # VALUE_UNKNOWN
__parse_null, # VALUE_NULL
__parse_string, # VALUE_STRING
__parse_integer, # VALUE_INTEGER
__parse_boolean, # VALUE_BOOLEAN
__parse_double, # VALUE_DOUBLE
__parse_array, # VALUE_ARRAY
__parse_edge, # VALUE_EDGE
__parse_node, # VALUE_NODE
__parse_path, # VALUE_PATH
__parse_map, # VALUE_MAP
__parse_point, # VALUE_POINT
__parse_vectorf32 # VALUE_VECTORF32
]

class QueryResult:
Expand Down

0 comments on commit e52c6ac

Please sign in to comment.