Search in sources :

Example 6 with Storable

use of org.apache.derby.iapi.services.io.Storable in project derby by apache.

the class T_RecoverBadLog method RTest4.

/*
	 * test recovery of test 4
	 */
void RTest4() throws T_Fail, StandardException {
    long cid = find(key(4, 1));
    if (cid < 0) {
        REPORT("bad log test4 not run");
        return;
    }
    int numcol = (int) find(key(4, 2));
    Transaction t = t_util.t_startTransaction();
    try {
        ContainerHandle c = t_util.t_openContainer(t, 0, cid, true);
        Page page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
        int optimisticNumcol = (int) ((RawStoreFactory.PAGE_SIZE_MINIMUM * 8) / (10 * 20));
        T_RawStoreRow bigrow = new T_RawStoreRow(optimisticNumcol);
        for (int i = 0; i < optimisticNumcol; i++) bigrow.setColumn(i, (String) null);
        page.fetchFromSlot((RecordHandle) null, 0, bigrow.getRow(), (FetchDescriptor) null, false);
        Storable column;
        // the original 20 char string
        String string1 = "01234567890123456789";
        for (int i = 0; i < numcol; i++) {
            column = bigrow.getStorableColumn(i);
            if (!(column.toString().equals(string1)))
                throw T_Fail.testFailMsg("Column " + i + " value incorrect, got :" + column.toString());
        }
        for (int i = numcol; i < optimisticNumcol; i++) {
            column = bigrow.getStorableColumn(i);
            if (!column.isNull())
                throw T_Fail.testFailMsg("Column " + i + " expect Null, got : " + column.toString());
        }
        REPORT("RTest4 passed");
    } finally {
        t_util.t_commit(t);
        t.close();
    }
}
Also used : Storable(org.apache.derby.iapi.services.io.Storable)

Example 7 with Storable

use of org.apache.derby.iapi.services.io.Storable in project derby by apache.

the class T_RecoverBadLog method RTest7.

/*
	 * test recovery of test 7
	 */
void RTest7() throws T_Fail, StandardException {
    long cid = find(key(6, 1));
    if (cid < 0) {
        REPORT("bad log test7 not run");
        return;
    }
    int numcol = (int) find(key(6, 2));
    Transaction t = t_util.t_startTransaction();
    try {
        ContainerHandle c = t_util.t_openContainer(t, 0, cid, true);
        Page page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
        int optimisticNumcol = (int) ((RawStoreFactory.PAGE_SIZE_MINIMUM * 8) / (10 * 20));
        T_RawStoreRow bigrow = new T_RawStoreRow(optimisticNumcol);
        for (int i = 0; i < optimisticNumcol; i++) bigrow.setColumn(i, (String) null);
        page.fetchFromSlot((RecordHandle) null, 0, bigrow.getRow(), (FetchDescriptor) null, false);
        Storable column;
        // the original 20 char string
        String string1 = "01234567890123456789";
        for (int i = 0; i < numcol; i++) {
            column = bigrow.getStorableColumn(i);
            if (!(column.toString().equals(string1)))
                throw T_Fail.testFailMsg("Column " + i + " value incorrect, got :" + column.toString());
        }
        for (int i = numcol; i < optimisticNumcol; i++) {
            column = bigrow.getStorableColumn(i);
            if (!column.isNull())
                throw T_Fail.testFailMsg("Column " + i + " expect Null, got : " + column.toString());
        }
        REPORT("RTest7 passed");
    } finally {
        t_util.t_commit(t);
        t.close();
    }
}
Also used : Storable(org.apache.derby.iapi.services.io.Storable)

Example 8 with Storable

use of org.apache.derby.iapi.services.io.Storable in project derby by apache.

the class T_RecoverBadLog method RTest5.

/*
	 * test recovery of test 5
	 */
void RTest5() throws T_Fail, StandardException {
    long cid = find(key(5, 1));
    if (cid < 0) {
        REPORT("bad log test5 not run");
        return;
    }
    int numcol = (int) find(key(5, 2));
    Transaction t = t_util.t_startTransaction();
    try {
        ContainerHandle c = t_util.t_openContainer(t, 0, cid, true);
        Page page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
        int optimisticNumcol = (int) ((RawStoreFactory.PAGE_SIZE_MINIMUM * 8) / (10 * 20));
        T_RawStoreRow bigrow = new T_RawStoreRow(optimisticNumcol);
        for (int i = 0; i < optimisticNumcol; i++) bigrow.setColumn(i, (String) null);
        page.fetchFromSlot((RecordHandle) null, 0, bigrow.getRow(), (FetchDescriptor) null, false);
        Storable column;
        // the original 20 char string
        String string1 = "01234567890123456789";
        for (int i = 0; i < numcol; i++) {
            column = bigrow.getStorableColumn(i);
            if (!(column.toString().equals(string1)))
                throw T_Fail.testFailMsg("Column " + i + " value incorrect, got :" + column.toString());
        }
        for (int i = numcol; i < optimisticNumcol; i++) {
            column = bigrow.getStorableColumn(i);
            if (!column.isNull())
                throw T_Fail.testFailMsg("Column " + i + " expect Null, got : " + column.toString());
        }
        REPORT("RTest5 passed");
    } finally {
        t_util.t_commit(t);
        t.close();
    }
}
Also used : Storable(org.apache.derby.iapi.services.io.Storable)

Example 9 with Storable

use of org.apache.derby.iapi.services.io.Storable in project derby by apache.

the class T_RecoverBadLog method RTest2.

/*
	 * test recovery of test 2
	 */
void RTest2() throws T_Fail, StandardException {
    long cid = find(key(2, 1));
    if (cid < 0) {
        REPORT("bad log test2 not run");
        return;
    }
    int numcol = (int) find(key(2, 2));
    Transaction t = t_util.t_startTransaction();
    try {
        ContainerHandle c = t_util.t_openContainer(t, 0, cid, true);
        Page page = t_util.t_getPage(c, ContainerHandle.FIRST_PAGE_NUMBER);
        int optimisticNumcol = (int) ((RawStoreFactory.PAGE_SIZE_MINIMUM * 8) / (10 * 20));
        T_RawStoreRow bigrow = new T_RawStoreRow(optimisticNumcol);
        for (int i = 0; i < optimisticNumcol; i++) bigrow.setColumn(i, (String) null);
        page.fetchFromSlot((RecordHandle) null, 0, bigrow.getRow(), (FetchDescriptor) null, false);
        Storable column;
        // the original 20 char string
        String string1 = "01234567890123456789";
        for (int i = 0; i < numcol; i++) {
            column = bigrow.getStorableColumn(i);
            if (!(column.toString().equals(string1)))
                throw T_Fail.testFailMsg("Column " + i + " value incorrect, got :" + column.toString());
        }
        for (int i = numcol; i < optimisticNumcol; i++) {
            column = bigrow.getStorableColumn(i);
            if (!column.isNull())
                throw T_Fail.testFailMsg("Column " + i + " expect Null, got : " + column.toString());
        }
        REPORT("RTest2 passed");
    } finally {
        t_util.t_commit(t);
        t.close();
    }
}
Also used : Storable(org.apache.derby.iapi.services.io.Storable)

Example 10 with Storable

use of org.apache.derby.iapi.services.io.Storable in project derby by apache.

the class T_StreamFile method SF002.

// this test test the rowSource over head.
// when param set to 1, also gets the overhead for writeExternal for Storables
protected void SF002(int param) throws StandardException, T_Fail {
    T_RowSource rowSource = new T_RowSource(500000, 13, 2, false, null);
    DynamicByteArrayOutputStream out = new DynamicByteArrayOutputStream(16384);
    FormatIdOutputStream logicalDataOut = new FormatIdOutputStream(out);
    long startms = System.currentTimeMillis();
    System.out.println("starting rowSource test, time: " + startms);
    try {
        FormatableBitSet validColumns = rowSource.getValidColumns();
        int numberFields = 0;
        if (validColumns != null) {
            for (int i = validColumns.size() - 1; i >= 0; i--) {
                if (validColumns.get(i)) {
                    numberFields = i + 1;
                    break;
                }
            }
        }
        DataValueDescriptor[] row = rowSource.getNextRowFromRowSource();
        while (row != null) {
            if (SanityManager.DEBUG) {
                SanityManager.ASSERT(row != null, "RowSource returned null");
            }
            int arrayPosition = -1;
            for (int i = 0; i < numberFields; i++) {
                // write each column out
                if (validColumns.get(i)) {
                    arrayPosition++;
                    DataValueDescriptor column = row[arrayPosition];
                    if (param == 1) {
                        try {
                            Storable sColumn = (Storable) column;
                            if (!sColumn.isNull()) {
                                sColumn.writeExternal(logicalDataOut);
                                out.reset();
                            }
                        } catch (IOException ioe) {
                            throw T_Fail.exceptionFail(ioe);
                        }
                    }
                }
            }
            row = rowSource.getNextRowFromRowSource();
        }
    } finally {
    }
    long endms = System.currentTimeMillis();
    long time2 = endms - startms;
    if (param != 1)
        System.out.println("ended rowSource test, time: " + endms + ", time spent = " + time2);
    else
        System.out.println("------ writeExternal called....\n ended rowSource test, time: " + endms + ", time spent = " + time2);
    PASS("SF002");
}
Also used : DynamicByteArrayOutputStream(org.apache.derby.iapi.services.io.DynamicByteArrayOutputStream) FormatableBitSet(org.apache.derby.iapi.services.io.FormatableBitSet) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) FormatIdOutputStream(org.apache.derby.iapi.services.io.FormatIdOutputStream) Storable(org.apache.derby.iapi.services.io.Storable)

Aggregations

Storable (org.apache.derby.iapi.services.io.Storable)11 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)3 StreamStorable (org.apache.derby.iapi.services.io.StreamStorable)2 BufferedInputStream (java.io.BufferedInputStream)1 EOFException (java.io.EOFException)1 Externalizable (java.io.Externalizable)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InvalidClassException (java.io.InvalidClassException)1 List (java.util.List)1 DynamicByteArrayOutputStream (org.apache.derby.iapi.services.io.DynamicByteArrayOutputStream)1 FormatIdInputStream (org.apache.derby.iapi.services.io.FormatIdInputStream)1 FormatIdOutputStream (org.apache.derby.iapi.services.io.FormatIdOutputStream)1 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)1 LimitInputStream (org.apache.derby.iapi.services.io.LimitInputStream)1 StatementContext (org.apache.derby.iapi.sql.conn.StatementContext)1 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)1 KeyHasher (org.apache.derby.iapi.store.access.KeyHasher)1 Qualifier (org.apache.derby.iapi.store.access.Qualifier)1 DataValueFactory (org.apache.derby.iapi.types.DataValueFactory)1