提交 43701f3f authored 作者: Thomas Mueller's avatar Thomas Mueller

Javadocs; lob storage bugfix.

上级 8d9dec61
...@@ -144,7 +144,6 @@ public abstract class Command implements CommandInterface { ...@@ -144,7 +144,6 @@ public abstract class Command implements CommandInterface {
private void stop() { private void stop() {
session.endStatement(); session.endStatement();
session.closeTemporaryResults();
session.setCurrentCommand(null); session.setCurrentCommand(null);
if (!isTransactional()) { if (!isTransactional()) {
session.commit(true); session.commit(true);
......
...@@ -584,6 +584,11 @@ public class Session extends SessionWithState { ...@@ -584,6 +584,11 @@ public class Session extends SessionWithState {
return undoLog.size() > 0; return undoLog.size() > 0;
} }
/**
* Create a savepoint to allow rolling back to this state.
*
* @return the savepoint
*/
public Savepoint setSavepoint() { public Savepoint setSavepoint() {
Savepoint sp = new Savepoint(); Savepoint sp = new Savepoint();
sp.logIndex = undoLog.size(); sp.logIndex = undoLog.size();
...@@ -1203,11 +1208,7 @@ public class Session extends SessionWithState { ...@@ -1203,11 +1208,7 @@ public class Session extends SessionWithState {
} }
} }
/** private void closeTemporaryResults() {
* Close all temporary result set. This also deletes all temporary files
* held by the result sets.
*/
public void closeTemporaryResults() {
if (temporaryResults != null) { if (temporaryResults != null) {
for (ResultInterface result : temporaryResults) { for (ResultInterface result : temporaryResults) {
result.close(); result.close();
...@@ -1325,8 +1326,13 @@ public class Session extends SessionWithState { ...@@ -1325,8 +1326,13 @@ public class Session extends SessionWithState {
return startStatement; return startStatement;
} }
/**
* Mark the statement as completed. This also close all temporary result
* set, and deletes all temporary files held by the result sets.
*/
public void endStatement() { public void endStatement() {
startStatement = -1; startStatement = -1;
closeTemporaryResults();
} }
/** /**
...@@ -1334,7 +1340,15 @@ public class Session extends SessionWithState { ...@@ -1334,7 +1340,15 @@ public class Session extends SessionWithState {
* back to). * back to).
*/ */
public static class Savepoint { public static class Savepoint {
/**
* The undo log index.
*/
int logIndex; int logIndex;
/**
* The transaction savepoint id.
*/
long transactionSavepoint; long transactionSavepoint;
} }
......
...@@ -145,6 +145,7 @@ public class ConditionInConstantSet extends Condition { ...@@ -145,6 +145,7 @@ public class ConditionInConstantSet extends Condition {
* Add an additional element if possible. Example: given two conditions * Add an additional element if possible. Example: given two conditions
* A IN(1, 2) OR A=3, the constant 3 is added: A IN(1, 2, 3). * A IN(1, 2) OR A=3, the constant 3 is added: A IN(1, 2, 3).
* *
* @param session the session
* @param other the second condition * @param other the second condition
* @return null if the condition was not added, or the new condition * @return null if the condition was not added, or the new condition
*/ */
......
...@@ -101,6 +101,9 @@ public class MVTableEngine implements TableEngine { ...@@ -101,6 +101,9 @@ public class MVTableEngine implements TableEngine {
return openTables; return openTables;
} }
/**
* Store all pending changes.
*/
public void store() { public void store() {
if (!store.isReadOnly()) { if (!store.isReadOnly()) {
store.commit(); store.commit();
...@@ -109,6 +112,9 @@ public class MVTableEngine implements TableEngine { ...@@ -109,6 +112,9 @@ public class MVTableEngine implements TableEngine {
} }
} }
/**
* Close the store, without persisting changes.
*/
public void closeImmediately() { public void closeImmediately() {
if (store.isClosed()) { if (store.isClosed()) {
return; return;
...@@ -123,6 +129,9 @@ public class MVTableEngine implements TableEngine { ...@@ -123,6 +129,9 @@ public class MVTableEngine implements TableEngine {
} }
} }
/**
* Close the store. Pending changes are persisted.
*/
public void close() { public void close() {
if (!store.isReadOnly()) { if (!store.isReadOnly()) {
store.store(); store.store();
......
...@@ -248,6 +248,13 @@ public class TransactionStore { ...@@ -248,6 +248,13 @@ public class TransactionStore {
endTransaction(t); endTransaction(t);
} }
/**
* Check whether the given transaction id is still open and contains log
* entries.
*
* @param transactionId the transaction id
* @return true if it is open
*/
boolean isTransactionOpen(long transactionId) { boolean isTransactionOpen(long transactionId) {
if (transactionId < firstOpenTransaction) { if (transactionId < firstOpenTransaction) {
return false; return false;
...@@ -267,6 +274,11 @@ public class TransactionStore { ...@@ -267,6 +274,11 @@ public class TransactionStore {
return key != null && key[0] == transactionId; return key != null && key[0] == transactionId;
} }
/**
* End this transaction
*
* @param t the transaction
*/
void endTransaction(Transaction t) { void endTransaction(Transaction t) {
if (t.getStatus() == Transaction.STATUS_PREPARED) { if (t.getStatus() == Transaction.STATUS_PREPARED) {
preparedTransactions.remove(t.getId()); preparedTransactions.remove(t.getId());
...@@ -308,6 +320,14 @@ public class TransactionStore { ...@@ -308,6 +320,14 @@ public class TransactionStore {
} }
} }
/**
* Get the set of changed maps.
*
* @param t the transaction
* @param maxLogId the maximum log id
* @param toLogId the minimum log id
* @return the set of changed maps
*/
HashSet<String> getChangedMaps(Transaction t, long maxLogId, long toLogId) { HashSet<String> getChangedMaps(Transaction t, long maxLogId, long toLogId) {
HashSet<String> set = New.hashSet(); HashSet<String> set = New.hashSet();
for (long logId = maxLogId - 1; logId >= toLogId; logId--) { for (long logId = maxLogId - 1; logId >= toLogId; logId--) {
...@@ -363,6 +383,9 @@ public class TransactionStore { ...@@ -363,6 +383,9 @@ public class TransactionStore {
*/ */
final long transactionId; final long transactionId;
/**
* The log id of the last entry in the undo log map.
*/
long logId; long logId;
private int status; private int status;
...@@ -1012,7 +1035,20 @@ public class TransactionStore { ...@@ -1012,7 +1035,20 @@ public class TransactionStore {
* value, and the value itself. * value, and the value itself.
*/ */
static class VersionedValue { static class VersionedValue {
public long transactionId, logId;
/**
* The transaction id.
*/
public long transactionId;
/**
* The log id.
*/
public long logId;
/**
* The value.
*/
public Object value; public Object value;
} }
......
...@@ -62,7 +62,7 @@ public interface LobStorageInterface { ...@@ -62,7 +62,7 @@ public interface LobStorageInterface {
* @param lobId the lob * @param lobId the lob
* @param table the table * @param table the table
*/ */
void setTable(long lobId, int tableIdSessionVariable); void setTable(long lobId, int table);
/** /**
* Delete a LOB from the database. * Delete a LOB from the database.
......
...@@ -142,6 +142,7 @@ public class ValueLob extends Value { ...@@ -142,6 +142,7 @@ public class ValueLob extends Value {
* @param objectId the object id * @param objectId the object id
* @param precision the precision (length in elements) * @param precision the precision (length in elements)
* @param compression if compression is used * @param compression if compression is used
* @param fileName the file name
* @return the value object * @return the value object
*/ */
public static ValueLob openUnlinked(int type, DataHandler handler, public static ValueLob openUnlinked(int type, DataHandler handler,
...@@ -237,7 +238,7 @@ public class ValueLob extends Value { ...@@ -237,7 +238,7 @@ public class ValueLob extends Value {
} }
} }
public static String getFileNamePrefix(String path, int objectId) { private static String getFileNamePrefix(String path, int objectId) {
String name; String name;
int f = objectId % SysProperties.LOB_FILES_PER_DIRECTORY; int f = objectId % SysProperties.LOB_FILES_PER_DIRECTORY;
if (f > 0) { if (f > 0) {
...@@ -480,7 +481,8 @@ public class ValueLob extends Value { ...@@ -480,7 +481,8 @@ public class ValueLob extends Value {
} }
} }
public void unlink() { @Override
public void unlink(DataHandler handler) {
if (linked && fileName != null) { if (linked && fileName != null) {
String temp; String temp;
// synchronize on the database, to avoid concurrent temp file // synchronize on the database, to avoid concurrent temp file
...@@ -751,7 +753,7 @@ public class ValueLob extends Value { ...@@ -751,7 +753,7 @@ public class ValueLob extends Value {
return compression; return compression;
} }
public static synchronized void deleteFile(DataHandler handler, String fileName) { private static synchronized void deleteFile(DataHandler handler, String fileName) {
// synchronize on the database, to avoid concurrent temp file creation / // synchronize on the database, to avoid concurrent temp file creation /
// deletion / backup // deletion / backup
synchronized (handler.getLobSyncObject()) { synchronized (handler.getLobSyncObject()) {
......
...@@ -203,7 +203,7 @@ public class Doclet { ...@@ -203,7 +203,7 @@ public class Doclet {
String name = field.name(); String name = field.name();
String text = field.commentText(); String text = field.commentText();
if (text == null || text.trim().length() == 0) { if (text == null || text.trim().length() == 0) {
addError("Undocumented field (" + clazz.name() + ".java:" + field.position().line() + ") " + name); addError("Undocumented field (" + getLink(clazz, field.position().line()) + ") " + name);
} }
if (text != null && text.startsWith("INTERNAL")) { if (text != null && text.startsWith("INTERNAL")) {
continue; continue;
...@@ -315,7 +315,7 @@ public class Doclet { ...@@ -315,7 +315,7 @@ public class Doclet {
if (hasComment && !method.commentText().startsWith("[")) { if (hasComment && !method.commentText().startsWith("[")) {
// [Not supported] and such are not problematic // [Not supported] and such are not problematic
addError("Undocumented parameter(s) (" + addError("Undocumented parameter(s) (" +
clazz.name() + ".java:" + method.position().line() + ") " + getLink(clazz, method.position().line()) + ") " +
name + " documented: " + paramTags.length + " params: "+ params.length); name + " documented: " + paramTags.length + " params: "+ params.length);
} }
} }
...@@ -324,7 +324,7 @@ public class Doclet { ...@@ -324,7 +324,7 @@ public class Doclet {
String comment = paramTags[j].parameterComment(); String comment = paramTags[j].parameterComment();
if (comment.trim().length() == 0) { if (comment.trim().length() == 0) {
addError("Undocumented parameter (" + addError("Undocumented parameter (" +
clazz.name() + ".java:" + method.position().line() + ") " + name + " " + paramName); getLink(clazz, method.position().line()) + ") " + name + " " + paramName);
} }
String p = paramName + " - " + comment; String p = paramName + " - " + comment;
if (j == 0) { if (j == 0) {
...@@ -339,7 +339,7 @@ public class Doclet { ...@@ -339,7 +339,7 @@ public class Doclet {
String returnComment = returnTags[0].text(); String returnComment = returnTags[0].text();
if (returnComment.trim().length() == 0) { if (returnComment.trim().length() == 0) {
addError("Undocumented return value (" + addError("Undocumented return value (" +
clazz.name() + ".java:" + method.position().line() + ") " + name); getLink(clazz, method.position().line()) + ") " + name);
} }
writer.println("<div class=\"item\">" + returnComment + "</div>"); writer.println("<div class=\"item\">" + returnComment + "</div>");
} else if (returnType != null && !returnType.toString().equals("void")) { } else if (returnType != null && !returnType.toString().equals("void")) {
...@@ -347,7 +347,7 @@ public class Doclet { ...@@ -347,7 +347,7 @@ public class Doclet {
// [Not supported] and such are not problematic // [Not supported] and such are not problematic
// also not problematic are methods that always throw an exception // also not problematic are methods that always throw an exception
addError("Undocumented return value (" + addError("Undocumented return value (" +
clazz.name() + ".java:" + method.position().line() + ") " + name + " " + getReturnType(method)); getLink(clazz, method.position().line()) + ") " + name + " " + getReturnType(method));
} }
} }
if (hasThrowsTag) { if (hasThrowsTag) {
...@@ -363,6 +363,15 @@ public class Doclet { ...@@ -363,6 +363,15 @@ public class Doclet {
} }
} }
private static String getLink(ClassDoc clazz, int line) {
String c = clazz.name();
int x = c.lastIndexOf('.');
if (x >= 0) {
c = c.substring(0, x);
}
return c + ".java:" + line;
}
private String getFieldLink(String text, String constant, ClassDoc clazz, String name) { private String getFieldLink(String text, String constant, ClassDoc clazz, String name) {
String link = constant != null ? constant : name.toLowerCase(); String link = constant != null ? constant : name.toLowerCase();
int linkStart = text.indexOf("<code>"); int linkStart = text.indexOf("<code>");
...@@ -431,7 +440,7 @@ public class Doclet { ...@@ -431,7 +440,7 @@ public class Doclet {
returnType.toString().equals("boolean"); returnType.toString().equals("boolean");
if (!setterOrGetter) { if (!setterOrGetter) {
addError("Undocumented method " + addError("Undocumented method " +
" (" + clazz.name() + ".java:" + method.position().line() +") " + " (" + getLink(clazz, method.position().line()) +") " +
clazz + "." + name + " " + raw); clazz + "." + name + " " + raw);
return true; return true;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论