Fix SQL request issue. Fix date computing. Add methods.
This commit is contained in:
parent
a9ebc14796
commit
2863aee6fa
6 changed files with 50 additions and 5 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -264,6 +264,18 @@ public class FileSikevaDB implements SikevaDB {
|
|||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long memorySizeOfAll() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long memorySizeOfAll(final String key) throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long memorySizeOfArchive() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
|
|
|
@ -46,7 +46,6 @@ public class SQLSikevaDB implements SikevaDB {
|
|||
private String login;
|
||||
private String password;
|
||||
private Connection singleConnection;
|
||||
|
||||
private String contextName;
|
||||
private DataSource dataSource;
|
||||
|
||||
|
@ -218,7 +217,7 @@ public class SQLSikevaDB implements SikevaDB {
|
|||
if (maxDays < 0) {
|
||||
throw new IndexOutOfBoundsException("maxDays is negative.");
|
||||
} else {
|
||||
Date beforeDate = new Date(new Date().getTime() + maxDays * 24 * 60 * 60 * 1000);
|
||||
Date beforeDate = new Date(new Date().getTime() - maxDays * 24 * 60 * 60 * 1000);
|
||||
clearArchive(beforeDate);
|
||||
}
|
||||
}
|
||||
|
@ -338,7 +337,7 @@ public class SQLSikevaDB implements SikevaDB {
|
|||
try {
|
||||
connection = getConnection();
|
||||
connection.setAutoCommit(true);
|
||||
statement = connection.prepareStatement("SELECT count(*) FROM elements WHERE AND TOPKEY=?");
|
||||
statement = connection.prepareStatement("SELECT count(*) FROM elements WHERE TOPKEY=?");
|
||||
statement.setString(1, key);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
|
@ -903,6 +902,10 @@ public class SQLSikevaDB implements SikevaDB {
|
|||
return result;
|
||||
}
|
||||
|
||||
public String getContextName() {
|
||||
return contextName;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
|
@ -1395,7 +1398,7 @@ public class SQLSikevaDB implements SikevaDB {
|
|||
try {
|
||||
connection = getConnection();
|
||||
connection.setAutoCommit(true);
|
||||
statement = connection.prepareStatement("SELECT SUM(SIZE) FROM elements WHERE ARCHIVE_DATE IS NULL AND TOPKEY=? AND SUBKEY IS NULL");
|
||||
statement = connection.prepareStatement("SELECT SUM(SIZE) FROM elements WHERE ARCHIVE_DATE IS NULL AND TOPKEY=?");
|
||||
statement.setString(1, key);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
|
@ -1445,6 +1448,32 @@ public class SQLSikevaDB implements SikevaDB {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public long memorySizeOfAll() throws Exception {
|
||||
long result;
|
||||
|
||||
result = memorySize() + memorySizeOfArchive();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public long memorySizeOfAll(final String key) throws Exception {
|
||||
long result;
|
||||
|
||||
result = memorySize(key) + memorySizeOfArchive(key);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -1487,7 +1516,7 @@ public class SQLSikevaDB implements SikevaDB {
|
|||
try {
|
||||
connection = getConnection();
|
||||
connection.setAutoCommit(true);
|
||||
statement = connection.prepareStatement("SELECT SUM(SIZE) FROM elements WHERE ARCHIVE_DATE IS NOT NULL AND TOPKEY=? AND SUBKEY IS NULL");
|
||||
statement = connection.prepareStatement("SELECT SUM(SIZE) FROM elements WHERE ARCHIVE_DATE IS NOT NULL AND TOPKEY=?");
|
||||
statement.setString(1, key);
|
||||
resultSet = statement.executeQuery();
|
||||
|
||||
|
|
|
@ -102,6 +102,10 @@ public interface SikevaDB {
|
|||
|
||||
public long memorySize(String key, String subkey) throws Exception;
|
||||
|
||||
public long memorySizeOfAll() throws Exception;
|
||||
|
||||
long memorySizeOfAll(String key) throws Exception;
|
||||
|
||||
public long memorySizeOfArchive() throws Exception;
|
||||
|
||||
long memorySizeOfArchive(String key) throws Exception;
|
||||
|
|
Loading…
Reference in a new issue