diff --git a/bin/fr/devinsy/sikevadb/FileSikevaDB.class b/bin/fr/devinsy/sikevadb/FileSikevaDB.class index 53312c1..d66033d 100644 Binary files a/bin/fr/devinsy/sikevadb/FileSikevaDB.class and b/bin/fr/devinsy/sikevadb/FileSikevaDB.class differ diff --git a/bin/fr/devinsy/sikevadb/SQLSikevaDB.class b/bin/fr/devinsy/sikevadb/SQLSikevaDB.class index 923950b..cc2ded4 100644 Binary files a/bin/fr/devinsy/sikevadb/SQLSikevaDB.class and b/bin/fr/devinsy/sikevadb/SQLSikevaDB.class differ diff --git a/bin/fr/devinsy/sikevadb/SikevaDB.class b/bin/fr/devinsy/sikevadb/SikevaDB.class index 613bc2e..9edca4e 100644 Binary files a/bin/fr/devinsy/sikevadb/SikevaDB.class and b/bin/fr/devinsy/sikevadb/SikevaDB.class differ diff --git a/src/fr/devinsy/sikevadb/FileSikevaDB.java b/src/fr/devinsy/sikevadb/FileSikevaDB.java index c9a6c36..d493560 100644 --- a/src/fr/devinsy/sikevadb/FileSikevaDB.java +++ b/src/fr/devinsy/sikevadb/FileSikevaDB.java @@ -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 diff --git a/src/fr/devinsy/sikevadb/SQLSikevaDB.java b/src/fr/devinsy/sikevadb/SQLSikevaDB.java index c6ae883..29fe99c 100644 --- a/src/fr/devinsy/sikevadb/SQLSikevaDB.java +++ b/src/fr/devinsy/sikevadb/SQLSikevaDB.java @@ -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(); diff --git a/src/fr/devinsy/sikevadb/SikevaDB.java b/src/fr/devinsy/sikevadb/SikevaDB.java index 83a5dda..360fb09 100644 --- a/src/fr/devinsy/sikevadb/SikevaDB.java +++ b/src/fr/devinsy/sikevadb/SikevaDB.java @@ -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;