Skip to content

Commit 500654e

Browse files
sraghunandanjackylk
authored andcommitted
[Review][CARBONDATA-1386] fixed findbugs errors in carbondata-core
fixed findbugs errors in carbondata-core This closes apache#1263
1 parent 2ee7775 commit 500654e

File tree

85 files changed

+663
-699
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+663
-699
lines changed

common/src/main/java/org/apache/carbondata/common/logging/impl/ExtendedRollingFileAppender.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ public boolean accept(File file) {
7474
}
7575
});
7676

77+
if (null == files) {
78+
return;
79+
}
80+
7781
int backupFiles = files.length - 1;
7882

7983
if (backupFiles <= maxBackupIndex) {

core/src/main/java/org/apache/carbondata/core/cache/dictionary/AbstractDictionaryCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private CarbonFile getDictionaryMetaCarbonFile(
173173
protected long getSortIndexSize(long numOfRecords) {
174174
// sort index has sort index and reverse sort index,each is 4 byte integer.
175175
// 32 byte is the array header of both the integer arrays
176-
return numOfRecords * ObjectSizeCalculator.estimate(new Integer(0), 16) * 2 + 32;
176+
return numOfRecords * ObjectSizeCalculator.estimate(0, 16) * 2 + 32;
177177
}
178178

179179
/**

core/src/main/java/org/apache/carbondata/core/cache/dictionary/DoubleArrayTrieDictionary.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
*/
3636

3737
public class DoubleArrayTrieDictionary {
38-
public static final byte[] HEAD_MAGIC = new byte[]{
38+
private static final byte[] HEAD_MAGIC = new byte[]{
3939
0x44, 0x41, 0x54, 0x54, 0x72, 0x69, 0x65, 0x44, 0x69, 0x63, 0x74
4040
}; // "DATTrieDict"
41-
public static final int HEAD_LEN = HEAD_MAGIC.length;
41+
private static final int HEAD_LEN = HEAD_MAGIC.length;
4242

4343
private static final int INIT_CAPA_VALUE = 256; // init len of double array
4444
private static final int BASE_ROOT_VALUE = 1; // root base value of trie root
@@ -168,7 +168,7 @@ private TreeSet<Integer> getChildren(int pos) {
168168
return null;
169169
}
170170
if (check[cpos] == pos) {
171-
children.add(new Integer(i));
171+
children.add(i);
172172
}
173173
}
174174
return children;
@@ -227,9 +227,9 @@ private int findAvailableHop(int value) {
227227
private int conflict(int start, int bKey) {
228228
int from = start;
229229
TreeSet<Integer> children = getChildren(from);
230-
children.add(new Integer(bKey));
230+
children.add(bKey);
231231
int newBasePos = findFreeRoom(children);
232-
children.remove(new Integer(bKey));
232+
children.remove(bKey);
233233

234234
int oldBasePos = base[start];
235235
base[start] = newBasePos;
@@ -351,7 +351,7 @@ public void write(DataOutputStream out) throws IOException {
351351
*/
352352
public void read(DataInputStream in) throws IOException {
353353
byte[] header = new byte[HEAD_LEN];
354-
in.read(header);
354+
in.readFully(header);
355355
int comp = 0;
356356
for (int i = 0; i < HEAD_LEN; i++) {
357357
comp = HEAD_MAGIC[i] - header[i];

core/src/main/java/org/apache/carbondata/core/cache/dictionary/ReverseDictionaryCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class ReverseDictionaryCache<K extends DictionaryColumnUniqueIdentifier,
5858

5959
private static final long sizeOfHashMapNode = ObjectSizeCalculator.estimate(new
6060
DictionaryByteArrayWrapper(new byte[0]), 16) +
61-
ObjectSizeCalculator.estimate(new Integer(0), 16);
61+
ObjectSizeCalculator.estimate(0, 16);
6262

6363
private static final long byteArraySize = ObjectSizeCalculator.estimate(new byte[0], 16);
6464

core/src/main/java/org/apache/carbondata/core/constants/CarbonCommonConstants.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ public final class CarbonCommonConstants {
189189
/**
190190
* Bytes for string 0, it is used in codegen in case of null values.
191191
*/
192-
public static final byte[] ZERO_BYTE_ARRAY = "0".getBytes();
193-
192+
public static final byte[] ZERO_BYTE_ARRAY = "0".getBytes(Charset.forName(DEFAULT_CHARSET));
194193
/**
195194
* FILE STATUS IN-PROGRESS
196195
*/

core/src/main/java/org/apache/carbondata/core/datamap/DataMapStoreManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public TableDataMap createAndRegisterDataMap(AbsoluteTableIdentifier identifier,
9292
try {
9393
DataMapFactory dataMapFactory = factoryClass.newInstance();
9494
dataMapFactory.init(identifier, dataMapName);
95-
dataMap = new TableDataMap(identifier, dataMapName, dataMapFactory);
95+
dataMap = new TableDataMap(dataMapName, dataMapFactory);
9696
} catch (Exception e) {
9797
LOGGER.error(e);
9898
throw new RuntimeException(e);
@@ -119,7 +119,7 @@ private TableDataMap getAbstractTableDataMap(String dataMapName,
119119
* @param dataMapName
120120
*/
121121
public void clearDataMap(AbsoluteTableIdentifier identifier, String dataMapName) {
122-
List<TableDataMap> tableDataMaps = allDataMaps.get(identifier);
122+
List<TableDataMap> tableDataMaps = allDataMaps.get(identifier.uniqueName());
123123
if (tableDataMaps != null) {
124124
int i = 0;
125125
for (TableDataMap tableDataMap: tableDataMaps) {

core/src/main/java/org/apache/carbondata/core/datamap/TableDataMap.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.apache.carbondata.core.events.ChangeEvent;
2626
import org.apache.carbondata.core.events.EventListener;
2727
import org.apache.carbondata.core.indexstore.Blocklet;
28-
import org.apache.carbondata.core.metadata.AbsoluteTableIdentifier;
2928
import org.apache.carbondata.core.scan.filter.resolver.FilterResolverIntf;
3029

3130
/**
@@ -34,18 +33,15 @@
3433
*/
3534
public final class TableDataMap implements EventListener {
3635

37-
private AbsoluteTableIdentifier identifier;
38-
3936
private String dataMapName;
4037

4138
private DataMapFactory dataMapFactory;
4239

4340
/**
4441
* It is called to initialize and load the required table datamap metadata.
4542
*/
46-
public TableDataMap(AbsoluteTableIdentifier identifier, String dataMapName,
43+
public TableDataMap(String dataMapName,
4744
DataMapFactory dataMapFactory) {
48-
this.identifier = identifier;
4945
this.dataMapName = dataMapName;
5046
this.dataMapFactory = dataMapFactory;
5147
}

core/src/main/java/org/apache/carbondata/core/datastore/AbstractBlockIndexStoreCache.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@
4141
*/
4242
public abstract class AbstractBlockIndexStoreCache<K, V>
4343
implements Cache<TableBlockUniqueIdentifier, AbstractIndex> {
44-
/**
45-
* carbon store path
46-
*/
47-
protected String carbonStorePath;
44+
4845
/**
4946
* CarbonLRU cache
5047
*/
@@ -70,8 +67,7 @@ public abstract class AbstractBlockIndexStoreCache<K, V>
7067
*/
7168
protected Map<String, Object> segmentIDLock;
7269

73-
public AbstractBlockIndexStoreCache(String carbonStorePath, CarbonLRUCache lruCache) {
74-
this.carbonStorePath = carbonStorePath;
70+
public AbstractBlockIndexStoreCache(CarbonLRUCache lruCache) {
7571
this.lruCache = lruCache;
7672
blockInfoLock = new ConcurrentHashMap<BlockInfo, Object>();
7773
segmentIDLock = new ConcurrentHashMap<String, Object>();

core/src/main/java/org/apache/carbondata/core/datastore/BlockIndexStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public class BlockIndexStore<K, V> extends AbstractBlockIndexStoreCache<K, V> {
5959
private static final LogService LOGGER =
6060
LogServiceFactory.getLogService(BlockIndexStore.class.getName());
6161
public BlockIndexStore(String carbonStorePath, CarbonLRUCache lruCache) {
62-
super(carbonStorePath, lruCache);
62+
super(lruCache);
6363
}
6464

6565
/**

core/src/main/java/org/apache/carbondata/core/datastore/block/TableBlockInfo.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,15 @@ public long getBlockLength() {
190190
if (blockLength != other.blockLength) {
191191
return false;
192192
}
193-
if (filePath == null && other.filePath != null) {
194-
return false;
195-
} else if (filePath != null && other.filePath == null) {
196-
return false;
197-
} else if (!filePath.equals(other.filePath)) {
193+
194+
if (null == filePath || null == other.filePath) {
195+
return false;
196+
}
197+
198+
if (!filePath.equals(other.filePath)) {
198199
return false;
199200
}
201+
200202
if (blockletInfos.getStartBlockletNumber() != other.blockletInfos.getStartBlockletNumber()) {
201203
return false;
202204
}

0 commit comments

Comments
 (0)