@Ignore @Test public void testWrite() throws IOException, SegmentLoadingException {

    final String dataSourceName = "testDataSource";
    final File segmentOutputDir = temporaryFolder.newFolder();
    final File workingDir = temporaryFolder.newFolder();
    Configuration config = new Configuration();

    final InputRowParser
        inputRowParser =
        new MapInputRowParser(new TimeAndDimsParseSpec(new TimestampSpec(DruidConstants.DEFAULT_TIMESTAMP_COLUMN,
            "auto",
            null), new DimensionsSpec(ImmutableList.of(new StringDimensionSchema("host")), null, null)));
    final Map<String, Object>
        parserMap =
        objectMapper.convertValue(inputRowParser, new TypeReference<Map<String, Object>>() {
        });

    DataSchema
        dataSchema =
        new DataSchema(dataSourceName,
            parserMap,
            new AggregatorFactory[] {new LongSumAggregatorFactory("visited_sum", "visited_sum"),
                new HyperUniquesAggregatorFactory("unique_hosts", "unique_hosts") },
            new UniformGranularitySpec(Granularities.DAY, Granularities.NONE, ImmutableList.of(INTERVAL_FULL)),
            null,
            objectMapper);

    IndexSpec indexSpec = new IndexSpec(new RoaringBitmapSerdeFactory(true), null, null, null);
    RealtimeTuningConfig
        tuningConfig =
        new RealtimeTuningConfig(null,
            null, null, null, temporaryFolder.newFolder(), null, null, null, null, indexSpec, null, null, 0, 0, null,
            null, 0L, null, null);
    LocalFileSystem localFileSystem = FileSystem.getLocal(config);
    DataSegmentPusher dataSegmentPusher = new LocalDataSegmentPusher(new LocalDataSegmentPusherConfig() {
      @Override public File getStorageDirectory() {
        return segmentOutputDir;
      }
    });

    Path
        segmentDescriptorPath =
        new Path(workingDir.getAbsolutePath(), DruidStorageHandler.SEGMENTS_DESCRIPTOR_DIR_NAME);
    DruidRecordWriter
        druidRecordWriter =
        new DruidRecordWriter(dataSchema, tuningConfig, dataSegmentPusher, 20, segmentDescriptorPath, localFileSystem);

    List<DruidWritable>
        druidWritables =
        expectedRows.stream()
            .map(input -> new DruidWritable(ImmutableMap.<String, Object>builder().putAll(input)
                .put(Constants.DRUID_TIMESTAMP_GRANULARITY_COL_NAME,
                    Granularities
                        .DAY
                        .bucketStart(new DateTime((long) input.get(DruidConstants.DEFAULT_TIMESTAMP_COLUMN)))
                        .getMillis())
                .build()))
            .collect(Collectors.toList());
    for (DruidWritable druidWritable : druidWritables) {
      druidRecordWriter.write(druidWritable);
    }
    druidRecordWriter.close(false);
    List<DataSegment> dataSegmentList = DruidStorageHandlerUtils.getCreatedSegments(segmentDescriptorPath, config);
    Assert.assertEquals(1, dataSegmentList.size());
    File tmpUnzippedSegmentDir = temporaryFolder.newFolder();
    new LocalDataSegmentPuller().getSegmentFiles(dataSegmentList.get(0), tmpUnzippedSegmentDir);
    final QueryableIndex queryableIndex = DruidStorageHandlerUtils.INDEX_IO.loadIndex(tmpUnzippedSegmentDir);

    QueryableIndexStorageAdapter adapter = new QueryableIndexStorageAdapter(queryableIndex);

    Firehose
        firehose =
        new IngestSegmentFirehose(ImmutableList.of(new WindowedStorageAdapter(adapter, adapter.getInterval())),
            null,
            ImmutableList.of("host"),
            ImmutableList.of("visited_sum", "unique_hosts"),
            null);

    List<InputRow> rows = Lists.newArrayList();
    while (firehose.hasMore()) {
      rows.add(firehose.nextRow());
    }

    verifyRows(expectedRows, rows);

  }
Test Class for Druid Record Writer.
druid-handler/src/test/org/apache/hadoop/hive/ql/io/TestDruidRecordWriter.java