You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vxquery.apache.org by pr...@apache.org on 2016/08/07 21:27:23 UTC

vxquery git commit: JSONiq Data Model Example

Repository: vxquery
Updated Branches:
  refs/heads/master 13e2ff328 -> 0970f5794


JSONiq Data Model Example


Project: http://git-wip-us.apache.org/repos/asf/vxquery/repo
Commit: http://git-wip-us.apache.org/repos/asf/vxquery/commit/0970f579
Tree: http://git-wip-us.apache.org/repos/asf/vxquery/tree/0970f579
Diff: http://git-wip-us.apache.org/repos/asf/vxquery/diff/0970f579

Branch: refs/heads/master
Commit: 0970f579469742663ec009ed679115e8955991dc
Parents: 13e2ff3
Author: Christina Pavlopoulou <cp...@ucr.edu>
Authored: Tue Jul 26 10:42:48 2016 -0700
Committer: Christina Pavlopoulou <cp...@ucr.edu>
Committed: Tue Aug 2 09:25:46 2016 -0700

----------------------------------------------------------------------
 src/site/apt/development_data_handling.apt |   4 +-
 src/site/apt/development_json_document.apt | 178 ++++++++++++++++++++++++
 src/site/site.xml                          |   3 +
 3 files changed, 183 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/0970f579/src/site/apt/development_data_handling.apt
----------------------------------------------------------------------
diff --git a/src/site/apt/development_data_handling.apt b/src/site/apt/development_data_handling.apt
index a161608..ece49ce 100644
--- a/src/site/apt/development_data_handling.apt
+++ b/src/site/apt/development_data_handling.apt
@@ -129,8 +129,7 @@ Developer Data Handling
 *-------------------------+----------------------+---------------:
 | xs:string               | UTF8StringPointable  |    2 + length |
 *-------------------------+----------------------+---------------:
-  
-  
+   
 * String Iterators
 
   For many string functions, we have used string iterators to traverse the
@@ -160,3 +159,4 @@ Developer Data Handling
   to hold your output. Adding to the result, if necessary. The array can be
   reused and can hold multiple pointable results due to the starting offset
   parameter in the pointable.
