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;
}
Aggregations