com.gemstone.gemfire.cache.query.SchwabQueryPerfOnItsDataTest 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 SchwabQueryPerfOnItsDataTest extends TestCase {
/** Creates a new instance of SchwabQueryPerfOnItsDataTest */
public SchwabQueryPerfOnItsDataTest(String name) {
super(name);
}//end of constructor1
/////////////////////
static Cache cache;
static Region regionPsq, regionSec, regionInv;
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};
/////////////queries ///////////
String queries[] ={
"SELECT DISTINCT inv.cusip, inv.upper_qty, "
+"inv.quote_price, inv.quote_timestamp, "
+"inv.price_type, "
+"inv.max_order_qty, inv.min_order_qty, "
+"inv.inc_order_qty "
+"FROM /sec1 sec, /inv1 inv, /psq1 psq "
+"WHERE inv.cusip = psq.cusip "
+"AND inv.dealer_code = psq.dealer_code "
+"AND inv.lower_qty = psq.lower_qty "
+"AND inv.upper_qty = psq.upper_qty "
+"AND inv.price_type = psq.price_type "
+"AND inv.cusip = sec.cusip "
//+"AND ((inv.product_group_code = 'MUNI')) "
+"AND inv.max_order_qty >= inv.lower_qty "
+"AND inv.max_order_qty >= inv.min_order_qty "
+"AND inv.min_order_qty > 0 "
// +"AND sec.security_description IS NOT NULL "
+"AND sec.cusip_prohibited <> 'Y' "
+"AND inv.price_type = 'ASK' "
//+"AND inv.quote_price > 0 "
//+"AND inv.retail_price > 0 "
};
////////////////////
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(SchwabQueryPerfOnItsDataTest.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