org.aksw.simba.benchmark.log.operations

## Class CleanQueryWriter

- java.lang.Object
- - org.aksw.simba.benchmark.log.operations.CleanQueryWriter

-     public class CleanQueryWriter
      extends java.lang.Object

  Write clean queries with stats into file, later used for benchmark generation
  Author:
    Saleem

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.io.BufferedWriter` | `bw`
    `static long` | `count`
    `static long` | `datasetSize`
    `static long` | `errorCount`
    `static long` | `timeOutCount`
    `static long` | `zeroCount`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CleanQueryWriter()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.lang.String` | `decodeQuery(java.lang.String query)` Decode query
    `static java.lang.String` | `encodeQuery(java.lang.String query)` Encode query
    `static void` | `main(java.lang.String[] args)`
    `static void` | `writeAskQueries(java.lang.String query, java.lang.String endpoint, java.lang.String graph)` Write SPARQL ASK queries into file
    `static void` | `writeCleanQueriesFromQueryFiles(java.lang.String inputFile, java.lang.String endpoint, java.lang.String graph, java.lang.String outputQueryFile)` This will read queries (one per line) from the file and write into another file with stats
    `static void` | `writeCleanQueriesWithStats(java.util.HashMap<java.lang.String,java.util.Set<java.lang.String>> queries, java.lang.String endpoint, java.lang.String graph, java.lang.String outputQueryFile)` Write clean queries with stats into file
    `static void` | `writeConstructQueries(java.lang.String query, java.lang.String endpoint, java.lang.String graph)` Wrtie CONSTRUCT queries in to file
    `static void` | `writeDescribeQueries(java.lang.String query, java.lang.String endpoint, java.lang.String graph)` Wrtie DESCRIBE queries in to file
    `static void` | `writeSelectQueries(java.lang.String query, java.lang.String endpoint, java.lang.String graph)` Wrtie SELECT queries in to file

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### count

          public static long count

    - #### zeroCount

          public static long zeroCount

    - #### errorCount

          public static long errorCount

    - #### timeOutCount

          public static long timeOutCount

    - #### bw

          public static java.io.BufferedWriter bw

    - #### datasetSize

          public static long datasetSize

  - ### Constructor Detail

    - #### CleanQueryWriter

          public CleanQueryWriter()

  - ### Method Detail

    - #### main

          public static void main(java.lang.String[] args)
                           throws org.openrdf.repository.RepositoryException,
                                  org.openrdf.query.MalformedQueryException,
                                  org.openrdf.query.QueryEvaluationException,
                                  java.io.IOException

      Throws:
        `org.openrdf.repository.RepositoryException`
        `org.openrdf.query.MalformedQueryException`
        `org.openrdf.query.QueryEvaluationException`
        `java.io.IOException`

    - #### writeCleanQueriesFromQueryFiles

          public static void writeCleanQueriesFromQueryFiles(java.lang.String inputFile,
                                                             java.lang.String endpoint,
                                                             java.lang.String graph,
                                                             java.lang.String outputQueryFile)
                                                      throws org.openrdf.repository.RepositoryException,
                                                             org.openrdf.query.MalformedQueryException,
                                                             org.openrdf.query.QueryEvaluationException,
                                                             java.io.IOException

      This will read queries (one per line) from the file and write into another file with stats
      Parameters:
        `inputFile` - Input query file
        `endpoint` - SPARQL endpoint
        `graph` - Named Graph. Can be null
        `outputQueryFile` -
      Throws:
        `org.openrdf.repository.RepositoryException`
        `org.openrdf.query.MalformedQueryException`
        `org.openrdf.query.QueryEvaluationException`
        `java.io.IOException`

    - #### encodeQuery

          public static java.lang.String encodeQuery(java.lang.String query)

      Encode query
      Parameters:
        `query` - query string
      Returns:
        encoded query

    - #### writeCleanQueriesWithStats

          public static void writeCleanQueriesWithStats(java.util.HashMap<java.lang.String,java.util.Set<java.lang.String>> queries,
                                                        java.lang.String endpoint,
                                                        java.lang.String graph,
                                                        java.lang.String outputQueryFile)
                                                 throws org.openrdf.query.QueryEvaluationException,
                                                        org.openrdf.repository.RepositoryException,
                                                        org.openrdf.query.MalformedQueryException,
                                                        java.io.IOException

      Write clean queries with stats into file
      Parameters:
        `queries` - Set of queries
        `endpoint` - the SPARQL endpoint to be used for calculating the results size and selectivities of queries
        `graph` - Default named graph can be null as well where complete SPARQL endpoint will be queried
        `outputQueryFile` - Output file to store the clean queries with stats
      Throws:
        `org.openrdf.query.QueryEvaluationException`
        `org.openrdf.repository.RepositoryException`
        `org.openrdf.query.MalformedQueryException`
        `java.io.IOException`

    - #### decodeQuery

          public static java.lang.String decodeQuery(java.lang.String query)

      Decode query
      Parameters:
        `query` - query string
      Returns:
        decoded query

    - #### writeDescribeQueries

          public static void writeDescribeQueries(java.lang.String query,
                                                  java.lang.String endpoint,
                                                  java.lang.String graph)
                                           throws org.openrdf.repository.RepositoryException,
                                                  org.openrdf.query.MalformedQueryException,
                                                  java.io.IOException

      Wrtie DESCRIBE queries in to file
      Parameters:
        `query` - SPARQL DESCRIBE query
        `endpoint` - SPARQL endpoint
        `graph` - Named Graph, cann be null
      Throws:
        `org.openrdf.repository.RepositoryException`
        `org.openrdf.query.MalformedQueryException`
        `java.io.IOException`

    - #### writeAskQueries

          public static void writeAskQueries(java.lang.String query,
                                             java.lang.String endpoint,
                                             java.lang.String graph)
                                      throws org.openrdf.query.MalformedQueryException,
                                             org.openrdf.repository.RepositoryException,
                                             org.openrdf.query.QueryEvaluationException,
                                             java.io.IOException

      Write SPARQL ASK queries into file
      Parameters:
        `query` - SPARQL ASK query
        `endpoint` - SPARQL endpoint
        `graph` - Named Graph, can be null as well
      Throws:
        `org.openrdf.query.MalformedQueryException`
        `org.openrdf.repository.RepositoryException`
        `org.openrdf.query.QueryEvaluationException`
        `java.io.IOException`

    - #### writeConstructQueries

          public static void writeConstructQueries(java.lang.String query,
                                                   java.lang.String endpoint,
                                                   java.lang.String graph)
                                            throws org.openrdf.repository.RepositoryException,
                                                   org.openrdf.query.MalformedQueryException,
                                                   java.io.IOException

      Wrtie CONSTRUCT queries in to file
      Parameters:
        `query` - SPARQL query
        `endpoint` - SPARQL endpoint
        `graph` - Named Graph, can be null
      Throws:
        `org.openrdf.repository.RepositoryException`
        `org.openrdf.query.MalformedQueryException`
        `java.io.IOException`

    - #### writeSelectQueries

          public static void writeSelectQueries(java.lang.String query,
                                                java.lang.String endpoint,
                                                java.lang.String graph)
                                         throws org.openrdf.repository.RepositoryException,
                                                org.openrdf.query.MalformedQueryException,
                                                org.openrdf.query.QueryEvaluationException,
                                                java.io.IOException

      Wrtie SELECT queries in to file
      Parameters:
        `query` - query
        `endpoint` - SPARQL endpoint
        `graph` - Named Graph, cann be null
      Throws:
        `org.openrdf.repository.RepositoryException`
        `org.openrdf.query.MalformedQueryException`
        `org.openrdf.query.QueryEvaluationException`
        `java.io.IOException`