Debian Codegraph @

doc/source/reference/command/output_format.rst

raw
1 .. -*- rst -*-
2
3 Output format
4 =============
5
6 Summary
7 -------
8
9 Commands output their result as JSON, MessagePack, XML or TSV format.
10
11 JSON and MessagePack output have the same structure. XML and TSV are
12 their original structure.
13
14 JSON or MessagePack is recommend format. XML is useful for visual
15 result check. TSV is just for special use. Normally you doesn't need
16 to use TSV.
17
18 JSON and MessagePack
19 --------------------
20
21 This section describes the structure of command result on JSON and
22 MessagePack format. JSON is used to show structure because MessagePack
23 is binary format. Binary format isn't proper for documenataion.
24
25 JSON and MessagePack uses the following structure::
26
27 [HEADER, BODY]
28
29 For example::
30
31 [
32 [
33 0,
34 1337566253.89858,
35 0.000355720520019531
36 ],
37 [
38 [
39 [
40 1
41 ],
42 [
43 [
44 "_id",
45 "UInt32"
46 ],
47 [
48 "_key",
49 "ShortText"
50 ],
51 [
52 "content",
53 "Text"
54 ],
55 [
56 "n_likes",
57 "UInt32"
58 ]
59 ],
60 [
61 2,
62 "Groonga",
63 "I started to use groonga. It's very fast!",
64 10
65 ]
66 ]
67 ]
68 ]
69
70 In the example, the following part is ``HEADER``::
71
72 [
73 0,
74 1337566253.89858,
75 0.000355720520019531
76 ]
77
78 The following part is ``BODY``::
79
80 [
81 [
82 [
83 1
84 ],
85 [
86 [
87 "_id",
88 "UInt32"
89 ],
90 [
91 "_key",
92 "ShortText"
93 ],
94 [
95 "content",
96 "Text"
97 ],
98 [
99 "n_likes",
100 "UInt32"
101 ]
102 ],
103 [
104 2,
105 "Groonga",
106 "I started to use groonga. It's very fast!",
107 10
108 ]
109 ]
110 ]
111
112 ``HEADER``
113 ^^^^^^^^^^
114
115 ``HEADER`` is an array. The content of ``HEADER`` has some patterns.
116
117 Success case
118 ++++++++++++
119
120 ``HEADER`` has three elements on success::
121
122 [0, UNIX_TIME_WHEN_COMMAND_IS_STARTED, ELAPSED_TIME]
123
124 The first element is always ``0``.
125
126 ``UNIX_TIME_WHEN_COMMAND_IS_STARTED`` is the number of seconds
127 since 1970-01-01 00:00:00 UTC when the command is started
128 processing. ``ELAPSED_TIME`` is the elapsed time for processing the
129 command in seconds. Both ``UNIX_TIME_WHEN_COMMAND_IS_STARTED`` and
130 ``ELAPSED_TIME`` are float value. The precision of them are
131 nanosecond.
132
133 Error case
134 ++++++++++
135
136 ``HEADER`` has four or five elements on error::
137
138 [
139 RETURN_CODE,
140 UNIX_TIME_WHEN_COMMAND_IS_STARTED,
141 ELAPSED_TIME,
142 ERROR_MESSAGE,
143 ERROR_LOCATION
144 ]
145
146 ``ERROR_LOCATION`` may not be included in ``HEADER`` but other four
147 elements are always included.
148
149 ``RETURN_CODE`` is non 0 value. See :doc:`return_code` about available
150 return codes.
151
152 ``UNIX_TIME_WHEN_COMMAND_IS_STARTED`` and ``ELAPSED_TIME`` are the
153 same as success case.
154
155 ``ERROR_MESSAGE`` is an error message in string.
156
157 ``ERROR_LOCATION`` is optional. If error location is collected,
158 ``ERROR_LOCATION`` is included. ``ERROR_LOCATION`` is an
159 array. ``ERROR_LOCATION`` has one or two elements::
160
161 [
162 LOCATION_IN_GROONGA,
163 LOCATION_IN_INPUT
164 ]
165
166 ``LOCATION_IN_GROONGA`` is the source location that error is occurred
167 in groonga. It is useful for groonga developers but not useful for
168 users. ``LOCATION_IN_GROONGA`` is an array. ``LOCATION_IN_GROONGA`` has
169 three elements::
170
171 [
172 FUNCTION_NAME,
173 SOURCE_FILE_NAME,
174 LINE_NUMBER
175 ]
176
177 ``FUNCTION_NAME`` is the name of function that error is occurred.
178
179 ``SOURCE_FILE_NAME`` is the name of groonga's source file that error is
180 occurred.
181
182 ``LINE_NUMBER`` is the line number of ``SOURCE_FILE_NAME`` that error
183 is occurred.
184
185 ``LOCATION_IN_INPUT`` is optional. ``LOCATION_IN_INPUT`` is included
186 when the location that error is occurred in input file is
187 collected. Input file can be specified by ``--file`` command line
188 option for ``groonga`` command. ``LOCATION_IN_INPUT`` is an
189 array. ``LOCATION_IN_INPUT`` has three elements::
190
191 [
192 INPUT_FILE_NAME,
193 LINE_NUMBER,
194 LINE_CONTENT
195 ]
196
197 ``INPUT_FILE_NAME`` is the input file name that error is occurred.
198
199 ``LINE_NUMBER`` is the line number of ``INPUT_FILE_NAME`` that error
200 is occurred.
201
202 ``LINE_CONTENT`` is the content at ``LINE_NUMBER`` in
203 ``INPUT_FILE_NAME``.
204
205 ``BODY``
206 ^^^^^^^^
207
208 ``BODY`` content depends on the executed command. It may be omitted.
209
210 ``BODY`` may be an error message on error case.
211
212 XML
213 ---
214
215 TODO
216
217 TSV
218 ---
219
220 TODO
221
222 See also
223 --------
224
225 * :doc:`return_code` describes about return code.
226