Search in sources :

Example 1 with CarbonIndexFileWriter

use of org.apache.carbondata.core.writer.CarbonIndexFileWriter in project carbondata by apache.

the class AbstractFactDataWriter method writeIndexFile.

/**
   * Below method will be used to write the idex file
   *
   * @throws IOException               throws io exception if any problem while writing
   * @throws CarbonDataWriterException data writing
   */
protected void writeIndexFile() throws IOException, CarbonDataWriterException {
    // get the header
    IndexHeader indexHeader = CarbonMetadataUtil.getIndexHeader(localCardinality, thriftColumnSchemaList, dataWriterVo.getBucketNumber());
    // get the block index info thrift
    List<BlockIndex> blockIndexThrift = CarbonMetadataUtil.getBlockIndexInfo(blockIndexInfoList);
    String fileName = dataWriterVo.getStoreLocation() + File.separator + carbonTablePath.getCarbonIndexFileName(dataWriterVo.getCarbonDataFileAttributes().getTaskId(), dataWriterVo.getBucketNumber(), dataWriterVo.getTaskExtension(), "" + dataWriterVo.getCarbonDataFileAttributes().getFactTimeStamp());
    CarbonIndexFileWriter writer = new CarbonIndexFileWriter();
    // open file
    writer.openThriftWriter(fileName);
    // write the header first
    writer.writeThrift(indexHeader);
    // write the indexes
    for (BlockIndex blockIndex : blockIndexThrift) {
        writer.writeThrift(blockIndex);
    }
    writer.close();
    // copy from temp to actual store location
    copyCarbonDataFileToCarbonStorePath(fileName);
}
Also used : IndexHeader(org.apache.carbondata.format.IndexHeader) CarbonIndexFileWriter(org.apache.carbondata.core.writer.CarbonIndexFileWriter) BlockIndex(org.apache.carbondata.format.BlockIndex)

Aggregations

CarbonIndexFileWriter (org.apache.carbondata.core.writer.CarbonIndexFileWriter)1 BlockIndex (org.apache.carbondata.format.BlockIndex)1 IndexHeader (org.apache.carbondata.format.IndexHeader)1