### Question:
BlockUtils { public static int copyRows(Block srcBlock, Block dstBlock, int firstRow, int lastRow) { if (firstRow > lastRow || lastRow > srcBlock.getRowCount() - 1) { throw new RuntimeException("src has " + srcBlock.getRowCount() + " but requested copy of " + firstRow + " to " + lastRow); } for (FieldReader src : srcBlock.getFieldReaders()) { int dstOffset = dstBlock.getRowCount(); for (int i = firstRow; i <= lastRow; i++) { FieldVector dst = dstBlock.getFieldVector(src.getField().getName()); src.setPosition(i); setValue(dst, dstOffset++, src.readObject()); } } int rowsCopied = 1 + (lastRow - firstRow); dstBlock.setRowCount(dstBlock.getRowCount() + rowsCopied); return rowsCopied; } private  BlockUtils(); static Block newBlock(BlockAllocator allocator, String columnName, ArrowType type, Object... values); static Block newBlock(BlockAllocator allocator, String columnName, ArrowType type, Collection<Object> values); static Block newEmptyBlock(BlockAllocator allocator, String columnName, ArrowType type); static void setComplexValue(FieldVector vector, int pos, FieldResolver resolver, Object value); static void setValue(FieldVector vector, int pos, Object value); static String rowToString(Block block, int row); static String fieldToString(FieldReader reader); static int copyRows(Block srcBlock, Block dstBlock, int firstRow, int lastRow); static boolean isNullRow(Block block, int row); @VisibleForTesting /** * Maps an Arrow Type to a Java class. * @param minorType * @return Java class mapping the Arrow type */ static Class getJavaType(Types.MinorType minorType); static void unsetRow(int row, Block block); static final ZoneId UTC_ZONE_ID; static final org.joda.time.MutableDateTime EPOCH; }### Answer:
@Test public void copyRows() { Schema schema = SchemaBuilder.newBuilder() .addField("col1", new ArrowType.Int(32, true)) .addField("col2", new ArrowType.Decimal(38, 9)) .addField("col3", new ArrowType.Timestamp(org.apache.arrow.vector.types.TimeUnit.MILLISECOND, "UTC")) .build(); LocalDateTime ldt = LocalDateTime.of(2020, 03, 18, 12,54,29); Date date = Date.from(ldt.atZone(ZoneId.systemDefault()).toInstant()); Block src = allocator.createBlock(schema); BlockUtils.setValue(src.getFieldVector("col1"), 0, 10); BlockUtils.setValue(src.getFieldVector("col2"), 0, new BigDecimal(20)); BlockUtils.setValue(src.getFieldVector("col3"), 0, ldt); BlockUtils.setValue(src.getFieldVector("col1"), 1, 11); BlockUtils.setValue(src.getFieldVector("col2"), 1, new BigDecimal(21)); BlockUtils.setValue(src.getFieldVector("col3"), 1, ZonedDateTime.of(ldt, ZoneId.of("-05:00"))); BlockUtils.setValue(src.getFieldVector("col1"), 2, 12); BlockUtils.setValue(src.getFieldVector("col2"), 2, new BigDecimal(22)); BlockUtils.setValue(src.getFieldVector("col3"), 2, date); src.setRowCount(3); Block dst = allocator.createBlock(schema); assertEquals(3, BlockUtils.copyRows(src, dst, 0, 2)); assertEquals(src, dst); }