Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 323854 - Implementing a cache for returned objects from XPath
Summary: Implementing a cache for returned objects from XPath
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Jet (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-27 12:33 EDT by Jean Neveux CLA
Modified: 2020-05-01 16:11 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jean Neveux CLA 2010-08-27 12:33:54 EDT
Hi,

Some XPath functions always returns the same result, especially if you start from the root element or if you have a generic functions such as "//".

For example I consider the following function "//Interface" beeing static. Meaning it will always return the same result for a given model. Putting a cache on this fonction will only consume process the first time it's executed.

This cache would be place before the XPath function eval inside "XPathExpressionImpl".

In this example the XPath expression is passed to the XPathExpressionImpl constructor :

  public Object evaluate(Object contextObject)
  {

    if (this.expression != null && isStaticExpr(this.expression))
    {
      // Look up cache.
      if (Cache.getXPathCache(expression) == null)
      {
        Cache.getXpathCache().put(
          expression,
          node.evalAsObject(new Context(contextObject, variableResolver, annotationManager, functionResolver)));
      }
      return Cache.getXPathCache(expression);
    }
    else
    {
      return node.evalAsObject(new Context(contextObject, variableResolver, annotationManager, functionResolver));
    }
  }

Best regards,

Jean