Block taxBlock,
Block shipDateBlock)
{
int rows = returnFlagBlock.getPositionCount();
BlockCursor returnFlagCursor = returnFlagBlock.cursor();
BlockCursor lineStatusCursor = lineStatusBlock.cursor();
BlockCursor quantityCursor = quantityBlock.cursor();
BlockCursor extendedPriceCursor = extendedPriceBlock.cursor();
BlockCursor discountCursor = discountBlock.cursor();
BlockCursor taxCursor = taxBlock.cursor();
BlockCursor shipDateCursor = shipDateBlock.cursor();
for (int position = 0; position < rows; position++) {
checkState(returnFlagCursor.advanceNextPosition());
checkState(lineStatusCursor.advanceNextPosition());
checkState(quantityCursor.advanceNextPosition());
checkState(extendedPriceCursor.advanceNextPosition());
checkState(discountCursor.advanceNextPosition());
checkState(taxCursor.advanceNextPosition());
checkState(shipDateCursor.advanceNextPosition());
if (shipDateCursor.isNull()) {
continue;
}
Slice shipDate = shipDateCursor.getSlice();
// where
// shipdate <= '1998-09-02'
if (shipDate.compareTo(MAX_SHIP_DATE) <= 0) {
// returnflag,
// linestatus
// quantity
// extendedprice
// extendedprice * (1 - discount)
// extendedprice * (1 - discount) * (1 + tax)
// discount
if (returnFlagCursor.isNull()) {
pageBuilder.getBlockBuilder(0).appendNull();
}
else {
pageBuilder.getBlockBuilder(0).appendSlice(returnFlagCursor.getSlice());
}
if (lineStatusCursor.isNull()) {
pageBuilder.getBlockBuilder(1).appendNull();
}
else {
pageBuilder.getBlockBuilder(1).appendSlice(lineStatusCursor.getSlice());
}
long quantity = quantityCursor.getLong();
double extendedPrice = extendedPriceCursor.getDouble();
double discount = discountCursor.getDouble();
double tax = taxCursor.getDouble();
boolean quantityIsNull = quantityCursor.isNull();
boolean extendedPriceIsNull = extendedPriceCursor.isNull();
boolean discountIsNull = discountCursor.isNull();
boolean taxIsNull = taxCursor.isNull();
if (quantityIsNull) {
pageBuilder.getBlockBuilder(2).appendNull();
}
else {
pageBuilder.getBlockBuilder(2).appendLong(quantity);
}
if (extendedPriceIsNull) {
pageBuilder.getBlockBuilder(3).appendNull();
}
else {
pageBuilder.getBlockBuilder(3).appendDouble(extendedPrice);
}
if (extendedPriceIsNull || discountIsNull) {
pageBuilder.getBlockBuilder(4).appendNull();
}
else {
pageBuilder.getBlockBuilder(4).appendDouble(extendedPrice * (1 - discount));
}
if (extendedPriceIsNull || discountIsNull || taxIsNull) {
pageBuilder.getBlockBuilder(5).appendNull();
}
else {
pageBuilder.getBlockBuilder(5).appendDouble(extendedPrice * (1 - discount) * (1 + tax));
}
if (discountIsNull) {
pageBuilder.getBlockBuilder(6).appendNull();
}
else {
pageBuilder.getBlockBuilder(6).appendDouble(discount);
}
}
}
checkState(!returnFlagCursor.advanceNextPosition());
checkState(!lineStatusCursor.advanceNextPosition());
checkState(!quantityCursor.advanceNextPosition());
checkState(!extendedPriceCursor.advanceNextPosition());
checkState(!discountCursor.advanceNextPosition());
checkState(!taxCursor.advanceNextPosition());
checkState(!shipDateCursor.advanceNextPosition());
}