Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hallgren2010-02-19 23:41:01 +0000
committerThomas Hallgren2010-02-19 23:41:01 +0000
commitbac0d0d80b49629932b68ebb0920ae197395e649 (patch)
tree1e21e5bf5ad839922b72b176ed60c210f71aa569 /bundles
parentd91933be414cbe75483e7e0c094ccd3131d80424 (diff)
downloadrt.equinox.p2-bac0d0d80b49629932b68ebb0920ae197395e649.tar.gz
rt.equinox.p2-bac0d0d80b49629932b68ebb0920ae197395e649.tar.xz
rt.equinox.p2-bac0d0d80b49629932b68ebb0920ae197395e649.zip
302201 : Unify the two query approaches used in p2 (fixed failing translation support test).
Diffstat (limited to 'bundles')
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ContextExpression.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RepeatableIterator.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/expression/IContextExpression.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/QueryContext.java34
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/ContextExpression.java11
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLUtil.java34
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/IContextExpression.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/QL.java6
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/QLContextQuery.java39
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/EvaluatorTest.java14
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/PerformanceTest.java34
11 files changed, 112 insertions, 105 deletions
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ContextExpression.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ContextExpression.java
index ec2394f50..37f561ba9 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ContextExpression.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/ContextExpression.java
@@ -12,6 +12,7 @@ package org.eclipse.equinox.internal.p2.metadata.expression;
import java.util.Iterator;
import org.eclipse.equinox.p2.metadata.expression.*;
+import org.eclipse.equinox.p2.metadata.index.IIndexProvider;
/**
* The context expression is the top expression in context queries. It introduces the
@@ -28,13 +29,21 @@ public class ContextExpression<T> extends Unary implements IContextExpression<T>
}
public boolean accept(IExpressionVisitor visitor) {
- return visitor.visit(operand);
+ return super.accept(visitor) && operand.accept(visitor);
}
public void toString(StringBuffer bld, Variable rootVariable) {
operand.toString(bld, rootVariable);
}
+ public IEvaluationContext createContext(Class<T> elementClass, IIndexProvider<T> indexProvider) {
+ Variable everything = ExpressionFactory.EVERYTHING;
+ IEvaluationContext context = EvaluationContext.create(parameters, everything);
+ context.setValue(everything, new Everything<T>(elementClass, indexProvider));
+ context.setIndexProvider(indexProvider);
+ return context;
+ }
+
public IEvaluationContext createContext(Class<T> elementClass, Iterator<T> iterator) {
Variable everything = ExpressionFactory.EVERYTHING;
IEvaluationContext context = EvaluationContext.create(parameters, everything);
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RepeatableIterator.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RepeatableIterator.java
index b7325286c..1ba8bfa01 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RepeatableIterator.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/RepeatableIterator.java
@@ -32,6 +32,8 @@ public class RepeatableIterator<T> implements IRepeatableIterator<T> {
return create((Set<T>) ((Map<?, ?>) unknown).entrySet());
if (unknown instanceof IQueryResult<?>)
return create((IQueryResult<T>) unknown);
+ if (unknown instanceof IIndexProvider<?>)
+ return create((IIndexProvider<T>) unknown);
throw new IllegalArgumentException("Cannot convert a " + unknown.getClass().getName() + " into an iterator"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -55,6 +57,10 @@ public class RepeatableIterator<T> implements IRepeatableIterator<T> {
return new ArrayIterator<T>(values);
}
+ public static <T> IRepeatableIterator<T> create(IIndexProvider<T> values) {
+ return new IndexProviderIterator<T>(values);
+ }
+
RepeatableIterator(List<T> values) {
this.values = values;
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/expression/IContextExpression.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/expression/IContextExpression.java
index 119d4edb7..dd6af8bc0 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/expression/IContextExpression.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/metadata/expression/IContextExpression.java
@@ -11,6 +11,7 @@
package org.eclipse.equinox.p2.metadata.expression;
import java.util.Iterator;
+import org.eclipse.equinox.p2.metadata.index.IIndexProvider;
/**
* This is an expression that will need access to the global variable
@@ -18,6 +19,19 @@ import java.util.Iterator;
* @since 2.0
*/
public interface IContextExpression<T> extends IExpression {
+
+ /**
+ * <p>Creates a new context to be passed to a subsequent evaluation. The context
+ * will have the variable 'everything' set to an expression that represents
+ * the <code>everything</code> iterator filtered for instances of <code>elementClass</code>.</p>
+ * <p>The values of the iterator will be copied if necessary (when everything is referenced
+ * more then once).</p>
+ * @param elementClass the class of the iterator elements
+ * @param indexProvider The index provider that represents all queried material.
+ * @return A new evaluation context.
+ */
+ IEvaluationContext createContext(Class<T> elementClass, IIndexProvider<T> indexProvider);
+
/**
* <p>Creates a new context to be passed to a subsequent evaluation. The context
* will have the variable 'everything' set to an expression that represents
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/QueryContext.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/QueryContext.java
index e984cc6f7..16a03649d 100644
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/QueryContext.java
+++ b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/QueryContext.java
@@ -1,31 +1,35 @@
package org.eclipse.equinox.internal.p2.ql;
import java.util.*;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.internal.p2.metadata.expression.IRepeatableIterator;
import org.eclipse.equinox.internal.p2.metadata.expression.RepeatableIterator;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
+import org.eclipse.equinox.p2.metadata.index.IIndex;
+import org.eclipse.equinox.p2.metadata.index.IIndexProvider;
import org.eclipse.equinox.p2.ql.IQueryContext;
import org.eclipse.equinox.p2.ql.ITranslationSupport;
-import org.eclipse.equinox.p2.query.*;
+import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.osgi.service.localization.LocaleProvider;
public class QueryContext<T> implements IQueryContext<T> {
- private final IQueryable<T> queryable;
+ private final IIndexProvider<T> indexProvider;
private Map<Locale, TranslationSupport> translationSupports;
- public QueryContext(IQueryable<T> queryable) {
- this.queryable = queryable;
+ public QueryContext(IIndexProvider<T> indexProvider) {
+ this.indexProvider = indexProvider;
}
public QueryContext(Iterator<T> iterator) {
final IRepeatableIterator<T> repeatable = RepeatableIterator.create(iterator);
- this.queryable = new IQueryable<T>() {
- public IQueryResult<T> query(IQuery<T> query, IProgressMonitor monitor) {
- return query.perform(repeatable.getCopy());
+ this.indexProvider = new IIndexProvider<T>() {
+ public Iterator<T> everything() {
+ return repeatable.getCopy();
+ }
+
+ public IIndex<T> getIndex(String memberName) {
+ return null;
}
};
}
@@ -38,7 +42,7 @@ public class QueryContext<T> implements IQueryContext<T> {
TranslationSupport ts = translationSupports.get(locale);
if (ts == null) {
ts = new TranslationSupport();
- ts.setTranslationSource((IQueryable<IInstallableUnit>) queryable);
+ ts.setTranslationSource((IQueryable<IInstallableUnit>) indexProvider);
ts.setLocaleProvider(new LocaleProvider() {
public Locale getLocale() {
// TODO Auto-generated method stub
@@ -51,14 +55,6 @@ public class QueryContext<T> implements IQueryContext<T> {
}
public Iterator<T> iterator() {
- @SuppressWarnings("unchecked")
- final Iterator<T>[] iteratorCatcher = new Iterator[1];
- queryable.query(new ContextQuery<T>() {
- public IQueryResult<T> perform(Iterator<T> iterator) {
- iteratorCatcher[0] = iterator;
- return null;
- }
- }, new NullProgressMonitor());
- return iteratorCatcher[0];
+ return indexProvider.everything();
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/ContextExpression.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/ContextExpression.java
index e7c3bc7ec..40943040e 100644
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/ContextExpression.java
+++ b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/ContextExpression.java
@@ -14,6 +14,7 @@ import java.util.Iterator;
import org.eclipse.equinox.internal.p2.metadata.expression.*;
import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
import org.eclipse.equinox.p2.metadata.expression.IExpression;
+import org.eclipse.equinox.p2.metadata.index.IIndexProvider;
import org.eclipse.equinox.p2.ql.IContextExpression;
import org.eclipse.equinox.p2.ql.ITranslationSupport;
@@ -27,6 +28,16 @@ public final class ContextExpression<T> extends org.eclipse.equinox.internal.p2.
super(expression, parameters);
}
+ public IEvaluationContext createContext(Class<T> elementClass, IIndexProvider<T> indexProvider, ITranslationSupport ts) {
+ Variable everything = ExpressionFactory.EVERYTHING;
+ IExpression translations = QLFactory.TRANSLATIONS;
+ IEvaluationContext context = EvaluationContext.create(parameters, new IExpression[] {everything, translations});
+ context.setValue(everything, new Everything<T>(elementClass, indexProvider));
+ context.setValue(translations, ts);
+ context.setIndexProvider(indexProvider);
+ return context;
+ }
+
public IEvaluationContext createContext(Class<T> elementClass, Iterator<T> iterator, ITranslationSupport ts) {
Variable everything = ExpressionFactory.EVERYTHING;
IExpression translations = QLFactory.TRANSLATIONS;
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLUtil.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLUtil.java
index 5ae9b8c6b..46553138c 100644
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLUtil.java
+++ b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLUtil.java
@@ -12,7 +12,8 @@ package org.eclipse.equinox.internal.p2.ql.expression;
import java.util.*;
import org.eclipse.equinox.internal.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.*;
+import org.eclipse.equinox.p2.metadata.expression.IExpression;
+import org.eclipse.equinox.p2.metadata.expression.IExpressionVisitor;
import org.eclipse.equinox.p2.query.IQueryResult;
/**
@@ -56,21 +57,30 @@ public abstract class QLUtil implements IExpression, IQLConstants {
return result;
}
+ private static class TranslationSupportFinder implements IExpressionVisitor {
+ private boolean found;
+
+ TranslationSupportFinder() { //
+ }
+
+ public boolean visit(IExpression expression) {
+ if (expression.getExpressionType() == TYPE_MEMBER && VARIABLE_TRANSLATIONS.equals(((Member) expression).getName()))
+ found = true;
+ return !found;
+ }
+
+ boolean isFound() {
+ return found;
+ }
+ }
+
/**
* Checks if the expression will make repeated requests for the 'everything' iterator.
* @return <code>true</code> if repeated requests will be made, <code>false</code> if not.
*/
public static boolean needsTranslationSupport(IExpression expression) {
- final boolean[] translationSupportNeeded = new boolean[] {false};
- ((Expression) expression).accept(new IExpressionVisitor() {
- public boolean visit(IExpression expr) {
- if (expr.getExpressionType() == TYPE_MEMBER && VARIABLE_TRANSLATIONS.equals(ExpressionUtil.getName(expr))) {
- translationSupportNeeded[0] = true;
- return false;
- }
- return true;
- }
- });
- return translationSupportNeeded[0];
+ TranslationSupportFinder tsFinder = new TranslationSupportFinder();
+ ((Expression) expression).accept(tsFinder);
+ return tsFinder.isFound();
}
}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/IContextExpression.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/IContextExpression.java
index fa588b58e..1943a9a4c 100644
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/IContextExpression.java
+++ b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/IContextExpression.java
@@ -12,12 +12,26 @@ package org.eclipse.equinox.p2.ql;
import java.util.Iterator;
import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
+import org.eclipse.equinox.p2.metadata.index.IIndexProvider;
/**
* This is an expression that will need access to the global variable
* <code>everything</code>.
*/
public interface IContextExpression<T> extends org.eclipse.equinox.p2.metadata.expression.IContextExpression<T> {
+
+ /**
+ * <p>Creates a new context to be passed to a subsequent evaluation. The context
+ * will have the variable 'everything' set to an expression that represents
+ * the <code>everything</code> iterator filtered for instances of <code>elementClass</code>.</p>
+ * <p>The values of the iterator will be copied if necessary (when everything is referenced
+ * more then once).</p>
+ * @param indexProvider The index provider that represents all queried material.
+ * @param translations A translation support object to be assigned to the variable 'translations'
+ * @return A new evaluation context.
+ */
+ IEvaluationContext createContext(Class<T> elementClass, IIndexProvider<T> indexProvider, ITranslationSupport ts);
+
/**
* <p>Creates a new context to be passed to a subsequent evaluation. The context
* will have the variable 'everything' set to an expression that represents
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/QL.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/QL.java
index d3f0a911b..170b15e60 100644
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/QL.java
+++ b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/QL.java
@@ -12,7 +12,7 @@ package org.eclipse.equinox.p2.ql;
import java.util.Iterator;
import org.eclipse.equinox.internal.p2.ql.QueryContext;
-import org.eclipse.equinox.p2.query.IQueryable;
+import org.eclipse.equinox.p2.metadata.index.IIndexProvider;
/**
* The public access point to all QL functionality.
@@ -23,8 +23,8 @@ public abstract class QL {
* @param queryable The queryable to use for the creation of the context
* @return A new context
*/
- public static <T> IQueryContext<T> newQueryContext(IQueryable<T> queryable) {
- return new QueryContext<T>(queryable);
+ public static <T> IQueryContext<T> newQueryContext(IIndexProvider<T> indexProvider) {
+ return new QueryContext<T>(indexProvider);
}
/**
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/QLContextQuery.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/QLContextQuery.java
index 8022adf2d..77bd77cfb 100644
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/QLContextQuery.java
+++ b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/p2/ql/QLContextQuery.java
@@ -22,7 +22,6 @@ import org.eclipse.equinox.p2.query.IQueryResult;
*/
public class QLContextQuery<T> extends QLQuery<T> implements IQueryWithIndex<T> {
private final IContextExpression<T> expression;
- private IIndexProvider indexProvider;
/**
* Creates a new query instance with indexed parameters.
@@ -44,16 +43,24 @@ public class QLContextQuery<T> extends QLQuery<T> implements IQueryWithIndex<T>
}
public IQueryResult<T> perform(IIndexProvider<T> idxProvider) {
- indexProvider = idxProvider;
-
- // TODO Fix so that we don't request everything here.
- return new QueryResult<T>(evaluate(idxProvider.everything()));
+ return new QueryResult<T>(evaluate(idxProvider));
}
public IQueryResult<T> perform(Iterator<T> iterator) {
return new QueryResult<T>(evaluate(iterator));
}
+ public Iterator<T> evaluate(IIndexProvider<T> idxProvider) {
+ IEvaluationContext ctx;
+ if (QLUtil.needsTranslationSupport(expression)) {
+ IQueryContext<T> queryContext = QL.newQueryContext(idxProvider);
+ ctx = expression.createContext(elementClass, idxProvider, queryContext.getTranslationSupport(getLocale()));
+ } else
+ ctx = expression.createContext(elementClass, idxProvider);
+ Iterator<T> result = expression.iterator(ctx);
+ return result;
+ }
+
public Iterator<T> evaluate(Iterator<T> iterator) {
IEvaluationContext ctx;
if (QLUtil.needsTranslationSupport(expression)) {
@@ -61,7 +68,6 @@ public class QLContextQuery<T> extends QLQuery<T> implements IQueryWithIndex<T>
ctx = expression.createContext(elementClass, iterator, queryContext.getTranslationSupport(getLocale()));
} else
ctx = expression.createContext(elementClass, iterator);
- ctx.setIndexProvider(indexProvider);
Iterator<T> result = expression.iterator(ctx);
return result;
}
@@ -69,25 +75,4 @@ public class QLContextQuery<T> extends QLQuery<T> implements IQueryWithIndex<T>
public IExpression getExpression() {
return expression;
}
-
- /**
- * Query without using a collector. Instead, return the result of the query directly.
- * @param queryContext The context for the query.
- * @return The result of the query.
- */
- public Object query(IQueryContext<T> queryContext) {
- // Check if we need translation support
- //
- IEvaluationContext ctx;
- if (QLUtil.needsTranslationSupport(expression))
- ctx = expression.createContext(elementClass, queryContext.iterator(), queryContext.getTranslationSupport(getLocale()));
- else
- ctx = expression.createContext(elementClass, queryContext.iterator());
- ctx.setIndexProvider(indexProvider);
- return expression.evaluate(ctx);
- }
-
- public void setIndexProvider(IIndexProvider indexProvider) {
- this.indexProvider = indexProvider;
- }
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/EvaluatorTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/EvaluatorTest.java
index 5765efcc5..5268cf906 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/EvaluatorTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/EvaluatorTest.java
@@ -19,13 +19,13 @@ import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.expression.*;
-import org.eclipse.equinox.p2.metadata.expression.IContextExpression;
import org.eclipse.equinox.p2.metadata.query.ExpressionQuery;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
import org.eclipse.equinox.p2.publisher.PublisherInfo;
import org.eclipse.equinox.p2.publisher.PublisherResult;
import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction;
-import org.eclipse.equinox.p2.ql.*;
+import org.eclipse.equinox.p2.ql.IQLFactory;
+import org.eclipse.equinox.p2.ql.QLContextQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.MatchQuery;
import org.eclipse.equinox.p2.repository.artifact.*;
@@ -229,9 +229,6 @@ public class EvaluatorTest extends AbstractProvisioningTest {
// Add some filtering of requirements
IMetadataRepository repo = getMDR("/testData/galileoM7");
- QLContextQuery indexQuery = new QLContextQuery(IInstallableUnit.class, "capabilityIndex(everything)");
- Object index = indexQuery.query(QL.newQueryContext(repo));
-
Map env = new Hashtable();
env.put("osgi.os", "linux");
env.put("osgi.ws", "gtk");
@@ -239,15 +236,14 @@ public class EvaluatorTest extends AbstractProvisioningTest {
IContextExpression<IInstallableUnit> expr = factory.contextExpression(parser.parseQuery("" + //
"select(x | x.id == $0 && x.version == $1).traverse(parent |" + //
- "$5.satisfiesAny(parent.requiredCapabilities.select(rc | rc.filter == null || $4 ~= rc.filter))).intersect(" + //
+ "parent.requiredCapabilities.select(rc | rc.filter == null || $4 ~= rc.filter).collect(rc | select(iu | iu ~= rc)).flatten()).intersect(" + //
"select(x | x.id == $2 && x.version == $3).traverse(parent |" + //
- "$5.satisfiesAny(parent.requiredCapabilities.select(rc | rc.filter == null || $4 ~= rc.filter))))"), //
+ "parent.requiredCapabilities.select(rc | rc.filter == null || $4 ~= rc.filter).collect(rc | select(iu | iu ~= rc)).flatten()))"), //
"org.eclipse.pde.feature.group", //
Version.create("3.5.0.v20090123-7Z7YF8NFE-z0VXhWU26Hu8gY"), //
"org.eclipse.gmf.feature.group", //
Version.create("1.1.1.v20090114-0940-7d8B0FXwkKwFanGNHeHHq8ymBgZ"), //
- env,//
- index);
+ env);
QLContextQuery query = new QLContextQuery(IInstallableUnit.class, expr);
IQueryResult result = repo.query(query, new NullProgressMonitor());
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/PerformanceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/PerformanceTest.java
index a37f1be3e..75acb300b 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/PerformanceTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/PerformanceTest.java
@@ -20,7 +20,6 @@ import org.eclipse.equinox.internal.provisional.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.query.ExpressionQuery;
import org.eclipse.equinox.p2.metadata.query.InstallableUnitQuery;
-import org.eclipse.equinox.p2.ql.QL;
import org.eclipse.equinox.p2.ql.QLContextQuery;
import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
@@ -59,39 +58,6 @@ public class PerformanceTest extends AbstractProvisioningTest {
System.out.println();
}
- public void testCapabilityQueryPerformance2() throws Exception {
-
- IMetadataRepository repo = getMDR("/testData/galileoM7");
- IQueryable qaRepo = new QueryableArray(gatherAvailableInstallableUnits(repo));
-
- IRequirement capability = MetadataFactory.createRequiredCapability("org.eclipse.equinox.p2.eclipse.type", "feature", new VersionRange("[1.0.0,2.0.0)"), null, false, false);
- QLContextQuery exprQuery = new QLContextQuery(IInstallableUnit.class, "capabilityIndex(everything)");
- IQuery capabilityQuery = new ExpressionQuery(IInstallableUnit.class, capability.getMatches());
- exprQuery = new QLContextQuery(IInstallableUnit.class, "$0.satisfiesAny([$1])", exprQuery.query(QL.newQueryContext(qaRepo)), capability);
- IQueryResult result;
- long tradQueryMS = 0;
- long exprQueryMS = 0;
-
- for (int i = 0; i < 5; ++i) {
- long start = System.currentTimeMillis();
- for (int idx = 0; idx < 80; ++idx) {
- result = qaRepo.query(capabilityQuery, new NullProgressMonitor());
- assertEquals(queryResultSize(result), 487);
- }
- tradQueryMS += (System.currentTimeMillis() - start);
-
- start = System.currentTimeMillis();
- for (int idx = 0; idx < 80; ++idx) {
- result = qaRepo.query(exprQuery, new NullProgressMonitor());
- assertEquals(queryResultSize(result), 487);
- }
- exprQueryMS += (System.currentTimeMillis() - start);
- }
- System.out.println("CapabilityQuery took: " + tradQueryMS + " milliseconds");
- System.out.println("PredicateQuery took: " + exprQueryMS + " milliseconds");
- System.out.println();
- }
-
public void testIUPropertyQueryPerformance() throws Exception {
IMetadataRepository repo = getMDR("/testData/galileoM7");

Back to the top