From 2863aee6faf587775a28c3e98af966fcd3480a17 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Tue, 10 Sep 2013 18:32:35 +0200 Subject: [PATCH] Fix SQL request issue. Fix date computing. Add methods. --- bin/fr/devinsy/sikevadb/FileSikevaDB.class | Bin 5238 -> 5402 bytes bin/fr/devinsy/sikevadb/SQLSikevaDB.class | Bin 29940 -> 30220 bytes bin/fr/devinsy/sikevadb/SikevaDB.class | Bin 2123 -> 2177 bytes src/fr/devinsy/sikevadb/FileSikevaDB.java | 12 +++++++ src/fr/devinsy/sikevadb/SQLSikevaDB.java | 39 ++++++++++++++++++--- src/fr/devinsy/sikevadb/SikevaDB.java | 4 +++ 6 files changed, 50 insertions(+), 5 deletions(-) diff --git a/bin/fr/devinsy/sikevadb/FileSikevaDB.class b/bin/fr/devinsy/sikevadb/FileSikevaDB.class index 53312c1124ebb8bef8f70ed473fc101b5daa78bb..d66033d356ac0de4f3959c7b8a6e6ab1bdee3ffd 100644 GIT binary patch delta 221 zcmeySF-wc<)W2Q(7#J9g82mPJ*{}-m=ceZ77gYvlR;BuE)1@d8-=wPjVA|)i1WHJxC7-F8C)2o7#JrTvdc0tT22mNSLF6! z5Mf{fOL$J!5>{ZepX@EH%?c7_o-8jC!00vkjIa))H&Cr6kgNx?1Azw0v-{G05_xKX8 zWMWjDe4ay;*_pv*@K}JkoAk02FR78r=b8>-*&g6GMRf|MaCM${fvU>v^ I#l+wP0P1-s`~Uy| diff --git a/bin/fr/devinsy/sikevadb/SQLSikevaDB.class b/bin/fr/devinsy/sikevadb/SQLSikevaDB.class index 923950be8da324f7184ae8e9f225dec7a8267bf4..cc2ded41135199afb668d580a6d6d4416fabf3f6 100644 GIT binary patch delta 6640 zcmZu#30PNE`hLH2?>!grCyQ($C_AEvVhD+fh$0H^A_A@;BBCq?m`f?z;$&%MCoS7- zrW&(FGYWOAw9TeXEo(|Et7&F(%iJnktpEE%o2BRf@NmC-&OPV*-tT?CbM8IA^T%ZM zNe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mcMK;lM2VCjD>RY;5g&p<&0;(0t7e{nC~{kIg^m+6e7);g5FLM206DQmpH~L=G)I5 zjI$}Fhio+N^uly!HY{fjv{MCdrv@#Yxd?LRAGW2Knsp z9#XN;p1-N^1vFoGbaOP*ehAbp(NVWTPaS}49f({VgnZowGjuTK>kur|p}1GKH+^RW zg?}z*A;{-Z>I+^e9=8F$pl9^<9RGRtH?=bo^9>C!S`Q;GqBqX?H8)(p|y!A!VEHvj*4oht>n(qX(mv&OwmQ zrLZB0(8CdDD>rZFZOS36dMZcB6U0cB6ZpgKY}EVO-@MDL1J+ zp~*hoWS`@)ucACI{g!>2Cj8ew?d56QGEn9d>WPd z8QiJ2;z7L)tMqm}u6J;)@LP-Cg>A&=^d214d+~Q&kN5RHe4+Q_M|}V{b%QkTqz_7% zeqLhri_%5EEXn#XZF^M)=~pC&I7YuF9KN5WhOsvtg0-OX69to z&}@B-OW`<|!h49-?;~D+gamyGiTX6x_ZdExpCU_t#>et3#_4k?)c?R#{T0ge*W~{d z_o8pj?MpUZs8uW%(@LyG<`&3hcWIoq5>MnF0N_mr0`y<=bqV7<0Y*d`;W0djs5A3{Wof2 ziY^y)YT8tW#_#^`rWeR<3NC&jbPb?@f$({1C#xp?y6HNNw3HVXs^SN>K3{a}= FzX2^Z=7j(N diff --git a/bin/fr/devinsy/sikevadb/SikevaDB.class b/bin/fr/devinsy/sikevadb/SikevaDB.class index 613bc2e6c34938db60255194b06203750107b2a6..9edca4ee3afbcbf5f4ee6af3bff770926ca6258a 100644 GIT binary patch delta 236 zcmX>t&?v}t>ff$?3=9lL4CWiTv{?lBb5nEkizyn5aGfQF+vkDwqamH7h*uyW`e2) MsNNLlTqXuH0DdnODgXcg delta 183 zcmZn^JT1U=>ff$?3=9lL3}zd-v{@#*v+QNm-^|K-kf~mmL6m`!fgLEx0;D-u7#Z{! mc+f=j84NH)xG+Qv(L{_G*f2!Ubs0;bDgtUS0Xl_=!4v?5K@CIz 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;