提交 62372306 authored 作者: noelgrandin's avatar noelgrandin

Make some more fields final where appropriate.

Found by UCDetector, which seems to have gotten smarter recently.
上级 38ed19b9
......@@ -15,16 +15,14 @@ import org.h2.util.StringUtils;
*/
class RuleElement implements Rule {
private boolean keyword;
private final boolean keyword;
private final String name;
private Rule link;
private final int type;
RuleElement(String name, String topic) {
this.name = name;
if (name.length() == 1 || name.equals(StringUtils.toUpperEnglish(name))) {
keyword = true;
}
this.keyword = name.length() == 1 || name.equals(StringUtils.toUpperEnglish(name));
topic = StringUtils.toLowerEnglish(topic);
this.type = topic.startsWith("function") ? Sentence.FUNCTION : Sentence.KEYWORD;
}
......
......@@ -34,22 +34,22 @@ class FullTextSettings {
/**
* The set of words not to index (stop words).
*/
private HashSet<String> ignoreList = New.hashSet();
private final HashSet<String> ignoreList = New.hashSet();
/**
* The set of words / terms.
*/
private HashMap<String, Integer> words = New.hashMap();
private final HashMap<String, Integer> words = New.hashMap();
/**
* The set of indexes in this database.
*/
private HashMap<Integer, IndexInfo> indexes = New.hashMap();
private final HashMap<Integer, IndexInfo> indexes = New.hashMap();
/**
* The prepared statement cache.
*/
private SoftHashMap<Connection, SoftHashMap<String, PreparedStatement>> cache =
private final SoftHashMap<Connection, SoftHashMap<String, PreparedStatement>> cache =
new SoftHashMap<Connection, SoftHashMap<String, PreparedStatement>>();
/**
......
......@@ -33,7 +33,7 @@ public class PageBtreeIndex extends PageIndex {
private final PageStore store;
private final RegularTable tableData;
private boolean needRebuild;
private final boolean needRebuild;
private long rowCount;
private int memoryPerPage;
private int memoryCount;
......@@ -55,7 +55,6 @@ public class PageBtreeIndex extends PageIndex {
if (create) {
// new index
rootPageId = store.allocatePage();
needRebuild = true;
// TODO currently the head position is stored in the log
// it should not for new tables, otherwise redo of other operations
// must ensure this page is not used for other things
......@@ -67,10 +66,8 @@ public class PageBtreeIndex extends PageIndex {
rootPageId = store.getRootPageId(id);
PageBtree root = getPage(rootPageId);
rowCount = root.getRowCount();
if (rowCount == 0 && store.isRecoveryRunning()) {
needRebuild = true;
}
}
this.needRebuild = create || (rowCount == 0 && store.isRecoveryRunning());
if (trace.isDebugEnabled()) {
trace.debug("opened {0} rows: {1}", getName() , rowCount);
}
......
......@@ -34,7 +34,7 @@ public class JdbcStatement extends TraceObject implements Statement {
protected int updateCount;
protected final int resultSetType;
protected final int resultSetConcurrency;
protected boolean closedByResultSet;
protected final boolean closedByResultSet;
private CommandInterface executingCommand;
private int lastExecutedCommandType;
private ArrayList<String> batchCommands;
......
......@@ -45,7 +45,7 @@ public class FileStore {
* The callback object is responsible to check access rights, and free up
* disk space if required.
*/
private DataHandler handler;
private final DataHandler handler;
private FileChannel file;
private long filePos;
......@@ -53,7 +53,7 @@ public class FileStore {
private Reference<?> autoDeleteReference;
private boolean checkedWriting = true;
private final String mode;
private TempFileDeleter tempFileDeleter;
private final TempFileDeleter tempFileDeleter;
private java.nio.channels.FileLock lock;
/**
......@@ -68,6 +68,8 @@ public class FileStore {
this.name = name;
if (handler != null) {
tempFileDeleter = handler.getTempFileDeleter();
} else {
tempFileDeleter = null;
}
try {
boolean exists = FileUtils.exists(name);
......
......@@ -21,7 +21,7 @@ public class FileStoreInputStream extends InputStream {
private FileStore store;
private final Data page;
private int remainingInBuffer;
private CompressTool compress;
private final CompressTool compress;
private boolean endOfFile;
private final boolean alwaysClose;
......@@ -30,6 +30,8 @@ public class FileStoreInputStream extends InputStream {
this.alwaysClose = alwaysClose;
if (compression) {
compress = CompressTool.getInstance();
} else {
compress = null;
}
page = Data.create(handler, Constants.FILE_BLOCK_SIZE);
try {
......
......@@ -16,15 +16,18 @@ import org.h2.tools.CompressTool;
public class FileStoreOutputStream extends OutputStream {
private FileStore store;
private final Data page;
private String compressionAlgorithm;
private CompressTool compress;
private byte[] buffer = { 0 };
private final String compressionAlgorithm;
private final CompressTool compress;
private final byte[] buffer = { 0 };
public FileStoreOutputStream(FileStore store, DataHandler handler, String compressionAlgorithm) {
this.store = store;
if (compressionAlgorithm != null) {
compress = CompressTool.getInstance();
this.compress = CompressTool.getInstance();
this.compressionAlgorithm = compressionAlgorithm;
} else {
this.compress = null;
this.compressionAlgorithm = null;
}
page = Data.create(handler, Constants.FILE_BLOCK_SIZE);
}
......
......@@ -150,7 +150,7 @@ public class BuildBase {
/**
* The output stream (System.out).
*/
protected PrintStream sysOut = System.out;
protected final PrintStream sysOut = System.out;
/**
* If output should be disabled.
......
......@@ -129,7 +129,7 @@ public class MVStore {
* split in 16 segments. The stack move distance is 2% of the expected
* number of entries.
*/
private CacheLongKeyLIRS<Page> cache;
private final CacheLongKeyLIRS<Page> cache;
private int lastChunkId;
private final HashMap<Integer, Chunk> chunks = New.hashMap();
......@@ -184,6 +184,8 @@ public class MVStore {
int mb = s == null ? 16 : Integer.parseInt(s.toString());
cache = CacheLongKeyLIRS.newInstance(
mb * 1024 * 1024, 2048, 16, mb * 1024 * 1024 / 2048 * 2 / 100);
} else {
cache = null;
}
}
......
......@@ -35,7 +35,7 @@ public class GenerateModels {
/**
* The output stream where this tool writes to.
*/
protected PrintStream out = System.out;
protected final PrintStream out = System.out;
public static void main(String... args) throws SQLException {
new GenerateModels().runTool(args);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论