com.gemstone.gemfire.cache.query.SchwabEquiJoinQueryPerfTest Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gemfire-junit Show documentation
Show all versions of gemfire-junit Show documentation
SnappyData store based off Pivotal GemFireXD
/*
* Copyright (c) 2010-2015 Pivotal Software, Inc. All rights reserved.
*
* Licensed 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. See accompanying
* LICENSE file.
*/
/*
* BaseLineAndCompareQueryPerfTest.java
*
* Created on October 13, 2005, 11:28 AM
*/
package com.gemstone.gemfire.cache.query;
/**
*
* @author prafulla
*This test is to baseline and compare the performance figures for index usage benchmarks for Schwab related queries.
*/
import com.gemstone.gemfire.cache.*;
import com.gemstone.gemfire.distributed.*;
import com.gemstone.gemfire.cache.query.data.*;
import com.gemstone.gemfire.cache.query.internal.*;
import junit.framework.*;
import java.util.*;
import java.io.*;
public class SchwabEquiJoinQueryPerfTest extends TestCase {
/** Creates a new instance of SchwabEquiJoinQueryPerfTest */
public SchwabEquiJoinQueryPerfTest(String name) {
super(name);
}//end of constructor1
/////////////////////
static Cache cache;
static Region region1;
static Region region2;
static Region region3;
static Index index;
static DistributedSystem ds;
static Properties props = new Properties();
static QueryService qs;
static Map queriesMap = new TreeMap();
//static Map withoutIndexTimeRegion = new TreeMap();
static Map withIndexTimeRegion = new TreeMap();
static Map indexNameRegion = new TreeMap();
//static Map withoutIndexResultSetSize = new TreeMap();
static Map withIndexResultSetSize = new TreeMap();
private static FileOutputStream file;
private static BufferedWriter wr;
private static int printCntr = 1;
static final int MAX_OBJECTS = 1000;
static final int QUERY_EXECUTED = 5;
static int [] regionSizes = {1000, 2000, 3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000, 11000, 12000, 13000, 14000, 15000, 16000, 17000, 18000, 19000, 20000};
/////////////queries ///////////
String queries[] ={
"SELECT DISTINCT q.cusip, q.uniqueQuoteType, q.dealerPortfolio, q.channelName, q.dealerCode, q.priceType, q.price, q.lowerQty, q.upperQty, q.ytm, r.minQty, r.maxQty, r.incQty FROM /Quotes1 q, /Restricted1 r WHERE q.uniqueQuoteType = r.uniqueQuoteType",
"SELECT DISTINCT q.cusip, q.uniqueQuoteType, q.dealerPortfolio, q.channelName, q.dealerCode, q.priceType, q.price, q.lowerQty, q.upperQty, q.ytm, r.minQty, r.maxQty, r.incQty FROM /Quotes1 q, /Restricted1 r WHERE q.uniqueQuoteType = r.uniqueQuoteType AND q.lowerQty < 200",
"SELECT DISTINCT q.cusip, q.uniqueQuoteType, q.dealerPortfolio, q.channelName, q.dealerCode, q.priceType, q.price, q.lowerQty, q.upperQty, q.ytm, r.minQty, r.maxQty, r.incQty FROM /Quotes1 q, /Restricted1 r WHERE q.uniqueQuoteType = r.uniqueQuoteType AND q.lowerQty > 200 AND r.maxQty > 1200",
"SELECT DISTINCT q1.getCusip(), q1.getUniqueQuoteType(), q1.getDealerPortfolio(), q1.getChannelName(), q2.dealerCode, q2.priceType, q2.price, q2.lowerQty, q2.upperQty, q2.ytm, r.minQty, r.maxQty, r.incQty FROM /Quotes1 q1, /Quotes2 q2, /Restricted1 r WHERE q1.cusip = r.cusip AND q2.uniqueQuoteType = r.uniqueQuoteType",
"SELECT DISTINCT q1.cusip, q1.uniqueQuoteType, q2.dealerPortfolio, q2.channelName, q1.dealerCode, q2.priceType, q1.price, q2.lowerQty, q1.upperQty, q1.ytm, r.minQty, r.maxQty, r.incQty FROM /Quotes1 q1, /Quotes2 q2, /Restricted1 r WHERE q2.uniqueQuoteType = r.uniqueQuoteType AND q1.cusip = r.cusip AND q1.priceType = 'priceType1'",
"SELECT DISTINCT q1.cusip, q1.uniqueQuoteType, q2.dealerPortfolio, q2.channelName, q1.dealerCode, q2.priceType, q1.price, q2.lowerQty, q1.upperQty, q1.ytm, r.minQty, r.maxQty, r.incQty FROM /Quotes1 q1, /Quotes2 q2, /Restricted1 r WHERE q2.uniqueQuoteType = r.uniqueQuoteType AND q1.cusip = r.cusip AND q1.priceType = 'priceType1' AND q2.priceType = 'priceType1'",
"SELECT DISTINCT q1.cusip, q1.uniqueQuoteType, q2.dealerPortfolio, q2.channelName, q1.dealerCode, q2.priceType, q1.price, q2.lowerQty, q1.upperQty, q1.ytm, r.minQty, r.maxQty, r.incQty FROM /Quotes1 q1, /Quotes2 q2, /Restricted1 r WHERE q2.uniqueQuoteType = r.uniqueQuoteType AND q1.cusip = r.cusip AND q1.priceType = 'priceType1' AND q2.priceType = 'priceType1' AND r.maxQty > 1200",
//queries for order by clause
"SELECT DISTINCT q.cusip, q.uniqueQuoteType, q.dealerPortfolio, q.channelName, q.dealerCode, q.priceType, q.price, q.lowerQty, q.upperQty, q.ytm, r.minQty, r.maxQty, r.incQty FROM /Quotes1 q, /Restricted1 r WHERE q.uniqueQuoteType = r.uniqueQuoteType order by q.cusip",
"SELECT DISTINCT q.cusip, q.uniqueQuoteType, q.dealerPortfolio, q.channelName, q.dealerCode, q.priceType, q.price, q.lowerQty, q.upperQty, q.ytm, r.minQty, r.maxQty, r.incQty FROM /Quotes1 q, /Restricted1 r WHERE q.uniqueQuoteType = r.uniqueQuoteType order by q.cusip, r.minQty",
"SELECT DISTINCT q.cusip, q.uniqueQuoteType, q.dealerPortfolio, q.channelName, q.dealerCode, q.priceType, q.price, q.lowerQty, q.upperQty, q.ytm, r.minQty, r.maxQty, r.incQty FROM /Quotes1 q, /Restricted1 r WHERE q.uniqueQuoteType = r.uniqueQuoteType order by q.cusip, q.uniqueQuoteType",
"SELECT DISTINCT q.cusip, q.uniqueQuoteType, q.dealerPortfolio, q.channelName, q.dealerCode, q.priceType, q.price, q.lowerQty, q.upperQty, q.ytm, r.minQty, r.maxQty, r.incQty FROM /Quotes1 q, /Restricted1 r WHERE q.uniqueQuoteType = r.uniqueQuoteType order by q.cusip, q.uniqueQuoteType, r.minQty",
"SELECT DISTINCT q1.getCusip(), q1.getUniqueQuoteType(), q1.getDealerPortfolio(), q1.getChannelName(), q2.dealerCode, q2.priceType, q2.price, q2.lowerQty, q2.upperQty, q2.ytm, r.minQty, r.maxQty, r.incQty FROM /Quotes1 q1, /Quotes2 q2, /Restricted1 r WHERE q1.cusip = r.cusip AND q2.uniqueQuoteType = r.uniqueQuoteType order by q1.cusip",
"SELECT DISTINCT q1.getCusip(), q1.getUniqueQuoteType(), q1.getDealerPortfolio(), q1.getChannelName(), q2.dealerCode, q2.priceType, q2.price, q2.lowerQty, q2.upperQty, q2.ytm, r.minQty, r.maxQty, r.incQty FROM /Quotes1 q1, /Quotes2 q2, /Restricted1 r WHERE q1.cusip = r.cusip AND q2.uniqueQuoteType = r.uniqueQuoteType order by q1.cusip, q2.priceType",
"SELECT DISTINCT q1.getCusip(), q1.getUniqueQuoteType(), q1.getDealerPortfolio(), q1.getChannelName(), q2.dealerCode, q2.priceType, q2.price, q2.lowerQty, q2.upperQty, q2.ytm, r.minQty, r.maxQty, r.incQty FROM /Quotes1 q1, /Quotes2 q2, /Restricted1 r WHERE q1.cusip = r.cusip AND q2.uniqueQuoteType = r.uniqueQuoteType order by q1.cusip, q2.priceType, r.minQty"
};
////////////////////
protected void setUp() throws java.lang.Exception {
}//end of setUp
protected void tearDown() throws java.lang.Exception {
closeCache();
}//end of tearDown
public void closeCache() throws java.lang.Exception{
if(! cache.isClosed() || cache != null){
cache.close();
}
if(ds.isConnected()){
ds.disconnect();
}
}//end of closeCache
public static Test suite(){
TestSuite suite = new TestSuite(SchwabEquiJoinQueryPerfTest.class);
return suite;
}//end of suite
////////////////test methods ///////////////
public void testPerf() throws Exception{
for(int i=0; i < regionSizes.length; i++){
System.out.println("Size of region is: "+regionSizes[i]);
queriesMap.clear();
withIndexTimeRegion.clear();
indexNameRegion.clear();
withIndexResultSetSize.clear();
executeTestPerf(regionSizes[i]);
closeCache();
}
}//end of testPerf
public void executeTestPerf(int regionSize) throws Exception{
createRegion();
populateData(regionSize);
String sqlStr;
long startTime, endTime, totalTime = 0;
SelectResults rs=null;
Query q;
/////without index ////////
/*for (int x = 0; x