Skip to content

Commit

Permalink
remove redundant local variable
Browse files Browse the repository at this point in the history
  • Loading branch information
QiangCai authored and jackylk committed Apr 9, 2017
1 parent dbc5262 commit af62a29
Show file tree
Hide file tree
Showing 44 changed files with 94 additions and 186 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ private Iterator<byte[]> load(ColumnIdentifier columnIdentifier, long startOffse
throws IOException {
CarbonDictionaryReader dictionaryReader = getDictionaryReader(columnIdentifier);
try {
Iterator<byte[]> columnDictionaryChunkWrapper = dictionaryReader.read(startOffset, endOffset);
return columnDictionaryChunkWrapper;
return dictionaryReader.read(startOffset, endOffset);
} finally {
dictionaryReader.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,10 @@ private int findAvailableHop(int value) {
*/
private int conflict(int start, int bKey) {
int from = start;
int newKey = bKey;
TreeSet<Integer> children = getChildren(from);
children.add(new Integer(newKey));
children.add(new Integer(bKey));
int newBasePos = findFreeRoom(children);
children.remove(new Integer(newKey));
children.remove(new Integer(bKey));

int oldBasePos = base[start];
base[start] = newBasePos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ public ReverseDictionaryCache(String carbonStorePath, CarbonLRUCache carbonLRUCa
for (final DictionaryColumnUniqueIdentifier uniqueIdent : dictionaryColumnUniqueIdentifiers) {
taskSubmitList.add(executorService.submit(new Callable<Dictionary>() {
@Override public Dictionary call() throws IOException {
Dictionary dictionary = getDictionary(uniqueIdent);
return dictionary;
return getDictionary(uniqueIdent);
}
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,10 @@ public String getUniqueTableBlockName() {
BlockInfo blockInfo = new BlockInfo(this.tableBlockInfo);
CarbonTableIdentifier carbonTableIdentifier =
this.absoluteTableIdentifier.getCarbonTableIdentifier();
String uniqueTableBlockName = carbonTableIdentifier.getDatabaseName()
return carbonTableIdentifier.getDatabaseName()
+ CarbonCommonConstants.FILE_SEPARATOR + carbonTableIdentifier
.getDatabaseName() + CarbonCommonConstants.FILE_SEPARATOR
+ this.tableBlockInfo.getSegmentId()
+ CarbonCommonConstants.FILE_SEPARATOR + blockInfo.hashCode();
return uniqueTableBlockName;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ public static DataOutputStream getDataOutputStream(String path, FileType fileTyp
case VIEWFS:
Path pt = new Path(path);
FileSystem fs = pt.getFileSystem(configuration);
FSDataOutputStream stream = fs.create(pt, true);
return stream;
return fs.create(pt, true);
default:
return new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path)));
}
Expand Down Expand Up @@ -244,9 +243,7 @@ public static DataOutputStream getDataOutputStream(String path, FileType fileTyp
case VIEWFS:
Path pt = new Path(path);
FileSystem fs = pt.getFileSystem(configuration);
FSDataOutputStream stream =
fs.create(pt, true, bufferSize, fs.getDefaultReplication(pt), blockSize);
return stream;
return fs.create(pt, true, bufferSize, fs.getDefaultReplication(pt), blockSize);
default:
path = getUpdatedFilePath(path, fileType);
return new DataOutputStream(
Expand Down Expand Up @@ -402,8 +399,7 @@ public static DataOutputStream getDataOutputStreamUsingAppend(String path, FileT
case VIEWFS:
Path pt = new Path(path);
FileSystem fs = pt.getFileSystem(configuration);
FSDataOutputStream stream = fs.append(pt);
return stream;
return fs.append(pt);
default:
return new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ private int generateDirectSurrogateKeyForNonTimestampType(String memberStr) {

private int generateKey(long timeValue) {
long milli = timeValue + threadLocalLocalTimeZone.get().getOffset(timeValue);
int key = (int) Math.floor((double) milli / MILLIS_PER_DAY) + cutOffDate;
return key;
return (int) Math.floor((double) milli / MILLIS_PER_DAY) + cutOffDate;
}

public void initialize() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,8 @@ public int getDimCount() {
* {start, end}
*/
public int[] getKeyByteOffsets(int index) {
int prefixPaddingBits = length % 8 == 0 ? 0 : (8 - length % 8);

int priorLen = prefixPaddingBits;
int priorLen = length % 8 == 0 ? 0 : (8 - length % 8);
int start = 0;
int end = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,9 @@ protected long[] get(byte[] keys, int wsize) {
}

public int[] unCompress(byte[] key, int offset, int length) {
int ls = length;
int arrayLength = (ls * BYTE_LENGTH) / bitsLength;
long[] words = new long[getWordsSizeFromBytesSize(ls)];
unCompressVal(key, ls, words, offset);
int arrayLength = (length * BYTE_LENGTH) / bitsLength;
long[] words = new long[getWordsSizeFromBytesSize(length)];
unCompressVal(key, length, words, offset);
return getArray(words, arrayLength);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,7 @@ public static void cleanStaleDeltaFiles(CarbonTable table, final String timeStam
*/
public static Long getTimeStampAsLong(String timtstamp) {
try {
long longValue = Long.parseLong(timtstamp);
return longValue;
return Long.parseLong(timtstamp);
} catch (NumberFormatException nfe) {
String errorMsg = "Invalid timestamp : " + timtstamp;
LOGGER.error(errorMsg);
Expand All @@ -358,8 +357,7 @@ public static Long getTimeStampAsLong(String timtstamp) {
*/
public static Integer getIntegerValue(String value) throws Exception {
try {
int intValue = Integer.parseInt(value);
return intValue;
return Integer.parseInt(value);
} catch (NumberFormatException nfe) {
LOGGER.error("Invalid row : " + value + nfe.getLocalizedMessage());
throw new Exception("Invalid row : " + nfe.getLocalizedMessage());
Expand All @@ -373,9 +371,8 @@ public static Integer getIntegerValue(String value) throws Exception {
* @return
*/
public static String getBlockName(String completeBlockName) {
String blockName =
completeBlockName.substring(0, completeBlockName.lastIndexOf(CarbonCommonConstants.HYPHEN));
return blockName;
return completeBlockName
.substring(0, completeBlockName.lastIndexOf(CarbonCommonConstants.HYPHEN));
}

/**
Expand All @@ -385,8 +382,7 @@ public static String getBlockName(String completeBlockName) {
* @return
*/
public static String getSegmentId(String segmentName) {
String id = segmentName.split(CarbonCommonConstants.UNDERSCORE)[1];
return id;
return segmentName.split(CarbonCommonConstants.UNDERSCORE)[1];
}

public static int getLatestTaskIdForSegment(String segmentId, CarbonTablePath tablePath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ public CarbonDictionaryMetadataReaderImpl(String storePath,
dictionaryChunkMeta = (ColumnDictionaryChunkMeta) dictionaryMetadataFileReader.read();
}
// create a new instance of chunk meta wrapper using thrift object
CarbonDictionaryColumnMetaChunk columnMetaChunkForLastSegment =
getNewInstanceOfCarbonDictionaryColumnMetaChunk(dictionaryChunkMeta);
return columnMetaChunkForLastSegment;
return getNewInstanceOfCarbonDictionaryColumnMetaChunk(dictionaryChunkMeta);
}

/**
Expand Down Expand Up @@ -190,10 +188,8 @@ private void openThriftReader() throws IOException {
*/
private CarbonDictionaryColumnMetaChunk getNewInstanceOfCarbonDictionaryColumnMetaChunk(
ColumnDictionaryChunkMeta dictionaryChunkMeta) {
CarbonDictionaryColumnMetaChunk columnMetaChunk =
new CarbonDictionaryColumnMetaChunk(dictionaryChunkMeta.getMin_surrogate_key(),
dictionaryChunkMeta.getMax_surrogate_key(), dictionaryChunkMeta.getStart_offset(),
dictionaryChunkMeta.getEnd_offset(), dictionaryChunkMeta.getChunk_count());
return columnMetaChunk;
return new CarbonDictionaryColumnMetaChunk(dictionaryChunkMeta.getMin_surrogate_key(),
dictionaryChunkMeta.getMax_surrogate_key(), dictionaryChunkMeta.getStart_offset(),
dictionaryChunkMeta.getEnd_offset(), dictionaryChunkMeta.getChunk_count());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ public class CarbonIndexFileReader {
* @throws IOException if any problem while reader the header
*/
public IndexHeader readIndexHeader() throws IOException {
IndexHeader indexHeader = (IndexHeader) thriftReader.read(new ThriftReader.TBaseCreator() {
return (IndexHeader) thriftReader.read(new ThriftReader.TBaseCreator() {
@Override public TBase create() {
return new IndexHeader();
}
});
return indexHeader;
}

/**
Expand All @@ -62,12 +61,11 @@ public void closeThriftReader() {
* @throws IOException if problem while reading the block index
*/
public BlockIndex readBlockIndexInfo() throws IOException {
BlockIndex blockInfo = (BlockIndex) thriftReader.read(new ThriftReader.TBaseCreator() {
return (BlockIndex) thriftReader.read(new ThriftReader.TBaseCreator() {
@Override public TBase create() {
return new BlockIndex();
}
});
return blockInfo;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ public void setDataType(DataType dataType) {
}

@Override public ExpressionResult evaluate(RowIntf value) {
ExpressionResult expressionResult =
new ExpressionResult(dataType, (null == value ? null : value.getVal(colIndex)));
return expressionResult;
return new ExpressionResult(dataType, (null == value ? null : value.getVal(colIndex)));
}

@Override public ExpressionType getFilterExpressionType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ public LiteralExpression(Object value, DataType dataType) {
}

@Override public ExpressionResult evaluate(RowIntf value) {
ExpressionResult expressionResult = new ExpressionResult(dataType, this.value, true);
return expressionResult;
return new ExpressionResult(dataType, this.value, true);
}

public ExpressionResult getExpressionResult() {
ExpressionResult expressionResult = new ExpressionResult(dataType, this.value, true);
return expressionResult;
return new ExpressionResult(dataType, this.value, true);
}

@Override public ExpressionType getFilterExpressionType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,7 @@ private int readSurrogatesFromColumnBlock(BlocksChunkHolder blockChunkHolder, in
if (dimColumnEvaluatorInfo.getDimension().isColumnar()) {
byte[] rawData = dataChunk.getChunkData(index);
ByteBuffer byteBuffer = ByteBuffer.allocate(CarbonCommonConstants.INT_SIZE_IN_BYTE);
int dictionaryValue = CarbonUtil.getSurrogateKey(rawData, byteBuffer);
return dictionaryValue;
return CarbonUtil.getSurrogateKey(rawData, byteBuffer);
} else {
return readSurrogatesFromColumnGroupBlock(dataChunk, index, dimColumnEvaluatorInfo);
}
Expand All @@ -444,9 +443,8 @@ private int readSurrogatesFromColumnGroupBlock(DimensionColumnDataChunk chunk, i
long[] result = keyStructureInfo.getKeyGenerator().getKeyArray(colData);
int colGroupId =
QueryUtil.getColumnGroupId(segmentProperties, dimensionBlocksIndex[0]);
int dictionaryValue = (int) result[segmentProperties
return (int) result[segmentProperties
.getColumnGroupMdKeyOrdinal(colGroupId, dimensionBlocksIndex[0])];
return dictionaryValue;
} catch (KeyGenException e) {
LOGGER.error(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ public class ValueBasedFilterExecuterImpl implements FilterExecuter {
@Override public BitSetGroup applyFilter(BlocksChunkHolder blockChunkHolder)
throws FilterUnsupportedException, IOException {

BitSetGroup bitSetGroup = new BitSetGroup(0);
return bitSetGroup;
return new BitSetGroup(0);
}

@Override public BitSet isScanRequired(byte[][] blockMaxValue, byte[][] blockMinValue) {
BitSet bitSet = new BitSet(1);
return bitSet;
return new BitSet(1);
}

@Override public void readBlocks(BlocksChunkHolder blockChunkHolder) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public DetailQueryResultIterator(List<BlockExecutionInfo> infos, QueryModel quer
}

@Override public BatchResult next() {
BatchResult batchResult = getBatchResult();
return batchResult;
return getBatchResult();
}

private BatchResult getBatchResult() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ public CarbonFile[] getDeleteDeltaFilesList(final String segmentId, final String
getStartTimeOfDeltaFile(CarbonCommonConstants.DELETE_DELTA_FILE_EXT, block);
final long deltaEndTimeStamp =
getEndTimeOfDeltaFile(CarbonCommonConstants.DELETE_DELTA_FILE_EXT, block);
CarbonFile[] files = segDir.listFiles(new CarbonFileFilter() {

return segDir.listFiles(new CarbonFileFilter() {

@Override public boolean accept(CarbonFile pathName) {
String fileName = pathName.getName();
Expand All @@ -444,8 +445,6 @@ public CarbonFile[] getDeleteDeltaFilesList(final String segmentId, final String
return false;
}
});

return files;
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -722,9 +722,8 @@ public static String getCarbonStorePath() {
if (null == prop) {
return null;
}
String basePath = prop.getProperty(CarbonCommonConstants.STORE_LOCATION,
return prop.getProperty(CarbonCommonConstants.STORE_LOCATION,
CarbonCommonConstants.STORE_LOCATION_DEFAULT_VAL);
return basePath;
}

/**
Expand Down Expand Up @@ -1055,9 +1054,8 @@ public static boolean[] identifyDimensionType(List<CarbonDimension> tableDimensi
isDictionaryDimensions.add(false);
}
}
boolean[] primitive = ArrayUtils
return ArrayUtils
.toPrimitive(isDictionaryDimensions.toArray(new Boolean[isDictionaryDimensions.size()]));
return primitive;
}

/**
Expand Down Expand Up @@ -1594,14 +1592,13 @@ public static boolean isInvalidTableBlock(TableBlockInfo tableInfo,
return true;
}

UpdateVO updatedVODetails = invalidBlockVOForSegmentId;
if (null != updatedVODetails) {
if (null != invalidBlockVOForSegmentId) {
Long blockTimeStamp = Long.parseLong(tableInfo.getFilePath()
.substring(tableInfo.getFilePath().lastIndexOf('-') + 1,
tableInfo.getFilePath().lastIndexOf('.')));
if ((blockTimeStamp > updatedVODetails.getFactTimestamp() && (
updatedVODetails.getUpdateDeltaStartTimestamp() != null
&& blockTimeStamp < updatedVODetails.getUpdateDeltaStartTimestamp()))) {
if ((blockTimeStamp > invalidBlockVOForSegmentId.getFactTimestamp() && (
invalidBlockVOForSegmentId.getUpdateDeltaStartTimestamp() != null
&& blockTimeStamp < invalidBlockVOForSegmentId.getUpdateDeltaStartTimestamp()))) {
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ public CarbonStorePath(String storePathString) {
*/
public static CarbonTablePath getCarbonTablePath(String storePath,
CarbonTableIdentifier tableIdentifier) {
CarbonTablePath carbonTablePath = new CarbonTablePath(tableIdentifier,
return new CarbonTablePath(tableIdentifier,
storePath + File.separator + tableIdentifier.getDatabaseName() + File.separator
+ tableIdentifier.getTableName());
return carbonTablePath;
}

public static CarbonTablePath getCarbonTablePath(String storePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,12 +557,11 @@ public static String getSegmentId(String dataFileAbsolutePath) {
* @return sort index carbon files
*/
public CarbonFile[] getSortIndexFiles(CarbonFile sortIndexDir, final String columnUniqueId) {
CarbonFile[] files = sortIndexDir.listFiles(new CarbonFileFilter() {
return sortIndexDir.listFiles(new CarbonFileFilter() {
@Override public boolean accept(CarbonFile file) {
return file.getName().startsWith(columnUniqueId) && file.getName().endsWith(SORT_INDEX_EXT);
}
});
return files;
}

/**
Expand All @@ -572,10 +571,9 @@ public CarbonFile[] getSortIndexFiles(CarbonFile sortIndexDir, final String colu
* @return
*/
public static String getCarbonDataFileName(String carbonDataFilePath) {
String carbonDataFileName = carbonDataFilePath
return carbonDataFilePath
.substring(carbonDataFilePath.lastIndexOf(CarbonCommonConstants.FILE_SEPARATOR) + 1,
carbonDataFilePath.indexOf(CARBON_DATA_EXT));
return carbonDataFileName;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,8 @@ protected void removeKeyFromLRUCache(Cache cacheObject) {
protected DictionaryColumnUniqueIdentifier createDictionaryColumnUniqueIdentifier(
String columnId) {
ColumnIdentifier columnIdentifier = new ColumnIdentifier(columnId, null, DataType.STRING);
DictionaryColumnUniqueIdentifier dictionaryColumnUniqueIdentifier =
new DictionaryColumnUniqueIdentifier(carbonTableIdentifier, columnIdentifier,
DataType.STRING);
return dictionaryColumnUniqueIdentifier;
return new DictionaryColumnUniqueIdentifier(carbonTableIdentifier, columnIdentifier,
DataType.STRING);
}

/**
Expand Down
Loading

0 comments on commit af62a29

Please sign in to comment.