### Question:
PrestoThriftBigint implements PrestoThriftColumnData { @Override public Block toBlock(Type desiredType) { checkArgument(BIGINT.equals(desiredType), "type doesn't match: %s", desiredType); int numberOfRecords = numberOfRecords(); return new LongArrayBlock( numberOfRecords, Optional.ofNullable(nulls), longs == null ? new long[numberOfRecords] : longs); } @ThriftConstructor  PrestoThriftBigint(
            @ThriftField(name = "nulls") @Nullable boolean[] nulls,
            @ThriftField(name = "longs") @Nullable long[] longs); @Nullable @ThriftField(value = 1, requiredness = OPTIONAL) boolean[] getNulls(); @Nullable @ThriftField(value = 2, requiredness = OPTIONAL) long[] getLongs(); @Override Block toBlock(Type desiredType); @Override int numberOfRecords(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static PrestoThriftBlock fromBlock(Block block); static PrestoThriftBlock fromRecordSetColumn(RecordSet recordSet, int columnIndex, int totalRecords);  }### Answer:
@Test public void testReadBlock() { PrestoThriftBlock columnsData = longColumn( new boolean[] {false, true, false, false, false, false, true}, new long[] {2, 0, 1, 3, 8, 4, 0}); Block actual = columnsData.toBlock(BIGINT); assertBlockEquals(actual, list(2L, null, 1L, 3L, 8L, 4L, null)); }
@Test public void testReadBlockAllNullsOption1() { PrestoThriftBlock columnsData = longColumn( new boolean[] {true, true, true, true, true, true, true}, null); Block actual = columnsData.toBlock(BIGINT); assertBlockEquals(actual, list(null, null, null, null, null, null, null)); }
@Test public void testReadBlockAllNullsOption2() { PrestoThriftBlock columnsData = longColumn( new boolean[] {true, true, true, true, true, true, true}, new long[] {0, 0, 0, 0, 0, 0, 0}); Block actual = columnsData.toBlock(BIGINT); assertBlockEquals(actual, list(null, null, null, null, null, null, null)); }
@Test public void testReadBlockAllNonNullOption1() { PrestoThriftBlock columnsData = longColumn( null, new long[] {2, 7, 1, 3, 8, 4, 5}); Block actual = columnsData.toBlock(BIGINT); assertBlockEquals(actual, list(2L, 7L, 1L, 3L, 8L, 4L, 5L)); }
@Test public void testReadBlockAllNonNullOption2() { PrestoThriftBlock columnsData = longColumn( new boolean[] {false, false, false, false, false, false, false}, new long[] {2, 7, 1, 3, 8, 4, 5}); Block actual = columnsData.toBlock(BIGINT); assertBlockEquals(actual, list(2L, 7L, 1L, 3L, 8L, 4L, 5L)); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testReadBlockWrongActualType() { PrestoThriftBlock columnsData = integerData(new PrestoThriftInteger(null, null)); columnsData.toBlock(BIGINT); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testReadBlockWrongDesiredType() { PrestoThriftBlock columnsData = longColumn(null, null); columnsData.toBlock(INTEGER); }