├── .gitignore ├── LICENSE ├── README.md ├── docs ├── article.md └── images │ ├── arangodb-config.png │ ├── arangodb-kino.png │ ├── arangodb-misc.png │ ├── arangodb-pie.png │ └── arangodb-table.png ├── pom.xml └── src ├── main ├── java │ └── io │ │ └── millesabords │ │ └── zeppelin │ │ └── interpreter │ │ └── arangodb │ │ └── ArangoDbInterpreter.java └── resources │ └── interpreter-setting.json └── test └── java └── io └── millesabords └── zeppelin └── interpreter └── arangodb ├── AbstractArangoDbInterpreterTest.java ├── ArangoDbInterpreterGraphTest.java ├── ArangoDbInterpreterTest.java └── MockArangoServer.java /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | pom.xml.tag 3 | pom.xml.releaseBackup 4 | pom.xml.versionsBackup 5 | pom.xml.next 6 | release.properties 7 | dependency-reduced-pom.xml 8 | buildNumber.properties 9 | .settings/ 10 | .classpath 11 | .project 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # zeppelin-arangodb-interpreter 2 | 3 | [ArangoDB](https://www.arangodb.com/) Interpreter for [Apache Zeppelin](https://zeppelin.incubator.apache.org/). 4 | This interpreter only supports AQL ([ArangoDB Query Language](https://docs.arangodb.com/Aql/)). 5 | 6 | > **Important** : the graph part of ArangoDB is **PARTIALLY** supported at the moment. To test it, you can use the data from the [Actors and Movies Database example](https://docs.arangodb.com/cookbook/GraphExampleActorsAndMovies.html). 7 | 8 | 9 | ![Search pie](/docs/images/arangodb-pie.png) 10 | 11 | ## Versions 12 | 13 | Interpreter | ArangoDB 14 | ------------|--------- 15 | 2.0 | 3.x 16 | 1.0 | 2.7 17 | 18 | ## Build 19 | It's a Maven project, so it's simple: 20 | ```bash 21 | mvn clean package 22 | ``` 23 | You should have a `arangodb-interpreter-jar-with-dependencies.jar` in the _target_ directory. 24 | 25 | ## Install 26 | 27 | `ZEPPELIN_HOME` is your Zeppelin installation directory. 28 | 29 | * Create a directory in /interpreter: 30 | ```bash 31 | cd /interpreter 32 | mkdir arangodb 33 | ``` 34 | 35 | * Copy the jar of arangodb-interpreter in the directory `/interpreter/arangodb. 36 | 37 | * (optional, it is for older version of Zeppelin) In `/conf/zeppelin-site.xml`, add the interpreter class: 38 | ```xml 39 | 40 | zeppelin.interpreters 41 | io.millesabords.zeppelin.arangodb.ArangoDbInterpreter,org.apache.zeppelin.spark.SparkInterpreter,... 42 | Comma separated interpreter configurations. First interpreter become a default 43 | 44 | ``` 45 | 46 | * Start Zeppelin: 47 | On Linux: 48 | ```bash 49 | /bin/zeppelin-daemon.sh start 50 | ``` 51 | or on Windows 52 | ```bash 53 | \bin\zeppelin.cmd 54 | ``` 55 | 56 | ## How to use the interpreter 57 | 58 | ### Configuration 59 | 60 | First, you have to configure the interpreter by setting the values of: 61 | * the host and port of your ArangoDB server 62 | * the user/password 63 | * the database name 64 | 65 | ![Config](/docs/images/arangodb-config.png) 66 | 67 | 68 | ### Commands 69 | 70 | In a paragraph, use `%arango` to select the ArangoDB interpreter and then input all commands. 71 | 72 | > **Important**: The result of a query can contain a list of JSON documents, so, as it is hierarchical (not flat as a row in a SQL table), for this interpreter, the result of a query is flattened. 73 | 74 | Suppose we have a JSON document: 75 | 76 | ``` 77 | { 78 | "date": "2015-12-08T21:03:13.588Z", 79 | "request": { 80 | "method": "GET", 81 | "url": "/zeppelin/4cd001cd-c517-4fa9-b8e5-a06b8f4056c4", 82 | "headers": [ "Accept: *.*", "Host: apache.org"] 83 | }, 84 | "status": "403", 85 | "content_length": 1234 86 | } 87 | ``` 88 | 89 | The data will be flattened like this: 90 | 91 | 92 | content_length | date | request.headers[0] | request.headers[1] | request.method | request.url | status 93 | ---------------|------|--------------------|--------------------|----------------|-------------|------- 94 | 1234 | 2015-12-08T21:03:13.588Z | Accept: \*.\* | Host: apache.org | GET | /zeppelin/4cd001cd-c517-4fa9-b8e5-a06b8f4056c4 | 403 95 | 96 | 97 | ### Examples : 98 | 99 | * Document database : 100 | 101 | ``` 102 | | %arango 103 | | 104 | | FOR log in logs 105 | | RETURN log 106 | | 107 | ``` 108 | 109 | * The display as the table : 110 | 111 | ![Display as a table](docs/images/arangodb-table.png) 112 | 113 | 114 | * The display as a pie : 115 | 116 | ![Display as a pie](docs/images/arangodb-pie.png) 117 | 118 | 119 | * Graph database : 120 | 121 | ``` 122 | | %arango 123 | | 124 | | FOR x IN actsIn COLLECT movie = x._to 125 | | WITH COUNT INTO counter 126 | | RETURN {movie: movie, nb_actors: counter} 127 | | 128 | ``` 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 |
nb_actorsmovie
11.0movies/AFewGoodMen
4.0movies/AsGoodAsItGets
9.0movies/JerryMaguire
3.0movies/JoeVersustheVolcano
6.0movies/SleeplessInSeattle
4.0movies/SnowFallingonCedars
139 | 140 | 141 | 142 | 143 | * Other examples : 144 | 145 | ![Display values](docs/images/arangodb-misc.png) 146 | 147 | 148 | -------------------------------------------------------------------------------- /docs/article.md: -------------------------------------------------------------------------------- 1 | 2 | # [ArangoDB](https://www.arangodb.com/) Interpreter for [Apache Zeppelin](https://zeppelin.incubator.apache.org/) 3 | 4 | What is Apache Zeppelin ? This project aims to provide a web environment for easing data discovery, analytics and visualization. This is the GUI you should have in your company for processing and collaborate on your (big) data. It provides interpreters to interact with databases (Cassandra, PostgreSQL and other JDBC compliant database, …), to define processing of your data with Spark or Flink, etc. 5 | 6 | 7 | The ArangoDB interpreter for Apache Zeppelin aims to provide a new interpreter to query an ArangoDB database. 8 | 9 | 10 | 11 | ## Foreword about data format 12 | 13 | Basically, in Zeppelin, you have notebooks with paragraphs in which you can type commands, that are interpreted and the results are displayed. Depending on your result format, you can automatically have access to charts for displaying your data. 14 | 15 | To have access to these charts, your output data format must be a table, but with ArangoDB, the result of a query can contain a list of JSON documents, so, as it is hierarchical (not flat as a row in a SQL table). 16 | 17 | So, to ease the integration in Zeppelin, the ArangoDB interpreter will flatten the result of the queries. 18 | 19 | Suppose we have a JSON document: 20 | 21 | ``` 22 | { 23 | "date": "2015-12-08T21:03:13.588Z", 24 | "request": { 25 | "method": "GET", 26 | "url": "/zeppelin/4cd001cd-c517-4fa9-b8e5-a06b8f4056c4", 27 | "headers": [ "Accept: *.*", "Host: apache.org"] 28 | }, 29 | "status": "403", 30 | "content_length": 1234 31 | } 32 | ``` 33 | 34 | The data will be flattened like this: 35 | 36 | 37 | content_length | date | request.headers[0] | request.headers[1] | request.method | request.url | status 38 | ---------------|------|--------------------|--------------------|----------------|-------------|------- 39 | 1234 | 2015-12-08T21:03:13.588Z | Accept: \*.\* | Host: apache.org | GET | /zeppelin/4cd001cd-c517-4fa9-b8e5-a06b8f4056c4 | 403 40 | 41 | 42 | 43 | ## How to use the interpreter 44 | 45 | ### Configuration 46 | 47 | First, you have to configure the interpreter by setting the values of: 48 | * the host and port of your ArangoDB server 49 | * the user/password 50 | * the database name 51 | 52 | ![Config](images/arangodb-config.png) 53 | 54 | 55 | ### Commands 56 | 57 | In a paragraph, use `%arango` to select the ArangoDB interpreter and then input all commands. 58 | 59 | > **Important**: The interpreter only supports AQL ([ArangoDB Query Language](https://docs.arangodb.com/Aql/)). 60 | 61 | 62 | 63 | ### Examples : 64 | 65 | * Document database : 66 | 67 | ``` 68 | | %arango 69 | | 70 | | FOR log in logs 71 | | RETURN log 72 | | 73 | ``` 74 | 75 | * The display as the table : 76 | 77 | ![Display as a table](images/arangodb-table.png) 78 | 79 | 80 | * The display as a pie : 81 | 82 | ![Display as a pie](images/arangodb-pie.png) 83 | 84 | 85 | * Graph database (to test it, you can use the data from the [Actors and Movies Database example](https://docs.arangodb.com/cookbook/GraphExampleActorsAndMovies.html)) : 86 | 87 | ``` 88 | | %arango 89 | | 90 | | FOR x IN actsIn COLLECT movie = x._to 91 | | WITH COUNT INTO counter 92 | | RETURN {movie: movie, nb_actors: counter} 93 | | 94 | ``` 95 | 96 | ![Display kino result](images/arangodb-kino.png) 97 | 98 | 99 | 100 | * Other examples : 101 | 102 | ![Display values](images/arangodb-misc.png) 103 | 104 | 105 | This interpreter can be found on github : https://github.com/bbonnin/zeppelin-arangodb-interpreter 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /docs/images/arangodb-config.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bbonnin/zeppelin-arangodb-interpreter/a33fc71621ed567ab5d72e16520f8a63dd66c2fa/docs/images/arangodb-config.png -------------------------------------------------------------------------------- /docs/images/arangodb-kino.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bbonnin/zeppelin-arangodb-interpreter/a33fc71621ed567ab5d72e16520f8a63dd66c2fa/docs/images/arangodb-kino.png -------------------------------------------------------------------------------- /docs/images/arangodb-misc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bbonnin/zeppelin-arangodb-interpreter/a33fc71621ed567ab5d72e16520f8a63dd66c2fa/docs/images/arangodb-misc.png -------------------------------------------------------------------------------- /docs/images/arangodb-pie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bbonnin/zeppelin-arangodb-interpreter/a33fc71621ed567ab5d72e16520f8a63dd66c2fa/docs/images/arangodb-pie.png -------------------------------------------------------------------------------- /docs/images/arangodb-table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bbonnin/zeppelin-arangodb-interpreter/a33fc71621ed567ab5d72e16520f8a63dd66c2fa/docs/images/arangodb-table.png -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | io.millesabords.zeppelin 5 | arangodb-interpreter 6 | 2.0-SNAPSHOT 7 | 8 | 9 | 10 | Apache License 11 | https://opensource.org/licenses/Apache-2.0 12 | repo 13 | 14 | 15 | 16 | 17 | 18 | bbonnin at gmail dot com 19 | Bruno Bonnin 20 | https://bbonnin.github.io 21 | 22 | 23 | 24 | 25 | https://github.com/bbonnin/zeppelin-arangodb-interpreter/issues 26 | GitHub Issues 27 | 28 | 29 | 30 | UTF-8 31 | 0.7.0 32 | 1.7.11 33 | 4.1.10 34 | 0.1.1 35 | 4.4.1 36 | 4.11 37 | 38 | 39 | 40 | 41 | org.apache.zeppelin 42 | zeppelin-interpreter 43 | ${zeppelin.version} 44 | 45 | 46 | org.slf4j 47 | slf4j-api 48 | ${slf4j.version} 49 | 50 | 51 | com.arangodb 52 | arangodb-java-driver 53 | ${arangodb.version} 54 | 55 | 56 | com.github.wnameless 57 | json-flattener 58 | ${json-flattener.version} 59 | 60 | 61 | org.apache.httpcomponents 62 | httpcore 63 | ${httpcore.version} 64 | 65 | 66 | junit 67 | junit 68 | ${junit.version} 69 | test 70 | 71 | 72 | 73 | 74 | arangodb-interpreter 75 | 76 | 77 | maven-compiler-plugin 78 | 3.3 79 | 80 | 1.7 81 | 1.7 82 | 83 | 84 | 85 | maven-assembly-plugin 86 | 2.6 87 | 88 | 89 | jar-with-dependencies 90 | 91 | 92 | 93 | 94 | make-assembly 95 | package 96 | 97 | single 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | apache.repo 108 | Apache Development Repository 109 | https://repository.apache.org/content/repositories/orgapachezeppelin-1003/ 110 | 111 | true 112 | 113 | 114 | true 115 | 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /src/main/java/io/millesabords/zeppelin/interpreter/arangodb/ArangoDbInterpreter.java: -------------------------------------------------------------------------------- 1 | package io.millesabords.zeppelin.interpreter.arangodb; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.HashMap; 6 | import java.util.LinkedList; 7 | import java.util.List; 8 | import java.util.Map; 9 | import java.util.Properties; 10 | import java.util.Set; 11 | import java.util.TreeSet; 12 | 13 | import org.apache.commons.lang.StringUtils; 14 | import org.apache.zeppelin.interpreter.Interpreter; 15 | import org.apache.zeppelin.interpreter.InterpreterContext; 16 | import org.apache.zeppelin.interpreter.InterpreterResult; 17 | import org.apache.zeppelin.interpreter.InterpreterResult.Code; 18 | import org.apache.zeppelin.interpreter.thrift.InterpreterCompletion; 19 | import org.slf4j.Logger; 20 | import org.slf4j.LoggerFactory; 21 | 22 | import com.arangodb.ArangoCursor; 23 | import com.arangodb.ArangoDB; 24 | import com.arangodb.ArangoDBException; 25 | import com.arangodb.ArangoDatabase; 26 | import com.github.wnameless.json.flattener.JsonFlattener; 27 | import com.google.gson.Gson; 28 | import com.google.gson.GsonBuilder; 29 | 30 | /** 31 | * ArangoDB Interpreter for Zeppelin. 32 | * 33 | * @see https://docs.arangodb.com/Aql/index.html 34 | * @see https://www.arangodb.com/sql-aql-comparison/ 35 | * 36 | * @author Bruno Bonnin 37 | */ 38 | public class ArangoDbInterpreter extends Interpreter { 39 | 40 | private static final Logger LOGGER = LoggerFactory.getLogger(ArangoDbInterpreter.class); 41 | 42 | private static final List COMMANDS = Arrays.asList("FOR", "RETURN", "FILTER", 43 | "SORT", "LIMIT", "LET", "COLLECT", "INSERT", "UPDATE", "REPLACE", "REMOVE", "UPSERT"); 44 | 45 | private static final List SUGGESTIONS = new ArrayList<>(); 46 | 47 | public static final String ARANGODB_HOST = "arangodb.host"; 48 | public static final String ARANGODB_PORT = "arangodb.port"; 49 | public static final String ARANGODB_DATABASE = "arangodb.database"; 50 | public static final String ARANGODB_USER = "arangodb.user"; 51 | public static final String ARANGODB_PWD = "arangodb.pwd"; 52 | 53 | static { 54 | for (final String cmd: COMMANDS) { 55 | SUGGESTIONS.add(new InterpreterCompletion(cmd, cmd)); 56 | } 57 | } 58 | 59 | 60 | private final Gson gson = new GsonBuilder().setPrettyPrinting().create(); 61 | private ArangoDB arango; 62 | 63 | public ArangoDbInterpreter(Properties property) { 64 | super(property); 65 | } 66 | 67 | @Override 68 | public void open() { 69 | try { 70 | final ArangoDB.Builder builder = new ArangoDB.Builder() 71 | .host(getProperty(ARANGODB_HOST), Integer.parseInt(getProperty(ARANGODB_PORT))); 72 | 73 | if (!StringUtils.isEmpty(getProperty(ARANGODB_USER))) { 74 | builder.user(getProperty(ARANGODB_USER)).password(getProperty(ARANGODB_PWD)); 75 | } 76 | 77 | arango = builder.build(); 78 | } 79 | catch (final Exception e) { 80 | LOGGER.error("Open connection with ArangoDB", e); 81 | } 82 | } 83 | 84 | @Override 85 | public void close() { 86 | if (arango != null) { 87 | arango.shutdown(); 88 | } 89 | } 90 | 91 | @Override 92 | public InterpreterResult interpret(String cmd, InterpreterContext interpreterContext) { 93 | LOGGER.info("Run AQL command '" + cmd + "'"); 94 | 95 | try { 96 | return interpretAql(cmd); 97 | } 98 | catch (final ArangoDBException e) { 99 | return new InterpreterResult(InterpreterResult.Code.ERROR, "Error : " + e.getMessage()); 100 | } 101 | } 102 | 103 | @Override 104 | public void cancel(InterpreterContext interpreterContext) { 105 | //Nothing to do 106 | } 107 | 108 | @Override 109 | public FormType getFormType() { 110 | return FormType.NATIVE; 111 | } 112 | 113 | @Override 114 | public int getProgress(InterpreterContext interpreterContext) { 115 | return 0; 116 | } 117 | 118 | @Override 119 | public List completion(String s, int i) { 120 | 121 | final List suggestions = new ArrayList<>(); 122 | 123 | if (StringUtils.isEmpty(s)) { 124 | suggestions.addAll(SUGGESTIONS); 125 | } 126 | else { 127 | for (final String cmd : COMMANDS) { 128 | if (cmd.contains(s.toUpperCase())) { 129 | suggestions.add(new InterpreterCompletion(cmd, cmd)); 130 | } 131 | } 132 | } 133 | 134 | return suggestions; 135 | } 136 | 137 | /** 138 | * Interpret the AQL query. 139 | * 140 | * @param cmd Contains the AQL query 141 | * @return The result of the query 142 | * @throws ArangoDBException Raised by the Arango driver in case of problem 143 | */ 144 | private InterpreterResult interpretAql(String cmd) throws ArangoDBException { 145 | 146 | final ArangoCursor cursor = db().query(cmd, null, null, Object.class); 147 | final List> flattenDocs = new LinkedList<>(); 148 | final Set keys = new TreeSet<>(); 149 | 150 | // First : get all the keys in order to build an ordered list of the values for each doc 151 | // 152 | while (cursor.hasNext()) { 153 | final Object item = cursor.next(); 154 | Map flattenMap; 155 | 156 | if (item instanceof Map) { 157 | flattenMap = JsonFlattener.flattenAsMap(gson.toJson(item)); 158 | } 159 | else { 160 | flattenMap = new HashMap<>(); 161 | flattenMap.put("value", item); 162 | } 163 | 164 | flattenDocs.add(flattenMap); 165 | for (final String key : flattenMap.keySet()) { 166 | keys.add(key); 167 | } 168 | } 169 | 170 | // Next : build the header of the table 171 | // 172 | final StringBuffer buffer = new StringBuffer(); 173 | for (final String key : keys) { 174 | buffer.append(key).append('\t'); 175 | } 176 | 177 | if (buffer.length() > 0) { 178 | buffer.replace(buffer.lastIndexOf("\t"), buffer.lastIndexOf("\t") + 1, "\n"); 179 | } 180 | else { 181 | return new InterpreterResult(Code.SUCCESS, InterpreterResult.Type.TEXT, "Empty result"); 182 | } 183 | 184 | // Finally : build the result by using the key set 185 | // 186 | for (final Map hit : flattenDocs) { 187 | for (final String key : keys) { 188 | final Object val = hit.get(key); 189 | if (val != null) { 190 | buffer.append(val); 191 | } 192 | buffer.append('\t'); 193 | } 194 | buffer.replace(buffer.lastIndexOf("\t"), buffer.lastIndexOf("\t") + 1, "\n"); 195 | } 196 | 197 | return new InterpreterResult(Code.SUCCESS, InterpreterResult.Type.TABLE, buffer.toString()); 198 | } 199 | 200 | private ArangoDatabase db() { 201 | return arango.db(getProperty(ARANGODB_DATABASE)); 202 | } 203 | 204 | } 205 | -------------------------------------------------------------------------------- /src/main/resources/interpreter-setting.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "group": "arango", 4 | "name": "arango", 5 | "className": "io.millesabords.zeppelin.interpreter.arangodb.ArangoDbInterpreter", 6 | "properties": { 7 | "arangodb.host": { 8 | "envName": "ARANGODB_HOST", 9 | "propertyName": "arangodb.host", 10 | "defaultValue": "localhost", 11 | "description": "The host for ArangoDB" 12 | }, 13 | "arangodb.port": { 14 | "envName": "ARANGODB_PORT", 15 | "propertyName": "arangodb.port", 16 | "defaultValue": "8529", 17 | "description": "The port for ArangoDB" 18 | }, 19 | "arangodb.database": { 20 | "envName": "ARANGODB_DATABASE", 21 | "propertyName": "arangodb.database", 22 | "defaultValue": "default", 23 | "description": "The database name" 24 | }, 25 | "arangodb.user": { 26 | "envName": "ARANGODB_USER", 27 | "propertyName": "arangodb.user", 28 | "defaultValue": "", 29 | "description": "Username for a basic authentication" 30 | }, 31 | "arangodb.pwd": { 32 | "envName": "ARANGODB_PWD", 33 | "propertyName": "arangodb.pwd", 34 | "defaultValue": "", 35 | "description": "Password for a basic authentication" 36 | } 37 | }, 38 | "editor": { 39 | "editOnDblClick": false 40 | } 41 | } 42 | ] 43 | -------------------------------------------------------------------------------- /src/test/java/io/millesabords/zeppelin/interpreter/arangodb/AbstractArangoDbInterpreterTest.java: -------------------------------------------------------------------------------- 1 | package io.millesabords.zeppelin.interpreter.arangodb; 2 | 3 | import java.util.Properties; 4 | 5 | import org.junit.AfterClass; 6 | 7 | import com.arangodb.ArangoDB; 8 | import com.arangodb.ArangoDBException; 9 | import com.arangodb.ArangoDatabase; 10 | 11 | /** 12 | * Base class for the tests. 13 | * 14 | * @author Bruno Bonnin 15 | * 16 | */ 17 | public abstract class AbstractArangoDbInterpreterTest { 18 | 19 | private static final String HOST = "localhost"; 20 | private static final int PORT = 8529; 21 | private static final String USERNAME = "root"; 22 | private static final String PASSWORD = "arango"; 23 | 24 | private static String dbName; 25 | 26 | protected static ArangoDB arango; 27 | protected static ArangoDbInterpreter interpreter; 28 | 29 | protected static void init(String dbName) { 30 | 31 | AbstractArangoDbInterpreterTest.dbName = dbName; 32 | 33 | arango = new ArangoDB.Builder() 34 | .host(HOST, PORT) 35 | .user(USERNAME).password(PASSWORD) 36 | .build(); 37 | 38 | try { 39 | arango.db(dbName).drop(); 40 | } 41 | catch (final ArangoDBException e) {} 42 | 43 | arango.createDatabase(dbName); 44 | 45 | final Properties props = new Properties(); 46 | props.put(ArangoDbInterpreter.ARANGODB_HOST, HOST); 47 | props.put(ArangoDbInterpreter.ARANGODB_PORT, "" + PORT); 48 | props.put(ArangoDbInterpreter.ARANGODB_DATABASE, dbName); 49 | props.put(ArangoDbInterpreter.ARANGODB_USER, USERNAME); 50 | props.put(ArangoDbInterpreter.ARANGODB_PWD, PASSWORD); 51 | interpreter = new ArangoDbInterpreter(props); 52 | interpreter.open(); 53 | } 54 | 55 | protected static ArangoDatabase db() { 56 | return arango.db(dbName); 57 | } 58 | 59 | @AfterClass 60 | public static void clean() { 61 | if (arango != null) { 62 | try { 63 | arango.db(dbName).drop(); 64 | } 65 | catch (final ArangoDBException e) {} 66 | 67 | arango.shutdown(); 68 | } 69 | 70 | if (interpreter != null) { 71 | interpreter.close(); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/test/java/io/millesabords/zeppelin/interpreter/arangodb/ArangoDbInterpreterGraphTest.java: -------------------------------------------------------------------------------- 1 | package io.millesabords.zeppelin.interpreter.arangodb; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | 5 | import java.io.IOException; 6 | import java.util.ArrayList; 7 | import java.util.Collection; 8 | 9 | import org.apache.zeppelin.interpreter.InterpreterResult; 10 | import org.apache.zeppelin.interpreter.InterpreterResult.Code; 11 | import org.junit.BeforeClass; 12 | import org.junit.Test; 13 | 14 | import com.arangodb.ArangoDBException; 15 | import com.arangodb.entity.BaseDocument; 16 | import com.arangodb.entity.BaseEdgeDocument; 17 | import com.arangodb.entity.CollectionType; 18 | import com.arangodb.entity.EdgeDefinition; 19 | import com.arangodb.model.CollectionCreateOptions; 20 | 21 | /** 22 | * Tests for graph queries. 23 | * 24 | * The data are coming from : https://docs.arangodb.com/3.1/cookbook/Graph/ExampleActorsAndMovies.html 25 | * 26 | * @author Bruno Bonnin 27 | * 28 | */ 29 | public class ArangoDbInterpreterGraphTest extends AbstractArangoDbInterpreterTest { 30 | 31 | private static final String DB_NAME = "cinema"; 32 | 33 | private static Object createMovie(String key, String title, int released, String tagline) { 34 | final BaseDocument doc = new BaseDocument(key); 35 | doc.addAttribute("title", title); 36 | doc.addAttribute("released", released); 37 | doc.addAttribute("tagline", tagline); 38 | return doc; 39 | } 40 | 41 | private static Object createActor(String key, String name, int born) { 42 | final BaseDocument doc = new BaseDocument(key); 43 | doc.addAttribute("name", name); 44 | doc.addAttribute("born", born); 45 | return doc; 46 | } 47 | 48 | private static Object createActsIn(String actor, String movie, int year, String... roles) { 49 | final BaseEdgeDocument doc = new BaseEdgeDocument(); 50 | doc.setFrom(actor); 51 | doc.setTo(movie); 52 | doc.addAttribute("roles", roles); 53 | doc.addAttribute("year", year); 54 | return doc; 55 | } 56 | 57 | @BeforeClass 58 | public static void populate() throws ArangoDBException, IOException { 59 | init(DB_NAME); 60 | 61 | db().createCollection("actors"); 62 | db().createCollection("movies"); 63 | db().createCollection("actsIn", new CollectionCreateOptions().type(CollectionType.EDGES)); 64 | 65 | final Collection edgeDefinitions = new ArrayList<>(); 66 | final EdgeDefinition edgeDefinition = new EdgeDefinition() 67 | .collection("actsIn") 68 | .from("actors") 69 | .to("movies"); 70 | edgeDefinitions.add(edgeDefinition); 71 | db().createGraph("moviesGraph", edgeDefinitions, null); 72 | 73 | final String theMatrix = db().collection("movies").insertDocument( 74 | createMovie("TheMatrix", "The Matrix", 1999, "Welcome to the Real World")).getId(); 75 | final String theDevilsAdvocate = db().collection("movies").insertDocument( 76 | createMovie("TheDevilsAdvocate", "The Devil's Advocate", 1997, "Evil has its winning ways")).getId(); 77 | 78 | final String keanu = db().collection("actors").insertDocument( 79 | createActor("Keanu", "Keanu Reeves", 1964)).getId(); 80 | final String carrie = db().collection("actors").insertDocument( 81 | createActor("Carrie", "Carrie-Anne Moss", 1967)).getId(); 82 | 83 | db().collection("actsIn").insertDocument( 84 | createActsIn(keanu, theMatrix, 1999, "Neo")); 85 | db().collection("actsIn").insertDocument( 86 | createActsIn(keanu, theDevilsAdvocate, 1997, "Kevin Lomax")); 87 | db().collection("actsIn").insertDocument( 88 | createActsIn(carrie, theMatrix, 1999, "Trinity")); 89 | } 90 | 91 | @Test 92 | public void testGraphQueries() { 93 | InterpreterResult res = interpreter.interpret("FOR x IN actsIn COLLECT actor = x._from WITH COUNT INTO counter FILTER counter >= 2 RETURN {actor: actor, movies: counter}", null); 94 | assertEquals(Code.SUCCESS, res.code()); 95 | 96 | res = interpreter.interpret("FOR x IN actsIn COLLECT movie = x._to WITH COUNT INTO counter FILTER counter == 1 RETURN movie", null); 97 | assertEquals(Code.SUCCESS, res.code()); 98 | 99 | res = interpreter.interpret("FOR x IN actsIn COLLECT movie = x._to WITH COUNT INTO counter RETURN {movie: movie, actors: counter}", null); 100 | assertEquals(Code.SUCCESS, res.code()); 101 | 102 | //res = interpreter.interpret("FOR x IN ANY 'movies/TheMatrix' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN x._id", null); 103 | res = interpreter.interpret("FOR x IN UNION_DISTINCT (" 104 | + "(FOR y IN ANY 'movies/TheMatrix' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN y._id), " 105 | + "(FOR y IN ANY 'movies/TheDevilsAdvocate' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN y._id)" 106 | + ") RETURN x", null); 107 | assertEquals(Code.SUCCESS, res.code()); 108 | 109 | res = interpreter.interpret("FOR x IN INTERSECTION (" 110 | + "(FOR y IN ANY 'movies/TheMatrix' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN y._id), " 111 | + "(FOR y IN ANY 'movies/TheDevilsAdvocate' actsIn OPTIONS {bfs: true, uniqueVertices: 'global'} RETURN y._id)) RETURN x", null); 112 | System.out.println(res.message()); 113 | assertEquals(Code.SUCCESS, res.code()); 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /src/test/java/io/millesabords/zeppelin/interpreter/arangodb/ArangoDbInterpreterTest.java: -------------------------------------------------------------------------------- 1 | package io.millesabords.zeppelin.interpreter.arangodb; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertTrue; 5 | 6 | import java.io.IOException; 7 | import java.util.Arrays; 8 | import java.util.Date; 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | import java.util.UUID; 12 | 13 | import org.apache.commons.lang.math.RandomUtils; 14 | import org.apache.zeppelin.interpreter.InterpreterResult; 15 | import org.apache.zeppelin.interpreter.InterpreterResult.Code; 16 | import org.junit.BeforeClass; 17 | import org.junit.Test; 18 | 19 | import com.arangodb.ArangoDBException; 20 | import com.arangodb.entity.BaseDocument; 21 | 22 | /** 23 | * Tests for basic queries. 24 | * 25 | * @author Bruno Bonnin 26 | * 27 | */ 28 | public class ArangoDbInterpreterTest extends AbstractArangoDbInterpreterTest { 29 | 30 | private static final String[] METHODS = { "GET", "PUT", "DELETE", "POST" }; 31 | private static final String[] STATUS = { "200", "404", "500", "403" }; 32 | private static final String DB_NAME = "monitoring"; 33 | private static final String COLL_NAME = "logs"; 34 | 35 | 36 | @BeforeClass 37 | public static void populate() throws ArangoDBException, IOException { 38 | init(DB_NAME); 39 | 40 | arango.db(DB_NAME).createCollection(COLL_NAME); 41 | 42 | for (Integer i = 0; i < 50; i++) { 43 | final BaseDocument log = new BaseDocument(); 44 | log.setKey(i.toString()); 45 | log.addAttribute("date", new Date()); 46 | log.addAttribute("status", STATUS[RandomUtils.nextInt(STATUS.length)]); 47 | log.addAttribute("content_length", RandomUtils.nextInt(2000)); 48 | 49 | final Map req = new HashMap<>(); 50 | req.put("method", METHODS[RandomUtils.nextInt(METHODS.length)]); 51 | req.put("url", "/zeppelin/" + UUID.randomUUID().toString()); 52 | req.put("headers", Arrays.asList("Accept: *.*", "Host: apache.org")); 53 | log.addAttribute("request", req); 54 | 55 | arango.db(DB_NAME).collection(COLL_NAME).insertDocument(log); 56 | } 57 | } 58 | 59 | @Test 60 | public void testBadQueries() { 61 | final InterpreterResult res = interpreter.interpret("nimportequoi", null); 62 | assertEquals(Code.ERROR, res.code()); 63 | } 64 | 65 | @Test 66 | public void testGoodQueries() { 67 | InterpreterResult res = interpreter.interpret("FOR l IN logs RETURN l", null); 68 | assertEquals(Code.SUCCESS, res.code()); 69 | 70 | res = interpreter.interpret("FOR l IN logs FILTER l.status == '200' RETURN l", null); 71 | assertEquals(Code.SUCCESS, res.code()); 72 | 73 | res = interpreter.interpret("FOR l IN logs FILTER l.status == '200' RETURN l.content_length", null); 74 | assertEquals(Code.SUCCESS, res.code()); 75 | 76 | res = interpreter.interpret("FOR l IN logs FILTER l.status == '404' RETURN { not_found_url : l.request.url }", null); 77 | assertEquals(Code.SUCCESS, res.code()); 78 | 79 | res = interpreter.interpret("FOR l IN logs FILTER l.status == '499' RETURN l", null); 80 | assertTrue(Code.SUCCESS.equals(res.code()) 81 | && res.message().size() == 1 82 | && "Empty result".equals(res.message().get(0).getData())); 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/test/java/io/millesabords/zeppelin/interpreter/arangodb/MockArangoServer.java: -------------------------------------------------------------------------------- 1 | package io.millesabords.zeppelin.interpreter.arangodb; 2 | 3 | import java.io.IOException; 4 | import java.io.OutputStream; 5 | import java.net.InetSocketAddress; 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | import com.sun.net.httpserver.HttpExchange; 10 | import com.sun.net.httpserver.HttpHandler; 11 | import com.sun.net.httpserver.HttpServer; 12 | 13 | /** 14 | * Simulates an ArangoDB server for test purpose. 15 | * 16 | * Default connection : http://127.0.0.1:8529 17 | * 18 | * @author Bruno Bonnin 19 | * 20 | */ 21 | @SuppressWarnings("restriction") 22 | public class MockArangoServer { 23 | 24 | private final HttpServer server; 25 | 26 | private final Map responses = new HashMap<>(); 27 | 28 | public MockArangoServer() throws IOException { 29 | this(8529); 30 | } 31 | 32 | public MockArangoServer(int port) throws IOException { 33 | server = HttpServer.create(new InetSocketAddress(port), 0); 34 | server.createContext("/", new HttpHandler() { 35 | @Override 36 | public void handle(HttpExchange exchange) throws IOException { 37 | final String req = exchange.getRequestMethod() + " " + exchange.getRequestURI(); 38 | final ArangoResponse response = responses.get(req); 39 | if (response != null) { 40 | exchange.sendResponseHeaders(response.status, 41 | response.body != null ? response.body.length() : 0); 42 | if (response.body != null) { 43 | final OutputStream out = exchange.getResponseBody(); 44 | out.write(response.body.getBytes()); 45 | out.close(); 46 | } 47 | } 48 | } 49 | }); 50 | server.setExecutor(null); 51 | } 52 | 53 | public void start() { 54 | server.start(); 55 | } 56 | 57 | public void stop() { 58 | server.stop(0); 59 | } 60 | 61 | public void addResponse(String request, int responseStatus, String responseBody) { 62 | responses.put(request, new ArangoResponse(responseStatus, responseBody)); 63 | } 64 | 65 | public void initResponses(String db, String coll) { 66 | addResponse("POST /_api/database", 201, "{\"result\":true,\"error\":false,\"code\":201}"); 67 | addResponse("DELETE /_api/database/" + db, 200, "{\"result\":true,\"error\":false,\"code\":200}"); 68 | addResponse("POST /_db/" + db + "/_api/collection", 200, "{\"id\":\"7984136251\",\"name\":\"" + coll + "\",\"waitForSync\":false,\"isVolatile\":false,\"isSystem\":false,\"status\":3,\"type\":2,\"error\":false,\"code\":200}"); 69 | addResponse("POST /_api/document?collection=" + coll, 202, "{\"error\":false,\"_id\":\"" + coll + "/1\",\"_rev\":\"1300562966\",\"_key\":\"1\"}"); 70 | // mockServer.addResponse("POST /_api/cursor", 201, "{\"result\":[{"b":47,"name":"Homer","_id":"firstCollection/5","_rev":"1302266902","_key":"5"},{"b":48,"name":"Homer","_id":"firstCollection/6","_rev":"1302463510","_key":"6"},{"b":45,"name":"Homer","_id":"firstCollection/3","_rev":"1301873686","_key":"3"},{"b":46,"name":"Homer","_id":"firstCollection/4","_rev":"1302070294","_key":"4"},{"b":43,"name":"Homer","_id":"firstCollection/1","_rev":"1301480470","_key":"1"},{"b":51,"name":"Homer","_id":"firstCollection/9","_rev":"1303053334","_key":"9"},{"b":44,"name":"Homer","_id":"firstCollection/2","_rev":"1301677078","_key":"2"},{"b":49,"name":"Homer","_id":"firstCollection/7","_rev":"1302660118","_key":"7"},{"b":42,"name":"Homer","_id":"firstCollection/0","_rev":"1301283862","_key":"0"},{"b":50,"name":"Homer","_id":"firstCollection/8","_rev":"1302856726","_key":"8"}],"hasMore":false,"count":10,"cached":false,"extra":{"stats":{"writesExecuted":0,"writesIgnored":0,"scannedFull":10,"scannedIndex":0,"filtered":0},"warnings":[]},"error":false,"code":201} 71 | 72 | } 73 | 74 | 75 | 76 | static class ArangoResponse { 77 | public int status; 78 | public String body; 79 | public ArangoResponse(int status, String body) { 80 | this.status = status; 81 | this.body = body; 82 | } 83 | } 84 | 85 | } 86 | --------------------------------------------------------------------------------