Author: genman
Date: 2008-09-26 17:38:03 -0400 (Fri, 26 Sep 2008)
New Revision: 6806
Modified:
core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
core/trunk/src/main/java/org/jboss/cache/loader/s3/S3CacheLoader.java
core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java
Log:
JBCACHE-1368 - Optimize BDB & S3
Modified: core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2008-09-26
17:44:22 UTC (rev 6805)
+++ core/trunk/src/main/java/org/jboss/cache/loader/bdbje/BdbjeCacheLoader.java 2008-09-26
21:38:03 UTC (rev 6806)
@@ -552,9 +552,10 @@
private void doPut(Transaction txn, Fqn name, Map values)
throws Exception
{
-
// JBCACHE-769 -- make a defensive copy
- values = (values == null ? null : new HashMap(values));
+ if (values != null && !(values instanceof HashMap)) {
+ values = new HashMap(values);
+ }
/* To update-or-insert, try putNoOverwrite first, then a RMW cycle. */
DatabaseEntry dataEntry = makeDataEntry(values);
@@ -562,25 +563,11 @@
Cursor cursor = cacheDb.openCursor(txn, null);
try
{
- OperationStatus status = cursor.putNoOverwrite(keyEntry, dataEntry);
+ OperationStatus status = cursor.put(keyEntry, dataEntry);
if (status == OperationStatus.SUCCESS)
{
createParentNodes(cursor, name);
}
- else
- {
- DatabaseEntry foundData = new DatabaseEntry();
- status = cursor.getSearchKey(keyEntry, foundData, LockMode.RMW);
- if (status == OperationStatus.SUCCESS)
- {
- Map map = makeDataObject(foundData);
- if (values != null)
- {
- map.putAll(values);
- }
- cursor.putCurrent(makeDataEntry(map));
- }
- }
}
finally
{
Modified: core/trunk/src/main/java/org/jboss/cache/loader/s3/S3CacheLoader.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/loader/s3/S3CacheLoader.java 2008-09-26
17:44:22 UTC (rev 6805)
+++ core/trunk/src/main/java/org/jboss/cache/loader/s3/S3CacheLoader.java 2008-09-26
21:38:03 UTC (rev 6806)
@@ -320,7 +320,7 @@
*/
public Object put(Fqn name, Object key, Object value) throws Exception
{
- Map map = mayGet(name);
+ Map map = get(name);
Object oldValue;
if (map != null)
{
@@ -389,17 +389,6 @@
}
/**
- * Returns null if optimized; else fetches.
- */
- private Map mayGet(Fqn name) throws Exception
- {
- if (config.getOptimize())
- return null;
- else
- return get(name);
- }
-
- /**
* Removes a key from an FQN.
* Not very fast.
*/
@@ -425,14 +414,9 @@
*/
public void put(Fqn name, Map<Object, Object> values) throws Exception
{
- Map map = mayGet(name);
if (values == null)
values = Collections.emptyMap();
- if (map != null)
- map.putAll(values);
- else
- map = new HashMap(values);
- put0(name, map);
+ put0(name, values);
}
/**
Modified: core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java 2008-09-26
17:44:22 UTC (rev 6805)
+++ core/trunk/src/test/java/org/jboss/cache/loader/BdbjeCacheLoaderTest.java 2008-09-26
21:38:03 UTC (rev 6806)
@@ -14,6 +14,8 @@
@Test(groups = "functional")
public class BdbjeCacheLoaderTest extends CacheLoaderTestsBase
{
+
+ @Override
protected void configureCache() throws Exception
{
String tmpDir = System.getProperty("java.io.tmpdir", "/tmp");
Show replies by date