mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Extended Properties to batch updates. This is really a salvage
from an aborted attempt to make basic attributes (creator, modifier, owner, modtime etc.) plain Properties. This resulted in a 30% performance hit. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3362 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -81,8 +81,15 @@
|
||||
timeToIdleSeconds="300"
|
||||
timeToLiveSeconds="600"
|
||||
memoryStoreEvictionPolicy="LRU"/>
|
||||
<cache name="DeletedChild.ByNameParent"
|
||||
maxElementsInMemory="1000"
|
||||
<cache name="Property.Lookup"
|
||||
maxElementsInMemory="5000"
|
||||
eternal="true"
|
||||
overflowToDisk="false"
|
||||
timeToIdleSeconds="300"
|
||||
timeToLiveSeconds="600"
|
||||
memoryStoreEvictionPolicy="LRU"/>
|
||||
<cache name="Properties.Lookup"
|
||||
maxElementsInMemory="2000"
|
||||
eternal="true"
|
||||
overflowToDisk="false"
|
||||
timeToIdleSeconds="300"
|
||||
|
@@ -142,6 +142,12 @@ public interface AVMNode
|
||||
*/
|
||||
public void setProperty(QName name, PropertyValue value);
|
||||
|
||||
/**
|
||||
* Set a collection of properties on this node.
|
||||
* @param properties The Map of QNames to PropertyValues.
|
||||
*/
|
||||
public void setProperties(Map<QName, PropertyValue> properties);
|
||||
|
||||
/**
|
||||
* Get a property by name.
|
||||
* @param name The name of the property to get.
|
||||
|
@@ -306,6 +306,18 @@ public abstract class AVMNodeImpl implements AVMNode, Serializable
|
||||
AVMContext.fgInstance.fAVMNodePropertyDAO.save(prop);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a collection of properties on this node.
|
||||
* @param properties The Map of QNames to PropertyValues.
|
||||
*/
|
||||
public void setProperties(Map<QName, PropertyValue> properties)
|
||||
{
|
||||
for (QName name : properties.keySet())
|
||||
{
|
||||
setProperty(name, properties.get(name));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a property by name.
|
||||
* @param name The name of the property.
|
||||
|
@@ -53,4 +53,10 @@ public interface AVMNodePropertyDAO
|
||||
* @param prop The property.
|
||||
*/
|
||||
public void update(AVMNodeProperty prop);
|
||||
|
||||
/**
|
||||
* Delete all properties associated with a node.
|
||||
* @param node The AVMNode whose properties should be deleted.
|
||||
*/
|
||||
public void deleteAll(AVMNode node);
|
||||
}
|
||||
|
@@ -879,6 +879,19 @@ class AVMRepository
|
||||
store.setProperty(pathParts[1], name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a collection of properties at once.
|
||||
* @param path The path to the node.
|
||||
* @param properties The Map of QNames to PropertyValues.
|
||||
*/
|
||||
public void setProperties(String path, Map<QName, PropertyValue> properties)
|
||||
{
|
||||
fLookupCount.set(1);
|
||||
String [] pathParts = SplitPath(path);
|
||||
AVMStore store = getAVMStoreByName(pathParts[0], true);
|
||||
store.setProperties(pathParts[1], properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a property by name for a node.
|
||||
* @param version The version to look under.
|
||||
|
@@ -319,6 +319,13 @@ public interface AVMService
|
||||
*/
|
||||
public void setProperty(String path, QName name, PropertyValue value);
|
||||
|
||||
/**
|
||||
* Set a collection of properties on a node.
|
||||
* @param path The path to the node.
|
||||
* @param properties The Map of properties to set.
|
||||
*/
|
||||
public void setProperties(String path, Map<QName, PropertyValue> properties);
|
||||
|
||||
/**
|
||||
* Get a property of a node by QName.
|
||||
* @param version The version to look under.
|
||||
|
@@ -1053,7 +1053,29 @@ public class AVMServiceImpl implements AVMService
|
||||
TxnCallback doit = new TxnCallback();
|
||||
fTransaction.perform(doit, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a collection of properties on a node.
|
||||
* @param path The path to the node.
|
||||
* @param properties The Map of properties to set.
|
||||
*/
|
||||
public void setProperties(final String path, final Map<QName, PropertyValue> properties)
|
||||
{
|
||||
if (path == null || properties == null)
|
||||
{
|
||||
throw new AVMBadArgumentException("Illegal null argument.");
|
||||
}
|
||||
class TxnCallback implements RetryingTransactionCallback
|
||||
{
|
||||
public void perform()
|
||||
{
|
||||
fAVMRepository.setProperties(path, properties);
|
||||
}
|
||||
}
|
||||
TxnCallback doit = new TxnCallback();
|
||||
fTransaction.perform(doit, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a property of a node by QName.
|
||||
* @param version The version to look under.
|
||||
|
@@ -24,6 +24,7 @@ import java.io.PrintStream;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
@@ -2038,6 +2039,22 @@ public class AVMServiceTest extends AVMServiceTestBase
|
||||
Map<QName, PropertyValue> props = fService.getProperties(-1, "main:/a/b/c/foo");
|
||||
assertEquals(1, props.size());
|
||||
assertEquals(value.toString(), props.get(name).toString());
|
||||
props = new HashMap<QName, PropertyValue>();
|
||||
QName n1 = QName.createQName("silly.uri", "Prop1");
|
||||
PropertyValue p1 = new PropertyValue(null, new Date(System.currentTimeMillis()));
|
||||
props.put(n1, p1);
|
||||
QName n2 = QName.createQName("silly.uri", "Prop2");
|
||||
PropertyValue p2 = new PropertyValue(null, "A String Property.");
|
||||
props.put(n2, p2);
|
||||
QName n3 = QName.createQName("silly.uri", "Prop3");
|
||||
PropertyValue p3 = new PropertyValue(null, 42);
|
||||
props.put(n3, p3);
|
||||
fService.setProperties("main:/a/b/c/bar", props);
|
||||
fService.createSnapshot("main");
|
||||
props = fService.getProperties(-1, "main:/a/b/c/bar");
|
||||
assertEquals(p1.toString(), props.get(n1).toString());
|
||||
assertEquals(p2.toString(), props.get(n2).toString());
|
||||
assertEquals(p3.toString(), props.get(n3).toString());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@@ -276,6 +276,13 @@ public interface AVMStore
|
||||
*/
|
||||
public void setProperty(String path, QName name, PropertyValue value);
|
||||
|
||||
/**
|
||||
* Set a collection of properties on a node.
|
||||
* @param path The path to the node.
|
||||
* @param properties The Map of QNames to PropertyValues.
|
||||
*/
|
||||
public void setProperties(String path, Map<QName, PropertyValue> properties);
|
||||
|
||||
/**
|
||||
* Get a property by name.
|
||||
* @param version The version to look under.
|
||||
|
@@ -840,6 +840,18 @@ public class AVMStoreImpl implements AVMStore, Serializable
|
||||
node.setProperty(name, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a collection of properties on a node.
|
||||
* @param path The path to the node.
|
||||
* @param properties The Map of QNames to PropertyValues.
|
||||
*/
|
||||
public void setProperties(String path, Map<QName, PropertyValue> properties)
|
||||
{
|
||||
Lookup lPath = lookup(-1, path, true);
|
||||
AVMNode node = lPath.getCurrentNode();
|
||||
node.setProperties(properties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a property by name.
|
||||
* @param version The version to lookup.
|
||||
|
@@ -238,8 +238,8 @@ public class OrphanReaper implements Runnable
|
||||
{
|
||||
AVMContext.fgInstance.fNewInAVMStoreDAO.delete(newInRep);
|
||||
}
|
||||
// TODO What to do about such Hibernate wackiness: session.flush();
|
||||
// TODO More of the same: node = AVMNodeUnwrapper.Unwrap(node);
|
||||
// Get rid of all properties belonging to this node.
|
||||
AVMContext.fgInstance.fAVMNodePropertyDAO.deleteAll(node);
|
||||
// Extra work for directories.
|
||||
if (node.getType() == AVMNodeType.PLAIN_DIRECTORY ||
|
||||
node.getType() == AVMNodeType.LAYERED_DIRECTORY)
|
||||
|
@@ -29,6 +29,8 @@ public class AVMNodePropertyDAOHibernate extends HibernateDaoSupport
|
||||
"from AVMNodePropertyImpl anp where anp.node = :node and anp.name = :name");
|
||||
query.setEntity("node", node);
|
||||
query.setParameter("name", name);
|
||||
query.setCacheable(true);
|
||||
query.setCacheRegion("Property.Lookup");
|
||||
return (AVMNodeProperty)query.uniqueResult();
|
||||
}
|
||||
|
||||
@@ -44,6 +46,8 @@ public class AVMNodePropertyDAOHibernate extends HibernateDaoSupport
|
||||
getSession().createQuery(
|
||||
"from AVMNodePropertyImpl anp where anp.node = :node");
|
||||
query.setEntity("node", node);
|
||||
query.setCacheable(true);
|
||||
query.setCacheRegion("Properties.Lookup");
|
||||
return (List<AVMNodeProperty>)query.list();
|
||||
}
|
||||
|
||||
@@ -64,4 +68,16 @@ public class AVMNodePropertyDAOHibernate extends HibernateDaoSupport
|
||||
{
|
||||
// Do nothing for Hibernate.
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all properties associated with a node.
|
||||
* @param node The AVMNode whose properties should be deleted.
|
||||
*/
|
||||
public void deleteAll(AVMNode node)
|
||||
{
|
||||
Query delete =
|
||||
getSession().createQuery("delete from AVMNodePropertyImpl anp where anp.node = :node");
|
||||
delete.setEntity("node", node);
|
||||
delete.executeUpdate();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user