Author: shawkins
Date: 2012-09-10 13:29:49 -0400 (Mon, 10 Sep 2012)
New Revision: 4419
Added:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/HardCodedExecutionFactory.java
trunk/test-integration/perf/src/test/java/org/teiid/query/eval/TestMaterializationPerformance.java
Modified:
trunk/test-integration/perf/pom.xml
trunk/test-integration/perf/src/test/java/org/teiid/query/eval/TestEnginePerformance.java
Log:
TEIID-2195 TEIID-2185 adding performance tests that show index selection
Added:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/HardCodedExecutionFactory.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/jdbc/HardCodedExecutionFactory.java
(rev 0)
+++
trunk/test-integration/common/src/test/java/org/teiid/jdbc/HardCodedExecutionFactory.java 2012-09-10
17:29:49 UTC (rev 4419)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.jdbc;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.teiid.language.QueryExpression;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.Translator;
+import org.teiid.translator.TranslatorException;
+
+@Translator(name="hardcoded")
+public final class HardCodedExecutionFactory extends ExecutionFactory<Object,
Object> {
+ Map<String, List<? extends List<?>>> dataMap = new HashMap<String,
List<? extends List<?>>>();
+
+ @Override
+ public ResultSetExecution createResultSetExecution(
+ final QueryExpression command, ExecutionContext executionContext,
+ RuntimeMetadata metadata, Object connection)
+ throws TranslatorException {
+ List<? extends List<?>> list = dataMap.get(command.toString());
+ if (list == null) {
+ throw new RuntimeException(command.toString());
+ }
+ final Iterator<? extends List<?>> result = list.iterator();
+ return new ResultSetExecution() {
+
+ @Override
+ public void execute() throws TranslatorException {
+
+ }
+
+ @Override
+ public void close() {
+
+ }
+
+ @Override
+ public void cancel() throws TranslatorException {
+
+ }
+
+ @Override
+ public List<?> next() throws TranslatorException, DataNotAvailableException {
+ if (result.hasNext()) {
+ return result.next();
+ }
+ return null;
+ }
+ };
+ }
+
+ @Override
+ public boolean isSourceRequired() {
+ return false;
+ }
+
+ public void addData(String key, List<? extends List<?>> list) {
+ this.dataMap.put(key, list);
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/test-integration/common/src/test/java/org/teiid/jdbc/HardCodedExecutionFactory.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/test-integration/perf/pom.xml
===================================================================
--- trunk/test-integration/perf/pom.xml 2012-09-10 17:02:33 UTC (rev 4418)
+++ trunk/test-integration/perf/pom.xml 2012-09-10 17:29:49 UTC (rev 4419)
@@ -9,5 +9,13 @@
<artifactId>test-integration-perf</artifactId>
<name>Performance Integration Tests</name>
<description>Performance tests that do not require external
dependencies</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>test-integration-common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ </dependency>
+ </dependencies>
</project>
\ No newline at end of file
Modified:
trunk/test-integration/perf/src/test/java/org/teiid/query/eval/TestEnginePerformance.java
===================================================================
---
trunk/test-integration/perf/src/test/java/org/teiid/query/eval/TestEnginePerformance.java 2012-09-10
17:02:33 UTC (rev 4418)
+++
trunk/test-integration/perf/src/test/java/org/teiid/query/eval/TestEnginePerformance.java 2012-09-10
17:29:49 UTC (rev 4419)
@@ -34,7 +34,6 @@
import java.sql.Time;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.concurrent.Callable;
@@ -192,13 +191,13 @@
runTask(iterations, threadCount, task);
}
- private List<?>[] sampleData(final int rowCount) {
+ static List<?>[] sampleData(final int rowCount) {
final List<?>[] data = new List<?>[rowCount];
for (int i = 0; i < rowCount; i++) {
data[i] = Arrays.asList(i, String.valueOf(i));
}
- Collections.shuffle(Arrays.asList(data), r);
+ //Collections.shuffle(Arrays.asList(data), r);
return data;
}
Added:
trunk/test-integration/perf/src/test/java/org/teiid/query/eval/TestMaterializationPerformance.java
===================================================================
---
trunk/test-integration/perf/src/test/java/org/teiid/query/eval/TestMaterializationPerformance.java
(rev 0)
+++
trunk/test-integration/perf/src/test/java/org/teiid/query/eval/TestMaterializationPerformance.java 2012-09-10
17:29:49 UTC (rev 4419)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor
+ * license agreements. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.query.eval;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.teiid.adminapi.impl.ModelMetaData;
+import org.teiid.jdbc.AbstractQueryTest;
+import org.teiid.jdbc.HardCodedExecutionFactory;
+import org.teiid.runtime.EmbeddedConfiguration;
+import org.teiid.runtime.EmbeddedServer;
+
+@SuppressWarnings({"nls"})
+public class TestMaterializationPerformance extends AbstractQueryTest {
+
+ EmbeddedServer es;
+
+ @Before public void setup() {
+ es = new EmbeddedServer();
+ es.start(new EmbeddedConfiguration());
+ }
+
+ @After public void teardown() {
+ es.stop();
+ }
+
+ @Test public void testIndexPerformance() throws Exception {
+ ModelMetaData mmm = new ModelMetaData();
+ mmm.setName("test");
+ mmm.setSchemaSourceType("ddl");
+ mmm.setSchemaText("create foreign table x (col1 integer, col2 string); " +
+ "create view matx (col1 integer, col2 string, constraint idx index (col2))
options (materialized true) as select * from x;");
+ mmm.addSourceMapping("x", "hardcoded", null);
+ HardCodedExecutionFactory hardCodedExecutionFactory = new HardCodedExecutionFactory();
+ hardCodedExecutionFactory.addData("SELECT x.col1, x.col2 FROM x",
Arrays.asList(TestEnginePerformance.sampleData(10000)));
+ es.addTranslator(hardCodedExecutionFactory);
+ es.deployVDB("test", mmm);
+ setConnection(es.getDriver().connect("jdbc:teiid:test", null));
+ for (int i = 0; i < 10000; i++) {
+ execute("SELECT * from matx where col2 = ?", new Object[]
{String.valueOf(i)});
+ assertEquals(String.valueOf(i), getRowCount(), 1);
+ }
+ }
+
+ @Test public void testFunctionBasedIndexPerformance() throws Exception {
+ ModelMetaData mmm = new ModelMetaData();
+ mmm.setName("test");
+ mmm.setSchemaSourceType("ddl");
+ mmm.setSchemaText("create foreign table x (col1 integer, col2 string); " +
+ "create view matx (col1 integer, col2 string, constraint idx index
(upper(col2))) options (materialized true) as select * from x;");
+ mmm.addSourceMapping("x", "hardcoded", null);
+ HardCodedExecutionFactory hardCodedExecutionFactory = new HardCodedExecutionFactory();
+ hardCodedExecutionFactory.addData("SELECT x.col1, x.col2 FROM x",
Arrays.asList(TestEnginePerformance.sampleData(10000)));
+ es.addTranslator(hardCodedExecutionFactory);
+ es.deployVDB("test", mmm);
+ setConnection(es.getDriver().connect("jdbc:teiid:test", null));
+ for (int i = 0; i < 10000; i++) {
+ execute("SELECT * from matx where upper(col2) = ?", new Object[]
{String.valueOf(i)});
+ assertEquals(String.valueOf(i), getRowCount(), 1);
+ }
+ }
+
+}
Property changes on:
trunk/test-integration/perf/src/test/java/org/teiid/query/eval/TestMaterializationPerformance.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain