Search in sources :

Example 1 with NullOutputStream

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

the class D_StoredPage method checkSlotTable.

/**
 *		Checks the slot table.
 *        <p>
 *
 *		1) checks the number of slot entries matches the record count
 *		2) checks the slot table lengths match the field lengths
 *
 *	    @exception  StandardException  Standard exception policy.
 */
public boolean checkSlotTable(PrintStream out) throws StandardException, IOException {
    boolean ok = true;
    int slotCount = page.getSlotsInUse();
    int recordCount = page.recordCount();
    if (slotCount != recordCount) {
        out.println("CORRUPT PAGE: slot count mismatch: slot count " + slotCount + " record count " + recordCount);
        ok = false;
    }
    for (int slot = 0; slot < slotCount; slot++) {
        int recordLength = page.getRecordPortionLength(slot);
        CounterOutputStream counter = new CounterOutputStream();
        counter.setOutputStream(new NullOutputStream());
        int recordId = page.fetchFromSlot(null, slot, new DataValueDescriptor[0], (FetchDescriptor) null, true).getId();
        page.logRecord(slot, page.LOG_RECORD_DEFAULT, recordId, (FormatableBitSet) null, counter, (RecordHandle) null);
        int actualLength = counter.getCount();
        if (actualLength != recordLength) {
            out.println("CORRUPT PAGE: record length mismatch at slot " + slot);
            out.println("              slot entry length " + recordLength);
            out.println("              actual     length " + actualLength);
            ok = false;
        }
    }
    return ok;
}
Also used : CounterOutputStream(org.apache.derby.iapi.services.io.CounterOutputStream) FetchDescriptor(org.apache.derby.iapi.store.raw.FetchDescriptor) DataValueDescriptor(org.apache.derby.iapi.types.DataValueDescriptor) NullOutputStream(org.apache.derby.iapi.services.io.NullOutputStream)

Aggregations

CounterOutputStream (org.apache.derby.iapi.services.io.CounterOutputStream)1 NullOutputStream (org.apache.derby.iapi.services.io.NullOutputStream)1 FetchDescriptor (org.apache.derby.iapi.store.raw.FetchDescriptor)1 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)1