<%--
/*
* 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.
*/
--%>

#import(java.util.UUID)

#import(com.datastax.oss.driver.api.core.uuid.Uuids)

<%@ val basicCommandsId: UUID = Uuids.random() %>
<%@ val schemaDiscoveryId: UUID = Uuids.random() %>
<%@ val queryParamsId: UUID = Uuids.random() %>
<%@ val formatParamsId: UUID = Uuids.random() %>
<%@ val preparedStatementsId: UUID = Uuids.random() %>
<%@ val dynamicFormsId: UUID = Uuids.random() %>
<%@ val configurationId: UUID = Uuids.random() %>
<%@ val sharedStatesId: UUID = Uuids.random() %>
<%@ val changelogId: UUID = Uuids.random() %>
<%@ val contactsId: UUID = Uuids.random() %>
<%@ val driverVersion: String %>

<br/>
<br/>
<nav class="navbar navbar-default">
    <ul class="nav navbar-nav">
        <li role="presentation" class="dropdown">
            <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                <span class="text-info"><span class="glyphicon glyphicon-book"></span>&nbsp;<strong>Please select ...</strong></span>
                <span class="text-info caret"></span>
                <ul class="dropdown-menu">
                    <li class="dropdown-header"><span class="text-info">Topics</span></li>
                    <li>
                        <a role="button" data-toggle="collapse" data-target="#${basicCommandsId}">
                            <span class="text-info"><span class="glyphicon glyphicon-bookmark"></span>&nbsp;&nbsp;Basic Commands</span>
                        </a>
                    </li>
                    <li>
                        <a role="button" data-toggle="collapse" data-target="#${schemaDiscoveryId}">
                            <span class="text-info"><span class="glyphicon glyphicon-bookmark"></span>&nbsp;&nbsp;Schema Discovery</span>
                        </a>
                    </li>
                    <li>
                        <a role="button" data-toggle="collapse" data-target="#${queryParamsId}">
                            <span class="text-info"><span class="glyphicon glyphicon-bookmark"></span>&nbsp;&nbsp;Query Parameters</span>
                        </a>
                    </li>
                    <li>
                        <a role="button" data-toggle="collapse" data-target="#${formatParamsId}">
                            <span class="text-info"><span class="glyphicon glyphicon-bookmark"></span>&nbsp;&nbsp;Formatting Parameters</span>
                        </a>
                    </li>
                    <li>
                        <a role="button" data-toggle="collapse" data-target="#${preparedStatementsId}">
                            <span class="text-info"><span class="glyphicon glyphicon-bookmark"></span>&nbsp;&nbsp;Prepared Statements</span>
                        </a>
                    </li>
                    <li>
                        <a role="button" data-toggle="collapse" data-target="#${dynamicFormsId}">
                            <span class="text-info"><span class="glyphicon glyphicon-bookmark"></span>&nbsp;&nbsp;Dynamic Forms</span>
                        </a>
                    </li>
                    <li>
                        <a role="button" data-toggle="collapse" data-target="#${configurationId}">
                            <span class="text-info"><span class="glyphicon glyphicon-bookmark"></span>&nbsp;&nbsp;Interpreter Configuration</span>
                        </a>
                    </li>                    
                    <li>
                        <a role="button" data-toggle="collapse" data-target="#${sharedStatesId}">
                            <span class="text-info"><span class="glyphicon glyphicon-bookmark"></span>&nbsp;&nbsp;Shared States</span>
                        </a>
                    </li>                    
                    <li>
                        <a role="button" data-toggle="collapse" data-target="#${changelogId}">
                            <span class="text-info"><span class="glyphicon glyphicon-bookmark"></span>&nbsp;&nbsp;Change Log</span>
                        </a>
                    </li>                     
                    <li>
                        <a role="button" data-toggle="collapse" data-target="#${contactsId}">
                            <span class="text-info"><span class="glyphicon glyphicon-bookmark"></span>&nbsp;&nbsp;Contacts &amp; Bugs</span>
                        </a>
                    </li>                      
                </ul>
            </a>
        </li>

        <li>
            <a><span class="text-info"><strong>CASSANDRA INTERPRETER DOCUMENTATION</strong></span></a>
        </li>
    </ul>
    <ul class="nav navbar-nav navbar-right">
        <li class="dropdown">
            <a class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
                <span class="text-info"><strong>About ...</strong></span>
                <span class="caret"></span>
            </a>
            <ul class="dropdown-menu">
                <li>
                    <a role="button">
                        <span class="text-info">Version <strong>4.0</strong></span>
                    </a>
                </li>
                <li>
                    <a role="button">
                        <span class="text-info">Java Driver Version <strong>${driverVersion}</strong></span>
                    </a>
                </li>
                <li>
                    <a role="button">
                        <span class="text-info">Author <strong>@doanduyhai, @alexott</strong></span>
                    </a>
                </li>
            </ul>
        </li>
        <li>
            <a href="#"></a>
        </li>    
