@Override public void close() { if (null != dataBlockIterator) { dataBlockIterator.close(); } try { fileReader.finish(); } catch (IOException e) { LOGGER.error(e); } }
private DataBlockIterator getDataBlockIterator() { if (blockExecutionInfos.size() > 0) { try { fileReader.finish(); } catch (IOException e) { throw new RuntimeException(e); } BlockExecutionInfo executionInfo = blockExecutionInfos.get(0); blockExecutionInfos.remove(executionInfo); return new DataBlockIterator(executionInfo, fileReader, batchSize, queryStatisticsModel, execService); } return null; }
@Override public List<ColumnSchema> getSchema(TableBlockInfo tableBlockInfo) throws IOException { FileReader fileReader = null; List<ColumnSchema> columnSchemaList = new ArrayList<ColumnSchema>(); try { long completeBlockLength = tableBlockInfo.getBlockLength(); long footerPointer = completeBlockLength - 8; fileReader = FileFactory.getFileHolder(FileFactory.getFileType(tableBlockInfo.getFilePath())); long actualFooterOffset = fileReader.readLong(tableBlockInfo.getFilePath(), footerPointer); CarbonFooterReader reader = new CarbonFooterReader(tableBlockInfo.getFilePath(), actualFooterOffset); FileFooter footer = reader.readFooter(); List<org.apache.carbondata.format.ColumnSchema> table_columns = footer.getTable_columns(); for (int i = 0; i < table_columns.size(); i++) { columnSchemaList.add(thriftColumnSchemaToWrapperColumnSchema(table_columns.get(i))); } } finally { if (null != fileReader) { fileReader.finish(); } } return columnSchemaList; } }
/** * The method calculate the B-Tree metadata size. * * @param tableBlockInfo * @return */ public static long calculateMetaSize(TableBlockInfo tableBlockInfo) throws IOException { FileReader fileReader = null; try { long completeBlockLength = tableBlockInfo.getBlockLength(); long footerPointer = completeBlockLength - 8; String filePath = tableBlockInfo.getFilePath(); fileReader = FileFactory.getFileHolder(FileFactory.getFileType(filePath)); long actualFooterOffset = fileReader.readLong(filePath, footerPointer); return footerPointer - actualFooterOffset; } finally { if (null != fileReader) { try { fileReader.finish(); } catch (IOException e) { // ignore the exception as nothing we can do about it fileReader = null; } } } }
/** * This method return the version details in formatted string by reading from carbondata file * * @param dataFilePath * @return * @throws IOException */ public static String getVersionDetails(String dataFilePath) throws IOException { long fileSize = FileFactory.getCarbonFile(dataFilePath, FileFactory.getFileType(dataFilePath)).getSize(); FileReader fileReader = FileFactory.getFileHolder(FileFactory.getFileType(dataFilePath)); ByteBuffer buffer = fileReader.readByteBuffer(FileFactory.getUpdatedFilePath(dataFilePath), fileSize - 8, 8); fileReader.finish(); CarbonFooterReaderV3 footerReader = new CarbonFooterReaderV3(dataFilePath, buffer.getLong()); FileFooter3 footer = footerReader.readFooterVersion3(); if (null != footer.getExtra_info()) { return footer.getExtra_info().get(CarbonCommonConstants.CARBON_WRITTEN_BY_FOOTER_INFO) + " in version: " + footer.getExtra_info() .get(CarbonCommonConstants.CARBON_WRITTEN_VERSION); } else { return "Version Details are not found in carbondata file"; } } }
} finally { if (null != fileReader) { fileReader.finish();
public void scan() throws Exception { BlockletScannedResult blockletScannedResult = null; while (blockletIterator.hasNext()) { DataRefNode dataBlock = blockletIterator.next(); if (dataBlock.getColumnsMaxValue() == null || blockletScanner.isScanRequired(dataBlock)) { RawBlockletColumnChunks rawBlockletColumnChunks = RawBlockletColumnChunks.newInstance( blockExecutionInfo.getTotalNumberDimensionToRead(), blockExecutionInfo.getTotalNumberOfMeasureToRead(), fileReader, dataBlock); blockletScanner.readBlocklet(rawBlockletColumnChunks); blockletScannedResult = blockletScanner.scanBlocklet(rawBlockletColumnChunks); if (blockletScannedResult != null && blockletScannedResult.hasNext()) { scannedResults.add(blockletScannedResult); } } } fileReader.finish(); }