julia smartreceive table defaults to a dataframe
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
name = "NATSBridge"
|
name = "NATSBridge"
|
||||||
uuid = "f2724d33-f338-4a57-b9f8-1be882570d10"
|
uuid = "f2724d33-f338-4a57-b9f8-1be882570d10"
|
||||||
version = "0.5.3"
|
version = "0.5.4"
|
||||||
authors = ["narawat <narawat@gmail.com>"]
|
authors = ["narawat <narawat@gmail.com>"]
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|||||||
@@ -931,8 +931,8 @@ It handles "text" (string), "dictionary" (JSON deserialization), "arrowtable" (A
|
|||||||
2. Converts bytes to appropriate Julia data type based on format
|
2. Converts bytes to appropriate Julia data type based on format
|
||||||
3. For text: converts bytes to string
|
3. For text: converts bytes to string
|
||||||
4. For dictionary: converts bytes to JSON string then parses to Julia object
|
4. For dictionary: converts bytes to JSON string then parses to Julia object
|
||||||
5. For arrowtable: reads Arrow IPC format and returns Arrow.Table
|
5. For arrowtable: reads Arrow IPC format and returns a DataFrame
|
||||||
6. For jsontable: converts bytes to JSON string then parses to Vector{Dict}
|
6. For jsontable: converts bytes to JSON string then parses to Vector{Dict} and return a DataFrame
|
||||||
7. For image/audio/video/binary: returns bytes directly
|
7. For image/audio/video/binary: returns bytes directly
|
||||||
|
|
||||||
# Arguments:
|
# Arguments:
|
||||||
@@ -958,11 +958,11 @@ json_data = _deserialize_data(json_bytes, "dictionary", "correlation123")
|
|||||||
|
|
||||||
# Arrow IPC data (arrowtable)
|
# Arrow IPC data (arrowtable)
|
||||||
arrow_bytes = Vector{UInt8}([1, 2, 3]) # Arrow IPC bytes
|
arrow_bytes = Vector{UInt8}([1, 2, 3]) # Arrow IPC bytes
|
||||||
arrow_table = _deserialize_data(arrow_bytes, "arrowtable", "correlation123")
|
df = _deserialize_data(arrow_bytes, "arrowtable", "correlation123")
|
||||||
|
|
||||||
# JSON table data (jsontable)
|
# JSON table data (jsontable)
|
||||||
json_table_bytes = UInt8[91, 123, 34, 105, 100, 34, 58, 49, 44, 34, 110, 97, 109, 101, 34, 58, 34, 65, 108, 105, 99, 101, 34, 125] # [{"id":1,"name":"Alice"}]
|
json_table_bytes = UInt8[91, 123, 34, 105, 100, 34, 58, 49, 44, 34, 110, 97, 109, 101, 34, 58, 34, 65, 108, 105, 99, 101, 34, 125] # [{"id":1,"name":"Alice"}]
|
||||||
json_table = _deserialize_data(json_table_bytes, "jsontable", "correlation123")
|
df = _deserialize_data(json_table_bytes, "jsontable", "correlation123")
|
||||||
```
|
```
|
||||||
"""
|
"""
|
||||||
function _deserialize_data(
|
function _deserialize_data(
|
||||||
@@ -977,11 +977,14 @@ function _deserialize_data(
|
|||||||
return JSON.parse(json_str) # Parse JSON string to JSON object
|
return JSON.parse(json_str) # Parse JSON string to JSON object
|
||||||
elseif payload_type == "arrowtable" # Arrow table data - deserialize Arrow IPC stream
|
elseif payload_type == "arrowtable" # Arrow table data - deserialize Arrow IPC stream
|
||||||
io = IOBuffer(data) # Create buffer from bytes
|
io = IOBuffer(data) # Create buffer from bytes
|
||||||
table = Arrow.Table(io) # Read Arrow IPC format from buffer
|
arrowtable = Arrow.Table(io) # Read Arrow IPC format from buffer
|
||||||
return table # Return Arrow.Table
|
df = DataFrame(arrowtable)
|
||||||
|
return df
|
||||||
elseif payload_type == "jsontable" # JSON table data - deserialize JSON
|
elseif payload_type == "jsontable" # JSON table data - deserialize JSON
|
||||||
json_str = String(data) # Convert bytes to string
|
json_str = String(data) # Convert bytes to string
|
||||||
return JSON.parse(json_str) # Parse JSON string to Vector{Dict}
|
jsontable = JSON.parse(json_str) # Parse JSON string to jsontable i.e. Vector{Dict}
|
||||||
|
df = DataFrame(jsontable)
|
||||||
|
return df
|
||||||
elseif payload_type == "image" # Image data - return binary
|
elseif payload_type == "image" # Image data - return binary
|
||||||
return data # Return bytes directly
|
return data # Return bytes directly
|
||||||
elseif payload_type == "audio" # Audio data - return binary
|
elseif payload_type == "audio" # Audio data - return binary
|
||||||
|
|||||||
Reference in New Issue
Block a user