Merged V2.0 to HEAD

5448: (From V1.4)
      5281 (V1.4): Patches not executed in read-only mode
      5284 (V1.4): Integrity messages
      5308 (V1.4): Category selector performance
      5331 (V1.4): Category performance
      5402 (V1.4): AR-1315
      5410 (V1.4): 
      5417 (V1.4): Upgrade script performance
      5435 (V1.4): Lucene test text encoding


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5482 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2007-04-11 23:24:00 +00:00
parent d3e08db677
commit 4ea83f7f2b
15 changed files with 183 additions and 22 deletions

View File

@@ -97,19 +97,9 @@ public class LuceneCategoryServiceImpl implements CategoryService
{
StringBuilder luceneQuery = new StringBuilder(64);
if (!mode.equals(Mode.ALL))
{
luceneQuery.append(mode.equals(Mode.SUB_CATEGORIES) ? "-" : "").append("PATH:\"");
luceneQuery.append(buildXPath(nodeService.getPath(categoryRef))).append("/");
if (depth.equals(Depth.ANY))
{
luceneQuery.append("/");
}
luceneQuery.append("member").append("\" ");
}
if (!mode.equals(Mode.MEMBERS))
switch(mode)
{
case ALL:
luceneQuery.append("PATH:\"");
luceneQuery.append(buildXPath(nodeService.getPath(categoryRef))).append("/");
if (depth.equals(Depth.ANY))
@@ -117,6 +107,26 @@ public class LuceneCategoryServiceImpl implements CategoryService
luceneQuery.append("/");
}
luceneQuery.append("*").append("\" ");
break;
case MEMBERS:
luceneQuery.append("PATH:\"");
luceneQuery.append(buildXPath(nodeService.getPath(categoryRef))).append("/");
if (depth.equals(Depth.ANY))
{
luceneQuery.append("/");
}
luceneQuery.append("member").append("\" ");
break;
case SUB_CATEGORIES:
luceneQuery.append("+PATH:\"");
luceneQuery.append(buildXPath(nodeService.getPath(categoryRef))).append("/");
if (depth.equals(Depth.ANY))
{
luceneQuery.append("/");
}
luceneQuery.append("*").append("\" ");
luceneQuery.append("+TYPE:\"" + ContentModel.TYPE_CATEGORY.toString() + "\"");
break;
}
resultSet = indexerAndSearcher.getSearcher(categoryRef.getStoreRef(), false).query(categoryRef.getStoreRef(), "lucene", luceneQuery.toString(), null, null);

View File

@@ -664,7 +664,96 @@ public class LuceneCategoryTest2 extends TestCase
tx.rollback();
}
public void xtestManyCategories() throws Exception
{
TransactionService transactionService = serviceRegistry.getTransactionService();
UserTransaction tx = transactionService.getUserTransaction();
tx.begin();
long start = System.nanoTime();
int startCount = categoryService.getRootCategories(serviceRegistry.getPersonService().getPeopleContainer().getStoreRef(),
ContentModel.ASPECT_GEN_CLASSIFIABLE).size();
System.out.println("1 Query complete in "+(System.nanoTime()-start)/1e9f);
tx.commit();
tx = transactionService.getUserTransaction();
tx.begin();
start = System.nanoTime();
startCount = categoryService.getRootCategories(serviceRegistry.getPersonService().getPeopleContainer().getStoreRef(),
ContentModel.ASPECT_GEN_CLASSIFIABLE).size();
System.out.println("2 Query complete in "+(System.nanoTime()-start)/1e9f);
tx.commit();
for (int i = 0; i < 0; i++)
{
tx = transactionService.getUserTransaction();
tx.begin();
categoryService.createRootCategory(serviceRegistry.getPersonService().getPeopleContainer().getStoreRef(), ContentModel.ASPECT_GEN_CLASSIFIABLE, "first" + i);
tx.commit();
}
for (int j = 0; j < 10; j++)
{
tx = transactionService.getUserTransaction();
tx.begin();
for (int i = 0; i < 1; i++)
{
NodeRef topref = categoryService.createRootCategory(serviceRegistry.getPersonService().getPeopleContainer().getStoreRef(),ContentModel.ASPECT_GEN_CLASSIFIABLE, "third" + (j*100)+ i);
for(int k = 0; k < 5; k++)
{
NodeRef oneRef = categoryService.createCategory(topref, "child_"+i+"_"+j+"_"+k);
for(int l = 0; l < 5; l++)
{
NodeRef twoRef = categoryService.createCategory(oneRef, "child_"+i+"_"+j+"_"+k+"_"+l);
for(int m = 0; m < 5; m++)
{
NodeRef threeRef = categoryService.createCategory(twoRef, "child_"+i+"_"+j+"_"+k+"_"+l+"_"+m);
for(int n = 0; n < 5; n++)
{
NodeRef fourRef = categoryService.createCategory(threeRef, "child_"+i+"_"+j+"_"+k+"_"+l+"_"+m+"_"+n);
for(int o = 0; o < 5; o++)
{
NodeRef fiveRef = categoryService.createCategory(fourRef, "child_"+i+"_"+j+"_"+k+"_"+l+"_"+m+"_"+n+"_"+o);
for(int p = 0; p < 5; p++)
{
NodeRef sixRef = categoryService.createCategory(fiveRef, "child_"+i+"_"+j+"_"+k+"_"+l+"_"+m+"_"+n+"_"+o+"_"+p);
}
}
}
}
}
}
}
tx.commit();
}
tx = transactionService.getUserTransaction();
tx.begin();
start = System.nanoTime();
assertEquals(startCount + 10, categoryService.getRootCategories(serviceRegistry.getPersonService().getPeopleContainer().getStoreRef(),
ContentModel.ASPECT_GEN_CLASSIFIABLE).size());
System.out.println("3 Query complete in "+(System.nanoTime()-start)/1e9f);
tx.commit();
tx = transactionService.getUserTransaction();
tx.begin();
start = System.nanoTime();
assertEquals(startCount + 10, categoryService.getRootCategories(serviceRegistry.getPersonService().getPeopleContainer().getStoreRef(),
ContentModel.ASPECT_GEN_CLASSIFIABLE).size());
System.out.println("4 Query complete in "+(System.nanoTime()-start)/1e9f);
tx.commit();
tx = transactionService.getUserTransaction();
tx.begin();
start = System.nanoTime();
ResultSet set = searcher.query(serviceRegistry.getPersonService().getPeopleContainer().getStoreRef(), "lucene", "@"+LuceneQueryParser.escape(ContentModel.ASPECT_GEN_CLASSIFIABLE.toString())+":second*");
System.out.println("Query complete in "+(System.nanoTime()-start)/1e9f);
tx.commit();
}
private int getTotalScore(ResultSet results)
{
int totalScore = 0;

View File

@@ -373,13 +373,14 @@ public class LuceneTest2 extends TestCase
getOrderProperties()).getChildRef();
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
properties.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-16"));
properties.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8"));
n14 = nodeService.createNode(n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}fourteen"),
ContentModel.TYPE_CONTENT, properties).getChildRef();
// nodeService.addAspect(n14, DictionaryBootstrap.ASPECT_QNAME_CONTENT,
// properties);
ContentWriter writer = contentService.getWriter(n14, ContentModel.PROP_CONTENT, true);
writer.setEncoding("UTF-8");
// InputStream is =
// this.getClass().getClassLoader().getResourceAsStream("test.doc");
// writer.putContent(is);