You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by rv...@apache.org on 2013/01/28 16:53:29 UTC
svn commit: r1439456 - in /jena/trunk/jena-arq/src:
main/java/org/apache/jena/riot/system/ test/java/org/apache/jena/riot/system/
Author: rvesse
Date: Mon Jan 28 15:53:28 2013
New Revision: 1439456
URL: http://svn.apache.org/viewvc?rev=1439456&view=rev
Log:
Fix copyright headers, add constructor overloads to FastPrefixMap
Modified:
jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/system/FastPrefixMap.java
jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/system/LightweightPrefixMap.java
jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TS_RiotSystem.java
jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TestAbbreviationPerformance.java
jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TestFastPrefixMap.java
jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TestPrefixMap.java
Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/system/FastPrefixMap.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/system/FastPrefixMap.java?rev=1439456&r1=1439455&r2=1439456&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/system/FastPrefixMap.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/system/FastPrefixMap.java Mon Jan 28 15:53:28 2013
@@ -1,5 +1,19 @@
/*
- * Copyright 2013 YarcData LLC All Rights Reserved.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.jena.riot.system;
@@ -28,6 +42,19 @@ public class FastPrefixMap extends Light
private Map<String, IRI> prefixes = new HashMap<String, IRI>();
private Map<String, IRI> prefixesView = Collections.unmodifiableMap(this.prefixes);
private Trie<String> abbrevs = new Trie<String>();
+
+ /**
+ * Create a new fast prefix map
+ */
+ public FastPrefixMap() { }
+
+ /**
+ * Create a new prefix map which copies mappings from an existing map
+ * @param pmap Prefix Map
+ */
+ public FastPrefixMap(LightweightPrefixMap pmap) {
+ this.putAll(pmap);
+ }
/**
* Gets the key for abbreviation lookup from an IRI
Modified: jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/system/LightweightPrefixMap.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/system/LightweightPrefixMap.java?rev=1439456&r1=1439455&r2=1439456&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/system/LightweightPrefixMap.java (original)
+++ jena/trunk/jena-arq/src/main/java/org/apache/jena/riot/system/LightweightPrefixMap.java Mon Jan 28 15:53:28 2013
@@ -1,7 +1,20 @@
/*
- * Copyright 2013 YarcData LLC All Rights Reserved.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
-
package org.apache.jena.riot.system;
import java.util.Map;
Modified: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TS_RiotSystem.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TS_RiotSystem.java?rev=1439456&r1=1439455&r2=1439456&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TS_RiotSystem.java (original)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TS_RiotSystem.java Mon Jan 28 15:53:28 2013
@@ -33,7 +33,8 @@ import org.junit.runners.Suite.SuiteClas
// Prefix Map implementations
, TestPrefixMap.class
, TestFastPrefixMap.class
- // Not included due to vagaries of performance on different systems
+ // May be subject to performance vagaries, often passes in Eclipse
+ // and not on maven command line so excluded for now
//, TestAbbreviationPerformance.class
})
Modified: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TestAbbreviationPerformance.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TestAbbreviationPerformance.java?rev=1439456&r1=1439455&r2=1439456&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TestAbbreviationPerformance.java (original)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TestAbbreviationPerformance.java Mon Jan 28 15:53:28 2013
@@ -1,5 +1,19 @@
/*
- * Copyright 2013 YarcData LLC All Rights Reserved.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
package org.apache.jena.riot.system;
@@ -12,28 +26,9 @@ import org.junit.Test;
*
*/
public class TestAbbreviationPerformance {
-
- /**
- * Compares the performance of looking up a specific namespaces 1000 times
- */
- private void test_performance(PrefixMap normal, FastPrefixMap fast, String input, String expected, boolean fastShouldWin) {
- long nPerf = this.run(normal, input, expected, 1000);
- long fPerf = this.run(fast, input, expected, 1000);
-
- //System.out.println("PrefixMap performance: " + nPerf + "ns");
- //System.out.println("Fast Prefix Map performance: " + fPerf + "ns");
-
- if (fastShouldWin) {
- if (fPerf > nPerf)
- Assert.fail("Expected FastPrefixMap to outperform PrefixMap");
- } else {
- if (nPerf > fPerf)
- Assert.fail("Expected PrefixMap to outperform FastPrefixMap");
- }
- }
/**
- * Compares the performance of looking up every namespace 100 times
+ * Compares the performance of looking up every namespace 1000 times
* @param normal PrefixMap
* @param fast FastPrefixMap
* @param namespaces Number of namespaces
@@ -45,8 +40,8 @@ public class TestAbbreviationPerformance
for (int i = 1; i <= namespaces; i++) {
String input = "http://example/ns" + i + "#x";
String expected = "ns" + i + ":x";
- nPerf += run(normal, input, expected, 100);
- fPerf += run(fast, input, expected, 100);
+ nPerf += run(normal, input, expected, 1000);
+ fPerf += run(fast, input, expected, 1000);
}
//System.out.println("PrefixMap performance: " + nPerf + "ns");
@@ -87,7 +82,7 @@ public class TestAbbreviationPerformance
FastPrefixMap fmap = new FastPrefixMap();
populate(fmap, 1);
- test_performance(pmap, fmap, "http://example/ns1#x", "ns1:x", false);
+ test_amalgamated_performance(pmap, fmap, 1, false);
}
/**
@@ -101,7 +96,7 @@ public class TestAbbreviationPerformance
FastPrefixMap fmap = new FastPrefixMap();
populate(fmap, 2);
- test_performance(pmap, fmap, "http://example/ns2#x", "ns2:x", true);
+ test_amalgamated_performance(pmap, fmap, 2, true);
}
/**
@@ -115,7 +110,7 @@ public class TestAbbreviationPerformance
FastPrefixMap fmap = new FastPrefixMap();
populate(fmap, 5);
- test_performance(pmap, fmap, "http://example/ns5#x", "ns5:x", true);
+ test_amalgamated_performance(pmap, fmap, 5, true);
}
/**
@@ -129,7 +124,7 @@ public class TestAbbreviationPerformance
FastPrefixMap fmap = new FastPrefixMap();
populate(fmap, 20);
- test_performance(pmap, fmap, "http://example/ns20#x", "ns20:x", true);
+ test_amalgamated_performance(pmap, fmap, 20, true);
}
/**
Modified: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TestFastPrefixMap.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TestFastPrefixMap.java?rev=1439456&r1=1439455&r2=1439456&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TestFastPrefixMap.java (original)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TestFastPrefixMap.java Mon Jan 28 15:53:28 2013
@@ -1,9 +1,27 @@
/*
- * Copyright 2013 YarcData LLC All Rights Reserved.
- */
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.jena.riot.system;
+/**
+ * Tests the {@link FastPrefixMap} implementation
+ *
+ */
public class TestFastPrefixMap extends TestLightweightPrefixMap {
@Override
Modified: jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TestPrefixMap.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TestPrefixMap.java?rev=1439456&r1=1439455&r2=1439456&view=diff
==============================================================================
--- jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TestPrefixMap.java (original)
+++ jena/trunk/jena-arq/src/test/java/org/apache/jena/riot/system/TestPrefixMap.java Mon Jan 28 15:53:28 2013
@@ -1,9 +1,27 @@
/*
- * Copyright 2013 YarcData LLC All Rights Reserved.
- */
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.jena.riot.system;
+/**
+ * Test the standard {@link PrefixMap} implementation
+ *
+ */
public class TestPrefixMap extends TestLightweightPrefixMap {
@Override