All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gemstone.gemfire.cache.query.SchwabQueryPerfTest Maven / Gradle / Ivy

There is a newer version: 2.0-BETA
Show newest version
/*
 * 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 SchwabQueryPerfTest extends TestCase {
    
    /** Creates a new instance of SchwabQueryPerfTest */
    public SchwabQueryPerfTest(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 = 100;
    static final int QUERY_EXECUTED = 3;
    
    /////////////queries ///////////
    
String queries[] ={
            
    		"SELECT DISTINCT * FROM /Quotes1 q, q.restrict r WHERE q.cusip > 900000000 AND r.cusip < 1000000000 AND q.quoteType = 'storage' OR q.quoteType = 'auto transport'",    		

    		"SELECT DISTINCT * FROM /Quotes1 q, q.restrict r WHERE q.quoteType = 'moving' OR q.quoteType = 'non binding' OR r.quoteType = 'storage'",    		

    		"SELECT DISTINCT * FROM /Quotes1 q, q.restrict r WHERE q.quoteType = 'moving' AND r.cusip < 1000000000",    		

    		"SELECT DISTINCT  q.cusip, q.quoteType, 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, q.restrict r WHERE q.cusip = r.cusip AND q.quoteType = r.quoteType",    		

    		"SELECT DISTINCT  q.cusip, q.quoteType, 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.quoteType = r.quoteType",//AND q.cusip = r.cusip,    		

    		"SELECT DISTINCT  q1.cusip, q1.quoteType, 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.quoteType = r.quoteType",//AND q1.cusip = r.cusip AND q1.priceType = 'priceType1' OR q2.priceType = 'priceType2'",
    		
    		"SELECT DISTINCT * FROM /Quotes1 q1, /Quotes2 q2, /Restricted1 r WHERE q1.quoteType = 'storage' OR q1.quoteType = 'auto transport'",
    		
    		"SELECT DISTINCT * FROM /Quotes1 q1, /Quotes2 q2, /Restricted1 r WHERE q1.cusip = 900000990 OR (q1.quoteType = 'storage' OR q1.quoteType = 'auto transport')",

    		"SELECT DISTINCT * FROM /Quotes1 q1, /Quotes2 q2, /Restricted1 r WHERE (q1.cusip = 900000990 OR q2.cusip = 900000989 OR r.cusip = 900000970) OR (q1.quoteType = 'storage' OR q1.quoteType = 'auto transport')",    		    		

    		"SELECT DISTINCT q1.cusip, q1.quoteType, r.maxQty, r.incQty FROM /Quotes1 q1, /Quotes2 q2, /Restricted1 r WHERE q1.lowerQty < 150 AND q2.upperQty > 1050 AND r.maxQty > 1050",    		

    		"SELECT DISTINCT * FROM /Quotes1 q1, q1.restrict r1, /Quotes2 q2, q2.restrict r2, /Restricted1 r3 WHERE r1.quoteType = r2.quoteType AND r2.quoteType = r3.quoteType",// AND r3.maxQty > 1050",    		

    		"SELECT DISTINCT * FROM /Quotes1 q1, q1.restrict r1, /Quotes2 q2, q2.restrict r2, /Restricted1 r3 WHERE q1.quoteIdStr = '123' OR q2.quoteIdStr = '124'",    		

    		"SELECT DISTINCT * FROM /Quotes1 q1, q1.restrict r1, /Quotes2 q2, q2.restrict r2, /Restricted1 r3 WHERE q1.getQuoteIdStr() = '123' OR q2.getQuoteIdStr() = '124'",    		

    		"SELECT DISTINCT * FROM /Quotes1 q1, q1.restrict r1, /Quotes2 q2, q2.restrict r2, /Restricted1 r3 WHERE r1.getQuoteType() = r2.getQuoteType() AND r2.getQuoteType() = r3.getQuoteType()", // AND r3.getMaxQty() > 1050",    		

    		"SELECT DISTINCT  q.getCusip(), q.getQuoteType(), q.getDealerPortfolio(), q.getChannelName(), q.dealerCode, q.priceType, q.price, q.lowerQty, q.upperQty, q.ytm, r.minQty, r.maxQty, r.incQty FROM /Quotes1 q, q.restrict r WHERE q.cusip = r.cusip AND q.quoteType = r.quoteType",    		

    		"SELECT DISTINCT * FROM /Quotes1 q, q.restrict r WHERE q.quoteType = 'moving' AND q.getChannelName() = 'channel1' AND q.getLowerQty() < 150",    		

    		"SELECT DISTINCT * FROM /Quotes1 q1, q1.restrict r1, /Quotes2 q2, q2.restrict r2, /Restricted1 r3 WHERE q1.getUpperQty() IN SET(1050, 1100) OR q2.getLowerQty() IN SET(150, 200)",    		

    		"SELECT DISTINCT * FROM /Quotes1 q1, q1.restrict r1, /Quotes2 q2, q2.restrict r2, /Restricted1 r3 WHERE q1.channelName IN SET('channel1', 'channel2', 'channel3') OR q2.priceType IN SET('priceType1', 'priceType2', 'priceType3')"
    };
    
    
    ////////////////////
    
    protected void setUp() throws java.lang.Exception {
    }//end of setUp
    
    protected void tearDown() throws java.lang.Exception {
        cache.close();
        ds.disconnect();
    }//end of tearDown
    
    
    public static Test suite(){
        TestSuite suite = new TestSuite(SchwabQueryPerfTest.class);
        return suite;
    }//end of suite
    
    ////////////////test methods ///////////////
    public void testPerf() throws Exception{
        createRegion();
        populateData();
        
        String sqlStr;
        long startTime, endTime, totalTime = 0;
        SelectResults rs=null;
        Query q;
        
        /////without index ////////
        for (int x = 0; x




© 2015 - 2024 Weber Informatics LLC | Privacy Policy