+  
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/vxquery/blob/0970f579/src/site/apt/development_json_document.apt
----------------------------------------------------------------------
diff --git a/src/site/apt/development_json_document.apt b/src/site/apt/development_json_document.apt
new file mode 100644
index 0000000..369a261
--- /dev/null
+++ b/src/site/apt/development_json_document.apt
@@ -0,0 +1,178 @@
+~~ Licensed to the Apache Software Foundation (ASF) under one or more
+~~ contributor license agreements.  See the NOTICE file distributed with
+~~ this work for additional information regarding copyright ownership.
+~~ The ASF licenses this file to You under the Apache License, Version 2.0
+~~ (the "License"); you may not use this file except in compliance with
+~~ the License.  You may obtain a copy of the License at
+~~
+~~     http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing, software
+~~ distributed under the License is distributed on an "AS IS" BASIS,
+~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~~ See the License for the specific language governing permissions and
+~~ limitations under the License.
+
+JSONiq Data Model Example 
+
+
+*Byte Array Break Down
+
+  Every JSONiq document in VXQuery is stored in memory as one continuous array of 
+  bytes. Pointables are used to refer to these bytes in the memory.
+  This document covers VXQuery's representation of all the different types of 
+  json-items of a JSONiq document. As a result, we use a lots of pointables 
+  (same and different) through out the document. 
+  Refer to the following link for details on the various pointables used: 
+  {{{http://vxquery.apache.org/development_xml_node_details.html} XML Node Details }}.
+
+**JSONiq Document
+  
+  We use the following JSONiq document as an example to explain VXQuery's json-item 
+  types. The different json-item types are Array Pointable (AP) and 
+  Object Pointable (OP). 
+   
+---
+{
+  "book":{
+    "isbn":"0812416139",
+    "title":"XQuery Kick Start",
+    "year":2005, 
+    "category":null,
+    "authors":["James McGovern", "James Linn"]
+  }
+}
+---
+
+** {Bytes}
+  
+  Following are the bytes for the JSONiq document above. Elements in VXQuery are
+  accessed using Tagged Value Pointables. Similarly, the JSONiq document is also 
+  accessed using a Tagged Value Pointable. The first byte is represents the 
+  value tag. It indicates the type of the bytes that follow. 
+    
+***  <<<109, 0, 0, 0, 1, 0, 0, 0, -101, 0, 4, 98, 111, 111, 107, 109, 0, 0, 0, 5, 0, 0, 0, 19, 0, 0, 0, 46, 0, 0, 0, 61, 0, 0, 0, 72, 0, 0, 0, 124, 0, 4, 105, 115, 98, 110, 4, 0, 10, 48, 56, 49, 50, 52, 49, 54, 49, 51, 57, 0, 5, 116, 105, 116, 108, 101, 4, 0, 17, 88, 81, 117, 101, 114, 121, 32, 75, 105, 99, 107, 32, 83, 116, 97, 114, 116, 0, 4, 121, 101, 97, 114, 25, 0, 0, 0, 0, 0, 0, 7, -43, 0, 8, 99, 97, 116, 101, 103, 111, 114, 52, 0, 7, 97, 117, 116, 104, 111, 114, 115, 108, 0, 0, 0, 2, 0, 0, 0, 17, 0, 0, 0, 30, 4, 0, 14, 74, 97, 109, 101, 115, 32, 77, 99, 71, 111, 118, 101, 114, 110, 4, 0, 10, 74, 97, 109, 101, 115, 32, 76, 105, 110, 110>>>
+
+
+=========================================================================
+** {Object}
+  
+  <<<109>>> The first byte as described above is the value tag for Object
+  Pointable.
+  
+  The rest of the bytes represent an Object Pointable. Refer to this link
+  to view the {{Bytes}} for the Object Pointable(OP).
+
+  Following are the bytes and contents of the Object Pointable for this JSONiq
+  document.
+  
+  <<< 0, 0, 0, 1 >>>  These 4 bytes represent the
+  number of key-value pairs in the object which is <<1>>
+  
+  <<< 0, 0, 0, -101 >>>  These 4 bytes represent the
+  offset for the key-value pair in the object which is <<-101>>
+
+
+  Following is the key in the object followed by the value of the key. Each key is a StringPointable  and the value of the key will be the respective Pointable starting with its Value Tag. The byte array break down is explained in details further ahead.
+ 
+*** <<<0, 4, 98, 111, 111, 107, 109, 0, 0, 0, 5, 0, 0, 0, 19, 0, 0, 0, 46, 0, 0, 0, 61, 0, 0, 0, 72, 0, 0, 0, 124, 0, 4, 105, 115, 98, 110, 4, 0, 10, 48, 56, 49, 50, 52, 49, 54, 49, 51, 57, 0, 5, 116, 105, 116, 108, 101, 4, 0, 17, 88, 81, 117, 101, 114, 121, 32, 75, 105, 99, 107, 32, 83, 116, 97, 114, 116, 0, 4, 121, 101, 97, 114, 25, 0, 0, 0, 0, 0, 0, 7, -43, 0, 8, 99, 97, 116, 101, 103, 111, 114, 121, 52, 0, 7, 97, 117, 116, 104, 111, 114, 115, 108, 0, 0, 0, 2, 0, 0, 0, 17, 0, 0, 0, 30, 4, 0, 14, 74, 97, 109, 101, 115, 32, 77, 99, 71, 111, 118, 101, 114, 110, 4, 0, 10, 74, 97, 109, 101, 115, 32, 76, 105, 110, 110>>>
+
+  The size of the string is <<4>>. The string value is <<book>>. The value of the key is an Object.
+ 
+  Object in OP(value):
+  
+  In this OP, the value  is again an Object Pointable 
+  (OP) ({{OP:0}}). <<109>> is the <Value Tag> for Object Pointable. 
+   
+  Following are the byte contents for the Object Pointable 
+  ({{OP:0}}). The byte array break down is explained further ahead.
+ 
+*** <<<109, 0, 0, 0, 5, 0, 0, 0, 19, 0, 0, 0, 46, 0, 0, 0, 61, 0, 0, 0, 72, 0, 0, 0, 124, 0, 4, 105, 115, 98, 110, 4, 0, 10, 48, 56, 49, 50, 52, 49, 54, 49, 51, 57, 0, 5, 116, 105, 116, 108, 101, 4, 0, 17, 88, 81, 117, 101, 114, 121, 32, 75, 105, 99, 107, 32, 83, 116, 97, 114, 116, 0, 4, 121, 101, 97, 114, 25, 0, 0, 0, 0, 0, 0, 7, -43, 0, 8, 99, 97, 116, 101, 103, 111, 114, 121, 52, 0, 7, 97, 117, 116, 104, 111, 114, 115, 108, 0, 0, 0, 2, 0, 0, 0, 17, 0, 0, 0, 30, 4, 0, 14, 74, 97, 109, 101, 115, 32, 77, 99, 71, 111, 118, 101, 114, 110, 4, 0, 10, 74, 97, 109, 101, 115, 32, 76, 105, 110, 110>>>
+
+=========================================================================
+** Object ({OP:0})
+  
+  This child is contained in the parent {{Object}}.
+   
+  Byte Array for Object (OP:0)
+  
+***  <<<109, 0, 0, 0, 5, 0, 0, 0, 19, 0, 0, 0, 46, 0, 0, 0, 61, 0, 0, 0, 72, 0, 0, 0, 124, 0, 4, 105, 115, 98, 110, 4, 0, 10, 48, 56, 49, 50, 52, 49, 54, 49, 51, 57, 0, 5, 116, 105, 116, 108, 101, 4, 0, 17, 88, 81, 117, 101, 114, 121, 32, 75, 105, 99, 107, 32, 83, 116, 97, 114, 116, 0, 4, 121, 101, 97, 114, 25, 0, 0, 0, 0, 0, 0, 7, -43, 0, 8, 99, 97, 116, 101, 103, 111, 114, 121, 52, 0, 7, 97, 117, 116, 104, 111, 114, 115, 108, 0, 0, 0, 2, 0, 0, 0, 17, 0, 0, 0, 30, 4, 0, 14, 74, 97, 109, 101, 115, 32, 77, 99, 71, 111, 118, 101, 114, 110, 4, 0, 10, 74, 97, 109, 101, 115, 32, 76, 105, 110, 110>>>
+  
+  <<<109>>> is the value tag for the Object Pointable.
+ 
+  Following are the bytes and contents of the Object Pointable.
+  
+  <<< 0, 0, 0, 5 >>>  These 4 bytes represent the
+  number of key-value pairs in the object which is <<5>>.
+  
+  Following are the bytes that represent the offsets of the three key-value pairs.
+  
+  <<< 0, 0, 0, 19 >>> The offset for the key <<isbn>>.
+  
+  <<< 0, 0, 0, 46 >>> The offset for the key <<title>>.
+  
+  <<< 0, 0, 0, 61 >>> The offset for the key <<year>>.
+  
+  <<< 0, 0, 0, 72 >>> The offset for the key <<category>>.
+  
+  <<< 0, 0, 0, 124 >>> The offset for the key <<authors>>.
+ 
+  As above, the following bytes represent the three key-value pairs inside the Object. 
+  
+  <<<0, 4, 105, 115, 98, 110, 4, 0, 10, 48, 56, 49, 50, 52, 49, 54, 49, 51, 57>>>
+  
+  The size of the string is <<4>>. The string value is <<isbn>>. The String Pointable is followed by a String Pointable.
+  The Value Tag of it is <<4>>. Its size is <<10>>. Its value is <<0812416139>>.
+ 
+  <<<0, 5, 116, 105, 116, 108, 101, 4, 0, 17, 88, 81, 117, 101, 114, 121, 32, 75, 105, 99, 107, 32, 83, 116, 97, 114, 116>>>
+  
+  The size of the string is <<5>>. The string value is <<title>>. The String Pointable is followed by a String Pointable.
+  Its Value Tag is <<4>>. Its size is <<17>>. Its value is <<XQuery Kick Start>>.
+  
+  <<<0, 4, 121, 101, 97, 114, 25, 0, 0, 0, 0, 0, 0, 7, -43>>>
+  
+  The size of the string is <<4>>. The string value is <<year>>. The String Pointable is followed by a Long Pointalbe.
+  Its Value Tag is <<25>>. Its value is <<2005>>.
+  
+  <<<0, 8, 99, 97, 116, 101, 103, 111, 114, 121, 52>>>
+  
+  The size of the string is <<8>>. The string value is <<category>>. The String Pointable is followed by a NULL Pointable.
+  Its Value Tag is <<52>>. Its value is <<null>>.
+  
+  <<<0, 7, 97, 117, 116, 104, 111, 114, 115, 108, 0, 0, 0, 2, 0, 0, 0, 17, 0, 0, 0, 30, 4, 0, 14, 74, 97, 109, 101, 115, 32, 77, 99, 71, 111, 118, 101, 114, 110, 4, 0, 10, 74, 97, 109, 101, 115, 32, 76, 105, 110, 110>>>
+  
+  The size of the string is <<7>>. The string value is <<authors>>. The String Pointable is followed by an Array Pointable.
+  The byte array break down of the Array Pointable ({{AP}}) is explained further ahead.
+ 
+  
+================================================================ 
+**  Array ({AP})
+
+  This child is contained in the parent Object ({{OP:0}}).
+  
+  Byte Array for Array AP
+  
+***  <<<108, 0, 0, 0, 2, 0, 0, 0, 17, 0, 0, 0, 30, 4, 0, 14, 74, 97, 109, 101, 115, 32, 77, 99, 71, 111, 118, 101, 114, 110, 4, 0, 10, 74, 97, 109, 101, 115, 32, 76, 105, 110, 110>>>
+ 
+  <<<108>>> is the value tag for Array Pointable.
+ 
+  Following are the bytes and contents of the Array Pointable.
+ 
+  <<<0, 0, 0, 2>>>  The number of items in the array which is <<2>>.
+          
+  <<<0, 0, 0, 17>>> The offset of the first item which is <<17>>. 
+ 
+  <<<0, 0, 0, 30>>> The offset of the second item which is <<30>>.
+ 
+  Following are the byte contents for each of the two items of the array.
+
+  <<<4, 0, 14, 74, 97, 109, 101, 115, 32, 77, 99, 71, 111, 118, 101, 114, 110>>>.
+  
+  The first item is a String Pointable with value tag <<4>>. The size of the string is <<14>>. The value of the string is <<James McGovern>>.
+  
+  <<<4, 0, 10, 74, 97, 109, 101, 115, 32, 76, 105, 110, 110>>>.  
+  
+  The second item is a String Pointable with value tag <<4>>. The size of the string is <<10>>. The value of the string is <<James Linn>>.
+ 
+
+================================================================

http://git-wip-us.apache.org/repos/asf/vxquery/blob/0970f579/src/site/site.xml
----------------------------------------------------------------------
diff --git a/src/site/site.xml b/src/site/site.xml
index d64fe0d..5b9e21b 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -101,6 +101,9 @@ limitations under the License.
             <item
                 name="XML Data Model Example"
                 href="development_xml_document.html" />
+            <item
+                name="JSONiq Data Model Example"
+                href="development_json_document.html" />
         </menu>
         <menu ref="reports" />
         <menu ref="modules" />