private static class WriteByteArrayMapper extends Mapper<LongWritable, Text, Void, HAWQRecord> { private HAWQRecord record = HAWQParquetOutputFormat.newRecord(); @Override protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { Integer recordNum = Integer.parseInt(value.toString()); try { for (int i = 0; i < recordNum; i++) { record.reset(); record.setBytes(1, String.format("hello %d", i).getBytes()); context.write(null, record); } } catch (HAWQException e) { throw new IOException(e); } } }
private static class WriteFloatingNumberMapper extends Mapper<LongWritable, Text, Void, HAWQRecord> { private HAWQRecord record = HAWQParquetOutputFormat.newRecord(); @Override protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { Integer recordNum = Integer.parseInt(value.toString()); try { for (int i = 0; i < recordNum; i++) { record.reset(); record.setFloat(1, 1.0f * i); record.setDouble(2, 2 * Math.PI * i); context.write(null, record); } } catch (HAWQException e) { throw new IOException(e); } } }
private static class WriteIntMapper extends Mapper<LongWritable, Text, Void, HAWQRecord> { private HAWQRecord record = HAWQParquetOutputFormat.newRecord(); @Override protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException { Integer recordNum = Integer.parseInt(value.toString()); try { for (int i = 0; i < recordNum; i++) { record.reset(); record.setShort(1, (short) (i + 1)); if (i % 2 == 0) { record.setInt(2, i); } record.setLong(3, i * 100); context.write(null, record); } } catch (HAWQException e) { throw new IOException(e); } } }