Example #1
0
 @Override
 public void run(TaskSource taskSource, Schema schema, FileInput input, PageOutput output) {
   try (final PageBuilder pageBuilder =
       new PageBuilder(Exec.getBufferAllocator(), schema, output)) {
     while (input.nextFile()) {
       Buffer buffer = input.poll();
       if (buffer != null) {
         for (Column column : schema.getColumns()) {
           Type type = column.getType();
           switch (type.getName()) {
             case "boolean":
               pageBuilder.setBoolean(column, true);
               break;
             case "long":
               pageBuilder.setLong(column, 2L);
               break;
             case "double":
               pageBuilder.setDouble(column, 3.0D);
               break;
             case "string":
               pageBuilder.setString(column, "45");
               break;
             case "timestamp":
               pageBuilder.setTimestamp(column, Timestamp.ofEpochMilli(678L));
               break;
             default:
               throw new IllegalStateException("Unknown type: " + type.getName());
           }
         }
         pageBuilder.addRecord();
         if (raiseException) {
           throw new RuntimeException("emulated exception");
         }
       }
     }
     pageBuilder.finish();
   }
 }
Example #2
0
 public void setTimestamp(int columnIndex, Timestamp value) {
   int offset = getOffset(columnIndex);
   bufferSlice.setLong(offset, value.getEpochSecond());
   bufferSlice.setInt(offset + 8, value.getNano());
   clearNull(columnIndex);
 }