</nav>
<br/><br/>
<div class="container">
    <div class="panel panel-default">
        <div class="panel-heading" role="tab">
            <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-target="#${basicCommandsId}" aria-expanded="false">
                    <span class="text-info"><strong>Basic Commands</strong></span>
                </a>
            </h4>
        </div>
        <div id="${basicCommandsId}" class="panel-collapse collapse" role="tabpanel">
            <div class="panel-body">

                <div class="panel panel-default">
                  <div class="panel-body">
                    <h3>I CQL Statements</h3>
                    <p>This interpreter is compatible with any CQL statement supported by Cassandra. Ex:
                        <br/><br/>
                        <div class="row">
                            <div class="col-md-6 col-md-offset-3">
                                <pre>
    INSERT INTO users(login,name) VALUES('jdoe','John DOE');
    SELECT * FROM users WHERE login='jdoe';</pre>
                            </div>
                        </div>
                        <br/>
                        Each statement should be separated by a <strong>semi-colon</strong> (;).
                        <br/>
                        <strong>Multi-line</strong> statements as well as multiple statements on the <strong>same line</strong>
                        are also supported as long as they are separated by a semi-colon. Ex:
                        <br/>
                        <br/>
                        <div class="row">
                            <div class="col-md-8 col-md-offset-2">
                                <pre>
    USE spark_demo;

    SELECT * FROM albums_by_country LIMIT 1; SELECT * FROM countries LIMIT 1;

    SELECT *
    FROM artists
    WHERE login='jlennon';</pre>
                            </div>
                        </div>
                        <br/>
                        <strong>Batch</strong> statements are supported and can span multiple lines, as well as
                        <strong>DDL</strong>(CREATE/ALTER/DROP) statements:
                        <br/>
                        <br/>
                        <div class="row">
                            <div class="col-md-8 col-md-offset-2">
                                <pre>
    BEGIN BATCH
        INSERT INTO users(login,name) VALUES('jdoe','John DOE');
        INSERT INTO users_preferences(login,account_type) VALUES('jdoe','BASIC');
    APPLY BATCH;

    CREATE TABLE IF NOT EXISTS test(
        key int PRIMARY KEY,
        value text
    );</pre>
                            </div>
                        </div>
                        <br/>
                        CQL statements are <strong>case-insensitive</strong> (except for column names and values).
                        This means that the following statements are equivalent and valid:
                        <br/>
                        <br/>
                        <div class="row">
                            <div class="col-md-8 col-md-offset-2">
                                <pre>
    INSERT INTO users(login,name) VALUES('jdoe','John DOE');
    Insert into users(login,name) vAlues('hsue','Helen SUE');</pre>
                            </div>
                        </div>
                        <br/>
                        The complete list of all CQL statements and versions can be found below:
                        <br/><br/>
                        <div class="row">
                            <div class="col-md-6 col-md-offset-3">
                               <table class="table table-bordered">
                                    <thead>
                                        <tr>
                                          <th style="text-align:left" width="20%">Cassandra version</th>
                                          <th style="text-align:left">Documentation</th></tr>
                                    </thead>
                                    <tbody>
                                    <tr>
                                        <td style="text-align:left"><strong>3.x</strong></td>
                                        <td style="text-align:left">
                                            <a href="http://docs.datastax.com/en/cql/3.3/cql/cqlIntro.html" target="_blank" rel="noopener noreferrer">
                                            http://docs.datastax.com/en/cql/3.3/cql/cqlIntro.html
                                            </a>
                                        </td>
                                    </tr>
                                        <tr>
                                            <td style="text-align:left"><strong>2.2</strong></td>
                                            <td style="text-align:left">
                                                <a href="http://docs.datastax.com/en/cql/3.3/cql/cqlIntro.html" target="_blank" rel="noopener noreferrer">
                                                    http://docs.datastax.com/en/cql/3.3/cql/cqlIntro.html
                                                </a>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="text-align:left"><strong>2.1</strong></td>
                                            <td style="text-align:left">
                                                <a href="http://docs.datastax.com/en/cql/3.1/cql/cql_intro_c.html" target="_blank" rel="noopener noreferrer">
                                                    http://docs.datastax.com/en/cql/3.1/cql/cql_intro_c.html
                                                </a>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>


                    </p>
                    <h3>II Comments</h3>
                    <p>
                        It is possible to add comments between statements. Single line comments start with the
                        <strong>hash</strong> sign (<code>#</code>), <strong>double minus</strong> (<code>--</code>), or <strong>double slashes</strong> (<code>//</code>). Multi-line comments are enclosed between
                        <strong>&sol;&ast;&ast;</strong> and <strong>&ast;&ast;&sol;</strong>. Ex:

                        <br/>
                        <br/>
                        <div class="row">
                            <div class="col-md-8 col-md-offset-2">
                                <pre>
    # Single line comment style 1
    INSERT INTO users(login,name) VALUES('jdoe','John DOE');

    -- Single line comment style 2

    // Single line comment style 3

    /**
     Multi line
     comments
     **/
    Insert into users(login,name) vAlues('hsue','Helen SUE');</pre>
                            </div>
                        </div>
                        <br/>

                    </p>
                    <h3>III Syntax Validation</h3>
                    <p>
                        The interpreters is shipped with a <em>built-in syntax validator</em>. This validator only
                        checks for <strong>basic syntax errors</strong>. All CQL-related syntax validation is delegated
                        directly to <strong>Cassandra</strong>
                        <br/><br/>
                        Most of the time, syntax errors are due to missing semi-colons between statements or typo errors.

                    </p>

                  </div>
                </div>



            </div>
        </div>
    </div>    
    <div class="panel panel-default">
        <div class="panel-heading" role="tab">
            <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-target="#${schemaDiscoveryId}" aria-expanded="false">
                    <span class="text-info"><strong>Schema Discovery</strong></span>
                </a>
            </h4>
        </div>
        <div id="${schemaDiscoveryId}" class="panel-collapse collapse" role="tabpanel">
            <div class="panel-body">

                <div class="panel panel-default">
                  <div class="panel-body">
                    <h3>I Commands For Discovery</h3>
                    <p>
                        To make schema discovery easier and more interactive, the following commands are supported:
                        <br/><br/>
                        <table class="table table-bordered">
                            <thead>
                                <tr>
                                  <th style="text-align:left" width="40%">Command</th>
                                  <th style="text-align:left">Description</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td style="text-align:left"><strong>DESCRIBE CLUSTER;</strong></td>
                                    <td style="text-align:left">Show the current cluster name and its partitioner</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left"><strong>DESCRIBE KEYSPACES;</strong></td>
                                    <td style="text-align:left">List all existing keyspaces in the cluster and their configuration
                                    (replication factor, durable write ...)</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left"><strong>DESCRIBE TABLES;</strong></td>
                                    <td style="text-align:left">List all existing keyspaces in the cluster and for each, all the tables name</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left"><strong>DESCRIBE TYPES;</strong></td>
                                    <td style="text-align:left">List all existing keyspaces in the cluster and for each, all the types name</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left"><strong>DESCRIBE FUNCTIONS;</strong></td>
                                    <td style="text-align:left">List all existing keyspaces in the cluster and for each, all the functions name and arguments</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left"><strong>DESCRIBE AGGREGATES;</strong></td>
                                    <td style="text-align:left">List all existing keyspaces in the cluster and for each, all the aggregates name and arguments</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left"><strong>DESCRIBE MATERIALIZED VIEWS;</strong></td>
                                    <td style="text-align:left">List all existing keyspaces in the cluster and for each, all the materialized view name</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left"><strong>DESCRIBE KEYSPACE &lt;keyspace name&gt;;</strong></td>
                                    <td style="text-align:left">Describe the given keyspace configuration and all its table details (name, columns, ...)</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left"><strong>DESCRIBE TABLE <em>(&lt;keyspace name&gt;).</em>&lt;table name&gt;;</strong></td>
                                    <td style="text-align:left">
                                        Describe the given table. If the keyspace is not provided, the current
                                        <strong>logged in</strong> keyspace is used. If there is no logged in keyspace,
                                        the default <em>system</em> keyspace is used. If no table is found, an error message is raised
                                    </td>
                                </tr>
                                <tr>
                                    <td style="text-align:left"><strong>DESCRIBE TYPE <em>(&lt;keyspace name&gt;).</em>&lt;type name&gt;;</strong></td>
                                    <td style="text-align:left">
                                        Describe the given type(UDT). If the keyspace is not provided, the current
                                        <strong>logged in</strong> keyspace is used. If there is no logged in keyspace,
                                        the default <em>system</em> keyspace is used. If no type is found, an error message is raised
                                    </td>
                                </tr>
                                <tr>
                                    <td style="text-align:left"><strong>DESCRIBE FUNCTION <em>(&lt;keyspace name&gt;).</em>&lt;function name&gt;;</strong></td>
                                    <td style="text-align:left">
                                        Describe the given function. If the keyspace is not provided, the current
                                        <strong>logged in</strong> keyspace is used. If there is no logged in keyspace,
                                        the default <em>system</em> keyspace is used. If no function is found, an error message is raised
                                    </td>
                                </tr>
                                <tr>
                                    <td style="text-align:left"><strong>DESCRIBE AGGREGATE <em>(&lt;keyspace name&gt;).</em>&lt;aggregate name&gt;;</strong></td>
                                    <td style="text-align:left">
                                        Describe the given aggregate. If the keyspace is not provided, the current
                                        <strong>logged in</strong> keyspace is used. If there is no logged in keyspace,
                                        the default <em>system</em> keyspace is used. If no aggregate is found, an error message is raised
                                    </td>
                                </tr>        
                                <tr>
                                    <td style="text-align:left"><strong>DESCRIBE MATERIALIZED VIEW <em>(&lt;keyspace name&gt;).</em>&lt;view name&gt;;</strong></td>
                                    <td style="text-align:left">
                                        Describe the given materialized view. If the keyspace is not provided, the current
                                        <strong>logged in</strong> keyspace is used. If there is no logged in keyspace,
                                        the default <em>system</em> keyspace is used. If no materialized view is found, an error message is raised
                                    </td>
                                </tr>                                                                                          
                            </tbody>
                        </table>
                        <br/>
                        <div class="alert alert-danger" role="alert">
                            Please note that each <strong>DESCRIBE</strong> command should be ended by <strong>a semi-colon</strong>.
                        </div>
                    </p>
                    <h3>II Schema Display</h3>
                    <p>
                        The schema objects (cluster, keyspace, table, type, view, function &amp; aggregate) are displayed in a tabular format. There is a <strong>drop-down</strong> menu on the top left corner to expand objects details. On the top right menu is shown the Icon legend.

                    </p>
                  </div>
                </div>

            </div>
        </div>
    </div>    
    <div class="panel panel-default">
        <div class="panel-heading" role="tab">
            <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-target="#${queryParamsId}" aria-expanded="false">
                    <span class="text-info"><strong>Query Parameters</strong></span>
                </a>
            </h4>
        </div>
        <div id="${queryParamsId}" class="panel-collapse collapse" role="tabpanel">
            <div class="panel-body">

                <div class="panel panel-default">
                  <div class="panel-body">
                    <p>
                        Sometimes you want to be able to pass runtime query parameters to your statements.
                        Those parameters are <strong>not</strong> part of the CQL specs and are specific to the interpreter.
                        Below is the list of all parameters:

                        <br/><br/>
                        <table class="table table-bordered">
                            <caption>
                                <h4>Query Parameters</h4>
                            </caption>
                            <thead>
                                <tr>
                                    <th style="text-align:left" width="20%">Parameter</th>
                                    <th style="text-align:left" width="20%">Syntax</th>
                                    <th style="text-align:left">Description</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td style="text-align:left">Consistency Level</td>
                                    <td style="text-align:left"><strong>@consistency=<em>value</em></strong></td>
                                    <td style="text-align:left">Apply the given consistency level to all queries in the paragraph</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left">Serial Consistency Level</td>
                                    <td style="text-align:left"><strong>@serialConsistency=<em>value</em></strong></td>
                                    <td style="text-align:left">Apply the given serial consistency level to all queries in the paragraph</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left">Timestamp</td>
                                    <td style="text-align:left"><strong>@timestamp=<em>long value</em></strong></td>
                                    <td style="text-align:left">Apply the given timestamp to all queries in the paragraph.<br/>
                                        Please note that timestamp value passed directly in CQL statement will override this value
                                    </td>
                                </tr>
                                <tr>
                                    <td style="text-align:left">Fetch Size</td>
                                    <td style="text-align:left"><strong>@fetchSize=<em>int value</em></strong></td>
                                    <td style="text-align:left">Apply the given fetch size to all queries in the paragraph</td>
                                </tr>
                                    <tr>
                                        <td style="text-align:left">Request Timeout</td>
                                        <td style="text-align:left"><strong>@requestTimeOut=<em>int value</em></strong></td>
                                        <td style="text-align:left">Apply the given request timeout <strong>in millisecs</strong> to all queries in the paragraph</td>
                                    </tr>
                            </tbody>
                        </table>
                        <br/>
                        Some parameters only accept restricted values:

                        <br/><br/>
                        <table class="table table-bordered">
                            <caption>
                                <h4>Allowed Values</h4>
                            </caption>
                            <thead>
                                <tr>
                                    <th style="text-align:left" width="30%">Parameter</th>
                                    <th style="text-align:left">Possible Values</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td style="text-align:left">Consistency Level</td>
                                    <td style="text-align:left"><strong>ALL, ANY, ONE, TWO, THREE, QUORUM, LOCAL_ONE, LOCAL_QUORUM, EACH_QUORUM</strong></td>
                                </tr>
                                <tr>
                                    <td style="text-align:left">Serial Consistency Level</td>
                                    <td style="text-align:left"><strong>SERIAL, LOCAL_SERIAL</strong></td>
                                </tr>
                                <tr>
                                    <td style="text-align:left">Timestamp</td>
                                    <td style="text-align:left">Any long value</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left">Fetch Size</td>
                                    <td style="text-align:left">Any integer value</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left">Request Timeout</td>
                                    <td style="text-align:left">Any integer value</td>
                                </tr>
                            </tbody>
                        </table>
                        <br/>

                        <div class="alert alert-danger" role="alert">
                            Please note that you <strong>should not add semi-colon (;)</strong> at the end of each parameter statement
                        </div>

                        Some examples:
                        <br/><br/>
                        <div class="row">
                            <div class="col-md-8 col-md-offset-2">
                                <pre>
    CREATE TABLE IF NOT EXISTS spark_demo.ts(
        key int PRIMARY KEY,
        value text
    );
    TRUNCATE spark_demo.ts;

    // Timestamp in the past
    @timestamp=10

    // Force timestamp directly in the first insert
    INSERT INTO spark_demo.ts(key,value) VALUES(1,'first insert') USING TIMESTAMP 100;

    // Select some data to make the clock turn
    SELECT * FROM spark_demo.albums LIMIT 100;

    // Now insert using the timestamp parameter set at the beginning(10)
    INSERT INTO spark_demo.ts(key,value) VALUES(1,'second insert');

    // Check for the result. You should see 'first insert'
    SELECT value FROM spark_demo.ts WHERE key=1;</pre>
                            </div>
                        </div>
                        <br/>

                        Some remarks about query parameters:
                        <br/><br/>
                        <div class="alert alert-info" role="alert">
                            <ul>
                                <li><strong>many</strong> query parameters can be set in the same paragraph</li>
                                <li>if the <strong>same</strong> query parameter is set many time with different values,
                                    the interpreter only take into account the first value
                                </li>
                                <li>each query parameter applies to <strong>all</strong> CQL statement in the same paragraph,
                                    unless you override the option using plain CQL text (like forcing timestamp with the USING clause)
                                </li>
                                <li>the order of each query parameter with regard to CQL statement does not matter</li>
                            </ul>
                        </div>
                    </p>
                    </div>
                </div>


            </div>
        </div>
    </div>        
    
    <div class="panel panel-default">
        <div class="panel-heading" role="tab">
            <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-target="#${formatParamsId}" aria-expanded="false">
                    <span class="text-info"><strong>Formatting Parameters</strong></span>
                </a>
            </h4>
        </div>
        <div id="${formatParamsId}" class="panel-collapse collapse" role="tabpanel">
            <div class="panel-body">

                <div class="panel panel-default">
                  <div class="panel-body">
                    <p>
                        Sometimes you want to be able to adjust formatting of results just
                        for single paragraph. You can do this by passing one or more
                        following parameters in the <tt>%cassandra</tt> interpreter local
                        properties:

                        <br/><br/>
                        <table class="table table-bordered">
                            <caption>
                                <h4>Formatting Parameters</h4>
                            </caption>
                            <thead>
                                <tr>
                                    <th style="text-align:left" width="20%">Parameter</th>
                                    <th style="text-align:left" width="20%">Syntax</th>
                                    <th style="text-align:left">Description</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr>
                                    <td style="text-align:left">Output Format</td>
                                    <td style="text-align:left"><strong>outputFormat=<em>cql|human</em></strong></td>
                                    <td style="text-align:left">Selects formatting of the results - as CQL
                                    literals, or human-readable (default)</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left">Locale</td>
                                    <td style="text-align:left"><strong>locale=<em>value</em></strong></td>
                                    <td style="text-align:left">Name of the locale for formatting of results.
                                    Should be a locale name supported by JVM.</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left">Timezone</td>
                                    <td style="text-align:left"><strong>timezone=<em>value</em></strong></td>
                                    <td style="text-align:left">Timezone string for formatting of values of
                                    time/date/timestamp type.  Should be a timezone
                                    supported by JVM.</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left">Timestamp Format</td>
                                    <td style="text-align:left"><strong>timestampFormat=<em>string</em></strong></td>
                                    <td style="text-align:left">Format string
                                    for <a href="https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html">DateTimeFormatter</>
                                    that will be used for formatting of the values
                                    of <tt>timestamp</tt> type</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left">Time Format</td>
                                    <td style="text-align:left"><strong>timeFormat=<em>string</em></strong></td>
                                    <td style="text-align:left">Format string
                                    for <a href="https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html">DateTimeFormatter</>
                                    that will be used for formatting of the values
                                    of <tt>time</tt> type</td>
                                </tr>
                                <tr>
                                    <td style="text-align:left">Date Format</td>
                                    <td style="text-align:left"><strong>dateFormat=<em>string</em></strong></td>
                                    <td style="text-align:left">Format string
                                    for <a href="https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html">DateTimeFormatter</>
                                    that will be used for formatting of the values
                                    of <tt>date</tt> type</td>
                                </tr>
                                <tr>
                                  <td style="text-align:left">Float Precision</td>
                                  <td style="text-align:left"><strong>floatPrecision=<em>int value</em></strong></td>
                                  <td style="text-align:left">Precision when output values of <tt>float</tt> type</td>
                                </tr>
                                <tr>
                                  <td style="text-align:left">Double Precision</td>
                                  <td style="text-align:left"><strong>doublePrecision=<em>int value</em></strong></td>
                                  <td style="text-align:left">Precision when output values of <tt>double</tt> type</td>
                                </tr>
                            </tbody>
                        </table>
<br/><br/><b>Note</b>: if you need to apply the same output for all paragraphs, you can set
corresponding settings on the interpreter level!
<br/><br/>

                        Some examples:
                        <br/><br/>
                        <div class="row">
                              <pre>
%cassandra(locale=de_DE, floatPrecision=2, doublePrecision=4, timeFormat=hh:mma, timestampFormat=MM/dd/yy HH:mm, dateFormat="E, d MMM yy", timezone=Etc/GMT+2)
select date, time, timestamp, double, float, tuple, udt from zep.test_format;
                                
%cassandra(outputFormat=cql)
select id, double, float, text, date, time, timestamp from zep.test_format;</pre>
                        </div>
                    </p>
                    </div>
                </div>


            </div>
        </div>
    </div>        
    
    <div class="panel panel-default">
        <div class="panel-heading" role="tab">
            <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-target="#${preparedStatementsId}" aria-expanded="false">
                    <span class="text-info"><strong>Prepared Statements</strong></span>
                </a>
            </h4>
        </div>
        <div id="${preparedStatementsId}" class="panel-collapse collapse" role="tabpanel">
            <div class="panel-body">
                <div class="panel panel-default">
                  <div class="panel-body">
                    <h3>I Syntax</h3>
                    <br/>
                    <p>
                        For performance reason, it is better to <strong>prepare statements</strong> before-hand and reuse
                        them later by providing bound values. This interpreter provides 3 commands to handle prepared and
                        bound statements:
                        <br/><br/>
                        <ol>
                            <li><strong>@prepare</strong></li>
                            <li><strong>@bind</strong></li>
                            <li><strong>@remove_prepared</strong></li>
                        </ol>
                        <br/>
                        Example:
                        <br/>
                        <div class="row">
                            <div class="col-md-10 col-md-offset-1">
                                <pre>
    @prepare[statement-name]=...

    @bind[statement-name]=’text’, 1223, ’2015-07-30 12:00:01’, null, true, [‘list_item1’, ’list_item2’]

    @bind[statement-name-with-no-bound-value]

    @remove_prepare[statement-name]</pre>
                            </div>
                        </div>
                        <br/>

                    <h3>II @prepare</h3>
                    <br/>
                    <p>
                        You can use the syntax "<strong>@prepare[statement-name]=SELECT ...</strong>" to create a prepared statement.
                        The <em>statement-name</em> is mandatory because the interpreter prepares the given statement with the
                        Java driver and saves the generated prepared statement in an internal map, using the provided
                        <em>statement-name</em> as search key.
                        <br/><br/>
                        <div class="alert alert-info">
                            Please note that this internal prepared statement map is shared with <strong>all notebooks</strong>
                            and <strong>all paragraphs</strong> because there is only one instance of the interpreter for Cassandra
                        </div>
                        <br/>
                        <div class="alert alert-warning">
                            If the interpreter encounters many @prepare for the <strong>same statement-name</strong> (key),
                            only the <strong>first</strong> statement will be taken into account.
                        </div>
                        <br/>
                        Example:
                        <br/>
                        <div class="row">
                            <div class="col-md-10 col-md-offset-1">
                                <pre>
    @prepare[select]=SELECT * FROM spark_demo.albums LIMIT ?

    @prepare[select]=SELECT * FROM spark_demo.artists LIMIT ?</pre>
                            </div>
                        </div>
                        <br/>

                        For the above example, the prepared statement is <strong>"SELECT * FROM spark_demo.albums LIMIT ?"</strong>.
                        <strong>"SELECT * FROM spark_demo.artists LIMIT ?"</strong> is ignored because an entry already exists in the
                        prepared statements map with the key <strong>select</strong>.
                        <br/><br/>
                        In the context of Zeppelin, a notebook can be scheduled to be executed at regular interval,
                        thus it is necessary to avoid re-preparing many time the same statement (considered an anti-pattern).
                    </p>
                    <h3>III @bind</h3>
                    <br/>
                    <p>
                        Once the statement is prepared (possibly in a separated notebook/paragraph). You can bind values to it:
                        <br/><br/>
                        <div class="row">
                            <div class="col-md-10 col-md-offset-1">
                                <pre>
    @bind[select_first]=10</pre>
                            </div>
                        </div>
                        <br/>
                        Bound values are not mandatory for the <strong>@bind</strong> statement.
                        However if you provide bound values, they need to comply to some syntax:

                        <ul>
                            <li>String values should be enclosed between simple quotes ( ‘ )</li>
                            <li>Date values should be enclosed between simple quotes ( ‘ ) and respect the formats:
                                <ol>
                                    <li>yyyy-MM-dd HH:MM:ss</li>
                                    <li>yyyy-MM-dd HH:MM:ss.SSS</li>
                                </ol>
                            </li>
                            <li><strong>null</strong> is parsed as-is</li>
                            <li><strong>boolean</strong> (true|false) are parsed as-is </li>
                            <li>collection values must follow the
                                <a href="http://docs.datastax.com/en/cql/3.1/cql/cql_using/use_collections_c.html" target="_blank" rel="noopener noreferrer">standard CQL syntax</a>:
                                <ul>
                                    <li>list:  [‘list_item1’, ’list_item2’, ...]</li>
                                    <li>set: {‘set_item1’, ‘set_item2’, …}</li>
                                    <li>map: {‘key1’: ‘val1’, ‘key2’: ‘val2’, …}</li>
                                </ul>
                            </li>
                            <li>
                                tuple values should be enclosed between parenthesis
                                (see <a href="http://docs.datastax.com/en/cql/3.1/cql/cql_reference/tupleType.html" target="_blank" rel="noopener noreferrer">tuple CQL syntax</a>):
                                (‘text’, 123, true)
                            </li>
                            <li>
                                udt values should be enclosed between brackets
                                (see <a href="http://docs.datastax.com/en/cql/3.1/cql/cql_using/cqlUseUDT.html" target="_blank" rel="noopener noreferrer">udt CQL syntax</a>):
                                {stree_name: ‘Beverly Hills’,  number: 104, zip_code: 90020, state: ‘California’, …}
                            </li>
                        </ul>
                        <br/>
                        <div class="alert alert-info">
                            It is possible to use the <strong>@bind</strong> statement inside a batch: <br/>
                            <pre>
    BEGIN BATCH
        @bind[insert_user]='jdoe','John DOE'
        UPDATE users SET age = 27 WHERE login='hsue';
    APPLY BATCH;</pre>
                        </div>
                        <br/>
                    </p>
                    <h3>IV @remove_prepare</h3>
                    <br/>
                    <p>
                        To avoid for a prepared statement to stay forever in the prepared statement map, you can use the <strong>@remove_prepare[statement-name]</strong> syntax
                        to remove it. Removing a non-existing prepared statement yields no error.
                    </p>
                    </div>
                </div>
            </div>
        </div>
    </div>  
    
    <div class="panel panel-default">
        <div class="panel-heading" role="tab">
            <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-target="#${dynamicFormsId}" aria-expanded="false">
                    <span class="text-info"><strong>Dynamic Forms</strong></span>
                </a>
            </h4>
        </div>
        <div id="${dynamicFormsId}" class="panel-collapse collapse" role="tabpanel">
            <div class="panel-body">

                <div class="panel panel-default">
                  <div class="panel-body">
                    <p>
                        Instead of hard-coding your CQL queries, it is possible to use <strong>
                        <a href="http://zeppelin.apache.org/docs/0.6.0-SNAPSHOT/manual/dynamicform.html" target="_blank" rel="noopener noreferrer">Zeppelin dynamic form</a>
                        </strong> syntax to inject simple value or multiple choices forms.

                        The legacy mustache syntax (  <strong>{{ }}</strong> ) to bind input text and select form is still supported but is deprecated and will be removed in future releases.

                        <br/><br/>

                        <h6> -- Legacy syntax -- </h6>
                        The syntax for simple parameter is: <strong>{{input_Label=default value}}</strong>.
                        The default value is mandatory because the first time the paragraph is executed,
                        we launch the CQL query before rendering the form so at least one value should be provided.
                        <br/><br/>
                        The syntax for multiple choices parameter is: <strong>{{input_Label=value1 | value2 | … | valueN }}</strong>.
                        By default the first choice is used for CQL query the first time the paragraph is executed.
                        <h6> -- End legacy syntax -- </h6>
                        <br/><br/>
                        Example:
                        <br/>
                        <div class="row">
                            <div class="col-md-10 col-md-offset-1">
                                <pre>
    #Secondary index on performer style
    SELECT name, country, performer
    FROM spark_demo.performers
    WHERE name='\${performer=Sheryl Crow|Doof|Fanfarlo|Los Paranoia}'
    AND styles CONTAINS '\${style=Rock}';</pre>
                            </div>
                        </div>
                        <br/>

                        In the above example, the first CQL query will be executed for <em>performer='Sheryl Crow'</em>
                        AND <em>style='Rock'</em>. For subsequent queries, you can change the value directly using the form.
                        Please note that we enclosed the {{ }} block between simple quotes (') because Cassandra expects a String here.
                        We could have also use the <strong>\${style='Rock'}</strong> syntax but this time, the value
                        displayed on the form is <em>'Rock'</em> and not <em>Rock</em>.

                        <br/><br/>
                        <div class="alert alert-info">
                            It is also possible to use dynamic forms for <strong>prepared statements</strong>: <br/>
                            <strong>@bind[select]=='\${performer=Sheryl Crow|Doof|Fanfarlo|Los Paranoia}', '\${style=Rock}'</strong>
                        </div>
                       </pre>
                    </p>
                    </div>
                </div>

            </div>
        </div>
    </div>  
    
    <div class="panel panel-default">
        <div class="panel-heading" role="tab">
            <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-target="#${configurationId}" aria-expanded="false">
                    <span class="text-info"><strong>Interpreter Configuration</strong></span>
                </a>
            </h4>
        </div>
        <div id="${configurationId}" class="panel-collapse collapse" role="tabpanel">
            <div class="panel-body">
                The <strong>Cassandra</strong> interpreter comes with some some configuration values for the Java driver:

                 <table class="table table-bordered">
                    <caption>
                        <h4>Interpreter Configuration</h4>
                    </caption>
                     <thead>
                        <tr>
                            <th style="text-align:left">Parameter</th>
                            <th style="text-align:left">Default Value</th>
                        </tr>
                     </thead>
                     <tbody>
                        <tr>
                            <td style="text-align:left">cassandra.cluster</td>
                            <td style="text-align:left"><strong>Test Cluster</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.compression.protocol</td>
                            <td style="text-align:left"><strong>NONE</strong>, possible values: LZ4, SNAPPY</td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.credentials.password</td>
                            <td style="text-align:left"><strong>none</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.credentials.username</td>
                            <td style="text-align:left"><strong>none</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.hosts</td>
                            <td style="text-align:left"><strong>localhost</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.interpreter.parallelism</td>
                            <td style="text-align:left"><strong>10</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.keyspace</td>
                            <td style="text-align:left"><strong>system</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.load.balancing.policy</td>
                            <td style="text-align:left"><strong>DEFAULT</strong>, or a FQCN of a custom class</td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.max.schema.agreement.wait.second</td>
                            <td style="text-align:left"><strong>10</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.native.port</td>
                            <td style="text-align:left"><strong>9042</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.pooling.core.connection.per.host.local</td>
                            <td style="text-align:left"><strong>V3 and above: 1</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.pooling.core.connection.per.host.remote</td>
                            <td style="text-align:left"><strong>V3 and above: 1</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.pooling.heartbeat.interval.seconds</td>
                            <td style="text-align:left"><strong>30</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.pooling.idle.timeout.seconds</td>
                            <td style="text-align:left"><strong>Test Cluster</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.pooling.max.connection.per.host.local</td>
                            <td style="text-align:left"><strong>V3 and above: 1</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.pooling.max.connection.per.host.remote</td>
                            <td style="text-align:left"><strong>V3 and above: 1</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.pooling.max.request.per.connection.local</td>
                            <td style="text-align:left"><strong>V3 and above: 1024</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.pooling.max.request.per.connection.remote</td>
                            <td style="text-align:left"><strong>V3 and above: 256</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.pooling.new.connection.threshold.local</td>
                            <td style="text-align:left"><strong>V3 and above: 800</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.pooling.new.connection.threshold.remote</td>
                            <td style="text-align:left"><strong>V3 and above: 200</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.pooling.pool.timeout.millisecs</td>
                            <td style="text-align:left"><strong>5000</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.protocol.version</td>
                            <td style="text-align:left"><strong>4</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.query.default.consistency</td>
                            <td style="text-align:left"><strong>ONE</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.query.default.fetchSize</td>
                            <td style="text-align:left"><strong>5000</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.query.default.serial.consistency</td>
                            <td style="text-align:left"><strong>SERIAL</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.reconnection.policy</td>
                            <td style="text-align:left"><strong>DEFAULT</strong>, or a FQCN of a custom class</td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.retry.policy</td>
                            <td style="text-align:left"><strong>DEFAULT</strong>, or a FQCN of a custom class</td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.socket.connection.timeout.millisecs</td>
                            <td style="text-align:left"><strong>500</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.socket.read.timeout.millisecs</td>
                            <td style="text-align:left"><strong>12000</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.socket.tcp.no_delay</td>
                            <td style="text-align:left"><strong>true</strong></td>
                        </tr>
                        <tr>
                            <td style="text-align:left">cassandra.speculative.execution.policy</td>
                            <td style="text-align:left"><strong>DEFAULT</strong>, or a FQCN of a custom class</td>
                        </tr>
                     </tbody>
                 </table>
            </div>
        </div>
    </div>    

    <div class="panel panel-default">
        <div class="panel-heading" role="tab">
            <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-target="#${sharedStatesId}" aria-expanded="false">
                    <span class="text-info"><strong>Shared states</strong></span>
                </a>
            </h4>
        </div>
        <div id="${sharedStatesId}" class="panel-collapse collapse" role="tabpanel">
            <div class="panel-body">
               It is possible to execute many paragraphs in parallel. However, at the back-end side, we’re still using synchronous queries. <em>Asynchronous execution</em> is only possible when it is possible to return a <strong>Future</strong> value in the <strong>InterpreterResult</strong>. It may be an interesting proposal for the <strong>Zeppelin</strong> project.
               <br/><br/>
               Recently, <strong>Zeppelin</strong> allows you to choose the level of isolation for your interpreters (see
               <strong><a href="http://zeppelin.apache.org/docs/0.6.0-SNAPSHOT/manual/interpreters.html" target="_blank" rel="noopener noreferrer">Interpreter Binding Mode</a></strong> ).
               <br/><br/>
               Long story short, you have 3 available bindings:

               <ul>
                   <li><strong>shared</strong> : <em>same JVM</em> and <em>same Interpreter instance</em> for all notes</li>
                   <li><strong>scoped</strong> : <em>same JVM</em> but <em>different Interpreter instances</em>, one for each note</li>
                   <li><strong>isolated</strong> : <em>different JVM</em> running a <em>single Interpreter instance</em>, one JVM for each note</li>
               </ul>

               <br/>
               Using the <strong>shared</strong> binding, the same <code>com.datastax.driver.core.Session</code> object is used for all notes and paragraphs.
               Consequently, if you use the <strong>USE keyspace name;</strong> statement to log into a keyspace,
               it will change the keyspace for all current users of the Cassandra interpreter because we only create 1
               <code>com.datastax.driver.core.Session</code> object per instance of Cassandra interpreter.

               <br/><br/>
               The same remark does apply to the <strong>prepared statement hash map</strong>, it is shared by all users using the same instance of Cassandra interpreter.
               <br/><br/>
               When using <strong>scoped</strong> binding, in the <em>same JVM</em> <strong>Zeppelin</strong> will create multiple instances of the Cassandra interpreter,
               thus multiple <code>com.datastax.driver.core.Session</code> objects.
               <strong>Beware of resource and memory usage using this binding !</strong>
               <br/><br/>
               The <strong>isolated</strong> mode is the most extreme and will create as many JVM/<code>com.datastax.driver.core.Session</code> object as there are distinct notes.


               </div>
        </div>
    </div>
        
    <div class="panel panel-default">
        <div class="panel-heading" role="tab">
            <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-target="#${changelogId}" aria-expanded="false">
                    <span class="text-info"><strong>Change Log</strong></span>
                </a>
            </h4>
        </div>        
        <div id="${changelogId}" class="panel-collapse collapse" role="tabpanel">
            <div class="panel-body">
                <strong>4.0</strong>&nbsp;:
                <br/>
                <ul>
                    <li>Migrate to DataStax Java driver 4.x that supports both Cassandra and DSE.  This contains breaking changes, like, deprecation of <code>@retryPolicy</code>, dropped support for Cassandra 1.2/2.0</li>
                    <li>Fix schema disagreement that could arise when executing multiple DDL statements</li>
                    <li>Added support for <code>--</code> comment style</li>
                    <li>Added options for formatting of output (interpreter and cell level)</li>
                </ul>
                <strong>3.0</strong>&nbsp;:
                <br/>
                <ul>
                    <li>Update documentation</li>
                    <li>Update interactive documentation</li>
                    <li>Add support for binary protocol <strong>V4</strong></li>
                    <li>Implement new <code>@requestTimeOut</code> runtime option</li>
                    <li>Upgrade Java driver version to <strong>3.0.1</strong></li>
                    <li>Allow interpreter to add dynamic forms programmatically when using FormType.SIMPLE</li>
                    <li>Allow dynamic form using default Zeppelin syntax</li>
                    <li>Fixing typo on FallThroughPolicy</li>
                    <li>Look for data in AngularObjectRegistry before creating dynamic form</li>
                    <li>Add missing support for <code>ALTER</code> statements</li>
                </ul>
                <strong>2.0</strong>&nbsp;: 
                <br/>
                <ul>
                    <li>Update help menu and add changelog</li>
                    <li>Add Support for User Defined Functions, User Defined Aggregates and Materialized Views</li>
                    <li>Upgrade Java driver version to <strong>3.0.0-rc1</strong></li>
                </ul>
                <strong>1.0</strong>&nbsp;: 
                <br/>
                <ul>
                    <li>Initial version</li>
                </ul>                
            </div>
        </div>    
    </div>
    <div class="panel panel-default">
        <div class="panel-heading" role="tab">
            <h4 class="panel-title">
                <a role="button" data-toggle="collapse" data-target="#${contactsId}" aria-expanded="false">
                    <span class="text-info"><strong>Contact &amp; Bugs</strong></span>
                </a>
            </h4>
        </div>        
        <div id="${contactsId}" class="panel-collapse collapse" role="tabpanel">
            <div class="panel-body">
                If you encounter a bug for this interpreter, please create a <a href="https://issues.apache.org/jira/browse/ZEPPELIN" target="_blank" rel="noopener noreferrer"><strong>JIRA</strong></a> ticket.</a>
            </div>
        </div>            
    </div>    
</div>
