[ 
https://issues.apache.org/jira/browse/IOTDB-742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17134154#comment-17134154
 ] 

Julian Feinauer commented on IOTDB-742:
---------------------------------------

I worked a bit on this issue and implemented a "Schema Manager" that takes care 
of the these objects and transforms the InsertPlan to a regular IoTDB insert 
plan. It works a bit like type erasure as the lower level doesnt know anything 
about types anymore, then.

It uses a predefined set of "user defined types" and parses the given json 
string to see if it mateches a type.

Such a type is something like that:

{code:java}
{"max_speed": DOUBLE,"look": {"color": TEXT,"clean": BOOLEAN,},"drivers": 
TEXT[],}
{code}
(which has the name "car" in this example).

Then one can do the query:
{code:java}
statement.execute("INSERT INTO root.sg1.d1 (timestamp, coordinates) VALUES 
(NOW(), \"{\\\"max_speed\\\": 160.0, \\\"look\\\":{\\\"clean\\\":true, 
\\\"color\\\": \\\"blue\\\"}, \\\"drivers\\\":[\\\"julian\\\", 
\\\"xiangdong\\\"]}::car\")");
{code}
which tells him to interpret the string as json of type car. 

Internally it is then validated and mapped to "primitive" iotdb types. So the 
result is printed (e.g. with SHOW TIMESERIES) as

{code:java}
"root.sg1.d1.\"coordinates.max_speed\",null,root.sg1,DOUBLE,GORILLA,SNAPPY,",
"root.sg1.d1.\"coordinates.look.color\",null,root.sg1,TEXT,PLAIN,SNAPPY,",
"root.sg1.d1.\"coordinates.look.clean\",null,root.sg1,BOOLEAN,RLE,SNAPPY,",
"root.sg1.d1.\"coordinates.drivers[0]\",null,root.sg1,TEXT,PLAIN,SNAPPY,",
"root.sg1.d1.\"coordinates.drivers[1]\",null,root.sg1,TEXT,PLAIN,SNAPPY,",
{code}


> Add Support for structured Messages, e.g. in JSON format
> --------------------------------------------------------
>
>                 Key: IOTDB-742
>                 URL: https://issues.apache.org/jira/browse/IOTDB-742
>             Project: Apache IoTDB
>          Issue Type: New Feature
>            Reporter: Julian Feinauer
>            Assignee: Julian Feinauer
>            Priority: Major
>
> Currently IoTDB Supports only primitives which are stored in a single 
> measurement. If we would add a "logical" layer on top we could just split 
> each JSON message into its primitives and store it accordingly. If the 
> message is not nested but only key-value pair this is simply a "syntactic 
> sugar".
> Consider the following IoTDB Command:
> {code:sql}
> INSERT INTO root.demo.cars.mycar (time, json) VALUES (NOW(), "{\"speed\": 
> 100, \"color\": \"red\"}")
> {code}
> It uses the word "json" as colum name which indicates that it wants to store 
> a json. Thus IoTDB should store the data from the json and this is equivalent 
> to the normal syntax
> {code:sql}
> INSERT INTO root.demo.cars.mycar (time, speed, color) VALUES (NOW(), 100, 
> "red")
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to