DataValueDescriptor[] template,
int[] keyCols,
DataValueDescriptor[][] rows)
throws StandardException
{
DiskHashtable dht = new DiskHashtable(tc, template, keyCols, removeDups, false);
boolean[] isDuplicate = new boolean[ rows.length];
boolean[] found = new boolean[ rows.length];
HashMap simpleHash = new HashMap( rows.length);
testElements( removeDups, dht, keyCols, 0, rows, simpleHash, isDuplicate, found);
for( int i = 0; i < rows.length; i++)
{
Object key = KeyHasher.buildHashKey( rows[i], keyCols);
Vector al = (Vector) simpleHash.get( key);
isDuplicate[i] = (al != null);
if( al == null)
{
al = new Vector(4);
simpleHash.put( key, al);
}
if( (!removeDups) || !isDuplicate[i])
al.add( rows[i]);
if( dht.put( key, rows[i]) != (removeDups ? (!isDuplicate[i]) : true))
REPORT_FAILURE( " put returned wrong value on row " + i);
for( int j = 0; j <= i; j++)
{
key = KeyHasher.buildHashKey( rows[j], keyCols);
if( ! rowsEqual( dht.get( key), simpleHash.get( key)))
REPORT_FAILURE( " get returned wrong value on key " + j);
}
testElements( removeDups, dht, keyCols, i+1, rows, simpleHash, isDuplicate, found);
}
// Remove them
for( int i = 0; i < rows.length; i++)
{
Object key = KeyHasher.buildHashKey( rows[i], keyCols);
if( ! rowsEqual( dht.remove( key), simpleHash.get( key)))
REPORT_FAILURE( " remove returned wrong value on key " + i);
simpleHash.remove( key);
if( dht.get( key) != null)
REPORT_FAILURE( " remove did not delete key " + i);
}
testElements( removeDups, dht, keyCols, 0, rows, simpleHash, isDuplicate, found);
testLargeTable( dht, keyCols, rows[0]);
dht.close();
} // end of testOneVariant