PagesHashStrategy expectedHashStrategy = new SimplePagesHashStrategy(types, channels, Ints.asList(1, 2, 3, 4));
// verify hashStrategy is consistent with equals and hash code from block
for (int leftBlockIndex = 0; leftBlockIndex < varcharChannel.size(); leftBlockIndex++) {
PageBuilder pageBuilder = new PageBuilder(types);
int leftPositionCount = varcharChannel.get(leftBlockIndex).getPositionCount();
for (int leftBlockPosition = 0; leftBlockPosition < leftPositionCount; leftBlockPosition++) {
// hash code of position must match block hash
assertEquals(
hashStrategy.hashPosition(leftBlockIndex, leftBlockPosition),
expectedHashStrategy.hashPosition(leftBlockIndex, leftBlockPosition));
// position must be equal to itself
assertTrue(hashStrategy.positionEqualsPosition(leftBlockIndex, leftBlockPosition, leftBlockIndex, leftBlockPosition));
// check equality of every position against every other position in the block
for (int rightBlockIndex = 0; rightBlockIndex < varcharChannel.size(); rightBlockIndex++) {
Block rightBlock = varcharChannel.get(rightBlockIndex);
for (int rightBlockPosition = 0; rightBlockPosition < rightBlock.getPositionCount(); rightBlockPosition++) {
assertEquals(
hashStrategy.positionEqualsPosition(leftBlockIndex, leftBlockPosition, rightBlockIndex, rightBlockPosition),
expectedHashStrategy.positionEqualsPosition(leftBlockIndex, leftBlockPosition, rightBlockIndex, rightBlockPosition));
}
}
// check equality of every position against every other position in the block cursor
for (int rightBlockIndex = 0; rightBlockIndex < varcharChannel.size(); rightBlockIndex++) {
Block[] rightBlocks = new Block[4];
rightBlocks[0] = varcharChannel.get(rightBlockIndex);
rightBlocks[1] = longChannel.get(rightBlockIndex);
rightBlocks[2] = doubleChannel.get(rightBlockIndex);
rightBlocks[3] = booleanChannel.get(rightBlockIndex);
int rightPositionCount = varcharChannel.get(rightBlockIndex).getPositionCount();
for (int rightPosition = 0; rightPosition < rightPositionCount; rightPosition++) {
assertEquals(
hashStrategy.positionEqualsRow(leftBlockIndex, leftBlockPosition, rightPosition, rightBlocks),
expectedHashStrategy.positionEqualsRow(leftBlockIndex, leftBlockPosition, rightPosition, rightBlocks));
}
}
// write position to output block
hashStrategy.appendTo(leftBlockIndex, leftBlockPosition, pageBuilder, 0);
}
// verify output block matches
Page page = pageBuilder.build();
assertPageEquals(types, page, new Page(
extraChannel.get(leftBlockIndex),
varcharChannel.get(leftBlockIndex),
longChannel.get(leftBlockIndex),
doubleChannel.get(leftBlockIndex),