GithubHelp home page GithubHelp logo

calldanfeng / aql-java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from viirya/aql-java

0.0 2.0 0.0 1.72 MB

A platform independent version of the Aerospike AQL utility, with the added capability of code generation from Aerospike Query Language

GAP 11.79% ANTLR 6.56% Java 75.26% Lua 6.39%

aql-java's Introduction

#AQL implemented in Java Aerospike AQL is a utility that executes Aerospike Query Language. Like the other Aerospike utilities, it is Linux only. It is does not exercise Aerospikes advanced capabilities.

AQL2 is written in Java, so it will run anywhere where Java will run.] is a utility written in Java so it can run where ever Java can run. It will execute in one of following modes:

  1. Translate - translates the AQL to a runnable Java application with the correct Aerospike API calls
  2. Interactive - executes the AQL, using the Java API, as it is interpreted.
  3. Embedded into your application to use AQL as you interface to Aerospike.

All the classes that make up this utility are packaged into a JAR. This makes them available to any other application that wants to use them.

##How ANTLR 4 is used as the parser generator, and Java is the implementation language. (ANTLR can also generate parsers in C, C# and a many other languages) The grammar that generates the parser is AQL.g4. The generated parser uses a tree listener and implements actions based on the recognition events in the parse tree. There are 2 Tree listeners:

  • AQLExecutor - Executes the AQL statements on a live cluster.
  • AQLGenerator - Generates code (Java) based using ANTLR StringTemplates.

###Code generation code generation is achieved using StringTemplates. There is a StringTemplate for each target language, these are:

  • AS_Go.stg - for Go
  • AS_Java.stg - for Java
  • AS_C_Sharp.stg - for C#

The templates are located in the same directory as AQL.java at: src/main/java/com/aerospike/aql. The AQL class expects them to be there, so don't move them!

##Why Developers work on many platforms. Most developers are use SQL and AQL will be very familiar to them. A quick way to learn Aerospike and get a prototype up and running is to:

  1. Write an AQL script interact with Aerospike matching the use case.
  2. Use Portable AQL to test the AQL statements interactively
  3. Use Portable AQL to generate a runnable application in Java, C or C#
  4. Take the generated code and include it in the "real" application

##Build The code can be built with Maven.

	mvn clean package -DskipTests

##Dependencies

  • Aerospike Java client 3.1.00
  • Apache commons cli 1.2
  • Log4j 1.2.17
  • ANTLR 4.x

##Status

  1. Java generation - complete
  2. Go generation - partial
  3. C# generation - complete
  4. Execution - complete
  5. API calls - limited testing

Usage

The packaged Jar can be run with the following:

java -jar aql2-2.0.0-jar-full.jar -h localhost -p 3000 -c test/resources/PkTest.aql -o output/PkTest.java -l JAVA

Where:

-c,--compile <arg>    AQL file name to compile
-h,--host <arg>       Server hostname (default: localhost)
-l,--language <arg>   Target language, supported languages: Go and JAVA. Only valid with -c
	                      option
-n,--namespace <arg>  Namespace (default: test)
-o,--output <arg>     Output file name. Only valid with -c option
-p,--port <arg>       Server port (default: 3000)
-s,--set <arg>        Set name. Use 'empty' for empty set (default: demoset)
-u,--usage            Print usage.

aql-java's People

Contributors

helipilot50 avatar viirya avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.