Search in sources :

Example 1 with NumReadsRuns

use of org.apache.rya.benchmark.query.Parameters.NumReadsRuns in project incubator-rya by apache.

the class QueriesBenchmarkConfReaderIT method load.

@Test
public void load() throws JAXBException, SAXException, ParserConfigurationException, IOException {
    // Unmarshal some XML.
    final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<QueriesBenchmarkConf>\n" + "    <Rya>\n" + "        <ryaInstanceName>test_</ryaInstanceName>\n" + "        <accumulo>\n" + "            <username>test</username>\n" + "            <password>t3stP@ssw0rd</password>\n" + "            <zookeepers>zoo-server-1,zoo-server-2</zookeepers>\n" + "            <instanceName>testInstance</instanceName>\n" + "        </accumulo>\n" + "        <secondaryIndexing>\n" + "            <usePCJ>true</usePCJ>\n" + "        </secondaryIndexing>\n" + "    </Rya>\n" + "    <Parameters>" + "        <NumReadsRuns>" + "            <NumReads>1</NumReads>" + "            <NumReads>10</NumReads>" + "            <NumReads>100</NumReads>" + "            <NumReads>ALL</NumReads>" + "        </NumReadsRuns>" + "        <Queries>\n" + "            <SPARQL><![CDATA[SELECT ?a WHERE { ?a <http://likes> <urn:icecream> . }]]></SPARQL>\n" + "            <SPARQL><![CDATA[SELECT ?a ?b WHERE { ?a <http://knows> ?b . }]]></SPARQL>\n" + "        </Queries>\n" + "    </Parameters>" + "</QueriesBenchmarkConf>";
    final InputStream xmlStream = new ByteArrayInputStream(xml.getBytes(Charsets.UTF_8));
    final QueriesBenchmarkConf benchmarkConf = new QueriesBenchmarkConfReader().load(xmlStream);
    // Ensure it was unmarshalled correctly.
    final Rya rya = benchmarkConf.getRya();
    assertEquals("test_", rya.getRyaInstanceName());
    final Accumulo accumulo = rya.getAccumulo();
    assertEquals("test", accumulo.getUsername());
    assertEquals("t3stP@ssw0rd", accumulo.getPassword());
    assertEquals("zoo-server-1,zoo-server-2", accumulo.getZookeepers());
    assertEquals("testInstance", accumulo.getInstanceName());
    final SecondaryIndexing secondaryIndexing = rya.getSecondaryIndexing();
    assertTrue(secondaryIndexing.isUsePCJ());
    final Parameters parameters = benchmarkConf.getParameters();
    final List<String> expectedNumReads = Lists.newArrayList("1", "10", "100", "ALL");
    final NumReadsRuns NumReads = parameters.getNumReadsRuns();
    assertEquals(expectedNumReads, NumReads.getNumReads());
    final List<String> expectedQueries = Lists.newArrayList("SELECT ?a WHERE { ?a <http://likes> <urn:icecream> . }", "SELECT ?a ?b WHERE { ?a <http://knows> ?b . }");
    final Queries queries = parameters.getQueries();
    assertEquals(expectedQueries, queries.getSPARQL());
}
Also used : Queries(org.apache.rya.benchmark.query.Parameters.Queries) ByteArrayInputStream(java.io.ByteArrayInputStream) NumReadsRuns(org.apache.rya.benchmark.query.Parameters.NumReadsRuns) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Accumulo(org.apache.rya.benchmark.query.Rya.Accumulo) SecondaryIndexing(org.apache.rya.benchmark.query.Rya.SecondaryIndexing) Test(org.junit.Test)

Example 2 with NumReadsRuns

use of org.apache.rya.benchmark.query.Parameters.NumReadsRuns in project incubator-rya by apache.

the class QueryBenchmark method main.

/**
 * Runs the query benchmarks.
 * </p>
 * Example command line:
 * <pre>
 * java -cp benchmarks.jar org.apache.rya.benchmark.query.QueryBenchmark
 * </pre>
 *
 * @param args - The command line arguments that will be fed into the benchmark.
 * @throws Exception The benchmark could not be run.
 */
public static void main(final String[] args) throws Exception {
    // Read the queries that will be benchmarked from the provided path.
    final InputStream queriesStream = Files.newInputStream(QUERY_BENCHMARK_CONFIGURATION_FILE);
    final QueriesBenchmarkConf benchmarkConf = new QueriesBenchmarkConfReader().load(queriesStream);
    final Parameters parameters = benchmarkConf.getParameters();
    // Setup the options that will be used to run the benchmark.
    final OptionsBuilder options = new OptionsBuilder();
    options.parent(new CommandLineOptions(args));
    options.include(QueryBenchmark.class.getSimpleName());
    // Provide the SPARQL queries that will be injected into the benchmark's 'sparql' parameter.
    final List<String> sparql = parameters.getQueries().getSPARQL();
    final String[] sparqlArray = new String[sparql.size()];
    sparql.toArray(sparqlArray);
    // Clean up the sparql's whitespace.
    for (int i = 0; i < sparqlArray.length; i++) {
        sparqlArray[i] = sparqlArray[i].trim();
    }
    options.param("sparql", sparqlArray);
    // If numReadsRuns was specified, inject them into the benchmark's 'numReads' parameter.
    final NumReadsRuns numReadsRuns = parameters.getNumReadsRuns();
    if (numReadsRuns != null) {
        // Validate the list.
        final List<String> numReadsList = numReadsRuns.getNumReads();
        for (final String numReads : numReadsList) {
            // It may be the READ_ALL flag.
            if (numReads.equals(READ_ALL)) {
                continue;
            }
            // Or it must be a Long.
            try {
                Long.parseLong(numReads);
            } catch (final NumberFormatException e) {
                throw new RuntimeException("There is a problem with the benchmark's configuration. Encountered " + "a numReads value of '" + numReads + "', which is inavlid. The value must be a Long or " + "'" + READ_ALL + "'");
            }
        }
        // Configure the benchmark with the numRuns.
        final String[] numReadsArray = new String[numReadsList.size()];
        numReadsList.toArray(numReadsArray);
        options.param("numReads", numReadsArray);
    }
    // Execute the benchmark.
    new Runner(options.build()).run();
}
Also used : Runner(org.openjdk.jmh.runner.Runner) InputStream(java.io.InputStream) CommandLineOptions(org.openjdk.jmh.runner.options.CommandLineOptions) OptionsBuilder(org.openjdk.jmh.runner.options.OptionsBuilder) NumReadsRuns(org.apache.rya.benchmark.query.Parameters.NumReadsRuns)

Aggregations

InputStream (java.io.InputStream)2 NumReadsRuns (org.apache.rya.benchmark.query.Parameters.NumReadsRuns)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Queries (org.apache.rya.benchmark.query.Parameters.Queries)1 Accumulo (org.apache.rya.benchmark.query.Rya.Accumulo)1 SecondaryIndexing (org.apache.rya.benchmark.query.Rya.SecondaryIndexing)1 Test (org.junit.Test)1 Runner (org.openjdk.jmh.runner.Runner)1 CommandLineOptions (org.openjdk.jmh.runner.options.CommandLineOptions)1 OptionsBuilder (org.openjdk.jmh.runner.options.OptionsBuilder)1