Package org.apache.derbyTesting.junit.IndexStatsUtil

Examples of org.apache.derbyTesting.junit.IndexStatsUtil.IdxStats


                prepareStatement("select * from " + TAB + " where id1 = 10")
                .executeQuery());

        // We expect three stats objects for the single index; one per
        // leading columns combination (c1, c1-c2, and c1-c2-c3).
        IdxStats statsObj[] = stats.getStatsTable(TAB, 3);
        assertEquals(3, statsObj.length);

        Timestamp now = new Timestamp(new Date().getTime());
        for (int i=0; i < statsObj.length; i++) {
            IdxStats s = statsObj[i];
            assertEquals(rows, s.rows);
            assertTrue(s.created.before(now));
            switch (s.lcols) {
                case 1:
                    assertEquals(100, s.card);
                    break;
                case 2:
                    assertEquals(5000, s.card);
                    break;
                case 3:
                    assertEquals(50000, s.card);
                    break;
            default:
                fail("unexpected number of leading columns: " + s.lcols);
            }
        }

        // Now create a second index in the opposite order, check stats.
        stmt.executeUpdate("create index IDXREV on " + TAB + "(id3, id2, id1)");
        statsObj = stats.getStatsIndex("IDXREV", 3);
        assertEquals(3, statsObj.length);
        Timestamp earlier = now;
        now = new Timestamp(new Date().getTime());
        for (int i=0; i < statsObj.length; i++) {
            IdxStats s = statsObj[i];
            assertEquals(rows, s.rows);
            assertTrue("current stats created " + s.created +
                    ", previous stats created " + earlier,
                    s.created.after(earlier));
            // Stats cannot have been created after the current time (future).
View Full Code Here


        // thread to be "starved". Add a timeout to give it a chance to do
        // what it has been told to do.
        IndexStatsUtil stats = new IndexStatsUtil(getConnection(), 5000);
        IdxStats[] myStats = stats.getStatsTable(TAB, 2);
        for (int i=0; i < myStats.length; i++) {
            IdxStats s = myStats[i];
            assertEquals(_100K, s.rows);
            switch (s.lcols) {
                case 1:
                    assertEquals(10, s.card);
                    break;
View Full Code Here

                prepareStatement("select * from " + TAB + " where id1 = 10")
                .executeQuery());

        // We expect three stats objects for the single index; one per
        // leading columns combination (c1, c1-c2, and c1-c2-c3).
        IdxStats statsObj[] = stats.getStatsTable(TAB, 3);
        assertEquals(3, statsObj.length);

        Timestamp now = new Timestamp(new Date().getTime());
        for (int i=0; i < statsObj.length; i++) {
            IdxStats s = statsObj[i];
            assertEquals(rows, s.rows);
           
            // DERBY-6144
            // Stats cannot have been created after the current time (future).
            assertFalse(
                "expected stat created in past:now = " + now +
                ";s.created = " + s.created,
                s.created.compareTo(now) > 0);

            switch (s.lcols) {
                case 1:
                    assertEquals(100, s.card);
                    break;
                case 2:
                    assertEquals(5000, s.card);
                    break;
                case 3:
                    assertEquals(50000, s.card);
                    break;
            default:
                fail("unexpected number of leading columns: " + s.lcols);
            }
        }

        // Now create a second index in the opposite order, check stats.
        stmt.executeUpdate("create index IDXREV on " + TAB + "(id3, id2, id1)");
        statsObj = stats.getStatsIndex("IDXREV", 3);
        assertEquals(3, statsObj.length);
        Timestamp earlier = now;
        now = new Timestamp(new Date().getTime());
        for (int i=0; i < statsObj.length; i++) {
            IdxStats s = statsObj[i];
            assertEquals(rows, s.rows);
            assertTrue("current stats created " + s.created +
                    ", previous stats created " + earlier,
                    s.created.after(earlier));
            // Stats cannot have been created after the current time (future).
View Full Code Here

                prepareStatement("select * from " + TAB + " where id1 = 10")
                .executeQuery());

        // We expect three stats objects for the single index; one per
        // leading columns combination (c1, c1-c2, and c1-c2-c3).
        IdxStats statsObj[] = stats.getStatsTable(TAB, 3);
        assertEquals(3, statsObj.length);

        Timestamp now = new Timestamp(new Date().getTime());
        for (int i=0; i < statsObj.length; i++) {
            IdxStats s = statsObj[i];
            assertEquals(rows, s.rows);
           
            // DERBY-6144
            // Stats cannot have been created after the current time (future).
            assertFalse(
                "expected stat created in past:now = " + now +
                ";s.created = " + s.created,
                s.created.compareTo(now) > 0);

            switch (s.lcols) {
                case 1:
                    assertEquals(100, s.card);
                    break;
                case 2:
                    assertEquals(5000, s.card);
                    break;
                case 3:
                    assertEquals(50000, s.card);
                    break;
            default:
                fail("unexpected number of leading columns: " + s.lcols);
            }
        }

        // Now create a second index in the opposite order, check stats.
        stmt.executeUpdate("create index IDXREV on " + TAB + "(id3, id2, id1)");
        statsObj = stats.getStatsIndex("IDXREV", 3);
        assertEquals(3, statsObj.length);
        Timestamp earlier = now;
        now = new Timestamp(new Date().getTime());
        for (int i=0; i < statsObj.length; i++) {
            IdxStats s = statsObj[i];
            assertEquals(rows, s.rows);
            assertTrue("current stats created " + s.created +
                    ", previous stats created " + earlier,
                    s.created.after(earlier));
            // Stats cannot have been created after the current time (future).
View Full Code Here

                prepareStatement("select * from " + TAB + " where id1 = 10")
                .executeQuery());

        // We expect three stats objects for the single index; one per
        // leading columns combination (c1, c1-c2, and c1-c2-c3).
        IdxStats statsObj[] = stats.getStatsTable(TAB, 3);
        assertEquals(3, statsObj.length);

        Timestamp now = new Timestamp(new Date().getTime());
        for (int i=0; i < statsObj.length; i++) {
            IdxStats s = statsObj[i];
            assertEquals(rows, s.rows);
            assertTrue(s.created.before(now));
            switch (s.lcols) {
                case 1:
                    assertEquals(100, s.card);
                    break;
                case 2:
                    assertEquals(5000, s.card);
                    break;
                case 3:
                    assertEquals(50000, s.card);
                    break;
            default:
                fail("unexpected number of leading columns: " + s.lcols);
            }
        }

        // Now create a second index in the opposite order, check stats.
        stmt.executeUpdate("create index IDXREV on " + TAB + "(id3, id2, id1)");
        statsObj = stats.getStatsIndex("IDXREV", 3);
        assertEquals(3, statsObj.length);
        Timestamp earlier = now;
        now = new Timestamp(new Date().getTime());
        for (int i=0; i < statsObj.length; i++) {
            IdxStats s = statsObj[i];
            assertEquals(rows, s.rows);
            assertTrue("current stats created " + s.created +
                    ", previous stats created " + earlier,
                    s.created.after(earlier));
            // Stats cannot have been created after the current time (future).
View Full Code Here

    private void verifyStatistics()
            throws SQLException {
        IndexStatsUtil stats = new IndexStatsUtil(getConnection());
        IdxStats[] myStats = stats.getStatsTable(TAB, 2);
        for (int i=0; i < myStats.length; i++) {
            IdxStats s = myStats[i];
            assertEquals(_100K, s.rows);
            switch (s.lcols) {
                case 1:
                    assertEquals(10, s.card);
                    break;
View Full Code Here

        // thread to be "starved". Add a timeout to give it a chance to do
        // what it has been told to do.
        IndexStatsUtil stats = new IndexStatsUtil(getConnection(), 5000);
        IdxStats[] myStats = stats.getStatsTable(TAB, 2);
        for (int i=0; i < myStats.length; i++) {
            IdxStats s = myStats[i];
            assertEquals(_100K, s.rows);
            switch (s.lcols) {
                case 1:
                    assertEquals(10, s.card);
                    break;
View Full Code Here

                prepareStatement("select * from " + TAB + " where id1 = 10")
                .executeQuery());

        // We expect three stats objects for the single index; one per
        // leading columns combination (c1, c1-c2, and c1-c2-c3).
        IdxStats statsObj[] = stats.getStatsTable(TAB, 3);
        assertEquals(3, statsObj.length);

        Timestamp now = new Timestamp(new Date().getTime());
        for (int i=0; i < statsObj.length; i++) {
            IdxStats s = statsObj[i];
            assertEquals(rows, s.rows);
            assertTrue(s.created.before(now));
            switch (s.lcols) {
                case 1:
                    assertEquals(100, s.card);
                    break;
                case 2:
                    assertEquals(5000, s.card);
                    break;
                case 3:
                    assertEquals(50000, s.card);
                    break;
            default:
                fail("unexpected number of leading columns: " + s.lcols);
            }
        }

        // Now create a second index in the opposite order, check stats.
        stmt.executeUpdate("create index IDXREV on " + TAB + "(id3, id2, id1)");
        statsObj = stats.getStatsIndex("IDXREV", 3);
        assertEquals(3, statsObj.length);
        Timestamp earlier = now;
        now = new Timestamp(new Date().getTime());
        for (int i=0; i < statsObj.length; i++) {
            IdxStats s = statsObj[i];
            assertEquals(rows, s.rows);
            assertTrue("current stats created " + s.created +
                    ", previous stats created " + earlier,
                    s.created.after(earlier));
            // Stats cannot have been created after the current time (future).
View Full Code Here

                prepareStatement("select * from " + TAB + " where id1 = 10")
                .executeQuery());

        // We expect three stats objects for the single index; one per
        // leading columns combination (c1, c1-c2, and c1-c2-c3).
        IdxStats statsObj[] = stats.getStatsTable(TAB, 3);
        assertEquals(3, statsObj.length);

        Timestamp now = new Timestamp(new Date().getTime());
        for (int i=0; i < statsObj.length; i++) {
            IdxStats s = statsObj[i];
            assertEquals(rows, s.rows);
            assertTrue(s.created.before(now));
            switch (s.lcols) {
                case 1:
                    assertEquals(100, s.card);
                    break;
                case 2:
                    assertEquals(5000, s.card);
                    break;
                case 3:
                    assertEquals(50000, s.card);
                    break;
            default:
                fail("unexpected number of leading columns: " + s.lcols);
            }
        }

        // Now create a second index in the opposite order, check stats.
        stmt.executeUpdate("create index IDXREV on " + TAB + "(id3, id2, id1)");
        statsObj = stats.getStatsIndex("IDXREV", 3);
        assertEquals(3, statsObj.length);
        Timestamp earlier = now;
        now = new Timestamp(new Date().getTime());
        for (int i=0; i < statsObj.length; i++) {
            IdxStats s = statsObj[i];
            assertEquals(rows, s.rows);
            assertTrue("current stats created " + s.created +
                    ", previous stats created " + earlier,
                    s.created.after(earlier));
            // Stats cannot have been created after the current time (future).
View Full Code Here

        // thread to be "starved". Add a timeout to give it a chance to do
        // what it has been told to do.
        IndexStatsUtil stats = new IndexStatsUtil(getConnection(), 5000);
        IdxStats[] myStats = stats.getStatsTable(TAB, 2);
        for (int i=0; i < myStats.length; i++) {
            IdxStats s = myStats[i];
            assertEquals(_100K, s.rows);
            switch (s.lcols) {
                case 1:
                    assertEquals(10, s.card);
                    break;
View Full Code Here

TOP

Related Classes of org.apache.derbyTesting.junit.IndexStatsUtil.IdxStats

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.