Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Hallgren2010-03-18 13:01:54 +0000
committerThomas Hallgren2010-03-18 13:01:54 +0000
commit93093759d06ee870a51be0933bb0106a3aa9c8cf (patch)
tree1ede30b0ef01b6e170f3bae255cd69ffd240ed4f
parent0d3a9648af11a58fb62f52523202d07ed6fd57ee (diff)
downloadrt.equinox.p2-93093759d06ee870a51be0933bb0106a3aa9c8cf.tar.gz
rt.equinox.p2-93093759d06ee870a51be0933bb0106a3aa9c8cf.tar.xz
rt.equinox.p2-93093759d06ee870a51be0933bb0106a3aa9c8cf.zip
305619 : GC test failure in HEAD + some optimizations
-rw-r--r--bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java38
-rw-r--r--bundles/org.eclipse.equinox.p2.console/Provisioning console.launch12
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java25
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/IUMap.java15
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/At.java30
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Matches.java68
-rw-r--r--bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/ExpressionMatchQuery.java7
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/At.java42
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Matches.java97
-rw-r--r--bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLFactory.java8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/All p2 Tests.launch8
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java20
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional3.java3
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/ql/PerformanceTest.java19
14 files changed, 176 insertions, 216 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
index 45afb00f7..1192a5d91 100644
--- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
+++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/SimpleArtifactRepository.java
@@ -16,6 +16,7 @@ import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
+import java.util.Map.Entry;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import org.eclipse.core.runtime.*;
@@ -210,10 +211,11 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
/**
* Map<IArtifactKey,List<IArtifactDescriptor>> containing the index of artifacts in the repository.
*/
- protected final Map<IArtifactKey, List<IArtifactDescriptor>> artifactMap = new HashMap<IArtifactKey, List<IArtifactDescriptor>>();
+ private Map<IArtifactKey, List<IArtifactDescriptor>> artifactMap = new HashMap<IArtifactKey, List<IArtifactDescriptor>>();
private transient BlobStore blobStore;
transient private Mapper mapper = new Mapper();
private KeyIndex keyIndex;
+ private boolean snapshotNeeded = false;
static final private String PUBLISH_PACK_FILES_AS_SIBLINGS = "publishPackFilesAsSiblings"; //$NON-NLS-1$
@@ -272,28 +274,43 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
mapDescriptor(desc);
}
- private void mapDescriptor(IArtifactDescriptor descriptor) {
+ private synchronized void mapDescriptor(IArtifactDescriptor descriptor) {
IArtifactKey key = descriptor.getArtifactKey();
+ if (snapshotNeeded) {
+ cloneAritfactMap();
+ snapshotNeeded = false;
+ }
List<IArtifactDescriptor> descriptors = artifactMap.get(key);
if (descriptors == null) {
descriptors = new ArrayList<IArtifactDescriptor>();
artifactMap.put(key, descriptors);
- keyIndex = null;
}
descriptors.add(descriptor);
+ keyIndex = null;
}
- private void unmapDescriptor(IArtifactDescriptor descriptor) {
+ private synchronized void unmapDescriptor(IArtifactDescriptor descriptor) {
IArtifactKey key = descriptor.getArtifactKey();
List<IArtifactDescriptor> descriptors = artifactMap.get(key);
if (descriptors == null)
return;
+ if (snapshotNeeded) {
+ cloneAritfactMap();
+ snapshotNeeded = false;
+ descriptors = artifactMap.get(key);
+ }
descriptors.remove(descriptor);
- if (descriptors.isEmpty()) {
+ if (descriptors.isEmpty())
artifactMap.remove(key);
- keyIndex = null;
- }
+ keyIndex = null;
+ }
+
+ private void cloneAritfactMap() {
+ HashMap<IArtifactKey, List<IArtifactDescriptor>> clone = new HashMap<IArtifactKey, List<IArtifactDescriptor>>(artifactMap.size());
+ for (Entry<IArtifactKey, List<IArtifactDescriptor>> entry : artifactMap.entrySet())
+ clone.put(entry.getKey(), new ArrayList<IArtifactDescriptor>(entry.getValue()));
+ artifactMap = clone;
}
public SimpleArtifactRepository(IProvisioningAgent agent, String repositoryName, URI location, Map<String, String> properties) {
@@ -1002,6 +1019,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
return new IQueryable<IArtifactDescriptor>() {
public IQueryResult<IArtifactDescriptor> query(IQuery<IArtifactDescriptor> query, IProgressMonitor monitor) {
synchronized (SimpleArtifactRepository.this) {
+ snapshotNeeded = true;
Collection<List<IArtifactDescriptor>> descs = SimpleArtifactRepository.this.artifactMap.values();
return query.perform(new CompoundIterator<IArtifactDescriptor>(descs.iterator()));
}
@@ -1009,11 +1027,12 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
};
}
- public synchronized IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> query, IProgressMonitor monitor) {
+ public IQueryResult<IArtifactKey> query(IQuery<IArtifactKey> query, IProgressMonitor monitor) {
return IndexProvider.query(this, query, monitor);
}
- public Iterator<IArtifactKey> everything() {
+ public synchronized Iterator<IArtifactKey> everything() {
+ snapshotNeeded = true;
return artifactMap.keySet().iterator();
}
@@ -1044,6 +1063,7 @@ public class SimpleArtifactRepository extends AbstractArtifactRepository impleme
public synchronized IIndex<IArtifactKey> getIndex(String memberName) {
if (ArtifactKey.MEMBER_ID.equals(memberName)) {
+ snapshotNeeded = true;
if (keyIndex == null)
keyIndex = new KeyIndex(artifactMap.keySet());
return keyIndex;
diff --git a/bundles/org.eclipse.equinox.p2.console/Provisioning console.launch b/bundles/org.eclipse.equinox.p2.console/Provisioning console.launch
index c4d876982..b8541dcab 100644
--- a/bundles/org.eclipse.equinox.p2.console/Provisioning console.launch
+++ b/bundles/org.eclipse.equinox.p2.console/Provisioning console.launch
@@ -5,16 +5,18 @@
<stringAttribute key="bootstrap" value=""/>
<stringAttribute key="checked" value="[NONE]"/>
<booleanAttribute key="clearConfig" value="false"/>
-<stringAttribute key="configLocation" value="d:\tmp\selfhosting"/>
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/Provisioning console"/>
<booleanAttribute key="default_auto_start" value="false"/>
<intAttribute key="default_start_level" value="4"/>
<booleanAttribute key="includeOptional" value="true"/>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
-<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-console -consolelog"/>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java-1.6.0-openjdk-1.6.0.0.x86_64"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-console -consolelog -noexit"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
+<stringAttribute key="pde.version" value="3.3"/>
<booleanAttribute key="show_selected_only" value="false"/>
-<stringAttribute key="target_bundles" value="org.eclipse.equinox.app*1.0.100.v20080303@default:default,org.eclipse.equinox.preferences*3.2.200.v20080201@default:default,javax.servlet*2.4.0.v200711021030@default:default,org.eclipse.core.runtime.compatibility.registry*3.2.200.v20070717@default:false,org.eclipse.core.runtime*3.4.0.v20080303@default:default,org.eclipse.core.jobs*3.3.100.v20080224@default:default,org.eclipse.core.net*1.0.100.I20080226@default:default,org.eclipse.equinox.common*3.4.0.v20080201@default:default,org.eclipse.osgi.services*3.1.200.v20071203@default:default,org.eclipse.osgi*3.4.0.v20080304@:,org.eclipse.core.runtime.compatibility.auth*3.2.100.v20070502@default:default,org.eclipse.equinox.registry*3.4.0.v20080201@default:default,org.eclipse.core.contenttype*3.3.0.v20080201@default:default"/>
+<stringAttribute key="target_bundles" value="org.eclipse.osgi.services@default:default,org.eclipse.ecf.ssl@default:false,org.eclipse.equinox.common@2:true,org.eclipse.core.net@default:default,org.eclipse.equinox.security@default:default,org.eclipse.ecf.provider.filetransfer.httpclient@default:default,org.eclipse.core.net.linux.x86_64@default:false,org.eclipse.core.contenttype@default:default,org.apache.commons.codec@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.app@default:default,org.eclipse.ecf@default:default,javax.servlet@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.apache.commons.logging@default:default,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.equinox.util@default:default,org.eclipse.core.runtime.compatibility.auth@default:default,org.eclipse.core.runtime@default:true,org.eclipse.equinox.preferences@default:default,org.apache.commons.httpclient@default:default,org.eclipse.core.jobs@default:default,org.eclipse.osgi@-1:true,org.eclipse.equinox.registry@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.equinox.concurrent@default:default,org.eclipse.ant.core@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.ecf.identity@default:default,org.eclipse.ecf.provider.filetransfer.httpclient.ssl@default:false,org.eclipse.core.variables@default:default"/>
<booleanAttribute key="tracing" value="false"/>
-<booleanAttribute key="useDefaultConfigArea" value="false"/>
-<stringAttribute key="workspace_bundles" value="org.eclipse.equinox.p2.metadata.generator*0.1.0.qualifier@default:default,org.eclipse.equinox.frameworkadmin*0.1.0.qualifier@default:default,org.sat4j.pb*2.0.0.v20080307@default:default,org.eclipse.equinox.p2.garbagecollector*0.1.0.qualifier@default:default,org.eclipse.equinox.p2.core*0.1.0.qualifier@default:default,org.eclipse.ecf.provider.filetransfer*1.6.0.qualifier@default:default,org.eclipse.equinox.p2.metadata*0.1.0.qualifier@default:default,org.eclipse.equinox.p2.exemplarysetup*0.1.0.qualifier@default:true,org.eclipse.equinox.p2.console*0.1.0.qualifier@default:true,org.eclipse.equinox.p2.touchpoint.eclipse*0.1.0.qualifier@default:default,org.eclipse.ecf*1.4.0.qualifier@default:default,org.eclipse.equinox.p2.artifact.repository*0.1.0.qualifier@default:default,org.eclipse.equinox.frameworkadmin.equinox*0.1.0.qualifier@default:true,org.eclipse.equinox.p2.metadata.repository*0.1.0.qualifier@default:default,org.sat4j.core*2.0.0.v20080307@default:default,org.eclipse.equinox.simpleconfigurator.manipulator*0.1.0.qualifier@default:default,org.eclipse.equinox.p2.director*0.1.0.qualifier@default:default,org.eclipse.equinox.p2.engine*0.1.0.qualifier@default:default,org.eclipse.ecf.filetransfer*2.0.0.qualifier@default:default,org.eclipse.equinox.p2.touchpoint.natives*0.1.0.qualifier@default:default,org.eclipse.equinox.simpleconfigurator*0.1.0.qualifier@1:true,org.eclipse.equinox.p2.jarprocessor*0.1.0.qualifier@default:default,org.eclipse.ecf.identity*1.3.0.qualifier@default:default"/>
+<booleanAttribute key="useDefaultConfigArea" value="true"/>
+<stringAttribute key="workspace_bundles" value="org.eclipse.equinox.p2.touchpoint.osgi@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.equinox.p2.metadata.generator@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.p2.updatesite@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:true,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.extensionlocation@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.sat4j.pb@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.eclipse.equinox.p2.publisher@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,org.eclipse.equinox.p2.exemplarysetup@default:true,org.eclipse.equinox.p2.operations@default:default,org.eclipse.equinox.p2.artifact.optimizers@default:default,ie.wombat.jbdiff@default:default,org.eclipse.equinox.p2.ql@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.equinox.p2.touchpoint.natives@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.eclipse.equinox.p2.director@default:default,org.eclipse.equinox.p2.sar@default:default,org.eclipse.equinox.p2.artifact.processors@default:default,org.eclipse.equinox.p2.console@default:true,org.eclipse.equinox.p2.repository.tools@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.p2.directorywatcher@default:default,org.sat4j.core@default:default,org.eclipse.equinox.simpleconfigurator@1:true"/>
</launchConfiguration>
diff --git a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java
index e2a8bc3ef..534681f51 100644
--- a/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java
+++ b/bundles/org.eclipse.equinox.p2.metadata.repository/src/org/eclipse/equinox/internal/p2/metadata/repository/LocalMetadataRepository.java
@@ -54,6 +54,7 @@ public class LocalMetadataRepository extends AbstractMetadataRepository implemen
private IIndex<IInstallableUnit> idIndex;
private IIndex<IInstallableUnit> capabilityIndex;
private TranslationSupport translationSupport;
+ private boolean snapshotNeeded = false;
private static File getActualLocation(URI location, String extension) {
File spec = URIUtil.toFile(location);
@@ -101,6 +102,11 @@ public class LocalMetadataRepository extends AbstractMetadataRepository implemen
public synchronized void addInstallableUnits(Collection<IInstallableUnit> installableUnits) {
if (installableUnits == null || installableUnits.isEmpty())
return;
+ if (snapshotNeeded) {
+ units = units.clone();
+ idIndex = null; // Backed by units
+ snapshotNeeded = false;
+ }
units.addAll(installableUnits);
capabilityIndex = null; // Generated, not backed by units
save();
@@ -128,12 +134,14 @@ public class LocalMetadataRepository extends AbstractMetadataRepository implemen
*/
public synchronized IIndex<IInstallableUnit> getIndex(String memberName) {
if (InstallableUnit.MEMBER_ID.equals(memberName)) {
+ snapshotNeeded = true;
if (idIndex == null)
idIndex = new IdIndex(units);
return idIndex;
}
if (InstallableUnit.MEMBER_PROVIDED_CAPABILITIES.equals(memberName)) {
+ snapshotNeeded = true;
if (capabilityIndex == null)
capabilityIndex = new CapabilityIndex(units.iterator());
return capabilityIndex;
@@ -209,14 +217,15 @@ public class LocalMetadataRepository extends AbstractMetadataRepository implemen
/* (non-Javadoc)
* @see org.eclipse.equinox.p2.query.IQueryable#query(org.eclipse.equinox.p2.query.IQuery, org.eclipse.core.runtime.IProgressMonitor)
*/
- public synchronized IQueryResult<IInstallableUnit> query(IQuery<IInstallableUnit> query, IProgressMonitor monitor) {
+ public IQueryResult<IInstallableUnit> query(IQuery<IInstallableUnit> query, IProgressMonitor monitor) {
return IndexProvider.query(this, query, monitor);
}
/* (non-Javadoc)
* @see org.eclipse.equinox.p2.metadata.index.IIndexProvider#everything()
*/
- public Iterator<IInstallableUnit> everything() {
+ public synchronized Iterator<IInstallableUnit> everything() {
+ snapshotNeeded = true;
return units.iterator();
}
@@ -225,7 +234,12 @@ public class LocalMetadataRepository extends AbstractMetadataRepository implemen
*/
@Override
public synchronized void removeAll() {
- units.clear();
+ if (snapshotNeeded) {
+ units = new IUMap();
+ idIndex = null; // Backed by units
+ snapshotNeeded = false;
+ } else
+ units.clear();
capabilityIndex = null; // Generated, not backed by units.
save();
}
@@ -238,6 +252,11 @@ public class LocalMetadataRepository extends AbstractMetadataRepository implemen
boolean changed = false;
if (installableUnits != null && !installableUnits.isEmpty()) {
changed = true;
+ if (snapshotNeeded) {
+ units = units.clone();
+ idIndex = null; // Backed by units
+ snapshotNeeded = false;
+ }
units.removeAll(installableUnits);
capabilityIndex = null; // Generated, not backed by units.
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/IUMap.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/IUMap.java
index ec1fb81d3..e3af9283d 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/IUMap.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/IUMap.java
@@ -20,7 +20,7 @@ import org.eclipse.equinox.p2.query.*;
/**
* A map that stores {@link IInstallableUnit} instances in a way that is efficient to query
*/
-public class IUMap {
+public class IUMap implements Cloneable {
/**
* Iterator over all the {@link IInstallableUnit} instances in the map.
*/
@@ -86,6 +86,14 @@ public class IUMap {
*/
final Map<String, Object> units = new HashMap<String, Object>();
+ public IUMap() {
+ //
+ }
+
+ private IUMap(IUMap cloneSource) {
+ units.putAll(cloneSource.units);
+ }
+
public void add(IInstallableUnit unit) {
String key = unit.getId();
Object matching = units.get(key);
@@ -131,6 +139,11 @@ public class IUMap {
units.clear();
}
+ @Override
+ public IUMap clone() {
+ return new IUMap(this);
+ }
+
public Iterator<IInstallableUnit> iterator() {
return new MapIterator();
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/At.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/At.java
index e089c1dbc..ea7cd0301 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/At.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/At.java
@@ -11,9 +11,11 @@
package org.eclipse.equinox.internal.p2.metadata.expression;
import java.util.*;
+import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
import org.eclipse.equinox.internal.p2.metadata.expression.Member.DynamicMember;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
+import org.eclipse.equinox.p2.metadata.index.IIndexProvider;
/**
* This class represents indexed or keyed access to an indexed collection
@@ -24,26 +26,24 @@ public class At extends Binary {
super(lhs, rhs);
}
- protected Object handleMember(IEvaluationContext context, Member member, Object instance, boolean[] handled) {
- if (instance instanceof IInstallableUnit) {
- if ("properties".equals(member.getName())) { //$NON-NLS-1$
- // Avoid full copy of the properties map just to get one member
- handled[0] = true;
- return ((IInstallableUnit) instance).getProperty((String) rhs.evaluate(context));
- }
- }
- return null;
- }
-
public Object evaluate(org.eclipse.equinox.p2.metadata.expression.IEvaluationContext context) {
Object lval;
if (lhs instanceof DynamicMember) {
DynamicMember lm = (DynamicMember) lhs;
Object instance = lm.operand.evaluate(context);
- boolean[] handled = new boolean[] {false};
- Object result = handleMember(context, lm, instance, handled);
- if (handled[0])
- return result;
+ if (instance instanceof IInstallableUnit) {
+ String name = lm.getName();
+ if (InstallableUnit.MEMBER_TRANSLATED_PROPERTIES == name || InstallableUnit.MEMBER_PROFILE_PROPERTIES == name) {
+ IIndexProvider<?> indexProvider = context.getIndexProvider();
+ if (indexProvider == null)
+ throw new UnsupportedOperationException("No managed properties available to QL"); //$NON-NLS-1$
+ return indexProvider.getManagedProperty(instance, name, rhs.evaluate(context));
+ }
+ if (InstallableUnit.MEMBER_PROPERTIES == name) {
+ // Avoid full copy of the properties map just to get one member
+ return ((IInstallableUnit) instance).getProperty((String) rhs.evaluate(context));
+ }
+ }
lval = lm.invoke(instance);
} else
lval = lhs.evaluate(context);
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Matches.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Matches.java
index 3c9a9cd1f..0c8f0ba21 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Matches.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/Matches.java
@@ -10,9 +10,10 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.metadata.expression;
-import org.eclipse.equinox.p2.metadata.Version;
-import org.eclipse.equinox.p2.metadata.VersionRange;
+import java.util.*;
+import org.eclipse.equinox.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.expression.*;
+import org.osgi.framework.Filter;
/**
* <p>A class that performs &quot;matching&quot; The actual algorithm used for
@@ -38,30 +39,46 @@ public class Matches extends Binary {
protected boolean match(Object lval, Object rval) {
if (lval == null || rval == null)
return false;
- if (rval instanceof VersionRange) {
+
+ if (rval instanceof IRequirement) {
+ IRequirement requirement = (IRequirement) rval;
+ if (lval instanceof IInstallableUnit)
+ return Boolean.valueOf(((IInstallableUnit) lval).satisfies(requirement));
+ } else if (rval instanceof VersionRange) {
VersionRange range = (VersionRange) rval;
if (lval instanceof Version)
- return range.isIncluded((Version) lval);
+ return Boolean.valueOf(range.isIncluded((Version) lval));
if (lval instanceof String)
return range.isIncluded(Version.create((String) lval));
+ } else if (rval instanceof SimplePattern) {
+ if (lval instanceof CharSequence)
+ return ((SimplePattern) rval).isMatch((CharSequence) lval);
+ if (lval instanceof Character || lval instanceof Number || lval instanceof Boolean)
+ return ((SimplePattern) rval).isMatch(lval.toString());
} else if (rval instanceof LDAPFilter) {
return ((LDAPFilter) rval).isMatch(MemberProvider.create(lval, true));
+ } else if (rval instanceof Filter) {
+ if (lval instanceof IInstallableUnit)
+ return Boolean.valueOf(((Filter) rval).match(new Hashtable<String, String>(((IInstallableUnit) lval).getProperties())));
+ if (lval instanceof Dictionary<?, ?>)
+ return Boolean.valueOf(((Filter) rval).match((Dictionary<?, ?>) lval));
+ if (lval instanceof Map<?, ?>)
+ return Boolean.valueOf(((Filter) rval).match(new Hashtable<Object, Object>((Map<?, ?>) lval)));
+ } else if (rval instanceof Locale) {
+ if (lval instanceof String)
+ return Boolean.valueOf(matchLocaleVariants((Locale) rval, (String) lval));
} else if (rval instanceof IMatchExpression<?>) {
@SuppressWarnings("unchecked")
IMatchExpression<Object> me = (IMatchExpression<Object>) rval;
return me.isMatch(lval);
- } else if (rval instanceof SimplePattern) {
- if (lval instanceof CharSequence)
- return ((SimplePattern) rval).isMatch((CharSequence) lval);
- if (lval instanceof Character || lval instanceof Number || lval instanceof Boolean)
- return ((SimplePattern) rval).isMatch(lval.toString());
-
+ } else if (rval instanceof IUpdateDescriptor) {
+ if (lval instanceof IInstallableUnit)
+ return Boolean.valueOf(((IUpdateDescriptor) rval).isUpdateOf((IInstallableUnit) lval));
} else if (rval instanceof LDAPApproximation) {
if (lval instanceof CharSequence)
return ((LDAPApproximation) rval).isMatch((CharSequence) lval);
if (lval instanceof Character || lval instanceof Number || lval instanceof Boolean)
return ((LDAPApproximation) rval).isMatch(lval.toString());
-
} else if (rval instanceof Class<?>) {
Class<?> rclass = (Class<?>) rval;
return lval instanceof Class<?> ? rclass.isAssignableFrom((Class<?>) lval) : rclass.isInstance(lval);
@@ -95,4 +112,33 @@ public class Matches extends Binary {
appendLDAPEscaped(buf, val.toString(), escapeWild);
buf.append(')');
}
+
+ private static boolean equals(String a, String b, int startPos, int endPos) {
+ if (endPos - startPos != b.length())
+ return false;
+
+ int bidx = 0;
+ while (startPos < endPos)
+ if (a.charAt(startPos++) != b.charAt(bidx++))
+ return false;
+ return true;
+ }
+
+ private static boolean matchLocaleVariants(Locale rval, String lval) {
+ int uscore = lval.indexOf('_');
+ if (uscore < 0)
+ // No country and no variant. Just match language
+ return lval.equals(rval.getLanguage());
+
+ if (!equals(lval, rval.getLanguage(), 0, uscore))
+ // Language part doesn't match. Give up.
+ return false;
+
+ // Check country and variant
+ int countryStart = uscore + 1;
+ uscore = lval.indexOf('_', countryStart);
+ return uscore < 0 ? equals(lval, rval.getCountry(), countryStart, lval.length()) //
+ : equals(lval, rval.getCountry(), countryStart, uscore) && equals(lval, rval.getVariant(), uscore + 1, lval.length());
+ }
+
}
diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/ExpressionMatchQuery.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/ExpressionMatchQuery.java
index 09e9f1ab1..276e49766 100644
--- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/ExpressionMatchQuery.java
+++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/p2/query/ExpressionMatchQuery.java
@@ -45,9 +45,8 @@ public class ExpressionMatchQuery<T> implements IMatchQuery<T>, IQueryWithIndex<
}
public IQueryResult<T> perform(IIndexProvider<T> indexProvider) {
- //if (((MatchExpression<T>) expression).operand == ExpressionUtil.TRUE_EXPRESSION)
- // return new QueryResult<T>(indexProvider.everything());
-
+ if (((MatchExpression<T>) expression).operand == ExpressionUtil.TRUE_EXPRESSION)
+ return new QueryResult<T>(indexProvider.everything());
Iterator<T> iterator = null;
int top = indexedMembers.size();
for (int idx = 0; idx < top; ++idx) {
@@ -65,7 +64,7 @@ public class ExpressionMatchQuery<T> implements IMatchQuery<T>, IQueryWithIndex<
}
public IQueryResult<T> perform(Iterator<T> iterator) {
- if (expression == null)
+ if (((MatchExpression<T>) expression).operand == ExpressionUtil.TRUE_EXPRESSION)
return new QueryResult<T>(iterator);
HashSet<T> result = null;
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/At.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/At.java
deleted file mode 100644
index d9681570b..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/At.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Cloudsmith Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
-import org.eclipse.equinox.internal.p2.metadata.expression.Expression;
-import org.eclipse.equinox.internal.p2.metadata.expression.Member;
-import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.metadata.expression.IEvaluationContext;
-import org.eclipse.equinox.p2.metadata.index.IIndexProvider;
-import org.eclipse.equinox.p2.ql.IQLExpression;
-
-/**
- * This class represents indexed or keyed access to an indexed collection
- * or a map.
- */
-final class At extends org.eclipse.equinox.internal.p2.metadata.expression.At implements IQLExpression {
- At(Expression lhs, Expression rhs) {
- super(lhs, rhs);
- }
-
- protected Object handleMember(IEvaluationContext context, Member member, Object instance, boolean[] handled) {
- if (instance instanceof IInstallableUnit) {
- if (InstallableUnit.MEMBER_TRANSLATED_PROPERTIES == member.getName() || InstallableUnit.MEMBER_PROFILE_PROPERTIES == member.getName()) {
- IIndexProvider<?> indexProvider = context.getIndexProvider();
- if (indexProvider == null)
- throw new UnsupportedOperationException("No managed properties available to QL"); //$NON-NLS-1$
- handled[0] = true;
- return indexProvider.getManagedProperty(instance, member.getName(), rhs.evaluate(context));
- }
- }
- return super.handleMember(context, member, instance, handled);
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Matches.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Matches.java
deleted file mode 100644
index 0a4a11aaa..000000000
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/Matches.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Cloudsmith Inc. and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Cloudsmith Inc. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.equinox.internal.p2.ql.expression;
-
-import java.util.*;
-import org.eclipse.equinox.internal.p2.metadata.expression.Expression;
-import org.eclipse.equinox.internal.p2.metadata.expression.LDAPApproximation;
-import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.metadata.expression.SimplePattern;
-import org.osgi.framework.Filter;
-
-/**
- * <p>A class that performs &quot;matching&quot; The actual algorithm used for
- * performing the match varies depending on the types of the items to match.</p>
- * <p>The following things can be matched:</p>
- * <table border="1" cellpadding="3">
- * <tr><th>LHS</th><th>RHS</th><th>Implemented as</th></tr>
- * <tr><td>IProvidedCapability</td><td>IRequirement</td><td>lhs.satisfies(rhs)</td></tr>
- * <tr><td>IInstallableUnit</td><td>IRequirement</td><td>lhs.satisfies(rhs)</td></tr>
- * <tr><td>Version</td><td>VersionRange</td><td>rhs.isIncluded(lhs)</td></tr>
- * <tr><td>IInstallableUnit</td><td>Filter</td><td>rhs.matches(lhs.properties)</td></tr>
- * <tr><td>Map</td><td>Filter</td><td>rhs.match(lhs)</td></tr>
- * <tr><td>{@link String}</td><td>{@link SimplePattern}</td><td>rhs.isMatch(lhs)</td></tr>
- * <tr><td>{@link String}</td><td>{@link LDAPApproximation}</td><td>rhs.isMatch(lhs)</td></tr>
- * <tr><td>&lt;any&gt;</td><td>{@link Class}</td><td>rhs.isInstance(lhs)</td></tr>
- * <tr><td>{@link Class}</td><td>{@link Class}</td><td>rhs.isAssignableFrom(lhs)</td></tr>
- * </table>
- */
-final class Matches extends org.eclipse.equinox.internal.p2.metadata.expression.Matches {
- private static boolean equals(String a, String b, int startPos, int endPos) {
- if (endPos - startPos != b.length())
- return false;
-
- int bidx = 0;
- while (startPos < endPos)
- if (a.charAt(startPos++) != b.charAt(bidx++))
- return false;
- return true;
- }
-
- private static boolean matchLocaleVariants(Locale rval, String lval) {
- int uscore = lval.indexOf('_');
- if (uscore < 0)
- // No country and no variant. Just match language
- return lval.equals(rval.getLanguage());
-
- if (!equals(lval, rval.getLanguage(), 0, uscore))
- // Language part doesn't match. Give up.
- return false;
-
- // Check country and variant
- int countryStart = uscore + 1;
- uscore = lval.indexOf('_', countryStart);
- return uscore < 0 ? equals(lval, rval.getCountry(), countryStart, lval.length()) //
- : equals(lval, rval.getCountry(), countryStart, uscore) && equals(lval, rval.getVariant(), uscore + 1, lval.length());
- }
-
- Matches(Expression lhs, Expression rhs) {
- super(lhs, rhs);
- }
-
- protected boolean match(Object lval, Object rval) {
- if (rval instanceof IRequirement) {
- IRequirement requirement = (IRequirement) rval;
- if (lval instanceof IInstallableUnit)
- return Boolean.valueOf(((IInstallableUnit) lval).satisfies(requirement));
- } else if (rval instanceof VersionRange) {
- if (lval instanceof Version)
- return Boolean.valueOf(((VersionRange) rval).isIncluded((Version) lval));
-
- } else if (rval instanceof IUpdateDescriptor) {
- if (lval instanceof IInstallableUnit)
- return Boolean.valueOf(((IUpdateDescriptor) rval).isUpdateOf((IInstallableUnit) lval));
-
- } else if (rval instanceof Filter) {
- if (lval instanceof IInstallableUnit)
- return Boolean.valueOf(((Filter) rval).match(new Hashtable<String, String>(((IInstallableUnit) lval).getProperties())));
- if (lval instanceof Dictionary<?, ?>)
- return Boolean.valueOf(((Filter) rval).match((Dictionary<?, ?>) lval));
- if (lval instanceof Map<?, ?>)
- return Boolean.valueOf(((Filter) rval).match(new Hashtable<Object, Object>((Map<?, ?>) lval)));
-
- } else if (rval instanceof Locale) {
- if (lval instanceof String)
- return Boolean.valueOf(matchLocaleVariants((Locale) rval, (String) lval));
- }
- return super.match(lval, rval);
- }
-}
diff --git a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLFactory.java b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLFactory.java
index cf075a44a..a238ed7dd 100644
--- a/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLFactory.java
+++ b/bundles/org.eclipse.equinox.p2.ql/src/org/eclipse/equinox/internal/p2/ql/expression/QLFactory.java
@@ -31,10 +31,6 @@ public class QLFactory extends ExpressionFactory implements IQLFactory, IQLConst
}
}
- public IExpression at(IExpression target, IExpression key) {
- return new At((Expression) target, (Expression) key);
- }
-
public IExpression intersect(IExpression c1, IExpression c2) {
return new Intersect((Expression) c1, (Expression) c2);
}
@@ -104,10 +100,6 @@ public class QLFactory extends ExpressionFactory implements IQLFactory, IQLConst
return new Limit((Expression) collection, (Expression) limit);
}
- public IExpression matches(IExpression lhs, IExpression rhs) {
- return new Matches((Expression) lhs, (Expression) rhs);
- }
-
public IExpression memberCall(IExpression target, String name, IExpression... args) {
if (args.length == 0)
return member(target, name);
diff --git a/bundles/org.eclipse.equinox.p2.tests/All p2 Tests.launch b/bundles/org.eclipse.equinox.p2.tests/All p2 Tests.launch
index 852c329c6..b371a01ec 100644
--- a/bundles/org.eclipse.equinox.p2.tests/All p2 Tests.launch
+++ b/bundles/org.eclipse.equinox.p2.tests/All p2 Tests.launch
@@ -1,4 +1,5 @@
-<?xml version="1.0" encoding="UTF-8"?><launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.pde.ui.JunitLaunchConfig">
<booleanAttribute key="append.args" value="true"/>
<stringAttribute key="application" value="org.eclipse.pde.junit.runtime.coretestapplication"/>
<booleanAttribute key="askclear" value="false"/>
@@ -52,12 +53,11 @@
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
-<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/IBM-1.6.0-20090519-SR5"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.equinox.p2.tests.AutomatedTests"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consolelog -console"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.equinox.p2.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
-<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.eclipse.equinox.p2.reconciler.tests.platform.archive=c:/dev/platform/zips/eclipse-platform-3.6M6-win32.zip&#13;&#10;-Dorg.eclipse.equinox.p2.reconciler.tests.35.platform.archive=c:/dev/platform/zips/eclipse-platform-3.5-win32.zip&#13;&#10;-Dorg.eclipse.equinox.p2.repository&#13;&#10;-Dorg.eclipse.equinox.p2.tests.current.build.repo=http://eclipsebuildserv/3.6-I-builds/&#13;&#13;&#10;-Xmx512m"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.eclipse.equinox.p2.reconciler.tests.platform.archive=/home/thhal/Download/eclipse-platform-N20091109-2000-linux-gtk-x86_64.tar.gz&#13;&#10;-Dorg.eclipse.equinox.p2.reconciler.tests.35.platform.archive=/home/thhal/Download/eclipse-platform-3.5.1-linux-gtk-x86_64.tar.gz&#13;&#10;-Dorg.eclipse.equinox.p2.repository&#13;&#10;-Dorg.eclipse.equinox.p2.tests.current.build.repo=http://eclipsebuildserv/3.6-I-builds/&#13;&#13;&#10;-Xmx512m"/>
<stringAttribute key="pde.version" value="3.3"/>
<stringAttribute key="product" value="org.eclipse.sdk.ide"/>
<booleanAttribute key="run_in_ui_thread" value="true"/>
@@ -68,4 +68,4 @@
<booleanAttribute key="useDefaultConfig" value="true"/>
<booleanAttribute key="useDefaultConfigArea" value="false"/>
<booleanAttribute key="useProduct" value="false"/>
-</launchConfiguration> \ No newline at end of file
+</launchConfiguration>
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java
index 1be8a3850..6cfcb74a5 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/metadata/repository/CompositeMetadataRepositoryTest.java
@@ -12,8 +12,6 @@
*******************************************************************************/
package org.eclipse.equinox.p2.tests.metadata.repository;
-import org.eclipse.equinox.p2.query.MatchQuery;
-
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
@@ -266,7 +264,7 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest {
assertContains("Assert child1's content is in composite repo", repo1, compRepo);
assertContains("Assert child2's content is in composite repo", repo2, compRepo);
//checks that the destination has the correct number of keys (no extras)
- assertEquals("Assert correct number of IUs", getNumUnique(repo1.query(QueryUtil.createIUAnyQuery(), null), repo2.query(QueryUtil.createIUAnyQuery(), null)), queryResultSize(compRepo.query(QueryUtil.createIUAnyQuery(), null)));
+ assertEquals("Assert correct number of IUs", getNumUnique(repo1.query(QueryUtil.createIUAnyQuery(), null), repo2.query(QueryUtil.createIUAnyQuery(), null)), compRepo.query(QueryUtil.createIUAnyQuery(), null).toUnmodifiableSet().size());
}
public void testRemoveNonexistantChild() {
@@ -528,7 +526,7 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest {
assertContains("Assert child1's content is in composite repo", repo1, compRepo);
assertContains("Assert child2's content is in composite repo", repo2, compRepo);
//checks that the destination has the correct number of keys (no extras)
- assertEquals("Assert correct number of IUs", getNumUnique(repo1.query(QueryUtil.createIUAnyQuery(), null), repo2.query(QueryUtil.createIUAnyQuery(), null)), queryResultSize(compRepo.query(QueryUtil.createIUAnyQuery(), null)));
+ assertEquals("Assert correct number of IUs", getNumUnique(repo1.query(QueryUtil.createIUAnyQuery(), null), repo2.query(QueryUtil.createIUAnyQuery(), null)), compRepo.query(QueryUtil.createIUAnyQuery(), null).toUnmodifiableSet().size());
}
private CompositeMetadataRepository createRepo(boolean compressed) {
@@ -553,16 +551,16 @@ public class CompositeMetadataRepositoryTest extends AbstractProvisioningTest {
* Takes 2 collectors, compares them, and returns the number of unique keys
* Needed to verify that only the appropriate number of files have been transfered by the mirror application
*/
- private int getNumUnique(IQueryResult c1, IQueryResult c2) {
- Object[] repo1 = c1.toArray(IInstallableUnit.class);
- Object[] repo2 = c2.toArray(IInstallableUnit.class);
+ private int getNumUnique(IQueryResult<IInstallableUnit> c1, IQueryResult<IInstallableUnit> c2) {
+ Set<IInstallableUnit> set1 = c1.toUnmodifiableSet();
+ Set<IInstallableUnit> set2 = c2.toUnmodifiableSet();
//initialize to the size of both collectors
- int numKeys = repo1.length + repo2.length;
+ int numKeys = set1.size() + set2.size();
- for (int i = 0; i < repo1.length; i++) {
- for (int j = 0; j < repo2.length; j++) {
- if (isEqual((IInstallableUnit) repo1[i], (IInstallableUnit) repo2[j]))
+ for (IInstallableUnit iu1 : set1) {
+ for (IInstallableUnit iu2 : set2) {
+ if (isEqual(iu1, iu2))
numKeys--;
//identical keys has bee found, therefore the number of unique keys is one less than previously thought
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional3.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional3.java
index 0ee5d9b1c..e4f517a35 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional3.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/planner/PatchTestOptional3.java
@@ -26,7 +26,6 @@ public class PatchTestOptional3 extends AbstractProvisioningTest {
private IInstallableUnit p2;
private IInstallableUnitPatch pp1;
private IInstallableUnit p2b;
- private IInstallableUnit p1b;
private IProfile profile1;
private IPlanner planner;
private IEngine engine;
@@ -44,7 +43,7 @@ public class PatchTestOptional3 extends AbstractProvisioningTest {
IRequirement[][] scopepp1 = new IRequirement[][] {{MetadataFactory.createRequirement(IInstallableUnit.NAMESPACE_IU_ID, P2_FEATURE, new VersionRange("[1.0.0,1.0.0]"), null, false, false)}};
pp1 = createIUPatch(PP1, Version.create("3.0.0"), true, new IRequirementChange[] {changepp1, changepp2}, scopepp1, lifeCyclepp1);
- createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p1b, p2b, pp1});
+ createTestMetdataRepository(new IInstallableUnit[] {p2Feature, p1, p2, p2b, pp1});
profile1 = createProfile("TestProfile." + getName());
planner = createPlanner();
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 c4eebc594..da7e13e2d 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
@@ -19,13 +19,24 @@ import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
import org.eclipse.equinox.internal.p2.metadata.expression.MatchIteratorFilter;
import org.eclipse.equinox.internal.p2.metadata.expression.QueryResult;
import org.eclipse.equinox.p2.metadata.*;
-import org.eclipse.equinox.p2.metadata.expression.SimplePattern;
+import org.eclipse.equinox.p2.metadata.expression.*;
import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
public class PerformanceTest extends AbstractProvisioningTest {
+ public void testParserPerformance() throws Exception {
+ long start = System.currentTimeMillis();
+ IExpressionFactory factory = ExpressionUtil.getFactory();
+ IExpressionParser parser = ExpressionUtil.getParser();
+ for (int i = 0; i < 20000; i++) {
+ factory.matchExpression(parser.parse("providedCapabilities.exists(x | x.name == foo)"));
+ }
+ long end = System.currentTimeMillis();
+ System.out.println(end - start);
+ }
+
public void testMatchQueryVersusExpressionPerformance() throws Exception {
IMetadataRepository repo = getMDR("/testData/galileoM7");
@@ -88,14 +99,14 @@ public class PerformanceTest extends AbstractProvisioningTest {
}
};
result = new QueryResult<IInstallableUnit>(matchIter);
- assertEquals(queryResultSize(result), 3465);
+ assertEquals(result.toUnmodifiableSet().size(), 3465);
}
matchFilterMS += (System.currentTimeMillis() - start);
start = System.currentTimeMillis();
for (int idx = 0; idx < 80; ++idx) {
result = repo.query(matchQuery, new NullProgressMonitor());
- assertEquals(queryResultSize(result), 3465);
+ assertEquals(result.toUnmodifiableSet().size(), 3465);
}
matchQueryMS += (System.currentTimeMillis() - start);
}
@@ -166,7 +177,7 @@ public class PerformanceTest extends AbstractProvisioningTest {
}
public void testSlicerPerformance() throws Exception {
- Hashtable env = new Hashtable();
+ HashMap<String, String> env = new HashMap<String, String>();
env.put("osgi.os", "linux");
env.put("osgi.ws", "gtk");
env.put("osgi.arch", "x86");

Back to the top