This list is closed, nobody may subscribe to it.
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(139) |
Aug
(94) |
Sep
(232) |
Oct
(143) |
Nov
(138) |
Dec
(55) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(127) |
Feb
(90) |
Mar
(101) |
Apr
(74) |
May
(148) |
Jun
(241) |
Jul
(169) |
Aug
(121) |
Sep
(157) |
Oct
(199) |
Nov
(281) |
Dec
(75) |
2012 |
Jan
(107) |
Feb
(122) |
Mar
(184) |
Apr
(73) |
May
(14) |
Jun
(49) |
Jul
(26) |
Aug
(103) |
Sep
(133) |
Oct
(61) |
Nov
(51) |
Dec
(55) |
2013 |
Jan
(59) |
Feb
(72) |
Mar
(99) |
Apr
(62) |
May
(92) |
Jun
(19) |
Jul
(31) |
Aug
(138) |
Sep
(47) |
Oct
(83) |
Nov
(95) |
Dec
(111) |
2014 |
Jan
(125) |
Feb
(60) |
Mar
(119) |
Apr
(136) |
May
(270) |
Jun
(83) |
Jul
(88) |
Aug
(30) |
Sep
(47) |
Oct
(27) |
Nov
(23) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(3) |
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
(4) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <mrp...@us...> - 2010-07-23 18:04:39
|
Revision: 3274 http://bigdata.svn.sourceforge.net/bigdata/?rev=3274&view=rev Author: mrpersonick Date: 2010-07-23 18:04:32 +0000 (Fri, 23 Jul 2010) Log Message: ----------- fixing a problem with term resolution Modified Paths: -------------- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java 2010-07-23 17:58:30 UTC (rev 3273) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java 2010-07-23 18:04:32 UTC (rev 3274) @@ -35,6 +35,7 @@ import org.openrdf.model.URI; import org.openrdf.model.Value; import org.openrdf.model.datatypes.XMLDatatypeUtil; +import com.bigdata.rdf.model.BigdataURI; import com.bigdata.rdf.model.BigdataValue; @@ -56,9 +57,6 @@ private Map<String, IExtension> datatypes; - public LexiconConfiguration() { - } - public LexiconConfiguration(final boolean inlineLiterals, final boolean inlineBNodes, final IExtensionFactory xFactory) { @@ -66,13 +64,13 @@ this.inlineBNodes = inlineBNodes; termIds = new HashMap<TermId, IExtension>(); - for (IExtension extension : xFactory.getExtensions()) { - termIds.put((TermId) extension.getDatatype().getIV(), extension); - } - datatypes = new HashMap<String, IExtension>(); for (IExtension extension : xFactory.getExtensions()) { - datatypes.put(extension.getDatatype().stringValue(), extension); + BigdataURI datatype = extension.getDatatype(); + if (datatype == null) + continue; + termIds.put((TermId) datatype.getIV(), extension); + datatypes.put(datatype.stringValue(), extension); } } Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java 2010-07-23 17:58:30 UTC (rev 3273) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java 2010-07-23 18:04:32 UTC (rev 3274) @@ -966,15 +966,29 @@ final BigdataURI buri = valueFactory.asValue(uri); if (buri.getIV() == null) { + + // will set tid on buri as a side effect + TermId tid = getTermId(buri); - _addTerms(new BigdataValue[] { buri }, 1, false); + if (tid == null) { - if (buri.getIV() == null) - throw new RuntimeException(); + try { + + // will set tid on buri as a side effect + _addTerms(new BigdataValue[] { buri }, 1, false); + + } catch (Exception ex) { + + // might be in a read-only transaction view + log.warn("unable to resolve term: " + uri); + + } + } + } - return buri; + return buri.getIV() != null ? buri : null; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <btm...@us...> - 2010-07-23 17:58:42
|
Revision: 3273 http://bigdata.svn.sourceforge.net/bigdata/?rev=3273&view=rev Author: btmurphy Date: 2010-07-23 17:58:30 +0000 (Fri, 23 Jul 2010) Log Message: ----------- merge -r3235:HEAD(3267) ~/bigdata/trunk ~/bigdata/branches/bugfix-btm [trunk --> branch bugfix-btm] Modified Paths: -------------- branches/bugfix-btm/bigdata/src/java/com/bigdata/util/config/NicUtil.java branches/bugfix-btm/bigdata-jini/src/java/com/bigdata/service/jini/util/LookupStarter.java branches/bugfix-btm/bigdata-jini/src/java/com/bigdata/service/jini/util/config/lookup.config branches/bugfix-btm/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config branches/bugfix-btm/bigdata-jini/src/test/com/bigdata/jini/start/testReggie.config branches/bugfix-btm/bigdata-jini/src/test/com/bigdata/jini/start/testStartJini.config branches/bugfix-btm/bigdata-jini/src/test/com/bigdata/zookeeper/testzoo.config branches/bugfix-btm/bigdata-sails/src/test/com/bigdata/rdf/sail/TestNamedGraphs.java branches/bugfix-btm/build.properties branches/bugfix-btm/build.xml branches/bugfix-btm/src/resources/config/bigdataCluster.config branches/bugfix-btm/src/resources/config/jini/reggie.config branches/bugfix-btm/src/resources/config/jini/startAll.config branches/bugfix-btm/src/resources/config/logging.properties branches/bugfix-btm/src/resources/config/standalone/bigdataStandalone.config Property Changed: ---------------- branches/bugfix-btm/ branches/bugfix-btm/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql/ branches/bugfix-btm/dsi-utils/ branches/bugfix-btm/src/resources/bin/config/ Property changes on: branches/bugfix-btm ___________________________________________________________________ Modified: svn:mergeinfo - /branches/BTREE_BUFFER_BRANCH:2004-2045 /branches/DEV_BRANCH_27_OCT_2009:2270-2546,2548-2782 /branches/dev-btm:2574-2730 /branches/fko:3150-3194 /trunk:2595-2877,2883-3010,3012-3235 + /branches/BTREE_BUFFER_BRANCH:2004-2045 /branches/DEV_BRANCH_27_OCT_2009:2270-2546,2548-2782 /branches/dev-btm:2574-2730 /branches/fko:3150-3194 /trunk:2595-2877,2883-3010,3012-3269 Modified: branches/bugfix-btm/bigdata/src/java/com/bigdata/util/config/NicUtil.java =================================================================== --- branches/bugfix-btm/bigdata/src/java/com/bigdata/util/config/NicUtil.java 2010-07-23 17:36:38 UTC (rev 3272) +++ branches/bugfix-btm/bigdata/src/java/com/bigdata/util/config/NicUtil.java 2010-07-23 17:58:30 UTC (rev 3273) @@ -505,6 +505,141 @@ } /** + * Special-purpose convenience method that returns a + * <code>String</code> value representing the ip address of + * the current node; where the value that is returned is + * determined according to following criteria: + * <p> + * <ul> + * <li> If a non-<code>null</code> value is input for the + * <code>systemPropertyName</code> parameter, then + * this is viewed as a declaration by the caller that + * that the system property with that given value + * should take precedence over all other means of + * determining the desired ip address. As such, this + * method determines if a system property having the + * given has indeed been set and, if it has, returns + * the ip address of the nic having that name; or + * <code>null</code> if there is no nic with the + * desired name installed on the node. + * <li> If a non-<code>null</code> value is input for the + * <code>systemPropertyName</code> parameter, but + * no system property with that name has been set, + * and <code>true</code> has been passed in for + * the <code>fallbackOk</code> parameter, then this + * method will return the IPV4 based address of the + * first reachable nic that is found on the node. + * Upon failing to find such an address, if the + * <code>loopbackOk</code> parameter is also + * <code>true</code>, then this method will return + * the <i>loop back</i> address of the node; otherwise + * <code>null</code> is returned. + * <li> If <code>null</code> is input for the + * <code>systemPropertyName</code> parameter, but + * a non-<code>null</code> value is input for the + * <code>defaultNic</code> parameter, then this + * method returns the ip address of the nic having + * that name; or <code>null</code> if there is no + * nic with the desired default name installed on the + * node. + * <li> If <code>null</code> is input for both the + * <code>systemPropertyName</code> parameter and the + * <code>defaultNic</code> parameter, and if the + * <code>fallbackOk</code> parameter is <code>true</code>, + * then this method will return the IPV4 based address + * of the first reachable nic that is found on the node. + * Upon failing to find such an address, if the + * <code>loopbackOk</code> parameter is also + * <code>true</code>, then this method will return + * the <i>loop back</i> address of the node; otherwise + * <code>null</code> is returned. + * </ul> + * <p> + * This method can be called from within a configuration + * as well as from within program control. + * + * @param systemPropertyName <code>String</code> value containing + * the name of a system property whose + * value is the network interface name + * whose ip address should be returned. + * May be <code>null</code>. + * + * @param defaultNic <code>String</code> value containing + * the name of the network interface + * whose ip address should be returned + * if <code>null</code> is input for the + * <code>systemPropertyName</code> parameter. + * + * @param fallbackOk if <code>true</code>, then if either + * no system property is set having the + * name referenced by the + * <code>systemPropertyName</code> parameter, + * or if <code>null</code> is input for both + * the <code>systemPropertyName</code> + * parameter and the <code>defaultNic</code> + * parameter, return the IPV4 based address + * of the first reachable network interface + * that can be found on the node. + * + * @param loopbackOk if <code>true</code>, and if <code>true</code> + * is also input for the <code>fallbackOk</code> + * parameter, then if this method attempts, + * but fails, to find a valid IPV4 fallback + * address, then the node's <i>loop back</i> + * address is returned. + * + * @return a <code>String</code> representing an ip address associated + * with the current node; where the value that is returned is + * determined according to the criteria described above. + */ + public static String getIpAddress(String systemPropertyName, + String defaultNic, + boolean fallbackOk, + boolean loopbackOk) + throws SocketException, IOException + { + if(systemPropertyName != null) {//system property takes precedence + String nicName = System.getProperty(systemPropertyName); + boolean propSet = true; + if(nicName == null) { + propSet = false; + } else { + // handle ant script case where the system property + // may not have been set on the command line, but + // was still set to "${<systemPropertyName>}" using + // ant <sysproperty> tag + String rawProp = "${" + systemPropertyName + "}"; + if( rawProp.equals(nicName) ) propSet = false; + } + if(propSet) { + return getIpAddress(nicName, 0, loopbackOk); + } else {//desired system property not set, try fallback + if(fallbackOk) { + return getDefaultIpv4Address(loopbackOk); + } else { + return null; + } + } + } else {//no system property name provided, try default nic + if(defaultNic != null) { + return getIpAddress(defaultNic, 0, loopbackOk); + } else {//no default nic provided, try fallback + if(fallbackOk) { + return getDefaultIpv4Address(loopbackOk); + } else { + return null; + } + } + } + } + + public static String getIpAddress() + throws SocketException, IOException + { + return getIpAddress(null, null, true, true); + } + + /** * Examines each address associated with each network interface * card (nic) installed on the current node, and returns the * <code>String</code> value of the first such address that is @@ -617,73 +752,6 @@ } /** - * Special-purpose convenience method that will return the - * value of the system property named <code>default.nic</code> - * if that property has been set on the current VM to any - * non-<code>null</code> value other than the value, - * <code>${default.nic}</code>; otherwise returns the value - * input for the <code>defaultVal</code> parameter. - * <p> - * This method can be called from within a configuration - * as well as from within program control. It is provided - * as a way to allow mechanisms that are not able to - * conditionally set system properties to always set the - * system property named <code>default.nic</code> to some - * value -- either valid or invalid -- depending on whether - * that property is set as a system property on the command - * line. - * <p> - * For example, the <code>java</code> ant task used to exec - * java based programs does not allow one to set a system - * property on that program's VM when that property is set - * on the command line used to execute ant, but leave that - * property un-set when ant's command line does not specify - * a value for that property. That is, although ant allows - * one to retrieve the value of a system property that is - * specified on ant's command line and substitute that value - * (using Java's '${}' token-substitution mechanism) into - * a system property set on the program's VM, ant does not - * allow one to leave that property un-set when the system - * property is not specified on ant's command line; the - * property must either always be set on the VM, or never - * set. If the ant script then is written to always set the - * system property on the exec'd program's VM to the - * value of the system property expected on ant's command - * line, then whenever that system property is not set on - * ant's command line, the value that is substituted into - * the system property when the program is exec-ed will be - * of the form, <code>${default.nic}</code>. If the program - * that is exec'd then attempts to call - * <code>System.getProperty("default.nic")</code>, that - * call will return the non-<code>null</code> value, - * <code>${default.nic}</code>; which is typically not - * what is desired. - * - * @param defaultVal <code>String</code> value that this method - * returns if the system property named - * <code>default.nic</code> is either not - * set or is equal to the value - * <code>${default.nic}</code>. - * - * @return a <code>String</code> value equal to the value of - * the system property named <code>${default.nic}</code> - * if that system property is set to any value except - * <code>null</code> or the value <code>${default.nic}</code>; - * otherwise, returns the value input for the - * <code>defaultVal</code> parameter. - */ - public static String getDefaultNic(String defaultVal) { - String defaultNic = System.getProperty("default.nic"); - if( ("${default.nic}").equals(defaultNic) ) defaultNic = null; - if(defaultNic == null) defaultNic = defaultVal; - return defaultNic; - } - - public static String getDefaultNic() { - return getDefaultNic(null); - } - - /** * Intended for use by scripts. */ public static void main(String[] args) { Modified: branches/bugfix-btm/bigdata-jini/src/java/com/bigdata/service/jini/util/LookupStarter.java =================================================================== --- branches/bugfix-btm/bigdata-jini/src/java/com/bigdata/service/jini/util/LookupStarter.java 2010-07-23 17:36:38 UTC (rev 3272) +++ branches/bugfix-btm/bigdata-jini/src/java/com/bigdata/service/jini/util/LookupStarter.java 2010-07-23 17:58:30 UTC (rev 3273) @@ -74,10 +74,8 @@ private static String defaultGroup = null; static { try { - thisHost = - NicUtil.getIpAddress - ( NicUtil.getDefaultNic - ( NicUtil.getDefaultIpv4Address(true) ) ); + thisHost = NicUtil.getIpAddress + ("default.nic", null, true, true); defaultGroup = System.getProperty("bigdata.fedname", "bigdata.test.group-"+thisHost); Modified: branches/bugfix-btm/bigdata-jini/src/java/com/bigdata/service/jini/util/config/lookup.config =================================================================== --- branches/bugfix-btm/bigdata-jini/src/java/com/bigdata/service/jini/util/config/lookup.config 2010-07-23 17:36:38 UTC (rev 3272) +++ branches/bugfix-btm/bigdata-jini/src/java/com/bigdata/service/jini/util/config/lookup.config 2010-07-23 17:58:30 UTC (rev 3273) @@ -10,8 +10,7 @@ com.sun.jini.reggie { private static exportPort = 0;//randomly chosen port private static exportIpAddr = - NicUtil.getDefaultNic - ( NicUtil.getDefaultIpv4Address(true) ); + NicUtil.getIpAddress("default.nic", null, true, true); private static codebasePort = 23333;//value used if not set by system prop // Public configuration entries Modified: branches/bugfix-btm/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config =================================================================== --- branches/bugfix-btm/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config 2010-07-23 17:36:38 UTC (rev 3272) +++ branches/bugfix-btm/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config 2010-07-23 17:58:30 UTC (rev 3273) @@ -77,8 +77,7 @@ static serviceDir = ConfigMath.getAbsoluteFile(new File(fedname)); private static localIpAddr = - NicUtil.getDefaultNic - ( NicUtil.getDefaultIpv4Address(true) ); + NicUtil.getIpAddress("default.nic", null, true, true); /* * Example cluster configuration. Modified: branches/bugfix-btm/bigdata-jini/src/test/com/bigdata/jini/start/testReggie.config =================================================================== --- branches/bugfix-btm/bigdata-jini/src/test/com/bigdata/jini/start/testReggie.config 2010-07-23 17:36:38 UTC (rev 3272) +++ branches/bugfix-btm/bigdata-jini/src/test/com/bigdata/jini/start/testReggie.config 2010-07-23 17:58:30 UTC (rev 3273) @@ -15,8 +15,7 @@ com.sun.jini.reggie { private static exportIpAddr = - NicUtil.getDefaultNic - ( NicUtil.getDefaultIpv4Address(true) ); + NicUtil.getIpAddress("default.nic", null, true, true); private static exportPort = Integer.parseInt("0"); private static serverILFactory = Modified: branches/bugfix-btm/bigdata-jini/src/test/com/bigdata/jini/start/testStartJini.config =================================================================== --- branches/bugfix-btm/bigdata-jini/src/test/com/bigdata/jini/start/testStartJini.config 2010-07-23 17:36:38 UTC (rev 3272) +++ branches/bugfix-btm/bigdata-jini/src/test/com/bigdata/jini/start/testStartJini.config 2010-07-23 17:58:30 UTC (rev 3273) @@ -15,8 +15,7 @@ private static appHome = System.getProperty("app.home", ConfigMath.getAbsolutePath(new File(".")) ); private static codebaseHost = - NicUtil.getDefaultNic - ( NicUtil.getDefaultIpv4Address(true) ); + NicUtil.getIpAddress("default.nic", null, true, true); private static codebasePort = "23334"; private static defaultCodebaseRootDir = ConfigUtil.concat( new String[] { appHome, "${/}bigdata-jini${/}lib${/}jini${/}lib-dl" } ); Modified: branches/bugfix-btm/bigdata-jini/src/test/com/bigdata/zookeeper/testzoo.config =================================================================== --- branches/bugfix-btm/bigdata-jini/src/test/com/bigdata/zookeeper/testzoo.config 2010-07-23 17:36:38 UTC (rev 3272) +++ branches/bugfix-btm/bigdata-jini/src/test/com/bigdata/zookeeper/testzoo.config 2010-07-23 17:58:30 UTC (rev 3273) @@ -34,8 +34,7 @@ private static appHome = System.getProperty("app.home", ConfigMath.getAbsolutePath(new File(".")) ); private static localIpAddr = - NicUtil.getDefaultNic - ( NicUtil.getDefaultIpv4Address(true) ); + NicUtil.getIpAddress("default.nic", null, true, true); /* A comma delimited list of the known zookeeper servers together * with their assigned "myid". Property changes on: branches/bugfix-btm/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql ___________________________________________________________________ Modified: svn:mergeinfo - /branches/fko/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql:3150-3194 /trunk/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql:2775-2877,2883-3010,3012-3235 + /branches/fko/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql:3150-3194 /trunk/bigdata-sails/src/java/com/bigdata/rdf/sail/sparql:2775-2877,2883-3010,3012-3269 Modified: branches/bugfix-btm/bigdata-sails/src/test/com/bigdata/rdf/sail/TestNamedGraphs.java =================================================================== --- branches/bugfix-btm/bigdata-sails/src/test/com/bigdata/rdf/sail/TestNamedGraphs.java 2010-07-23 17:36:38 UTC (rev 3272) +++ branches/bugfix-btm/bigdata-sails/src/test/com/bigdata/rdf/sail/TestNamedGraphs.java 2010-07-23 17:58:30 UTC (rev 3273) @@ -33,7 +33,9 @@ import org.apache.log4j.Logger; import org.openrdf.model.BNode; +import org.openrdf.model.Resource; import org.openrdf.model.URI; +import org.openrdf.model.ValueFactory; import org.openrdf.model.impl.BNodeImpl; import org.openrdf.model.impl.LiteralImpl; import org.openrdf.model.impl.URIImpl; @@ -50,6 +52,7 @@ import org.openrdf.query.impl.BindingImpl; import org.openrdf.repository.RepositoryException; import org.openrdf.sail.SailException; +import com.bigdata.rdf.store.BD; /** * Unit tests for named graphs. Specify @@ -1559,4 +1562,114 @@ } + public void testSearchQuery() throws Exception { + + final BigdataSail sail = getSail(); + sail.initialize(); + final BigdataSailRepository repo = new BigdataSailRepository(sail); + final BigdataSailRepositoryConnection cxn = (BigdataSailRepositoryConnection) repo + .getConnection(); + cxn.setAutoCommit(false); + + try { + + if (!sail.getDatabase().isQuads()) { + + log.warn("test requires quads."); + + return; + + } + + final ValueFactory vf = cxn.getValueFactory(); + + //create context + final Resource context1 = vf.createURI( "http://example.org" ); + + //add statement to context1 + cxn.add( vf.createStatement( + vf.createURI("http://example.org#Chris"), + RDFS.LABEL, + vf.createLiteral("Chris") ), + context1); + cxn.commit(); + + //add statement to default graph + cxn.add( vf.createStatement( + vf.createURI("http://example.org#Christian"), + RDFS.LABEL, + vf.createLiteral("Christian") ) ); + cxn.commit(); + + { + //when running this query, we correctly get bindings for both triples + final String query = + "select ?x ?y " + + "where { " + + " ?y <"+ BD.SEARCH+"> \"Chris\" . " + + " ?x <"+ RDFS.LABEL.stringValue() + "> ?y . " + + "}"; + + final TupleQuery tupleQuery = cxn.prepareTupleQuery( + QueryLanguage.SPARQL, query); + final TupleQueryResult result = tupleQuery.evaluate(); + +// int i = 1; +// while (result.hasNext()) { +// System.err.println(i++ + "#: " + result.next()); +// } + + final Collection<BindingSet> answer = new LinkedList<BindingSet>(); + answer.add(createBindingSet(// + new BindingImpl("x", vf.createURI("http://example.org#Christian")),// + new BindingImpl("y", vf.createLiteral("Christian"))// + )); + answer.add(createBindingSet(// + new BindingImpl("x", vf.createURI("http://example.org#Chris")),// + new BindingImpl("y", vf.createLiteral("Chris"))// + )); + + compare(result, answer); + + } + + { + //however, when running this query, we incorrectly get both results as it should only return bindings for the triple added to context 1. + String query = + "select ?x ?y " + + "where { " + + " graph <http://example.org> { " + + " ?y <"+ BD.SEARCH+"> \"Chris\" . " + + " ?x <"+ RDFS.LABEL.stringValue() + "> ?y ." + + " } . " + + "}"; + + final TupleQuery tupleQuery = cxn.prepareTupleQuery( + QueryLanguage.SPARQL, query); + final TupleQueryResult result = tupleQuery.evaluate(); + +// int i = 1; +// while (result.hasNext()) { +// System.err.println(i++ + "#: " + result.next()); +// } + + final Collection<BindingSet> answer = new LinkedList<BindingSet>(); + answer.add(createBindingSet(// + new BindingImpl("x", vf.createURI("http://example.org#Chris")),// + new BindingImpl("y", vf.createLiteral("Chris"))// + )); + + compare(result, answer); + + } + + } finally { + + cxn.close(); + sail.__tearDownUnitTest(); + + } + + } + } Modified: branches/bugfix-btm/build.properties =================================================================== --- branches/bugfix-btm/build.properties 2010-07-23 17:36:38 UTC (rev 3272) +++ branches/bugfix-btm/build.properties 2010-07-23 17:58:30 UTC (rev 3273) @@ -131,6 +131,9 @@ # Where to write the log files. install.log.dir=${NAS}/log +# Where to write the deployment distribution. +install.dist.dir=${NAS}/dist + # The 'install-as' user (defaults to the user running the installer). # # @TODO ant lacks sufficient mechanisms to set the user (chown). Modified: branches/bugfix-btm/build.xml =================================================================== --- branches/bugfix-btm/build.xml 2010-07-23 17:36:38 UTC (rev 3272) +++ branches/bugfix-btm/build.xml 2010-07-23 17:58:30 UTC (rev 3273) @@ -493,6 +493,7 @@ <mkdir dir="${install.lib.dir}" /> <mkdir dir="${install.bin.dir}" /> <mkdir dir="${install.log.dir}" /> +<mkdir dir="${install.dist.dir}" /> <!-- install configuration files. --> <copy toDir="${install.config.dir}"> <fileset dir="${bigdata.dir}/src/resources/config"> @@ -849,57 +850,39 @@ <!-- --> <!-- STANDALONE FEDERATION TARGETS --> - <!-- --> + <!-- (test/benchamarking) --> -<target name="standalone-setup" description="Setup properties used by the standalone federation and LUS start/stop."> +<target name="generateLookupStarterJar" unless="lookupStarterJarAvailable"> + <antcall target="testCompile" /> +</target> + +<target name="testLookupStarterJarAvailability"> + <property name="bigdata-test.lib" location="${bigdata.dir}/bigdata-test/lib" /> + <condition property="lookupStarterJarAvailable"> + <available file="${bigdata-test.lib}/lookupstarter.jar"/> + </condition> +</target> + +<target name="standalone-setup" depends="testLookupStarterJarAvailability,generateLookupStarterJar" description="Setup properties used by standalone federation and LUS start/stop."> <property name="app.home" location="${bigdata.dir}" /> <property name="test.codebase.port" value="23333"/> - <property name="test.codebase.dir" location="${bigdata.dir}/bigdata-jini/lib/jini/lib-dl" /> + <property name="test.codebase.dir" location="${bigdata.dir}/bigdata-jini/lib/jini/lib-dl"/> + <property name="dist.lib" location="${bigdata.dir}/bigdata-jini/lib/jini/lib" /> + <property name="dist.lib.dl" location="${bigdata.dir}/bigdata-jini/lib/jini/lib-dl" /> <property name="test.codebase" value="http://${this.hostname}:${test.codebase.port}/jsk-dl.jar"/> <property name="java.security.policy" value="${bigdata.dir}/policy.all"/> - <property name="log4j.configuration" value="${bigdata.dir}/src/resources/config/standalone/log4j.properties"/> + <property name="log4j.configuration" value="resources/logging/log4j.properties"/> <property name="java.net.preferIPv4Stack" value="true"/> <property name="bigdata.fedname" value="${standalone.fed}"/> </target> -<target name="standalone-startLookup" depends="jar,standalone-setup" description="Start the lookup service for the standalone federation."> - <java classname="com.bigdata.service.jini.util.LookupStarter" - fork="true" spawn="true"> - <classpath refid="runtime.classpath" /> - <sysproperty key="app.home" value="${app.home}"/> - <sysproperty key="jini.lib" value="${dist.lib}"/> - <sysproperty key="jini.lib.dl" value="${dist.lib.dl}"/> - <sysproperty key="java.security.policy" value="${java.security.policy}"/> - <sysproperty key="java.security.debug" value="off"/> - <sysproperty key="java.protocol.handler.pkgs" value="net.jini.url"/> - <sysproperty key="log4j.configuration" value="${log4j.configuration}"/> - <sysproperty key="codebase.port" value="${test.codebase.port}"/> - <sysproperty key="java.net.preferIPv4Stack" value="${java.net.preferIPv4Stack}"/> - <sysproperty key="bigdata.fedname" value="${bigdata.fedname}"/> - </java> -</target> - -<target name="standalone-stopLookup" depends="jar,standalone-setup" description="Stop the lookup service for the standalone federation."> - <java classname="com.bigdata.service.jini.util.LookupStarter" - failonerror="true" fork="true" logerror="true"> - <classpath refid="runtime.classpath" /> - <sysproperty key="app.home" value="${app.home}"/> - <sysproperty key="jini.lib" value="${dist.lib}"/> - <sysproperty key="jini.lib.dl" value="${dist.lib.dl}"/> - <sysproperty key="java.security.policy" value="${java.security.policy}"/> - <sysproperty key="log4j.configuration" value="${log4j.configuration}"/> - <sysproperty key="java.net.preferIPv4Stack" value="${java.net.preferIPv4Stack}"/> - <sysproperty key="bigdata.fedname" value="${bigdata.fedname}"/> - <arg value="-stop" /> - </java> -</target> - <!-- Note: You should 'nohup' this, e.g., "nohup ant standalone-start" to avoid taking down the ServicesManagerServer if you are disconnected from a terminal. --> <target name="standalone-start" depends="jar,standalone-setup" description="Start the standalone federation."> <!-- Start the lookup service. --> - <antcall target="standalone-startLookup" /> + <antcall target="startHttpd" /> + <antcall target="startLookup" /> <java classname="com.bigdata.jini.start.ServicesManagerServer" failonerror="true" fork="true" logerror="true"> <classpath refid="runtime.classpath" /> @@ -930,28 +913,26 @@ <arg value="src/resources/config/standalone/bigdataStandalone.config" /> </java> <!-- Then take down the lookup service as well. --> - <antcall target="standalone-stopLookup" /> + <antcall target="stopLookup" /> + <antcall target="stopHttpd" /> </target> -<!-- @todo Add target to stand up a SPARQL endpoint for a KB namespace. Could be - Sesame Server or bigdata REST API. --> - -<!-- Note: The source files must be "reasonable" for the bulk loader. Each file - will be fully parsed into memory before writing onto the database. Very - large source files must be split into smaller files. See the 'split' - command under unix, but be aware that it will not generate more than 576 - output files (24 x 24 = 576) and only 100 if you are using number suffixes. - For example, split an NT file into files of 200000 lines each: - - mkdir splits; cd splits - split -l 200000 ../dataset.nt dataset - - You will also have to fix up the file extensions. You can do this using - bash as follows: - - for file in *; do mv $file $file.nt; done - - --> +<target name="standalone-start-nano-server" depends="jar" description="Start a small http server fronting for a bigdata database instance."> + <java classname="com.bigdata.rdf.sail.bench.NanoSparqlServer" fork="true" failonerror="true"> + <arg line="${standalone.nanoServerPort} ${standalone.namespace} src/resources/config/standalone/bigdataStandalone.config" /> + <jvmarg line="-server"/> + <jvmarg line="-Xmx200M"/> + <classpath refid="runtime.classpath" /> + </java> +</target> + +<target name="standalone-stop-nano-server" depends="jar" description="Stop the small http server running at the configured port."> + <java classname="com.bigdata.rdf.sail.bench.NanoSparqlServer" fork="true" failonerror="true"> + <arg line="${standalone.nanoServerPort} -stop" /> + <classpath refid="runtime.classpath" /> + </java> +</target> + <target name="standalone-bulk-load" depends="jar" description="Bulk load RDF data into the standalone federation."> <java classname="com.bigdata.rdf.load.MappedRDFDataLoadMaster" failonerror="true" fork="true" logerror="true"> @@ -967,30 +948,14 @@ <!-- --> <!-- Per job parameters --> <!-- --> - <!-- The KB namespace ("kb" is a common default). --> - <jvmarg value="-Dbigdata.rdf.namespace=U10"/> + <!-- The namespace of the target KB. --> + <jvmarg value="-Dbigdata.rdf.namespace=${standalone.namespace}"/> <!-- The job name (same as the KB namespace is a common default). --> - <jvmarg value="-Dbigdata.rdf.job.name=bulk-load-kb"/> - <!-- The file or directory containing RDF data to be loaded. - - Possible interesting data: - - d:/bigdata-perf-analysis/lubm/U10 - d:/bigdata-perf-analysis/bsbm/bsbm_2785/dataset.nt - --> - <jvmarg value="-Dbigdata.rdf.data=d:/bigdata-perf-analysis/lubm/U10"/> - <!-- The file or directory containing zero or more RDF ontology files to be loaded. - - Note: If you do not want to load any "ontology" data you can point this at an - empty directory. "ontology" data is loaded once - when a new KB instance is - created. - - Possible interesting ontologies: - - bigdata-rdf/src/resources/data/lehigh/univ-bench.owl - d:/bigdata-perf-analysis/emptyDir - --> - <jvmarg value="-Dbigdata.rdf.ontology=bigdata-rdf/src/resources/data/lehigh/univ-bench.owl"/> + <jvmarg value="-Dbigdata.rdf.job.name=bulk-load-kb-${standalone-namespace}"/> + <!-- The file or directory containing zero or more files to be loaded first. --> + <jvmarg value="-Dbigdata.rdf.ontology=${standalone.bulkLoad.ontology}"/> + <!-- The file or directory containing RDF data to be loaded. --> + <jvmarg value="-Dbigdata.rdf.data=${standalone.bulkLoad.data}"/> <!-- The main configuration file. --> <arg value="src/resources/config/standalone/bigdataStandalone.config" /> </java> @@ -1082,10 +1047,9 @@ </java> </target> - <!-- --> - <!-- UNIT TESTS ONLY BELOW HERE --> - <!-- --> - + <!-- --> + <!-- STAGING --> + <!-- --> <target name="stage" description="stages resources (jar, config, policy, logging files) needed to package or execute the bigdata distribution." depends="jar"> @@ -1103,7 +1067,6 @@ <property name="dist.var.config" location="${dist.var}/config" /> <property name="dist.var.config.policy" location="${dist.var.config}/policy" /> <property name="dist.var.config.logging" location="${dist.var.config}/logging" /> - <property name="dist.var.config.zookeeper" location="${dist.var.config}/zookeeper" /> <property name="dist.var.config.jini" location="${dist.var.config}/jini" /> <delete dir="${dist.dir}" quiet="true"/> @@ -1116,7 +1079,6 @@ <mkdir dir="${dist.var.config}"/> <mkdir dir="${dist.var.config.policy}"/> <mkdir dir="${dist.var.config.logging}"/> - <mkdir dir="${dist.var.config.zookeeper}"/> <mkdir dir="${dist.var.config.jini}"/> <!-- Copy build.properties to the top-level config file --> @@ -1186,10 +1148,6 @@ <!-- Zookeeper library --> <copy file="${bigdata-zookeeper.lib}/zookeeper-3.2.1.jar" tofile="${dist.lib}/zookeeper.jar"/> -<!-- - <copy file="/home/brmurphy/zookeeper/cdd99c5/build/zookeeper-3.3.0.jar" - tofile="${dist.lib}/zookeeper.jar"/> ---> <!-- Jini library --> @@ -1249,8 +1207,6 @@ todir="${dist.bin.config}"/> <copy file="${src.resources}/bin/config/serviceStarter.config" todir="${dist.bin.config}"/> - <copy file="${src.resources}/bin/config/zookeeper.config" - todir="${dist.bin.config}"/> <!-- Stage security policy (config) files --> <copy file="${src.resources.config}/policy.all" @@ -1303,6 +1259,329 @@ todir="${dist.var.config.jini}"/> </target> + <!-- --> + <!-- RELEASE --> + <!-- --> + <target name="deploy-artifact" depends="clean, stage" + description="Create compressed tar file for deployment."> + <tar destfile="${bigdata.dir}/REL.${version}.tgz" + compression="gzip"> + + <tarfileset dir="${bigdata.dir}/dist"> + <include name="bigdata/**" /> + + <exclude name="bigdata/bin/pstart" /> + + </tarfileset> + + <!-- Add scripts separately, making them executable --> + + <tarfileset dir="${bigdata.dir}/dist" filemode="755"> + <include name="bigdata/bin/pstart" /> + + </tarfileset> + </tar> + </target> + + <target name="ant-install-prepare" depends="jar, bundle" + description="Stage all files (src, lib, config, etc.) needed for ant based install."> + <copy toDir="${build.dir}/bigdata/src"> + <fileset dir="${bigdata.dir}/bigdata/src" /> + </copy> + <copy toDir="${build.dir}/bigdata-jini/src"> + <fileset dir="${bigdata.dir}/bigdata-jini/src" /> + </copy> + <copy toDir="${build.dir}/bigdata-rdf/src"> + <fileset dir="${bigdata.dir}/bigdata-rdf/src" /> + </copy> + <copy toDir="${build.dir}/bigdata-sails/src"> + <fileset dir="${bigdata.dir}/bigdata-sails/src" /> + </copy> + <copy toDir="${build.dir}/lgpl-utils/src"> + <fileset dir="${bigdata.dir}/lgpl-utils/src" /> + </copy> + + <mkdir dir="${build.dir}/bigdata/lib" /> + <copy toDir="${build.dir}/bigdata/lib"> + <fileset dir="${bigdata.dir}/bigdata/lib" /> + </copy> + + <mkdir dir="${build.dir}/bigdata-jini/lib" /> + <copy toDir="${build.dir}/bigdata-jini/lib"> + <fileset dir="${bigdata.dir}/bigdata-jini/lib" /> + </copy> + <mkdir dir="${build.dir}/bigdata-rdf/lib" /> + <copy toDir="${build.dir}/bigdata-rdf/lib"> + <fileset dir="${bigdata.dir}/bigdata-rdf/lib" /> + </copy> + + <mkdir dir="${build.dir}/bigdata-sails/lib" /> + <copy toDir="${build.dir}/bigdata-sails/lib"> + <fileset dir="${bigdata.dir}/bigdata-sails/lib" /> + </copy> + + <mkdir dir="${build.dir}/src" /> + <mkdir dir="${build.dir}/src/resources" /> + <mkdir dir="${build.dir}/src/resources/config" /> + <copy toDir="${build.dir}/src/resources/config"> + <fileset dir="${bigdata.dir}/src/resources/config" /> + </copy> + + <mkdir dir="${build.dir}/src/resources/scripts" /> + <copy toDir="${build.dir}/src/resources/scripts"> + <fileset dir="${bigdata.dir}/src/resources/scripts" /> + </copy> + + <copy tofile="${build.dir}/build.properties" file="build.properties" /> + <copy tofile="${build.dir}/build.xml" file="build.xml" /> + <copy tofile="${build.dir}/LICENSE.txt" file="LICENSE.txt" /> + <copy tofile="${build.dir}/overview.html" file="overview.html" /> + <copy tofile="${build.dir}/README-JINI" file="README-JINI" /> + <copy toDir="${build.dir}/LEGAL" flatten="true"> + <fileset dir="${bigdata.dir}"> + <include name="**/LEGAL/*" /> + </fileset> + </copy> + </target> + + <target name="ant-install-artifact" depends="clean, ant-install-prepare, stage" + description="Create complete source tar file for ant based install."> + <mkdir dir="${release.dir}" /> + <tar destfile="${bigdata.dir}/DIST.${version}.tgz" compression="gzip"> + <tarfileset dir="${build.dir}" prefix="${version}"> + <include name="build.properties" /> + <include name="build.xml" /> + <include name="LICENSE.txt" /> + <include name="overview.html" /> + <include name="README-JINI" /> + <include name="LEGAL/*" /> + + <include name="bigdata/src/**" /> + <include name="bigdata-jini/src/**" /> + <include name="bigdata-rdf/src/**" /> + <include name="bigdata-sails/src/**" /> + <include name="lgpl-utils/src/**" /> + <include name="bigdata/lib/**" /> + <include name="bigdata-jini/lib/**" /> + <include name="bigdata-rdf/lib/**" /> + <include name="bigdata-sails/lib/**" /> + <include name="src/**" /> + <exclude name="classes/**" /> + <exclude name="${version}.jar" /> + <exclude name="lib/**" /> + <exclude name="docs/**" /> + + <exclude name="dist/bigdata/**" /> + + </tarfileset> + + <!-- Add dist files separately, minus scripts --> + + <tarfileset dir="${bigdata.dir}" prefix="${version}"> + <include name="dist/bigdata/**" /> + + <exclude name="dist/bigdata/bin/pstart" /> + </tarfileset> + + <!-- Add dist scripts separately, making them executable --> + + <tarfileset dir="${bigdata.dir}" prefix="${version}" filemode="755"> + <include name="dist/bigdata/bin/pstart" /> + </tarfileset> + </tar> + + <tar destfile="${bigdata.dir}/REL.${version}.tgz" + basedir="${bigdata.dir}/dist" + compression="gzip"> + </tar> + </target> + + <target name="ant-install" depends="jar, banner, bundle" description="Ant based install on a node."> + <mkdir dir="${NAS}" /> + <mkdir dir="${LAS}" /> + <chmod perm="ug+rw,o-rw"> + <fileset dir="${NAS}" /> + </chmod> + <chmod perm="ug+rw,o-rw"> + <fileset dir="${LAS}" /> + </chmod> + <mkdir dir="${install.config.dir}" /> + <mkdir dir="${install.doc.dir}" /> + <mkdir dir="${install.lib.dir}" /> + <mkdir dir="${install.bin.dir}" /> + <mkdir dir="${install.log.dir}" /> + <mkdir dir="${install.dist.dir}" /> + <copy toDir="${install.config.dir}"> + <fileset dir="${bigdata.dir}/src/resources/config" /> + </copy> + <copy toDir="${install.doc.dir}"> + <fileset dir="${bigdata.dir}"> + <include name="LICENSE.txt" /> + <include name="overview.html" /> + <include name="README-JINI" /> + <include name="bigdata/LEGAL/*" /> + <include name="bigdata-jini/LEGAL/*" /> + <include name="bigdata-rdf/LEGAL/*" /> + <include name="bigdata-sails/LEGAL/*" /> + </fileset> + </copy> + + <copy toDir="${install.lib.dir}"> + <fileset dir="${build.dir}/lib" /> + <fileset file="${build.dir}/${version}.jar" /> + </copy> + + <copy toDir="${install.bin.dir}"> + <fileset dir="src/resources/scripts" /> + </copy> + + <copy toDir="${install.dist.dir}"> + <fileset dir="${bigdata.dir}/dist"> + <include name="bigdata/**" /> + </fileset> + </copy> + + <!-- parameter substitution. --> + <property name="myclasspath" refid="install.classpath" /> + <replace dir="${install.bin.dir}" summary="true"> + <replacefilter token="@FED@" value="${FED}" /> + <replacefilter token="@NAS@" value="${NAS}" /> + <replacefilter token="@LAS@" value="${LAS}" /> + <replacefilter token="@JAVA_HOME@" value="${JAVA_HOME}" /> + <replacefilter token="@JINI_CLASS_SERVER_PORT@" value="${JINI_CLASS_SERVER_PORT}" /> + <replacefilter token="@LOAD_BALANCER_PORT@" value="${LOAD_BALANCER_PORT}" /> + <replacefilter token="@SYSSTAT_HOME@" value="${SYSSTAT_HOME}" /> + <replacefilter token="@USE_NIO@" value="${USE_NIO}" /> + <replacefilter token="@BIN_DIR@" value="${install.bin.dir}" /> + <replacefilter token="@LIB_DIR@" value="${install.lib.dir}" /> + <replacefilter token="@LOG_DIR@" value="${install.log.dir}" /> + <replacefilter token="@CONFIG_DIR@" value="${install.config.dir}" /> + <replacefilter token="@INSTALL_USER@" value="${install.user}" /> + <replacefilter token="@INSTALL_GROUP@" value="${install.group}" /> + <replacefilter token="@LOCK_FILE@" value="${LOCK_FILE}" /> + <replacefilter token="@BIGDATA_CONFIG@" value="${bigdata.config}" /> + <replacefilter token="@JINI_CONFIG@" value="${jini.config}" /> + <replacefilter token="@POLICY_FILE@" value="${policyFile}" /> + <replacefilter token="@LOG4J_SOCKET_LOGGER_HOST@" value="${LOG4J_SOCKET_LOGGER_HOST}" /> + <replacefilter token="@LOG4J_SOCKET_LOGGER_PORT@" value="${LOG4J_SOCKET_LOGGER_PORT}" /> + <replacefilter token="@LOG4J_SOCKET_LOGGER_CONFIG@" value="${log4jServer.config}" /> + <replacefilter token="@LOG4J_DATE_PATTERN@" value="${LOG4J_DATE_PATTERN}" /> + <replacefilter token="@LOG4J_CONFIG@" value="${log4j.config}" /> + <replacefilter token="@LOGGING_CONFIG@" value="${logging.config}" /> + <replacefilter token="@ERROR_LOG@" value="${errorLog}" /> + <replacefilter token="@DETAIL_LOG@" value="${detailLog}" /> + <replacefilter token="@EVENT_LOG@" value="${eventLog}" /> + <replacefilter token="@RULE_LOG@" value="${ruleLog}" /> + <replacefilter token="@STATE_LOG@" value="${stateLog}" /> + <replacefilter token="@STATE_FILE@" value="${stateFile}" /> + <replacefilter token="@FORCE_KILL_ALL@" value="${forceKillAll}" /> + <replacefilter token="@NTP_MASTER@" value="${NTP_MASTER}" /> + <replacefilter token="@NTP_NETWORK@" value="${NTP_NETWORK}" /> + <replacefilter token="@NTP_NETMASK@" value="${NTP_NETMASK}" /> + <replacefilter token="@CLASSPATH@" value="${myclasspath}" /> + </replace> + + <replace dir="${install.config.dir}" summary="true"> + <replacefilter token="@FED@" value="${FED}" /> + <replacefilter token="@NAS@" value="${NAS}" /> + <replacefilter token="@LAS@" value="${LAS}" /> + <replacefilter token="@LOG4J_SOCKET_LOGGER_HOST@" value="${LOG4J_SOCKET_LOGGER_HOST}" /> + <replacefilter token="@JAVA_HOME@" value="${JAVA_HOME}" /> + <replacefilter token="@JINI_CLASS_SERVER_PORT@" value="${JINI_CLASS_SERVER_PORT}" /> + <replacefilter token="@LOAD_BALANCER_PORT@" value="${LOAD_BALANCER_PORT}" /> + <replacefilter token="@SYSSTAT_HOME@" value="${SYSSTAT_HOME}" /> + <replacefilter token="@USE_NIO@" value="${USE_NIO}" /> + <replacefilter token="@BIN_DIR@" value="${install.bin.dir}" /> + <replacefilter token="@LIB_DIR@" value="${install.lib.dir}" /> + <replacefilter token="@LOG_DIR@" value="${install.log.dir}" /> + <replacefilter token="@CONFIG_DIR@" value="${install.config.dir}" /> + <replacefilter token="@INSTALL_USER@" value="${install.user}" /> + <replacefilter token="@INSTALL_GROUP@" value="${install.group}" /> + <replacefilter token="@LOCK_FILE@" value="${LOCK_FILE}" /> + <replacefilter token="@BIGDATA_CONFIG@" value="${bigdata.config}" /> + <replacefilter token="@JINI_CONFIG@" value="${jini.config}" /> + <replacefilter token="@POLICY_FILE@" value="${policyFile}" /> + <replacefilter token="@LOG4J_SOCKET_LOGGER_HOST@" value="${LOG4J_SOCKET_LOGGER_HOST}" /> + <replacefilter token="@LOG4J_SOCKET_LOGGER_PORT@" value="${LOG4J_SOCKET_LOGGER_PORT}" /> + <replacefilter token="@LOG4J_SOCKET_LOGGER_CONFIG@" value="${log4jServer.config}" /> + <replacefilter token="@LOG4J_DATE_PATTERN@" value="${LOG4J_DATE_PATTERN}" /> + <replacefilter token="@LOG4J_CONFIG@" value="${log4j.config}" /> + <replacefilter token="@LOGGING_CONFIG@" value="${logging.config}" /> + <replacefilter token="@ERROR_LOG@" value="${errorLog}" /> + <replacefilter token="@DETAIL_LOG@" value="${detailLog}" /> + <replacefilter token="@EVENT_LOG@" value="${eventLog}" /> + <replacefilter token="@RULE_LOG@" value="${ruleLog}" /> + <replacefilter token="@STATE_LOG@" value="${stateLog}" /> + <replacefilter token="@STATE_FILE@" value="${stateFile}" /> + <replacefilter token="@FORCE_KILL_ALL@" value="${forceKillAll}" /> + <replacefilter token="@NTP_MASTER@" value="${NTP_MASTER}" /> + <replacefilter token="@NTP_NETWORK@" value="${NTP_NETWORK}" /> + <replacefilter token="@NTP_NETMASK@" value="${NTP_NETMASK}" /> + <replacefilter token="@CLASSPATH@" value="${myclasspath}" /> + <!-- updates the configuration file to locate the lubm ontology. --> + <replacefilter token="@install.lubm.config.dir@" value="${install.lubm.config.dir}" /> + </replace> + + <!-- fix newlines (otherwise substitutions cause things to break). --> + <fixcrlf srcDir="${install.config.dir}" /> + <fixcrlf srcDir="${install.bin.dir}" /> + + <!-- set execute bit for scripts in this directory (must be the last step). --> + <chmod perm="u+x,g+rx,o-rwx"> + <fileset dir="${install.bin.dir}"> + <exclude name="README"/> + <exclude name="POST-INSTALL"/> + </fileset> + </chmod> + + <!-- Setup the status file which will be read by the bigdata script and + the log on which that script will write its output. This is used + if cron, or a similar process, will execute the script on a periodic + basis. The initial state is always 'status'. The initial stateLog + is always empty. The state file must be readable by the group, but + could be restricted to write by a specific user. The stateLog must be + read/write for the group. --> + +<echo file="${stateFile}">status</echo> +<echo file="${stateLog}"> +</echo> + + <chmod perm="g+rw,o-rw" file="${stateFile}" /> + <chmod perm="g+rw,o-rw" file="${stateLog}" /> + + <!-- Make sure that the entire shared directory structure is read/write for the group. --> + <chmod perm="g+rwx" type="both" dir="${NAS}" verbose="true"/> + +<!-- Make sure that it is all accessible to the install group (ant 1.6+ plus extension module required). + <chown file="${NAS}" type="both" owner="${install.user}.${install.group}" verbose="true"/> +--> + + <!-- Works for earlier versions of ant LT 1.6 which do not bundle "chown". --> + <apply executable="chown" description="set owner on NAS files" os="Linux"> + <arg value="-R"/> + <arg value="${install.user}.${install.group}"/> + <dirset dir="${NAS}"/> + </apply> + + <!-- @todo check the installed configuration file (after parameter substitution). --> + <!-- @todo also check the installed jini configuration files. --> + <java classname="com.bigdata.jini.util.CheckConfiguration" + failonerror="true" fork="true" logerror="true"> + <classpath refid="install.classpath" /> + <arg value="${bigdata.config}" /> + </java> + + <loadfile property="postInstallMessage" srcFile="${install.bin.dir}/POST-INSTALL" /> + +<echo> + +${postInstallMessage}</echo> + + </target> + + <!-- --> + <!-- UNIT TESTS --> + <!-- --> <target name="testCompile" description="compiles the test source and generates the appropriate jar files." depends="stage"> Property changes on: branches/bugfix-btm/dsi-utils ___________________________________________________________________ Modified: svn:mergeinfo - /branches/fko/dsi-utils:3150-3194 /trunk/dsi-utils:2775-2877,2883-3010,3012-3235 + /branches/fko/dsi-utils:3150-3194 /trunk/dsi-utils:2775-2877,2883-3010,3012-3269 Property changes on: branches/bugfix-btm/src/resources/bin/config ___________________________________________________________________ Modified: svn:mergeinfo - /branches/fko/src/resources/bin/config:3150-3194 /trunk/src/resources/bin/config:2775-2877,2883-3010,3012-3235 + /branches/fko/src/resources/bin/config:3150-3194 /trunk/src/resources/bin/config:2775-2877,2883-3010,3012-3269 Modified: branches/bugfix-btm/src/resources/config/bigdataCluster.config =================================================================== --- branches/bugfix-btm/src/resources/config/bigdataCluster.config 2010-07-23 17:36:38 UTC (rev 3272) +++ branches/bugfix-btm/src/resources/config/bigdataCluster.config 2010-07-23 17:58:30 UTC (rev 3273) @@ -378,6 +378,9 @@ "-Xmx400m", "-Djava.security.policy="+bigdata.policy, "-Djava.util.logging.config.file="+bigdata.logging, + "-Dlog4j.configuration="+bigdata.log4j, + "-Dlog4j.primary.configuration="+bigdata.log4j, + "-DinitialMemberGroups="+bigdata.fedname }; Modified: branches/bugfix-btm/src/resources/config/jini/reggie.config =================================================================== --- branches/bugfix-btm/src/resources/config/jini/reggie.config 2010-07-23 17:36:38 UTC (rev 3272) +++ branches/bugfix-btm/src/resources/config/jini/reggie.config 2010-07-23 17:58:30 UTC (rev 3273) @@ -1,3 +1,52 @@ + +import java.net.NetworkInterface; + +import com.sun.jini.config.ConfigUtil; +import net.jini.constraint.BasicMethodConstraints; +import net.jini.core.constraint.ConnectionRelativeTime; +import net.jini.core.constraint.InvocationConstraints; +import net.jini.jeri.BasicILFactory; +import net.jini.jeri.BasicJeriExporter; +import net.jini.jeri.tcp.TcpServerEndpoint; +import net.jini.core.discovery.LookupLocator; + +import com.bigdata.util.config.NicUtil; + com.sun.jini.reggie { - initialMemberGroups = new String[] { System.getProperty("user.name") + "InstallVerifyGroup" }; + + private static exportIpAddr = NicUtil.getIpAddress(null, null, true, true); + + private static exportPort = + Integer.parseInt( System.getProperty("exportPort", "0") ); + + private static serverILFactory = + new BasicILFactory( + new BasicMethodConstraints( + new InvocationConstraints( + new ConnectionRelativeTime(10000L), + null)), + null); + + serverExporter = new BasicJeriExporter(TcpServerEndpoint.getInstance(exportIpAddr,exportPort), + serverILFactory, + false, + true); + + initialMemberGroups = new String[] { System.getProperty("initialMemberGroups", System.getProperty("user.name")+"InstallVerifyGroup" ) }; + initialLookupGroups = initialMemberGroups; + initialLookupLocators = new LookupLocator[] { }; + + unicastDiscoveryHost = exportIpAddr; + multicastInterfaces = new NetworkInterface[] { + NicUtil.getNetworkInterface(exportIpAddr) + }; + + minMaxServiceLease = 60000L; } + +net.jini.discovery.LookupDiscovery { + multicastRequestHost = com.sun.jini.reggie.exportIpAddr; + multicastInterfaces = new NetworkInterface[] { + NicUtil.getNetworkInterface(com.sun.jini.reggie.exportIpAddr) + }; +} Modified: branches/bugfix-btm/src/resources/config/jini/startAll.config =================================================================== --- branches/bugfix-btm/src/resources/config/jini/startAll.config 2010-07-23 17:36:38 UTC (rev 3272) +++ branches/bugfix-btm/src/resources/config/jini/startAll.config 2010-07-23 17:58:30 UTC (rev 3273) @@ -19,11 +19,6 @@ browser: A visualization tool for exploring Jini(TM) Network Technology communities. reggie: Provides implementations of ServiceRegistrar. - fiddler: Provides the server side of an implementation of the lookup discovery service. - mahalo: Provides implementations of the TransactionManager service. - mercury: Provides implementations of the EventMailbox service. - norm: Provides implementations of LeaseRenewalService. -outrigger: Provides implementation of a JavaSpaces(TM) technology-enabled service. */ com.sun.jini.start { @@ -63,41 +58,6 @@ policyFile, libDir+"reggie.jar", "com.sun.jini.reggie.TransientRegistrarImpl", - new String[] { configDir+"reggie.config" }), - - new NonActivatableServiceDescriptor( - "http://" + host + ":" + port + "/fiddler-dl.jar" + jskdl, - policyFile, - libDir+"fiddler.jar", - "com.sun.jini.fiddler.TransientFiddlerImpl", - new String[] { configDir+"fiddler.config" }), - - new NonActivatableServiceDescriptor( - "http://" + host + ":" + port + "/mahalo-dl.jar" + jskdl, - policyFile, - libDir+"mahalo.jar", - "com.sun.jini.mahalo.TransientMahaloImpl", - new String[] { configDir+"mahalo.config" }), - - new NonActivatableServiceDescriptor( - "http://" + host + ":" + port + "/mercury-dl.jar" + jskdl, - policyFile, - libDir+"mercury.jar", - "com.sun.jini.mercury.TransientMercuryImpl", - new String[] { configDir+"mercury.config" }), - - new NonActivatableServiceDescriptor( - "http://" + host + ":" + port + "/norm-dl.jar" + jskdl, - policyFile, - libDir+"norm.jar", - "com.sun.jini.norm.TransientNormServerImpl", - new String[] { configDir+"norm.config" }), - - new NonActivatableServiceDescriptor( - "http://" + host + ":" + port + "/outrigger-dl.jar" + jskdl, - policyFile, - libDir+"outrigger.jar", - "com.sun.jini.outrigger.TransientOutriggerImpl", - new String[] { configDir+"outrigger.config" }) + new String[] { configDir+"reggie.config" }) }; } Modified: branches/bugfix-btm/src/resources/config/logging.properties =================================================================== --- branches/bugfix-btm/src/resources/config/logging.properties 2010-07-23 17:36:38 UTC (rev 3272) +++ branches/bugfix-btm/src/resources/config/logging.properties 2010-07-23 17:58:30 UTC (rev 3273) @@ -40,7 +40,7 @@ java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter # Limit the message that are printed on the console to INFO and above. -java.util.logging.ConsoleHandler.level = INFO +java.util.logging.ConsoleHandler.level = FINEST java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter @@ -51,11 +51,18 @@ # For example, set the com.xyz.foo logger to only log SEVERE # messages: -com.xyz.foo.level = SEVERE +# com.xyz.foo.level = SEVERE # This turns off the annoying stack trace when we probe to determine # whether or not jini is already running on a specific host (unicast # discovery). Of course, it could also hide other things so you may # want to comment this out. -net.jini.discovery.LookupLocatorDiscovery = WARN +net.jini.discovery.LookupLocatorDiscovery.level = WARNING + +#com.sun.jini.start.level = FINEST +#com.sun.jini.reggie.level = FINEST +#net.jini.discovery.level = FINEST +#net.jini.config.level = FINEST +#net.jini.lookup.JoinManager.level = FINEST +#net.jini.lookup.ServiceDiscoveryManager.level = FINEST Modified: branches/bugfix-btm/src/resources/config/standalone/bigdataStandalone.config =================================================================== --- branches/bugfix-btm/src/resources/config/standalone/bigdataStandalone.config 2010-07-23 17:36:38 UTC (rev 3272) +++ branches/bugfix-btm/src/resources/config/standalone/bigdataStandalone.config 2010-07-23 17:58:30 UTC (rev 3273) @@ -30,6 +30,7 @@ // imports for various options. import com.bigdata.btree.IndexMetadata; +import com.bigdata.btree.keys.KeyBuilder; import com.bigdata.rdf.sail.BigdataSail; import com.bigdata.rdf.spo.SPORelation; import co... [truncated message content] |
From: <mrp...@us...> - 2010-07-23 17:36:44
|
Revision: 3272 http://bigdata.svn.sourceforge.net/bigdata/?rev=3272&view=rev Author: mrpersonick Date: 2010-07-23 17:36:38 +0000 (Fri, 23 Jul 2010) Log Message: ----------- adding support for extensions Added Paths: ----------- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/ColorsEnumExtension.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/DefaultExtensionFactory.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/EpochExtension.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/ExtensionIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IDatatypeURIResolver.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IExtension.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IExtensionFactory.java Added: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/ColorsEnumExtension.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/ColorsEnumExtension.java (rev 0) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/ColorsEnumExtension.java 2010-07-23 17:36:38 UTC (rev 3272) @@ -0,0 +1,148 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2010. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +package com.bigdata.rdf.internal; + +import org.openrdf.model.Literal; +import org.openrdf.model.URI; +import org.openrdf.model.Value; +import org.openrdf.model.impl.URIImpl; +import com.bigdata.rdf.model.BigdataURI; +import com.bigdata.rdf.model.BigdataValueFactory; +import com.bigdata.rdf.store.BD; + + +public class ColorsEnumExtension implements IExtension { + + public static final URI COLOR = new URIImpl(BD.NAMESPACE + "Color"); + + private final BigdataURI color; + + public ColorsEnumExtension(final IDatatypeURIResolver resolver) { + + this.color = resolver.resolve(COLOR); + + } + + public BigdataURI getDatatype() { + + return color; + + } + + public ExtensionIV createIV(final Value value) { + + if (value instanceof Literal == false) + throw new IllegalArgumentException(); + + final Literal l = (Literal) value; + + if (l.getDatatype() == null || !color.equals(l.getDatatype())) + throw new IllegalArgumentException(); + + final String s = value.stringValue(); + + final Color c = Enum.valueOf(Color.class, s); + + // not a valid color + if (c == null) + return null; + + final AbstractLiteralIV delegate = new XSDByteIV(c.getByte()); + + return new ExtensionIV(delegate, (TermId) getDatatype().getIV()); + + } + + public Value asValue(final ExtensionIV iv, final BigdataValueFactory vf) { + + final byte b = iv.getDelegate().byteValue(); + + final Color c = Color.valueOf(b); + + return vf.createLiteral(c.toString(), color); + + } + + /** + * Simple demonstration enum for some common colors. Can fit up to 256 enum + * values into an enum projected onto a byte. + */ + public enum Color { + + Red((byte) 0), + Blue((byte) 1), + Green((byte) 2), + Yellow((byte) 3), + Orange((byte) 4), + Purple((byte) 5), + Black((byte) 6), + White((byte) 7), + Brown((byte) 8); + + private Color(final byte b) { + this.b = b; + } + + static final public Color valueOf(final byte b) { + /* + * Note: This switch MUST correspond to the declarations above (you can + * not made the cases of the switch from [v] since it is not considered + * a to be constant by the compiler). + * + * Note: This masks off everything but the lower 4 bits. + */ + switch (b) { + case 0: + return Red; + case 1: + return Blue; + case 2: + return Green; + case 3: + return Yellow; + case 4: + return Orange; + case 5: + return Purple; + case 6: + return Black; + case 7: + return White; + case 8: + return Brown; + default: + throw new IllegalArgumentException(Byte.toString(b)); + } + } + + private final byte b; + + public byte getByte() { + return b; + } + + } + +} Added: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/DefaultExtensionFactory.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/DefaultExtensionFactory.java (rev 0) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/DefaultExtensionFactory.java 2010-07-23 17:36:38 UTC (rev 3272) @@ -0,0 +1,22 @@ +package com.bigdata.rdf.internal; + +public class DefaultExtensionFactory implements IExtensionFactory { + + private final IExtension[] extensions; + + public DefaultExtensionFactory(final IDatatypeURIResolver resolver) { + + extensions = new IExtension[] { + new EpochExtension(resolver), + new ColorsEnumExtension(resolver) + }; + + } + + public IExtension[] getExtensions() { + + return extensions; + + } + +} Added: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/EpochExtension.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/EpochExtension.java (rev 0) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/EpochExtension.java 2010-07-23 17:36:38 UTC (rev 3272) @@ -0,0 +1,86 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2010. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +package com.bigdata.rdf.internal; + +import org.openrdf.model.Literal; +import org.openrdf.model.URI; +import org.openrdf.model.Value; +import org.openrdf.model.datatypes.XMLDatatypeUtil; +import org.openrdf.model.impl.URIImpl; +import com.bigdata.rdf.model.BigdataURI; +import com.bigdata.rdf.model.BigdataValueFactory; +import com.bigdata.rdf.store.BD; + + +public class EpochExtension implements IExtension { + + public static final URI EPOCH = new URIImpl(BD.NAMESPACE + "Epoch"); + + private final BigdataURI epoch; + + public EpochExtension(final IDatatypeURIResolver resolver) { + + this.epoch = resolver.resolve(EPOCH); + + } + + public BigdataURI getDatatype() { + + return epoch; + + } + + public ExtensionIV createIV(final Value value) { + + if (value instanceof Literal == false) + throw new IllegalArgumentException(); + + final Literal lit = (Literal) value; + + if (lit.getDatatype() == null || + !EPOCH.stringValue().equals(lit.getDatatype().stringValue())) + throw new IllegalArgumentException(); + + final String s = value.stringValue(); + + final long l = XMLDatatypeUtil.parseLong(s); + + // can't have negative epoch values + if (l < 0) + return null; + + final AbstractLiteralIV delegate = new XSDLongIV(l); + + return new ExtensionIV(delegate, (TermId) getDatatype().getIV()); + + } + + public Value asValue(final ExtensionIV iv, final BigdataValueFactory vf) { + + return vf.createLiteral(iv.stringValue(), epoch); + + } + +} Added: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/ExtensionIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/ExtensionIV.java (rev 0) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/ExtensionIV.java 2010-07-23 17:36:38 UTC (rev 3272) @@ -0,0 +1,88 @@ +package com.bigdata.rdf.internal; + +import com.bigdata.rawstore.Bytes; +import com.bigdata.rdf.model.BigdataLiteral; +import com.bigdata.rdf.model.BigdataValue; +import com.bigdata.rdf.model.BigdataValueFactory; + +public class ExtensionIV<V extends BigdataLiteral> + extends AbstractInlineIV<V, Object> { + + /** + * + */ + private static final long serialVersionUID = 8267554196603121194L; + + private final AbstractLiteralIV delegate; + + private final TermId datatype; + + public ExtensionIV(final AbstractLiteralIV delegate, + final TermId datatype) { + super(VTE.LITERAL, DTE.Extension); + + this.delegate = delegate; + this.datatype = datatype; + } + + public AbstractLiteralIV getDelegate() { + return delegate; + } + + @Override + public String stringValue() { + return delegate.stringValue(); + } + + public Object getInlineValue() { + return delegate.getInlineValue(); + } + + @Override + public TermId getExtensionDatatype() { + return datatype; + } + + /** + * Return the hash code of the long epoch value. + */ + public int hashCode() { + return delegate.hashCode(); + } + + public boolean equals(final Object o) { + if(this==o) return true; + if(o instanceof ExtensionIV) { + return this.delegate.equals(((ExtensionIV) o).delegate) && + this.datatype.equals(((ExtensionIV) o).datatype); + } + return false; + } + + protected int _compareTo(final IV o) { + + int ret = datatype._compareTo(((ExtensionIV) o).datatype); + + if (ret != 0) + return ret; + + return delegate._compareTo(((ExtensionIV) o).delegate); + + } + + /** + * Return the normal length of the delegate plus 8 bytes for the term ID + * of the extension datatype. + */ + public int byteLength() { + return delegate.byteLength() + Bytes.SIZEOF_LONG; + } + + @SuppressWarnings("unchecked") + public V asValue(final BigdataValueFactory f, + final ILexiconConfiguration config) + throws UnsupportedOperationException { + return (V) config.getExtension(datatype).asValue(this, f); + } + +} Added: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IDatatypeURIResolver.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IDatatypeURIResolver.java (rev 0) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IDatatypeURIResolver.java 2010-07-23 17:36:38 UTC (rev 3272) @@ -0,0 +1,53 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2010. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +package com.bigdata.rdf.internal; + +import org.openrdf.model.URI; +import com.bigdata.rdf.lexicon.LexiconRelation; +import com.bigdata.rdf.model.BigdataURI; + +public interface IDatatypeURIResolver { + + /** + * Returns a fully resolved datatype URI with the {@link TermId} set. + * {@link IExtension}s will handle encoding and decoding of inline literals + * for custom datatypes, however to do so they will need the term identifier + * for the custom datatype. By passing an instance of this interface into + * the constructor for the {@link IExtension}, it will be able to resolve + * its datatype URI and cache it for future use. + * <p> + * If the datatype URI is not already in the lexicon this method MUST add + * it to the lexicon so that it has an assigned term identifier. + * <p> + * This is implemented by the {@link LexiconRelation}. + * + * @param uri + * the term to resolve + * @return + * the fully resolved term + */ + BigdataURI resolve(final URI datatypeURI); + +} Added: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IExtension.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IExtension.java (rev 0) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IExtension.java 2010-07-23 17:36:38 UTC (rev 3272) @@ -0,0 +1,40 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2010. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +package com.bigdata.rdf.internal; + +import org.openrdf.model.Value; +import com.bigdata.rdf.model.BigdataURI; +import com.bigdata.rdf.model.BigdataValueFactory; + + +public interface IExtension { + + BigdataURI getDatatype(); + + ExtensionIV createIV(final Value value); + + Value asValue(final ExtensionIV iv, final BigdataValueFactory vf); + +} Added: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IExtensionFactory.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IExtensionFactory.java (rev 0) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IExtensionFactory.java 2010-07-23 17:36:38 UTC (rev 3272) @@ -0,0 +1,31 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2010. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ + +package com.bigdata.rdf.internal; + +public interface IExtensionFactory { + + IExtension[] getExtensions(); + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-07-23 17:35:25
|
Revision: 3271 http://bigdata.svn.sourceforge.net/bigdata/?rev=3271&view=rev Author: mrpersonick Date: 2010-07-23 17:35:18 +0000 (Fri, 23 Jul 2010) Log Message: ----------- adding support for bnode inlining and extensions Modified Paths: -------------- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractBNodeIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInlineIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractLiteralIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/DummyIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/ILexiconConfiguration.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IVUtility.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/NumericBNodeIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/TermId.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/UUIDBNodeIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/UUIDLiteralIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDBooleanIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDByteIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDDecimalIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDDoubleIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDFloatIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDIntIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDIntegerIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDLongIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDShortIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/internal/TestEncodeDecodeKeys.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestInlining.java Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractBNodeIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractBNodeIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractBNodeIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -54,11 +54,8 @@ } - final public long getTermId() { - throw new UnsupportedOperationException(); - } - - public V asValue(BigdataValueFactory f) + public V asValue(final BigdataValueFactory f, + final ILexiconConfiguration config) throws UnsupportedOperationException { final V bnode = (V) f.createBNode(stringValue()); bnode.setIV(this); Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -548,30 +548,6 @@ if (ret > 0) return 1; - if(this instanceof TermId) { - - final long tid1 = ((TermId<?>) this).getTermId(); - final long tid2 = ((TermId<?>) o).getTermId(); - - /* - * Note: logic avoids possible overflow of [long] by not computing - * the difference between two longs. - */ - - ret = tid1 < tid2 ? -1 : tid1 > tid2 ? 1 : 0; - - return ret; - - } - - if(isExtension()) { - /* - * @todo we may need to handle extension types here explicitly once - * their semantics are firmed up further. - */ - throw new UnsupportedOperationException(); - } - /* * At this point we are comparing two IVs of the same intrinsic * datatype. That is, they are both datatype literals expressed using @@ -590,17 +566,10 @@ * {@link AbstractInlineIV} and implementations provided * for each concrete instance of that abstract class. */ - protected int _compareTo(IV o) { + protected abstract int _compareTo(IV o); - throw new UnsupportedOperationException(getClass().toString()); - - } - /** * {@inheritDoc} - * - * FIXME Handle extension types, probably in a subclass, and maybe requiring - * the caller to pass in an object with the context for the extension types. */ public IKeyBuilder encode(final IKeyBuilder keyBuilder) { @@ -616,6 +585,12 @@ return keyBuilder; } + if (isExtension()) { + + keyBuilder.append(getExtensionDatatype().getTermId()); + + } + /* * Append the natural value type representation. * @@ -677,4 +652,8 @@ } + protected TermId getExtensionDatatype() { + return null; + } + } Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInlineIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInlineIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInlineIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -82,6 +82,13 @@ return false; } + /** + * No term identifier for an inline IV - throws an exception. + */ + final public long getTermId() { + throw new UnsupportedOperationException(); + } + public String toString() { return super.getDTE() + "(" + stringValue() + ")"; Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractLiteralIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractLiteralIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractLiteralIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -66,10 +66,6 @@ } - final public long getTermId() { - throw new UnsupportedOperationException(); - } - /** Return the <code>boolean</code> value of <i>this</i> value. */ abstract public boolean booleanValue(); Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/DummyIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/DummyIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/DummyIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -55,7 +55,8 @@ return "DummyIV"; } - public BigdataValue asValue(BigdataValueFactory f) + public BigdataValue asValue(final BigdataValueFactory f, + final ILexiconConfiguration config) throws UnsupportedOperationException { throw new UnsupportedOperationException(); } @@ -79,6 +80,10 @@ return 0; } + protected int _compareTo(IV o) { + return 0; + } + @Override public boolean equals(Object o) { return this == o; Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/ILexiconConfiguration.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/ILexiconConfiguration.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/ILexiconConfiguration.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -24,7 +24,10 @@ package com.bigdata.rdf.internal; +import org.openrdf.model.URI; +import org.openrdf.model.Value; + /** * Configuration determines which RDF Values are inlined into the statement * indices rather than being assigned term identifiers by the lexicon. @@ -38,16 +41,20 @@ public boolean isLegacyEncoding(); */ + IV createIV(final Value value); + + IExtension getExtension(final TermId datatype); + /** - * <code>true</code> iff the <code>vte</code> and <code>dte</code> should - * be inlined. + * <code>true</code> iff the <code>vte</code> and <code>dte</code> + * should be inlined. * * @param vte * the term type * @param dte * the data type + public boolean isInline(VTE vte, DTE dte); */ - public boolean isInline(VTE vte, DTE dte); // /** // * <code>true</code> iff <code>xsd:boolean</code> should be inlined. Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -217,8 +217,10 @@ * factory. However, implementations are encouraged to cache the inflated * {@link BigdataValue} on a transient field. * - * @param f + * @param vf * The value factory. + * @param config + * The lexicon configuration. * @return The corresponding {@link BigdataValue}. * @throws UnsupportedOperationException * unless the RDF value is inline. @@ -241,6 +243,7 @@ * and/or quad stores since the lexicon does not interact with * whether we are using triples or quads (except for SIDs). */ - V asValue(BigdataValueFactory f) throws UnsupportedOperationException; + V asValue(final BigdataValueFactory vf, final ILexiconConfiguration config) + throws UnsupportedOperationException; } Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IVUtility.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IVUtility.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IVUtility.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -32,6 +32,7 @@ import java.util.ArrayList; import java.util.UUID; import com.bigdata.btree.keys.KeyBuilder; +import com.bigdata.rawstore.Bytes; import com.bigdata.rdf.internal.constraints.AbstractInlineConstraint; import com.bigdata.rdf.internal.constraints.InlineGT; import com.bigdata.rdf.model.BigdataLiteral; @@ -256,7 +257,9 @@ private static IV decodeFromOffset(final byte[] key, final int offset) { - final byte flags = KeyBuilder.decodeByte(key[offset]); + int o = offset; + + final byte flags = KeyBuilder.decodeByte(key[o++]); /* * FIXME iNull does not work yet @@ -271,7 +274,7 @@ if (!AbstractIV.isInline(flags)) { // decode the term identifier. - final long termId = KeyBuilder.decodeLong(key, offset+1); + final long termId = KeyBuilder.decodeLong(key, o); /* * FIXME this is here for now until @@ -292,52 +295,69 @@ // The data type final DTE dte = AbstractIV.getInternalDataTypeEnum(flags); + + final boolean isExtension = AbstractIV.isExtension(flags); + + final TermId datatype; + if (isExtension) { + datatype = new TermId(VTE.URI, KeyBuilder.decodeLong(key, o)); + o += Bytes.SIZEOF_LONG; + } else { + datatype = null; + } switch (dte) { case XSDBoolean: { - final byte x = KeyBuilder.decodeByte(key[offset+1]); - if (x == 0) { - return XSDBooleanIV.FALSE; - } else { - return XSDBooleanIV.TRUE; - } + final byte x = KeyBuilder.decodeByte(key[o]); + final AbstractLiteralIV iv = (x == 0) ? + XSDBooleanIV.FALSE : XSDBooleanIV.TRUE; + return isExtension ? new ExtensionIV(iv, datatype) : iv; } case XSDByte: { - final byte x = KeyBuilder.decodeByte(key[offset+1]); - return new XSDByteIV<BigdataLiteral>(x); + final byte x = KeyBuilder.decodeByte(key[o]); + final AbstractLiteralIV iv = new XSDByteIV<BigdataLiteral>(x); + return isExtension ? new ExtensionIV(iv, datatype) : iv; } case XSDShort: { - final short x = KeyBuilder.decodeShort(key, offset+1); - return new XSDShortIV<BigdataLiteral>(x); + final short x = KeyBuilder.decodeShort(key, o); + final AbstractLiteralIV iv = new XSDShortIV<BigdataLiteral>(x); + return isExtension ? new ExtensionIV(iv, datatype) : iv; } case XSDInt: { - final int x = KeyBuilder.decodeInt(key, offset+1); - return new XSDIntIV<BigdataLiteral>(x); + final int x = KeyBuilder.decodeInt(key, o); + final AbstractLiteralIV iv = new XSDIntIV<BigdataLiteral>(x); + return isExtension ? new ExtensionIV(iv, datatype) : iv; } case XSDLong: { - final long x = KeyBuilder.decodeLong(key, offset+1); - return new XSDLongIV<BigdataLiteral>(x); + final long x = KeyBuilder.decodeLong(key, o); + final AbstractLiteralIV iv = new XSDLongIV<BigdataLiteral>(x); + return isExtension ? new ExtensionIV(iv, datatype) : iv; } case XSDFloat: { - final float x = KeyBuilder.decodeFloat(key, offset+1); - return new XSDFloatIV<BigdataLiteral>(x); + final float x = KeyBuilder.decodeFloat(key, o); + final AbstractLiteralIV iv = new XSDFloatIV<BigdataLiteral>(x); + return isExtension ? new ExtensionIV(iv, datatype) : iv; } case XSDDouble: { - final double x = KeyBuilder.decodeDouble(key, offset+1); - return new XSDDoubleIV<BigdataLiteral>(x); + final double x = KeyBuilder.decodeDouble(key, o); + final AbstractLiteralIV iv = new XSDDoubleIV<BigdataLiteral>(x); + return isExtension ? new ExtensionIV(iv, datatype) : iv; } - case UUID: { - final UUID x = KeyBuilder.decodeUUID(key, offset+1); - return new UUIDLiteralIV<BigdataLiteral>(x); - } case XSDInteger: { - final BigInteger x = KeyBuilder.decodeBigInteger(offset+1, key); - return new XSDIntegerIV<BigdataLiteral>(x); + final BigInteger x = KeyBuilder.decodeBigInteger(o, key); + final AbstractLiteralIV iv = new XSDIntegerIV<BigdataLiteral>(x); + return isExtension ? new ExtensionIV(iv, datatype) : iv; } case XSDDecimal: { - final BigDecimal x = KeyBuilder.decodeBigDecimal(offset+1, key); - return new XSDDecimalIV<BigdataLiteral>(x); + final BigDecimal x = KeyBuilder.decodeBigDecimal(o, key); + final AbstractLiteralIV iv = new XSDDecimalIV<BigdataLiteral>(x); + return isExtension ? new ExtensionIV(iv, datatype) : iv; } + case UUID: { + final UUID x = KeyBuilder.decodeUUID(key, o); + final AbstractLiteralIV iv = new UUIDLiteralIV<BigdataLiteral>(x); + return isExtension ? new ExtensionIV(iv, datatype) : iv; + } // case XSDUnsignedByte: // keyBuilder.appendUnsigned(t.byteValue()); // break; Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -27,7 +27,17 @@ package com.bigdata.rdf.internal; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import org.openrdf.model.BNode; +import org.openrdf.model.Literal; +import org.openrdf.model.URI; +import org.openrdf.model.Value; +import org.openrdf.model.datatypes.XMLDatatypeUtil; +import com.bigdata.rdf.model.BigdataValue; + /** * An object which describes which kinds of RDF Values are inlined into the * statement indices and how other RDF Values are coded into the lexicon. @@ -42,20 +52,207 @@ private boolean inlineLiterals, inlineBNodes; + private Map<TermId, IExtension> termIds; + + private Map<String, IExtension> datatypes; + public LexiconConfiguration() { } public LexiconConfiguration(final boolean inlineLiterals, - final boolean inlineBNodes) { + final boolean inlineBNodes, + final IExtensionFactory xFactory) { this.inlineLiterals = inlineLiterals; this.inlineBNodes = inlineBNodes; + + termIds = new HashMap<TermId, IExtension>(); + for (IExtension extension : xFactory.getExtensions()) { + termIds.put((TermId) extension.getDatatype().getIV(), extension); + } + + datatypes = new HashMap<String, IExtension>(); + for (IExtension extension : xFactory.getExtensions()) { + datatypes.put(extension.getDatatype().stringValue(), extension); + } + } + public IExtension getExtension(final TermId datatype) { + return termIds.get(datatype); + } + + public IV createIV(final Value value) { + + // we know right away we can't handle URIs + if (value instanceof URI) + return null; + + if (value instanceof Literal) { + + final Literal l = (Literal) value; + + final URI datatype = l.getDatatype(); + + // not a datatyped literal + if (datatype == null) + return null; + + if (datatypes.containsKey(datatype.stringValue())) { + + try { + + final IExtension xFactory = + datatypes.get(datatype.stringValue()); + + final IV iv = xFactory.createIV(value); + + if (iv != null && value instanceof BigdataValue) + ((BigdataValue) value).setIV(iv); + + return iv; + + } catch (Exception ex) { + + /* + * Some sort of parse error in the literal value most + * likely. Resort to term identifiers. + */ + return null; + + } + + } + + // get the native DTE + final DTE dte = DTE.valueOf(datatype); + + // no native DTE for this datatype + if (dte == null) + return null; + + // check to see if we are inlining literals of this type + if (!isInline(VTE.LITERAL, dte)) + return null; + + final String v = value.stringValue(); + + IV iv = null; + + try { + + switch(dte) { + case XSDBoolean: + iv = new XSDBooleanIV(XMLDatatypeUtil.parseBoolean(v)); + break; + case XSDByte: + iv = new XSDByteIV(XMLDatatypeUtil.parseByte(v)); + break; + case XSDShort: + iv = new XSDShortIV(XMLDatatypeUtil.parseShort(v)); + break; + case XSDInt: + iv = new XSDIntIV(XMLDatatypeUtil.parseInt(v)); + break; + case XSDLong: + iv = new XSDLongIV(XMLDatatypeUtil.parseLong(v)); + break; + case XSDFloat: + iv = new XSDFloatIV(XMLDatatypeUtil.parseFloat(v)); + break; + case XSDDouble: + iv = new XSDDoubleIV(XMLDatatypeUtil.parseDouble(v)); + break; + case XSDInteger: + iv = new XSDIntegerIV(XMLDatatypeUtil.parseInteger(v)); + break; + case XSDDecimal: + iv = new XSDDecimalIV(XMLDatatypeUtil.parseDecimal(v)); + break; + case UUID: + iv = new UUIDLiteralIV(UUID.fromString(v)); + break; + default: + iv = null; + } + + } catch (NumberFormatException ex) { + + // some dummy doesn't know how to format a number + // default to term identifier for this term + + } + + if (iv != null && value instanceof BigdataValue) + ((BigdataValue) value).setIV(iv); + + return iv; + + } else if (value instanceof BNode) { + + final BNode b = (BNode) value; + + final String id = b.getID(); + + final char c = id.charAt(0); + + try { + + final UUID uuid = UUID.fromString(id); + + if (!uuid.toString().equals(id)) + return null; + + if (!isInline(VTE.BNODE, DTE.UUID)) + return null; + + final IV iv = new UUIDBNodeIV(uuid); + + if (value instanceof BigdataValue) + ((BigdataValue) value).setIV(iv); + + return iv; + + } catch (Exception ex) { + + // string id could not be converted to a UUID + + } + + try { + + final Integer i = Integer.valueOf(id); + + // cannot normalize id, needs to remain syntactically identical + if (!i.toString().equals(id)) + return null; + + if (!isInline(VTE.BNODE, DTE.XSDInt)) + return null; + + final IV iv = new NumericBNodeIV(i); + + if (value instanceof BigdataValue) + ((BigdataValue) value).setIV(iv); + + return iv; + + } catch (Exception ex) { + + // string id could not be converted to an Integer + + } + + } + + return null; + + } + /** * See {@link ILexiconConfiguration#isInline(VTE, DTE)}. */ public boolean isInline(final VTE vte, final DTE dte) { - + switch(vte) { case BNODE: return inlineBNodes && isSupported(dte); @@ -91,13 +288,4 @@ } - /** - * See {@link ILexiconConfiguration#isLegacyEncoding()}. - public boolean isLegacyEncoding() { - - return true; - - } - */ - } Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/NumericBNodeIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/NumericBNodeIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/NumericBNodeIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -76,6 +76,15 @@ return false; } + @Override + protected int _compareTo(IV o) { + + final int id2 = ((NumericBNodeIV) o).id; + + return id == id2 ? 0 : id < id2 ? -1 : 1; + + } + public int hashCode() { return id; } Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/TermId.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/TermId.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/TermId.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -136,7 +136,8 @@ * @throws UnsupportedOperationException * always since {@link TermId}s are never inline. */ - final public V asValue(BigdataValueFactory f) + final public V asValue(final BigdataValueFactory f, + final ILexiconConfiguration config) throws UnsupportedOperationException { throw new UnsupportedOperationException(); } @@ -202,30 +203,6 @@ return (int) (termId ^ (termId >>> 32)); } -// @Override -// public int compareTo(IV o) { -// -// if (!(o instanceof TermId)) -// return super.compareTo(o); -// -// if (this == o) -// return 0; -// -//// if (o == null) // already known to be non-null. -//// return 1; -// -// final long tid1 = ((TermId<?>) this).getTermId(); -// final long tid2 = ((TermId<?>) o).getTermId(); -// -// /* -// * Note: logic avoids possible overflow of [long] by not computing -// * the difference between two longs. -// */ -// -// return tid1 < tid2 ? -1 : tid1 > tid2 ? 1 : 0; -// -// } - /** * {@inheritDoc} * @@ -239,5 +216,14 @@ return 1 + Bytes.SIZEOF_LONG; } + + @Override + protected int _compareTo(IV o) { + + final long termId2 = ((TermId<?>) o).termId; + + return termId < termId2 ? -1 : termId > termId2 ? 1 : 0; + + } } Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/UUIDBNodeIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/UUIDBNodeIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/UUIDBNodeIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -80,6 +80,13 @@ return false; } + @Override + protected int _compareTo(IV o) { + + return id.compareTo(((UUIDBNodeIV) o).id); + + } + public int hashCode() { return id.hashCode(); } Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/UUIDLiteralIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/UUIDLiteralIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/UUIDLiteralIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -61,7 +61,8 @@ } @SuppressWarnings("unchecked") - public V asValue(final BigdataValueFactory f) { + public V asValue(final BigdataValueFactory f, + final ILexiconConfiguration config) { final V v = (V) f.createLiteral(value.toString(), // f.createURI(DTE.UUID.getDatatype())); v.setIV(this); Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDBooleanIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDBooleanIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDBooleanIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -62,7 +62,8 @@ } @SuppressWarnings("unchecked") - public V asValue(final BigdataValueFactory f) { + public V asValue(final BigdataValueFactory f, + final ILexiconConfiguration config) { final V v = (V) f.createLiteral(value); v.setIV(this); return v; Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDByteIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDByteIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDByteIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -56,7 +56,8 @@ } @SuppressWarnings("unchecked") - public V asValue(final BigdataValueFactory f) { + public V asValue(final BigdataValueFactory f, + final ILexiconConfiguration config) { final V v = (V) f.createLiteral(value); v.setIV(this); return v; Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDDecimalIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDDecimalIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDDecimalIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -61,7 +61,8 @@ } @SuppressWarnings("unchecked") - public V asValue(final BigdataValueFactory f) { + public V asValue(final BigdataValueFactory f, + final ILexiconConfiguration config) { // @todo factory should cache the XSD URIs. final V v = (V) f.createLiteral(value.toString(),// f.createURI(DTE.XSDDecimal.getDatatype())); @@ -143,7 +144,12 @@ */ int dataLen = value.unscaledValue().toString().length(); - byteLength = 1 /* sign */ + 4 /* exponent */+ dataLen + 1 /* data and null termination */; + byteLength = + 1 /* flags */ + + 1 /* sign */ + + 4 /* exponent */ + + dataLen + + 1 /* data and null termination */; } Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDDoubleIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDDoubleIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDDoubleIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -55,7 +55,8 @@ } @SuppressWarnings("unchecked") - public V asValue(final BigdataValueFactory f) { + public V asValue(final BigdataValueFactory f, + final ILexiconConfiguration config) { final V v = (V) f.createLiteral(value); v.setIV(this); return v; Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDFloatIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDFloatIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDFloatIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -55,7 +55,8 @@ } @SuppressWarnings("unchecked") - public V asValue(final BigdataValueFactory f) { + public V asValue(final BigdataValueFactory f, + final ILexiconConfiguration config) { final V v = (V) f.createLiteral(value); v.setIV(this); return v; Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDIntIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDIntIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDIntIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -57,7 +57,8 @@ } @SuppressWarnings("unchecked") - public V asValue(final BigdataValueFactory f) { + public V asValue(final BigdataValueFactory f, + final ILexiconConfiguration config) { final V v = (V) f.createLiteral(value); v.setIV(this); return v; Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDIntegerIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDIntegerIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDIntegerIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -60,7 +60,8 @@ } @SuppressWarnings("unchecked") - public V asValue(final BigdataValueFactory f) { + public V asValue(final BigdataValueFactory f, + final ILexiconConfiguration config) { // @todo factory should cache the XSD URIs. final V v = (V) f.createLiteral(value.toString(),// f.createURI(DTE.XSDInteger.getDatatype())); Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDLongIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDLongIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDLongIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -55,7 +55,8 @@ } @SuppressWarnings("unchecked") - public V asValue(final BigdataValueFactory f) { + public V asValue(final BigdataValueFactory f, + final ILexiconConfiguration config) { final V v = (V) f.createLiteral(value); v.setIV(this); return v; Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDShortIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDShortIV.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDShortIV.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -57,7 +57,8 @@ } @SuppressWarnings("unchecked") - public V asValue(final BigdataValueFactory f) { + public V asValue(final BigdataValueFactory f, + final ILexiconConfiguration config) { final V v = (V) f.createLiteral(value); v.setIV(this); return v; Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -27,6 +27,7 @@ package com.bigdata.rdf.lexicon; +import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; @@ -41,7 +42,6 @@ import java.util.Map; import java.util.Properties; import java.util.Set; -import java.util.UUID; import java.util.concurrent.Callable; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Future; @@ -53,7 +53,6 @@ import org.openrdf.model.Statement; import org.openrdf.model.URI; import org.openrdf.model.Value; -import org.openrdf.model.datatypes.XMLDatatypeUtil; import com.bigdata.btree.BytesUtil; import com.bigdata.btree.IIndex; import com.bigdata.btree.IRangeQuery; @@ -76,39 +75,30 @@ import com.bigdata.journal.IIndexManager; import com.bigdata.journal.IResourceLock; import com.bigdata.rawstore.Bytes; -import com.bigdata.rdf.internal.DTE; +import com.bigdata.rdf.internal.ColorsEnumExtension; +import com.bigdata.rdf.internal.DefaultExtensionFactory; +import com.bigdata.rdf.internal.EpochExtension; +import com.bigdata.rdf.internal.IExtension; +import com.bigdata.rdf.internal.IDatatypeURIResolver; +import com.bigdata.rdf.internal.IExtensionFactory; import com.bigdata.rdf.internal.ILexiconConfiguration; import com.bigdata.rdf.internal.IV; import com.bigdata.rdf.internal.IVUtility; import com.bigdata.rdf.internal.LexiconConfiguration; -import com.bigdata.rdf.internal.NumericBNodeIV; import com.bigdata.rdf.internal.TermId; -import com.bigdata.rdf.internal.UUIDBNodeIV; -import com.bigdata.rdf.internal.UUIDLiteralIV; -import com.bigdata.rdf.internal.VTE; -import com.bigdata.rdf.internal.XSDBooleanIV; -import com.bigdata.rdf.internal.XSDByteIV; -import com.bigdata.rdf.internal.XSDDecimalIV; -import com.bigdata.rdf.internal.XSDDoubleIV; -import com.bigdata.rdf.internal.XSDFloatIV; -import com.bigdata.rdf.internal.XSDIntIV; -import com.bigdata.rdf.internal.XSDIntegerIV; -import com.bigdata.rdf.internal.XSDLongIV; -import com.bigdata.rdf.internal.XSDShortIV; import com.bigdata.rdf.lexicon.Term2IdWriteProc.Term2IdWriteProcConstructor; import com.bigdata.rdf.model.BigdataBNode; +import com.bigdata.rdf.model.BigdataURI; import com.bigdata.rdf.model.BigdataValue; import com.bigdata.rdf.model.BigdataValueFactory; import com.bigdata.rdf.model.BigdataValueFactoryImpl; import com.bigdata.rdf.model.StatementEnum; -import com.bigdata.rdf.model.TermIdComparator2; import com.bigdata.rdf.rio.IStatementBuffer; import com.bigdata.rdf.rio.StatementBuffer; import com.bigdata.rdf.spo.ISPO; import com.bigdata.rdf.spo.SPOComparator; import com.bigdata.rdf.store.AbstractTripleStore; import com.bigdata.rdf.store.IRawTripleStore; -import com.bigdata.rdf.store.AbstractTripleStore.Options; import com.bigdata.relation.AbstractRelation; import com.bigdata.relation.accesspath.IAccessPath; import com.bigdata.relation.accesspath.IElementFilter; @@ -150,7 +140,7 @@ * @version $Id$ */ public class LexiconRelation extends AbstractRelation<BigdataValue> - /*implements ILexiconConfiguration*/ { + implements IDatatypeURIResolver { final protected static Logger log = Logger.getLogger(LexiconRelation.class); @@ -208,7 +198,35 @@ return (Class<ITextIndexer>) cls; } + + @SuppressWarnings("unchecked") + protected Class<IExtensionFactory> determineExtensionFactoryClass() { + final String className = getProperty( + AbstractTripleStore.Options.EXTENSION_FACTORY_CLASS, + AbstractTripleStore.Options.DEFAULT_EXTENSION_FACTORY_CLASS); + + final Class<?> cls; + try { + cls = Class.forName(className); + } catch (ClassNotFoundException e) { + throw new RuntimeException("Bad option: " + + AbstractTripleStore.Options.EXTENSION_FACTORY_CLASS, e); + } + + if (!IExtensionFactory.class.isAssignableFrom(cls)) { + throw new RuntimeException( + AbstractTripleStore.Options.EXTENSION_FACTORY_CLASS + + ": Must implement: " + + IExtensionFactory.class.getName()); + } + + return (Class<IExtensionFactory>) cls; + + } + + + /** * Note: The term:id and id:term indices MUST use unisolated write operation * to ensure consistency without write-write conflicts. The only exception @@ -376,9 +394,6 @@ AbstractTripleStore.Options.INLINE_LITERALS, AbstractTripleStore.Options.DEFAULT_INLINE_LITERALS)); - lexiconConfiguration = - new LexiconConfiguration(inlineLiterals, inlineBNodes); - } } @@ -943,7 +958,26 @@ } + /** + * See {@link IDatatypeURIResolver}. + */ + public BigdataURI resolve(final URI uri) { + + final BigdataURI buri = valueFactory.asValue(uri); + + if (buri.getIV() == null) { + + _addTerms(new BigdataValue[] { buri }, 1, false); + + if (buri.getIV() == null) + throw new RuntimeException(); + } + + return buri; + + } + /** * Batch insert of terms into the database. * <p> @@ -969,13 +1003,7 @@ @SuppressWarnings("unchecked") public void addTerms(final BigdataValue[] terms, final int numTerms, final boolean readOnly) { - - if (log.isDebugEnabled()) - log.debug("numTerms=" + numTerms + ", readOnly=" + readOnly); - if (numTerms == 0) - return; - /* * Very strange that we need to pass in the numTerms. The * semantics are that we should only consider terms from @@ -1021,8 +1049,44 @@ // } // } // } - + + // write the non-inline terms to the indices + _addTerms(terms2, numTerms2, readOnly); + } + + /** + * Batch insert of terms into the database. + * <p> + * Note: Duplicate {@link BigdataValue} references and {@link BigdataValue}s + * that already have an assigned term identifiers are ignored by this + * operation. + * <p> + * Note: This implementation is designed to use unisolated batch writes on + * the terms and ids index that guarantee consistency. + * <p> + * If the full text index is enabled, then the terms will also be inserted + * into the full text index. + * + * @param terms + * An array whose elements [0:nterms-1] will be inserted. + * @param numTerms + * The #of terms to insert. + * @param readOnly + * When <code>true</code>, unknown terms will not be inserted + * into the database. Otherwise unknown terms are inserted into + * the database. + */ + @SuppressWarnings("unchecked") + private void _addTerms(final BigdataValue[] terms, final int numTerms, + final boolean readOnly) { + + if (log.isDebugEnabled()) + log.debug("numTerms=" + numTerms + ", readOnly=" + readOnly); + + if (numTerms == 0) + return; + final long begin = System.currentTimeMillis(); final WriteTaskStats stats = new WriteTaskStats(); @@ -1030,7 +1094,7 @@ final KVO<BigdataValue>[] a; try { // write on the forward index (sync RPC) - a = new Term2IdWriteTask(this, readOnly, numTerms2, terms2, stats) + a = new Term2IdWriteTask(this, readOnly, numTerms, terms, stats) .call(); } catch (Exception ex) { throw new RuntimeException(ex); @@ -1147,14 +1211,14 @@ if (log.isInfoEnabled() && readOnly && stats.nunknown.get() > 0) { log.info("There are " + stats.nunknown + " unknown terms out of " - + numTerms2 + " given"); + + numTerms + " given"); } - if (numTerms2 > 1000 || elapsed > 3000) { + if (numTerms > 1000 || elapsed > 3000) { if(log.isInfoEnabled()) - log.info("Processed " + numTerms2 + " in " + elapsed + log.info("Processed " + numTerms + " in " + elapsed + "ms; keygen=" + stats.keyGenTime + "ms, sort=" + stats.sortTime + "ms, insert=" + stats.indexTime + "ms" + " {forward=" + stats.forwardIndexTime + ", reverse=" + stats.reverseIndexTime @@ -1504,7 +1568,7 @@ if (iv.isInline()) { // translate it into a value directly - ret.put(iv, iv.asValue(valueFactory)); + ret.put(iv, iv.asValue(valueFactory, getLexiconConfiguration())); } else { @@ -2134,7 +2198,7 @@ final public BigdataValue getTerm(final IV iv) { if (iv.isInline()) - return iv.asValue(valueFactory); + return iv.asValue(valueFactory, getLexiconConfiguration()); TermId tid = (TermId) iv; @@ -2240,133 +2304,8 @@ */ private IV getInlineIV(Value value) { - // just literals for now, maybe bnodes too eventually? - if (value instanceof Literal) { - - final Literal l = (Literal) value; - - final URI datatype = l.getDatatype(); - - final DTE dte = datatype == null ? null : DTE.valueOf(datatype); - - if (dte == null) - return null; - - if (!getLexiconConfiguration().isInline(VTE.LITERAL, dte)) - return null; - - final String v = value.stringValue(); - - IV iv = null; - - try { - - switch(dte) { - case XSDBoolean: - iv = new XSDBooleanIV(XMLDatatypeUtil.parseBoolean(v)); - break; - case XSDByte: - iv = new XSDByteIV(XMLDatatypeUtil.parseByte(v)); - break; - case XSDShort: - iv = new XSDShortIV(XMLDatatypeUtil.parseShort(v)); - break; - case XSDInt: - iv = new XSDIntIV(XMLDatatypeUtil.parseInt(v)); - break; - case XSDLong: - iv = new XSDLongIV(XMLDatatypeUtil.parseLong(v)); - break; - case XSDFloat: - iv = new XSDFloatIV(XMLDatatypeUtil.parseFloat(v)); - break; - case XSDDouble: - iv = new XSDDoubleIV(XMLDatatypeUtil.parseDouble(v)); - break; - case XSDInteger: - iv = new XSDIntegerIV(XMLDatatypeUtil.parseInteger(v)); - break; - case XSDDecimal: - iv = new XSDDecimalIV(XMLDatatypeUtil.parseDecimal(v)); - break; - case UUID: - iv = new UUIDLiteralIV(UUID.fromString(v)); - break; - default: - iv = null; - } - - } catch (NumberFormatException ex) { - - // some dummy doesn't know how to format a number - // default to term identifier for this term - - } - - if (iv != null && value instanceof BigdataValue) - ((BigdataValue) value).setIV(iv); - - return iv; - - } else if (value instanceof BNode) { - - final BNode b = (BNode) value; - - final String id = b.getID(); - - final char c = id.charAt(0); - - try { + return getLexiconConfiguration().createIV(value); - final UUID uuid = UUID.fromString(id); - - if (!uuid.toString().equals(id)) - return null; - - if (!getLexiconConfiguration().isInline(VTE.BNODE, DTE.UUID)) - return null; - - final IV iv = new UUIDBNodeIV(uuid); - - if (value instanceof BigdataValue) - ((BigdataValue) value).setIV(iv); - - return iv; - - } catch (Exception ex) { - - // string id could not be converted to a UUID - - } - - try { - - final Integer i = Integer.valueOf(id); - - // cannot normalize id, needs to remain syntactically identical - if (!i.toString().equals(id)) - return null; - - if (!getLexiconConfiguration().isInline(VTE.BNODE, DTE.XSDInt)) - return null; - - final IV iv = new NumericBNodeIV(i); - - if (value instanceof BigdataValue) - ((BigdataValue) value).setIV(iv); - - return iv; - - } catch (Exception ex) { - - // string id could not be converted to an Integer - - } - - } - - return null; - } /** @@ -2678,7 +2617,38 @@ * how to encode and decode terms in the key space. */ public ILexiconConfiguration getLexiconConfiguration() { + + if (lexiconConfiguration == null) { + + try { + + final Class<IExtensionFactory> xfc = determineExtensionFactoryClass(); + final Constructor<IExtensionFactory> ctor = xfc.getConstructor( + IDatatypeURIResolver.class); + final IExtensionFactory xFactory = ctor.newInstance( + (IDatatypeURIResolver) this); + + lexiconConfiguration = new LexiconConfiguration( + inlineLiterals, inlineBNodes, xFactory); + + } catch (InstantiationException e) { + throw new IllegalArgumentException( + AbstractTripleStore.Options.EXTENSION_FACTORY_CLASS, e); + } catch (NoSuchMethodException e) { + throw new IllegalArgumentException( + AbstractTripleStore.Options.EXTENSION_FACTORY_CLASS, e); + } catch (InvocationTargetException e) { + throw new IllegalArgumentException( + AbstractTripleStore.Options.EXTENSION_FACTORY_CLASS, e); + } catch (IllegalAccessException e) { + throw new IllegalArgumentException( + AbstractTripleStore.Options.EXTENSION_FACTORY_CLASS, e); + } + + } + return lexiconConfiguration; + } } Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -78,6 +78,8 @@ import com.bigdata.rdf.inf.IJustificationIterator; import com.bigdata.rdf.inf.Justification; import com.bigdata.rdf.inf.JustificationIterator; +import com.bigdata.rdf.internal.DefaultExtensionFactory; +import com.bigdata.rdf.internal.IDatatypeURIResolver; import com.bigdata.rdf.internal.IV; import com.bigdata.rdf.lexicon.BigdataRDFFullTextIndex; import com.bigdata.rdf.lexicon.ITermIdCodes; @@ -877,6 +879,21 @@ String DEFAULT_INLINE_BNODES = "false"; + /** + * The name of the {@link IExtensionFactory} class. The implementation + * MUST declare a constructor that accepts an + * {@link IDatatypeURIResolver} as its only argument. The + * {@link IExtension}s constructed by the factory need a resolver to + * resolve datatype URIs to term identifiers in the database. + * + * @see #DEFAULT_EXTENSION_FACTORY_CLASS + */ + String EXTENSION_FACTORY_CLASS = AbstractTripleStore.class.getName() + + ".extensionFactoryClass"; + + String DEFAULT_EXTENSION_FACTORY_CLASS = DefaultExtensionFactory.class + .getName(); + } protected Class determineAxiomClass() { Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/internal/TestEncodeDecodeKeys.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/internal/TestEncodeDecodeKeys.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/internal/TestEncodeDecodeKeys.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -253,7 +253,12 @@ throw new UnsupportedOperationException(); } - public BigdataValue asValue(BigdataValueFactory f) + protected int _compareTo(IV o) { + throw new UnsupportedOperationException(); + } + + public BigdataValue asValue(final BigdataValueFactory f, + final ILexiconConfiguration config) throws UnsupportedOperationException { // TODO Auto-generated method stub return null; Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestInlining.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestInlining.java 2010-07-23 15:21:57 UTC (rev 3270) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestInlining.java 2010-07-23 17:35:18 UTC (rev 3271) @@ -33,11 +33,15 @@ import java.util.Map; import java.util.Properties; import java.util.UUID; -import org.openrdf.model.vocabulary.RDF; import com.bigdata.rdf.axioms.NoAxioms; +import com.bigdata.rdf.internal.ColorsEnumExtension; +import com.bigdata.rdf.internal.EpochExtension; +import com.bigdata.rdf.internal.ExtensionIV; import com.bigdata.rdf.internal.IV; import com.bigdata.rdf.internal.XSD; import com.bigdata.rdf.model.BigdataBNode; +import com.bigdata.rdf.model.BigdataLiteral; +import com.bigdata.rdf.model.BigdataURI; import com.bigdata.rdf.model.BigdataValue; import com.bigdata.rdf.model.BigdataValueFactory; import com.bigdata.rdf.store.AbstractTripleStore; @@ -243,6 +247,194 @@ } + public void test_epoch() { + + final Properties properties = getProperties(); + + // test w/o predefined vocab. + properties.setProperty(Options.VOCABULARY_CLASS, NoVocabulary.class + .getName()); + + // test w/o axioms - they imply a predefined vocab. + properties.setProperty(Options.AXIOMS_CLASS, NoAxioms.class.getName()); + + // test w/o the full text index. + properties.setProperty(Options.TEXT_INDEX, "false"); + + AbstractTripleStore store = getStore(properties); + + try { + + if (!store.isStable()) { + + /* + * We need a restart safe store to test this since otherwise a + * term cache could give us a false positive. + */ + + return; + + } + + final Collection<BigdataValue> terms = new HashSet<BigdataValue>(); + + // lookup/add some values. + final BigdataValueFactory f = store.getValueFactory(); + + final BigdataLiteral l1 = f.createLiteral("1", EpochExtension.EPOCH); + final BigdataLiteral l2 = f.createLiteral(String.valueOf(System.currentTimeMillis()), EpochExtension.EPOCH); + final BigdataLiteral l3 = f.createLiteral("-100", EpochExtension.EPOCH); + final BigdataURI datatype = f.createURI(EpochExtension.EPOCH.stringValue()); + + terms.add(l1); + terms.add(l2); + terms.add(l3); + terms.add(datatype); + + final Map<IV, BigdataValue> ids = doAddTermsTest(store, terms); + + assertTrue(l1.getIV().isInline()); + assertTrue(l2.getIV().isInline()); + assertFalse(l3.getIV().isInline()); + + final ExtensionIV iv1 = (ExtensionIV) l1.getIV(); + final ExtensionIV iv2 = (ExtensionIV) l2.getIV(); + + assertTrue(iv1.getExtensionDatatype().equals(datatype.getIV())); + assertTrue(iv2.getExtensionDatatype().equals(datatype.getIV())); + + if (store.isStable()) { + + store.commit(); + + store = reopenStore(store); + + // verify same reverse mappings. + + final Map<IV, BigdataValue> ids2 = store.getLexiconRelation() + .getTerms(ids.keySet()); + + assertEquals(ids.size(),ids2.size()); + + for (IV iv : ids.keySet()) { + + System.err.println(iv); + + assertEquals("Id mapped to a different term? : iv=" + + iv, ids.get(iv), ids2.get(iv)); + + } + + } + + } finally { + + store.__tearDownUnitTest(); + + } + + } + + public void test_colorsEnum() { + + final Properties properties = getProperties(); + + // test w/o predefined vocab. + properties.setProperty(Options.VOCABULARY_CLASS, NoVocabulary.class + .getName()); + + // test w/o axioms - they imply a predefined vocab. + properties.setProperty(Options.AXIOMS_CLASS, NoAxioms.class.getName()); + + // test w/o the full text index. + properties.setProperty(Options.TEXT_INDEX, "false"); + + AbstractTripleStore store = getStore(properties); + + try { + + if (!store.isStable()) { + + /* + ... [truncated message content] |
From: <mar...@us...> - 2010-07-23 15:22:03
|
Revision: 3270 http://bigdata.svn.sourceforge.net/bigdata/?rev=3270&view=rev Author: martyncutcher Date: 2010-07-23 15:21:57 +0000 (Fri, 23 Jul 2010) Log Message: ----------- provide byteLength implementation Modified Paths: -------------- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDDecimalIV.java Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDDecimalIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDDecimalIV.java 2010-07-23 12:19:14 UTC (rev 3269) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDDecimalIV.java 2010-07-23 15:21:57 UTC (rev 3270) @@ -41,6 +41,7 @@ private static final long serialVersionUID = 1L; private final BigDecimal value; + private transient int byteLength; public XSDDecimalIV(final BigDecimal value) { @@ -134,12 +135,21 @@ return value.hashCode(); } - // FIXME byteLength() public int byteLength() { -// throw new UnsupportedOperationException(); - return 1 + Bytes.SIZEOF_DOUBLE; + if (byteLength == 0) { + + /* + * Cache the byteLength if not yet set. + */ + int dataLen = value.unscaledValue().toString().length(); + + byteLength = 1 /* sign */ + 4 /* exponent */+ dataLen + 1 /* data and null termination */; + + } + + return byteLength; } - + @Override protected int _compareTo(IV o) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <btm...@us...> - 2010-07-23 12:19:21
|
Revision: 3269 http://bigdata.svn.sourceforge.net/bigdata/?rev=3269&view=rev Author: btmurphy Date: 2010-07-23 12:19:14 +0000 (Fri, 23 Jul 2010) Log Message: ----------- [branch dev-btm]: CHECKPOINT - smart proxy work, still incomplete and including debug println's and BTM markers, but checkpointed for syncing with trunk changes Modified Paths: -------------- branches/dev-btm/bigdata/src/java/com/bigdata/counters/AbstractCounterSet.java branches/dev-btm/bigdata/src/java/com/bigdata/service/AbstractFederation.java branches/dev-btm/bigdata/src/java/com/bigdata/service/EmbeddedFederation.java branches/dev-btm/bigdata/src/java/com/bigdata/service/LocalDataServiceFederation.java branches/dev-btm/bigdata/src/java/com/bigdata/util/config/NicUtil.java branches/dev-btm/bigdata/src/test/com/bigdata/service/StressTestConcurrent.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/executor/ServiceImpl.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/AbstractServicesManagerService.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/ManageLogicalServiceTask.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/MonitorCreatePhysicalServiceLocksTask.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/RestartPersistentServices.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/ServiceConfigurationZNodeMonitorTask.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/ServicesManagerServer.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/ServicesManagerStartupTask.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/config/AbstractHostConstraint.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/config/BigdataServiceConfiguration.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/config/JavaServiceConfiguration.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/config/JiniCoreServicesConfiguration.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/config/JiniServiceConfiguration.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/config/LoadBalancerConfiguration.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/config/ManagedServiceConfiguration.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/config/ServiceConfiguration.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/config/ServicesManagerConfiguration.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/config/ZookeeperServerEntry.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/process/JiniCoreServicesProcessHelper.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/process/JiniServiceProcessHelper.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/process/ProcessHelper.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/process/ZookeeperProcessHelper.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/loadbalancer/EmbeddedLoadBalancer.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/loadbalancer/ServiceImpl.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/loadbalancer/ServiceProxy.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/loadbalancer/config/logging.properties branches/dev-btm/bigdata-jini/src/java/com/bigdata/metadata/ServiceImpl.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/service/jini/AbstractServer.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/service/jini/JiniFederation.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/service/jini/lookup/LoadBalancerClient.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/service/jini/util/JiniServicesHelper.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/service/jini/util/LookupStarter.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/service/jini/util/config/lookup.config branches/dev-btm/bigdata-jini/src/java/com/bigdata/shard/ServiceImpl.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/transaction/ServiceImpl.java branches/dev-btm/bigdata-jini/src/java/com/bigdata/util/Util.java branches/dev-btm/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config branches/dev-btm/bigdata-jini/src/test/com/bigdata/jini/start/config/TestZookeeperServerEntry.java branches/dev-btm/bigdata-jini/src/test/com/bigdata/jini/start/testReggie.config branches/dev-btm/bigdata-jini/src/test/com/bigdata/jini/start/testStartJini.config branches/dev-btm/bigdata-jini/src/test/com/bigdata/zookeeper/testzoo.config branches/dev-btm/build.properties branches/dev-btm/build.xml branches/dev-btm/src/resources/config/bigdataCluster.config branches/dev-btm/src/resources/config/jini/reggie.config branches/dev-btm/src/resources/config/log4j.properties branches/dev-btm/src/resources/config/logging.properties Added Paths: ----------- branches/dev-btm/bigdata-jini/src/java/com/bigdata/util/EntryUtil.java Modified: branches/dev-btm/bigdata/src/java/com/bigdata/counters/AbstractCounterSet.java =================================================================== --- branches/dev-btm/bigdata/src/java/com/bigdata/counters/AbstractCounterSet.java 2010-07-23 11:04:00 UTC (rev 3268) +++ branches/dev-btm/bigdata/src/java/com/bigdata/counters/AbstractCounterSet.java 2010-07-23 12:19:14 UTC (rev 3269) @@ -42,6 +42,8 @@ */ public abstract class AbstractCounterSet implements ICounterSet { +public static org.apache.log4j.Logger logger = com.bigdata.util.config.LogUtil.getLog4jLogger((AbstractCounterSet.class).getName()); + protected final String name; protected AbstractCounterSet parent; @@ -198,11 +200,39 @@ if( path.contains("//")) { +if (logger.isEnabledFor(org.apache.log4j.Level.WARN)) { + logger.warn("***** AbstractCounterSet.getPath: CONTAINS SLASH-SLASH: path INPUT = "+path); + logger.warn("***** AbstractCounterSet.getPath: path.length = "+path.length()); + byte[] pathBytes = path.getBytes(); + StringBuffer strBuf = new StringBuffer(); + if( (pathBytes[0] < 32) || (pathBytes[0] > 126) ) { + strBuf.append("X"); + }else{ + strBuf.append( new String(new byte[] {pathBytes[0]}) ); + } + for(int i=1;i<pathBytes.length; i++) { + if( (pathBytes[i] < 32) || (pathBytes[i] > 126) ) { + strBuf.append("X"); + }else{ + strBuf.append( new String(new byte[] {pathBytes[i]}) ); + } + } + logger.warn("***** AbstractCounterSet.getPath: CONTAINS SLASH-SLASH: path CONVERTED = "+strBuf.toString()); +} +int slashSlashIndex = path.indexOf("//"); +if(slashSlashIndex >= 0) {//contains "//" + logger.warn("***** AbstractCounterSet.getPath: INDEX OF SLASH-SLASH = "+slashSlashIndex); +}else{//does not contain "//" + logger.warn("***** AbstractCounterSet.getPath: !!!! path CONTAINS SLASH-SLASH, but indexOf = "+slashSlashIndex+" !!!!"); +} + +if(slashSlashIndex >= 0) {//throw exception only if BOTH path.contains AND path.indexOf say that the given path contains "//" /* * Empty path names are not allowed. */ throw new IllegalArgumentException(path); +}//BTM } Modified: branches/dev-btm/bigdata/src/java/com/bigdata/service/AbstractFederation.java =================================================================== --- branches/dev-btm/bigdata/src/java/com/bigdata/service/AbstractFederation.java 2010-07-23 11:04:00 UTC (rev 3268) +++ branches/dev-btm/bigdata/src/java/com/bigdata/service/AbstractFederation.java 2010-07-23 12:19:14 UTC (rev 3269) @@ -1388,7 +1388,7 @@ // Note: This _is_ a local method call. final UUID serviceUUID = fed.getServiceUUID(); - +System.out.println("\n>>>>> AbstractFederation.reportPerformanceCounters: serviceUUID = "+serviceUUID); // Will be null until assigned by the service registrar. if (serviceUUID == null) { @@ -1403,12 +1403,14 @@ final LoadBalancer loadBalancerService = fed.getLoadBalancerService(); if (loadBalancerService == null) { +System.out.println(">>>>> AbstractFederation.reportPerformanceCounters: loadBalancerService = NULL"); log.warn("Could not discover load balancer service."); return; } +System.out.println(">>>>> AbstractFederation.reportPerformanceCounters: loadBalancerService = "+loadBalancerService); /* * @todo this is probably worth compressing as there will be a lot @@ -1419,9 +1421,12 @@ final ByteArrayOutputStream baos = new ByteArrayOutputStream( Bytes.kilobyte32 * 2); +System.out.println(">>>>> AbstractFederation.reportPerformanceCounters: CALLING fed.getCounterSet() ..."); fed.getCounterSet().asXML(baos, "UTF-8", null/* filter */); +System.out.println(">>>>> AbstractFederation.reportPerformanceCounters: CALLING loadBalancer.notify ..."); loadBalancerService.notify(serviceUUID, baos.toByteArray()); +System.out.println(">>>>> AbstractFederation.reportPerformanceCounters: DONE CALLING loadBalancer.notify"); if (log.isInfoEnabled()) log.info("Notified the load balancer."); Modified: branches/dev-btm/bigdata/src/java/com/bigdata/service/EmbeddedFederation.java =================================================================== --- branches/dev-btm/bigdata/src/java/com/bigdata/service/EmbeddedFederation.java 2010-07-23 11:04:00 UTC (rev 3268) +++ branches/dev-btm/bigdata/src/java/com/bigdata/service/EmbeddedFederation.java 2010-07-23 12:19:14 UTC (rev 3269) @@ -620,6 +620,9 @@ //BTM p.setProperty(LoadBalancerService.Options.TRANSIENT, "true"); p.setProperty(EmbeddedLoadBalancerServiceImpl.Options.TRANSIENT, "true"); +p.setProperty(EmbeddedLoadBalancerServiceImpl.Options.LOG_DIR, + new File(EmbeddedLoadBalancerServiceImpl.Options.DEFAULT_LOG_DIR).toString()); + } else { // specify the data directory for the load balancer. @@ -860,6 +863,7 @@ { super(serviceUUID, hostname, sdm, +properties.getProperty(EmbeddedLoadBalancerServiceImpl.Options.LOG_DIR), //BTM*** EmbeddedFederation.this, dataServiceMap,//BTM*** - remove after DataService smart proxy? properties); Modified: branches/dev-btm/bigdata/src/java/com/bigdata/service/LocalDataServiceFederation.java =================================================================== --- branches/dev-btm/bigdata/src/java/com/bigdata/service/LocalDataServiceFederation.java 2010-07-23 11:04:00 UTC (rev 3268) +++ branches/dev-btm/bigdata/src/java/com/bigdata/service/LocalDataServiceFederation.java 2010-07-23 12:19:14 UTC (rev 3269) @@ -193,6 +193,7 @@ loadBalancerService = new EmbeddedLoadBalancer(UUID.randomUUID(), hostname, null,//SDM - replace with real SDM after conversion to smart proxy? +p.getProperty(EmbeddedLoadBalancer.Options.LOG_DIR), //BTM*** LocalDataServiceFederation.this, //BTM*** remove after EmbeddedDataService is converted to smart proxy? dataServiceMap, Modified: branches/dev-btm/bigdata/src/java/com/bigdata/util/config/NicUtil.java =================================================================== --- branches/dev-btm/bigdata/src/java/com/bigdata/util/config/NicUtil.java 2010-07-23 11:04:00 UTC (rev 3268) +++ branches/dev-btm/bigdata/src/java/com/bigdata/util/config/NicUtil.java 2010-07-23 12:19:14 UTC (rev 3269) @@ -505,6 +505,253 @@ } /** + * Special-purpose convenience method that returns a + * <code>String</code> value representing the ip address of + * the current node; where the value that is returned is + * determined according to following criteria: + * <p> + * <ul> + * <li> If a non-<code>null</code> value is input for the + * <code>systemPropertyName</code> parameter, then + * this is viewed as a declaration by the caller that + * that the system property with that given value + * should take precedence over all other means of + * determining the desired ip address. As such, this + * method determines if a system property having the + * given has indeed been set and, if it has, returns + * the ip address of the nic having that name; or + * <code>null</code> if there is no nic with the + * desired name installed on the node. + * <li> If a non-<code>null</code> value is input for the + * <code>systemPropertyName</code> parameter, but + * no system property with that name has been set, + * and <code>true</code> has been passed in for + * the <code>fallbackOk</code> parameter, then this + * method will return the IPV4 based address of the + * first reachable nic that is found on the node. + * Upon failing to find such an address, if the + * <code>loopbackOk</code> parameter is also + * <code>true</code>, then this method will return + * the <i>loop back</i> address of the node; otherwise + * <code>null</code> is returned. + * <li> If <code>null</code> is input for the + * <code>systemPropertyName</code> parameter, but + * a non-<code>null</code> value is input for the + * <code>defaultNic</code> parameter, then this + * method returns the ip address of the nic having + * that name; or <code>null</code> if there is no + * nic with the desired default name installed on the + * node. + * <li> If <code>null</code> is input for both the + * <code>systemPropertyName</code> parameter and the + * <code>defaultNic</code> parameter, and if the + * <code>fallbackOk</code> parameter is <code>true</code>, + * then this method will return the IPV4 based address + * of the first reachable nic that is found on the node. + * Upon failing to find such an address, if the + * <code>loopbackOk</code> parameter is also + * <code>true</code>, then this method will return + * the <i>loop back</i> address of the node; otherwise + * <code>null</code> is returned. + * </ul> + * <p> + * This method can be called from within a configuration + * as well as from within program control. + * + * @param systemPropertyName <code>String</code> value containing + * the name of a system property whose + * value is the network interface name + * whose ip address should be returned. + * May be <code>null</code>. + * + * @param defaultNic <code>String</code> value containing + * the name of the network interface + * whose ip address should be returned + * if <code>null</code> is input for the + * <code>systemPropertyName</code> parameter. + * + * @param fallbackOk if <code>true</code>, then if either + * no system property is set having the + * name referenced by the + * <code>systemPropertyName</code> parameter, + * or if <code>null</code> is input for both + * the <code>systemPropertyName</code> + * parameter and the <code>defaultNic</code> + * parameter, return the IPV4 based address + * of the first reachable network interface + * that can be found on the node. + * + * @param loopbackOk if <code>true</code>, and if <code>true</code> + * is also input for the <code>fallbackOk</code> + * parameter, then if this method attempts, + * but fails, to find a valid IPV4 fallback + * address, then the node's <i>loop back</i> + * address is returned. + * + * @return a <code>String</code> representing an ip address associated + * with the current node; where the value that is returned is + * determined according to the criteria described above. + */ + public static String getIpAddress(String systemPropertyName, + String defaultNic, + boolean fallbackOk, + boolean loopbackOk) + throws SocketException, IOException + { + if(systemPropertyName != null) {//system property takes precedence + String nicName = System.getProperty(systemPropertyName); + boolean propSet = true; + if(nicName == null) { + propSet = false; + } else { + // handle ant script case where the system property + // may not have been set on the command line, but + // was still set to "${<systemPropertyName>}" using + // ant <sysproperty> tag + String rawProp = "${" + systemPropertyName + "}"; + if( rawProp.equals(nicName) ) propSet = false; + } + if(propSet) { + return getIpAddress(nicName, 0, loopbackOk); + } else {//desired system property not set, try fallback + if(fallbackOk) { + return getDefaultIpv4Address(loopbackOk); + } else { + return null; + } + } + } else {//no system property name provided, try default nic + if(defaultNic != null) { + return getIpAddress(defaultNic, 0, loopbackOk); + } else {//no default nic provided, try fallback + if(fallbackOk) { + return getDefaultIpv4Address(loopbackOk); + } else { + return null; + } + } + } + } + + public static String getIpAddress() + throws SocketException, IOException + { + return getIpAddress(null, null, true, true); + } + + /** + * Examines each address associated with each network interface + * card (nic) installed on the current node, and returns the + * <code>String</code> value of the first such address that is + * determined to be both <i>reachable</i> and an address type + * that represents an <i>IPv4</i> address. + * + * This method will always first examine addresses that are + * <i>not</i> the <i>loopback</i> address (<i>local host</i>); + * returning a loopback adddress only if <code>true</code> + * is input for the <code>loopbackOk</code> parameter, and + * none of the non-loopback addresses satisfy this method's + * search criteria. + * + * If this method fails to find any address that satisfies the + * above criteria, then this method returns <code>null</code>. + * + * @param loopbackOk if <code>true</code>, then upon failure + * find an non-<i>loopback</i> address that + * satisfies this method's search criteria + * (an IPv4 type address and reachable), the + * first loopback address that is found to be + * reachable is returned. + * + * If <code>false</code> is input for this + * parameter, then this method will examine + * only those addresses that do <i>not</i> + * correspond to the corresponding nic's + * loopback address. + * + * @return a <code>String</code> value representing the first + * network interface address installed on the current + * node that is determined to be both <i>reachable</i> + * and an IPv4 type address; where the return value + * corresponds to a <i>loopback</i> address only if + * <code>true</code> is input for the <code>loopbackOk</code> + * parameter, and no non-loopback address satisfying + * the desired criteria can be found. If this method + * fails to find any address that satisfies the desired + * criteria, then <code>null</code> is returned. + * + * @throws SocketException if there is an error in the underlying + * I/O subsystem and/or protocol while retrieving the + * the network interfaces currently installed on the + * node. + * + * @throws IOException if a network error occurs while determining + * if a candidate return address is <i>reachable</i>. + */ + public static String getDefaultIpv4Address(boolean loopbackOk) + throws SocketException, IOException + { + //get all nics on the current node + Enumeration<NetworkInterface> nics = + NetworkInterface.getNetworkInterfaces(); + while( nics.hasMoreElements() ) { + NetworkInterface curNic = nics.nextElement(); + List<InterfaceAddress> interfaceAddrs = + curNic.getInterfaceAddresses(); + for(InterfaceAddress interfaceAddr : interfaceAddrs) { + InetAddress inetAddr = interfaceAddr.getAddress(); + boolean isIpv4 = inetAddr instanceof Inet4Address; + boolean isLoopbackAddress = inetAddr.isLoopbackAddress(); + if(isIpv4) { + if(isLoopbackAddress) continue; + boolean isReachable = inetAddr.isReachable(3*1000); + Inet4Address inet4Addr = (Inet4Address)inetAddr; + String retVal = inet4Addr.getHostAddress(); + + jiniConfigLogger.log + (CONFIG, "default IPv4 address: "+retVal); + utilLogger.log + (Level.TRACE, "default IPv4 address: "+retVal); + return retVal; + } + } + } + + if(!loopbackOk) return null; + + nics = NetworkInterface.getNetworkInterfaces(); + while( nics.hasMoreElements() ) { + NetworkInterface curNic = nics.nextElement(); + List<InterfaceAddress> interfaceAddrs = + curNic.getInterfaceAddresses(); + for(InterfaceAddress interfaceAddr : interfaceAddrs) { + InetAddress inetAddr = interfaceAddr.getAddress(); + boolean isIpv4 = inetAddr instanceof Inet4Address; + boolean isLoopbackAddress = inetAddr.isLoopbackAddress(); + if(isIpv4) { + if(!isLoopbackAddress) continue; + boolean isReachable = inetAddr.isReachable(3*1000); + Inet4Address inet4Addr = (Inet4Address)inetAddr; + String retVal = inet4Addr.getHostAddress(); + + jiniConfigLogger.log + (CONFIG, "default IPv4 address: "+retVal); + utilLogger.log + (Level.TRACE, "default IPv4 address: "+retVal); + return retVal; + } + } + } + return null; + } + + public static String getDefaultIpv4Address() + throws SocketException, IOException + { + return getDefaultIpv4Address(false);//localhost NOT ok + } + + /** * Intended for use by scripts. */ public static void main(String[] args) { Modified: branches/dev-btm/bigdata/src/test/com/bigdata/service/StressTestConcurrent.java =================================================================== --- branches/dev-btm/bigdata/src/test/com/bigdata/service/StressTestConcurrent.java 2010-07-23 11:04:00 UTC (rev 3268) +++ branches/dev-btm/bigdata/src/test/com/bigdata/service/StressTestConcurrent.java 2010-07-23 12:19:14 UTC (rev 3269) @@ -791,10 +791,12 @@ throws IOException { // explicitly set the log level for the load balancer. - LoadBalancerService.log.setLevel(Level.INFO); +//BTM LoadBalancerService.log.setLevel(Level.INFO); +EmbeddedLoadBalancer.logger.setLevel(Level.INFO); - final AbstractEmbeddedLoadBalancerService lbs = ((AbstractEmbeddedLoadBalancerService) ((EmbeddedFederation<?>) fed) - .getLoadBalancerService()); +//BTM final AbstractEmbeddedLoadBalancerService lbs = ((AbstractEmbeddedLoadBalancerService) ((EmbeddedFederation<?>) fed) +//BTM .getLoadBalancerService()); +final EmbeddedLoadBalancer lbs = ((EmbeddedLoadBalancer)((EmbeddedFederation)fed).getLoadBalancerService()); final ServiceScore[] fakeServiceScores = new ServiceScore[2]; Modified: branches/dev-btm/bigdata-jini/src/java/com/bigdata/executor/ServiceImpl.java =================================================================== --- branches/dev-btm/bigdata-jini/src/java/com/bigdata/executor/ServiceImpl.java 2010-07-23 11:04:00 UTC (rev 3268) +++ branches/dev-btm/bigdata-jini/src/java/com/bigdata/executor/ServiceImpl.java 2010-07-23 12:19:14 UTC (rev 3269) @@ -286,7 +286,7 @@ +", locators=" +Util.writeArrayElementsToString(locatorsToJoin)); - waitThread = new Util.WaitOnInterruptThread(); + waitThread = new Util.WaitOnInterruptThread(logger); waitThread.start(); readyState.ready();//ready to accept calls from clients Modified: branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/AbstractServicesManagerService.java =================================================================== --- branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/AbstractServicesManagerService.java 2010-07-23 11:04:00 UTC (rev 3268) +++ branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/AbstractServicesManagerService.java 2010-07-23 12:19:14 UTC (rev 3269) @@ -67,6 +67,7 @@ * processes. */ +System.out.println("\nXXXXXXX AbstractServicesManagerService.add >>>>> KILLING process = "+service.name); service.kill(true/* immediateShutdown */); } catch (InterruptedException e) { @@ -121,6 +122,7 @@ // halt our monitor tasks. getFederation().cancelMonitoredTasks(true/* mayInterruptIfRunning */); +System.out.println("\nXXXXXXX AbstractServicesManagerService.shutdown >>>>> KILLING CHILD PROCESSES"); // kill our children. killChildProcesses(false/* immediateShutdown */); @@ -146,6 +148,7 @@ // halt our monitor tasks. getFederation().cancelMonitoredTasks(true/* mayInterruptIfRunning */); +System.out.println("\nXXXXXXX AbstractServicesManagerService.shutdownNow >>>>> KILLING CHILD PROCESSES"); // kill our children. killChildProcesses(true/* immediateShutdown */); @@ -186,6 +189,7 @@ try { +System.out.println("\nXXXXXXX AbstractServicesManagerService.killChildProcesses >>>>> calling Process.kill"); helper.kill(immediateShutdown); } catch (Throwable t) { @@ -301,6 +305,7 @@ /* * Run startup. */ +System.out.println("\n*** AbstractServicesManagerService: setup() - ServicesManagerStartupTask().call() ***\n"); new ServicesManagerStartupTask(fed, config, true/* pushConfig */, true/* restartServices */, this/* listener */).call(); Modified: branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/ManageLogicalServiceTask.java =================================================================== --- branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/ManageLogicalServiceTask.java 2010-07-23 11:04:00 UTC (rev 3268) +++ branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/ManageLogicalServiceTask.java 2010-07-23 12:19:14 UTC (rev 3269) @@ -107,6 +107,7 @@ this.configZPath = configZPath; this.children = children; this.config = config; +System.out.println("\nEEEE ManageLogicalServiceTask.constructor: configZPath="+this.configZPath); } @@ -178,6 +179,7 @@ */ protected void newLogicalService() throws KeeperException, InterruptedException { +System.out.println("\nEEEE ManageLogicalServiceTask.newLogicalService: className="+config.className); if (INFO) log.info("className=" + config.className); @@ -194,31 +196,38 @@ /* * Create zpath for the new logical service. */ +System.out.println("EEEE ManageLogicalServiceTask.newLogicalService: CREATING ZNODE ---> configZPath="+configZPath+", LOGICAL_SERVICE_PREFIX="+BigdataZooDefs.LOGICAL_SERVICE_PREFIX+", path="+(configZPath+"/"+BigdataZooDefs.LOGICAL_SERVICE_PREFIX)); final String logicalServiceZPath = zookeeper.create(configZPath + "/" + BigdataZooDefs.LOGICAL_SERVICE_PREFIX, new byte[0], acl, CreateMode.PERSISTENT_SEQUENTIAL); +System.out.println("EEEE ManageLogicalServiceTask.newLogicalService: CREATED ZNODE ---> logicalServiceZPath="+logicalServiceZPath); /* * The new znode (last path component of the new zpath). */ final String logicalServiceZNode = logicalServiceZPath .substring(logicalServiceZPath.lastIndexOf('/') + 1); +System.out.println("EEEE ManageLogicalServiceTask.newLogicalService: logicalServiceZNode="+logicalServiceZNode); /* * Create the znode that is the parent for the physical service * instances (direct child of the logicalSevice znode). */ +System.out.println("EEEE ManageLogicalServiceTask.newLogicalService: CREATING ZNODE Physical Service Parent ---> logicalServiceZPath="+logicalServiceZPath+", PHYSICAL_SERVICES_CONTAINER="+BigdataZooDefs.PHYSICAL_SERVICES_CONTAINER+", path="+(logicalServiceZPath+"/"+BigdataZooDefs.PHYSICAL_SERVICES_CONTAINER)); zookeeper.create(logicalServiceZPath + "/" + BigdataZooDefs.PHYSICAL_SERVICES_CONTAINER, new byte[0], acl, CreateMode.PERSISTENT); +System.out.println("EEEE ManageLogicalServiceTask.newLogicalService: CREATED Parent ZNODE ---> "+(logicalServiceZPath+"/"+BigdataZooDefs.PHYSICAL_SERVICES_CONTAINER)); /* * Create the znode for the election of the primary physical service for * this logical service (direct child of the logicalSevice znode). */ +System.out.println("EEEE ManageLogicalServiceTask.newLogicalService: CREATING Election ZNODE ---> logicalServiceZPath="+logicalServiceZPath+", MASTER_ELECTION="+BigdataZooDefs.MASTER_ELECTION+", path="+(logicalServiceZPath+"/"+BigdataZooDefs.MASTER_ELECTION)); zookeeper.create(logicalServiceZPath + "/" + BigdataZooDefs.MASTER_ELECTION, new byte[0], acl, CreateMode.PERSISTENT); +System.out.println("EEEE ManageLogicalServiceTask.newLogicalService: CREATED Election ZNODE ---> "+(logicalServiceZPath+"/"+BigdataZooDefs.MASTER_ELECTION)); try { @@ -239,14 +248,19 @@ * lock. */ +System.out.println("EEEE ManageLogicalServiceTask.newLogicalService: zroot="+(fed.getZooConfig().zroot)+", LOCKS_CREATE_PHYSICAL_SERVICE="+BigdataZooDefs.LOCKS_CREATE_PHYSICAL_SERVICE+", className="+config.className+", UNDERSCORE, logicalServiceZNode="+logicalServiceZNode); + final String lockNodeZPath = fed.getZooConfig().zroot + "/" + BigdataZooDefs.LOCKS_CREATE_PHYSICAL_SERVICE + "/" + config.className + "_" + logicalServiceZNode; +System.out.println("EEEE ManageLogicalServiceTask.newLogicalService: *** lockNodeZPath="+lockNodeZPath); +System.out.println("EEEE ManageLogicalServiceTask.newLogicalService: CREATING ZNODE for physical service host decision ---> logicalServiceZPath="+logicalServiceZPath); zookeeper .create(lockNodeZPath, SerializerUtil .serialize(logicalServiceZPath), acl, CreateMode.PERSISTENT); +System.out.println("EEEE ManageLogicalServiceTask.newLogicalService: CREATED ZNODE for physical service host decision ---> logicalServiceZPath="+logicalServiceZPath); if (INFO) log.info("Created lock node: " + lockNodeZPath); Modified: branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/MonitorCreatePhysicalServiceLocksTask.java =================================================================== --- branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/MonitorCreatePhysicalServiceLocksTask.java 2010-07-23 11:04:00 UTC (rev 3268) +++ branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/MonitorCreatePhysicalServiceLocksTask.java 2010-07-23 12:19:14 UTC (rev 3269) @@ -1,6 +1,7 @@ package com.bigdata.jini.start; import java.io.IOException; +import java.net.SocketException; import java.net.UnknownHostException; import java.nio.channels.FileLock; import java.rmi.RemoteException; @@ -121,12 +122,15 @@ * Note: This task runs until cancelled. */ public Void call() throws Exception { +System.out.println("\nDDDD MonitorCreatePhysicalServiceLocksTask.call: zroot="+fed.getZooConfig().zroot); +System.out.println("DDDD MonitorCreatePhysicalServiceLocksTask.call: BigdataZooDefs.LOCKS_CREATE_PHYSICAL_SERVICE="+BigdataZooDefs.LOCKS_CREATE_PHYSICAL_SERVICE); /* * All the locks of interest are direct children of this znode. */ final String locksZPath = fed.getZooConfig().zroot + "/" + BigdataZooDefs.LOCKS_CREATE_PHYSICAL_SERVICE; +System.out.println("DDDD MonitorCreatePhysicalServiceLocksTask.call: locksZPath="+locksZPath); while (true) { @@ -170,15 +174,17 @@ protected void acquireWatcherAndRun(final String locksZPath) throws KeeperException, InterruptedException { - final ZooKeeper zookeeper = fed.getZookeeper(); /* * Note: The UnknownChildrenWatcher will keep trying until it is * able to establish the watch. */ +System.out.println("DDDD MonitorCreatePhysicalServiceLocksTask.acquireWatcherAndRun: locksZPath="+locksZPath); +System.out.println("DDDD MonitorCreatePhysicalServiceLocksTask.acquireWatcherAndRun: ADD EVENT WATCHER"); final UnknownChildrenWatcher watcher = new UnknownChildrenWatcher( zookeeper, locksZPath); +System.out.println("DDDD MonitorCreatePhysicalServiceLocksTask.acquireWatcherAndRun: EVENT WATCHER ADDED"); try { @@ -188,7 +194,9 @@ try { // child znode. +System.out.println("DDDD MonitorCreatePhysicalServiceLocksTask.acquireWatcherAndRun: WAITING FOR EVENT ..."); final String znode = watcher.queue.take(); +System.out.println("DDDD MonitorCreatePhysicalServiceLocksTask.acquireWatcherAndRun: *** EVENT ---> znode="+znode); if (znode.endsWith(ZLockImpl.INVALID)) { @@ -204,6 +212,7 @@ // path to the new lock node. final String lockNodeZPath = locksZPath + "/" + znode; +System.out.println("DDDD MonitorCreatePhysicalServiceLocksTask.acquireWatcherAndRun: lockNodeZPath="+lockNodeZPath); if (log.isInfoEnabled()) log.info("new lock: zpath=" + lockNodeZPath); @@ -508,6 +517,8 @@ final String logicalServiceZPath = (String) SerializerUtil .deserialize(zookeeper.getData(lockNodeZPath, false, new Stat())); +System.out.println("DDDD MonitorCreatePhysicalServiceLocksTask.checkConstraintsAndStartService: lockNodeZPath="+lockNodeZPath); +System.out.println("DDDD MonitorCreatePhysicalServiceLocksTask.checkConstraintsAndStartService: **** logicalServiceZPath="+logicalServiceZPath); /* * If we hack off the last path component, we now have the zpath for the @@ -515,6 +526,7 @@ */ final String serviceConfigZPath = logicalServiceZPath.substring(0, logicalServiceZPath.lastIndexOf('/')); +System.out.println("DDDD MonitorCreatePhysicalServiceLocksTask.checkConstraintsAndStartService: **** serviceConfigZPath="+serviceConfigZPath); if (log.isInfoEnabled()) log.info("logicalServiceZPath=" + logicalServiceZPath); @@ -662,6 +674,7 @@ try { if (!isLocalService(attributes)) { +System.out.println("*** MonitorCreatePhysicalServiceLocks.restartIfNotRunning: NOT local service >>> RETURNING WITHOUT STARTING ["+serviceConfig.className+"]"); /* * The service does not live on this host so we do not have @@ -672,7 +685,9 @@ } - } catch (UnknownHostException ex) { + } catch (IOException ex) {//SocketException or UnknownHostException +System.out.println("*** MonitorCreatePhysicalServiceLocks.restartIfNotRunning: IOException ["+serviceConfig.className+"]"); +ex.printStackTrace(); log.warn("className=" + serviceConfig.className + ", physicalServiceZPath=" + physicalServiceZPath, ex); @@ -686,6 +701,7 @@ + ", physicalServiceZPath=" + physicalServiceZPath); // block until we can evaluate this service for restart. +System.out.println("*** MonitorCreatePhysicalServiceLocks.restartIfNotRunning: LOCAL SERVICE >>> start it ["+serviceConfig.className+"] ... BLOCKING"); lock.lockInterruptibly(); try { @@ -695,6 +711,7 @@ if (!shouldRestartPhysicalService(zookeeper, serviceConfig, physicalServiceZPath, attributes)) { +System.out.println("*** MonitorCreatePhysicalServiceLocks.restartIfNotRunning: should NOT RESTART service ["+serviceConfig.className+"]"); if (log.isInfoEnabled()) log.info("Will not restart: className=" @@ -709,6 +726,8 @@ } catch (RemoteException ex) { +System.out.println("*** MonitorCreatePhysicalServiceLocks.restartIfNotRunning: RemoteException ["+serviceConfig.className+"]"); +ex.printStackTrace(); log.error("RMI problem: className=" + serviceConfig.className + ", physicalServiceZPath=" + physicalServiceZPath, ex); @@ -716,6 +735,8 @@ return false; } catch (KeeperException ex) { +System.out.println("*** MonitorCreatePhysicalServiceLocks.restartIfNotRunning: KeeperException ["+serviceConfig.className+"]"); +ex.printStackTrace(); log.error("Zookeeper problem: className=" + serviceConfig.className + ", physicalServiceZPath=" @@ -740,6 +761,7 @@ final LinkedList<IServiceConstraint> violatedConstraints = new LinkedList<IServiceConstraint>(); if (!serviceConfig.canStartService(fed, violatedConstraints)) { +System.out.println("*** MonitorCreatePhysicalServiceLocks.restartIfNotRunning: restart PREVENTED BY CONSTRAINTS ["+serviceConfig.className+"] >>> violatedConstraints="+violatedConstraints); log.warn("Restart prevented by constraints: className=" + serviceConfig.className + ", physicalServiceZPath=" + physicalServiceZPath + ", violatedConstraints=" @@ -755,6 +777,7 @@ log.warn("Will restart: className=" + serviceConfig.className + ", physicalServiceZPath=" + physicalServiceZPath); +System.out.println("*** MonitorCreatePhysicalServiceLocks.restartIfNotRunning: WILL RESTART service ["+serviceConfig.className+"] >>> restartPhysicalService"); return restartPhysicalService(serviceConfig, logicalServiceZPath, physicalServiceZPath, attributes); @@ -764,11 +787,15 @@ log.error("Service restart interrupted: className=" + serviceConfig.className + ", physicalServiceZPath=" + physicalServiceZPath); +System.out.println("*** MonitorCreatePhysicalServiceLocks.restartIfNotRunning: InterruptedException ["+serviceConfig.className+"]"); +t.printStackTrace(); // rethrow so that the caller will see the interrupt. throw t; } catch (Throwable t) { +System.out.println("*** MonitorCreatePhysicalServiceLocks.restartIfNotRunning: RESTART ERROR - "+t+" ["+serviceConfig.className+"]"); +t.printStackTrace(); // log and ignore. log.error("Service restart error: className=" @@ -1148,10 +1175,11 @@ * * @return <code>true</code> if the service lives on this host. * + * @throws SocketException * @throws UnknownHostException */ protected boolean isLocalService(final Entry[] attributes) - throws UnknownHostException { + throws SocketException, UnknownHostException { boolean isLocalHost = false; Modified: branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/RestartPersistentServices.java =================================================================== --- branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/RestartPersistentServices.java 2010-07-23 11:04:00 UTC (rev 3268) +++ branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/RestartPersistentServices.java 2010-07-23 12:19:14 UTC (rev 3269) @@ -171,12 +171,15 @@ if (log.isInfoEnabled()) log.info("Considering " + serviceConfigZNodes.size() + " service configurations"); +System.out.println("\n*********************************************************"); +System.out.println("*** RestartPersistentServices.runOnce: Considering " + serviceConfigZNodes.size()+ " service configurations"); for (String serviceConfigZNode : serviceConfigZNodes) { if (log.isInfoEnabled()) log.info("Considering service configuration: " + serviceConfigZNode); +System.out.println("*** RestartPersistentServices.runOnce: Considering service configuration: "+ serviceConfigZNode); /* * Get the service configuration. We will need it iff we restart an @@ -200,6 +203,7 @@ log.info("Considering " + logicalServiceZNodes.size() + " logical services configurations for " + serviceConfigZNode); +System.out.println("*** RestartPersistentServices.runOnce: Considering " + logicalServiceZNodes.size()+ " logical services configurations for "+ serviceConfigZNode); for (String logicalServiceZNode : logicalServiceZNodes) { @@ -224,6 +228,7 @@ + " physical services configurations for " + logicalServiceZNode + " of " + serviceConfigZNode); +System.out.println("*** RestartPersistentServices.runOnce: Considering " + physicalServiceZNodes.size()+ " physical services configurations for "+ logicalServiceZNode + " of "+ serviceConfigZNode); for (String physicalServiceZNode : physicalServiceZNodes) { @@ -238,6 +243,7 @@ log.info("Considering: " + physicalServicesContainerZPath); +System.out.println("*** RestartPersistentServices.runOnce >>> monitorCreatePhysicalServiceLocksTask.restartIfNotRunning <<<< [serviceConfig="+serviceConfig+", logicalServiceZPath="+logicalServiceZPath+", physicalServiceZPath="+physicalServiceZPath+"]"); monitorCreatePhysicalServiceLocksTask.restartIfNotRunning( serviceConfig, logicalServiceZPath, physicalServiceZPath, attributes); @@ -247,6 +253,7 @@ } } +System.out.println("*********************************************************\n"); // Success. return true; Modified: branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/ServiceConfigurationZNodeMonitorTask.java =================================================================== --- branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/ServiceConfigurationZNodeMonitorTask.java 2010-07-23 11:04:00 UTC (rev 3268) +++ branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/ServiceConfigurationZNodeMonitorTask.java 2010-07-23 12:19:14 UTC (rev 3269) @@ -93,6 +93,13 @@ // zpath for the service configuration node. serviceConfigZPath = zroot + "/" + BigdataZooDefs.CONFIG + "/" + className; + +System.out.println("\nGGGG ServiceConfigurationZNodeMonitorTask.constructor: zroot = "+zroot); +System.out.println( "GGGG ServiceConfigurationZNodeMonitorTask.constructor: className = "+className); +System.out.println( "GGGG ServiceConfigurationZNodeMonitorTask.constructor: LOCKS_SERVICE_CONFIG_MONITOR = "+BigdataZooDefs.LOCKS_SERVICE_CONFIG_MONITOR); +System.out.println( "GGGG ServiceConfigurationZNodeMonitorTask.constructor: CONFIG = "+BigdataZooDefs.CONFIG); +System.out.println( "GGGG ServiceConfigurationZNodeMonitorTask.constructor: lockZPath = "+lockZPath); +System.out.println( "GGGG ServiceConfigurationZNodeMonitorTask.constructor: serviceConfigZPath = "+serviceConfigZPath); } @@ -216,6 +223,7 @@ * Note: This is done while we are holding the zlock. If we loose the * zlock, the we cancel the watcher until we can reacquire the zlock. */ +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.runWithLock: SETTING WATCHER for ZNodes of interest ..."); final ServiceConfigurationHierarchyWatcher watcher = new ServiceConfigurationHierarchyWatcher( zookeeper, serviceConfigZPath); @@ -225,7 +233,11 @@ * them now and make sure that everything is in balance. */ final String[] watchedSet = watcher.getWatchedNodes(); - +if(watchedSet == null) { + System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.runWithLock: znodes-of-interest = "+watchedSet); +}else{ + System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.runWithLock: znodes-of-interest = "+java.util.Arrays.asList(watchedSet)); +} // Get the service configuration. final ManagedServiceConfiguration config = (ManagedServiceConfiguration) SerializerUtil .deserialize(zookeeper.getData(serviceConfigZPath, false, @@ -237,16 +249,20 @@ while (true) { +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.runWithLock: WAITING FOR EVENT ..."); final WatchedEvent e = watcher.queue.take(); if (!zlock.isLockHeld()) { +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.runWithLock: LOST THE LOCK [event="+e+"]"); // Lost the lock. break; } +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.runWithLock: HANDLE EVENT [event="+e+"]"); handleEvent(zookeeper, watcher, e); +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.runWithLock: EVENT HANDLED [event="+e+"]"); } @@ -307,6 +323,7 @@ if (config.serviceCount != children.size()) { // adjust the #of logical service instances (blocks). +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.runWithLock: *** NEW LOGICAL SERVICE TASK"); config.newLogicalServiceTask(fed, listener, serviceConfigZPath, children).call(); @@ -339,6 +356,7 @@ throws KeeperException, InterruptedException { for (String s : watchedSet) { +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.balancePhysicalServices: serviceConfigZPath = "+serviceConfigZPath+", zpath="+s); switch (ServiceConfigurationZNodeEnum .getType(serviceConfigZPath, s)) { @@ -348,10 +366,12 @@ // the parent is the logicalService. final String logicalServiceZPath = s.substring(0, s .lastIndexOf('/')); +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.balancePhysicalServices: logicalServiceZPath = "+logicalServiceZPath); // the znode of the logical service (last path component). final String logicalServiceZNode = logicalServiceZPath .substring(logicalServiceZPath.lastIndexOf('/') + 1); +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.balancePhysicalServices: logicalServiceZNode = "+logicalServiceZNode); // get children (the list of physical services). final List<String> children = zookeeper.getChildren( @@ -365,9 +385,11 @@ + ", targetReplicationCount=" + config.replicationCount + ", #children=" + children.size() + ", children=" + children); +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.balancePhysicalServices: serviceConfigZPath=" + serviceConfigZPath+ ", logicalServiceZPath=" + logicalServiceZPath+ ", targetReplicationCount="+ config.replicationCount + ", #children="+ children.size() + ", children=" + children); // too few instances? : @todo handle too many instances also. if (config.replicationCount > children.size()) { +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.balancePhysicalServices: (config.replicationCount > children.size()) ["+config.replicationCount+" > "+children.size()+"]"); try { @@ -384,9 +406,11 @@ + "/" + config.className + "_" + logicalServiceZNode; +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.balancePhysicalServices: *** CREATING logicalServiceZPath under lockNodeZPath ---> [zroot="+zroot+", LOCKS_CREATE_PHYSICAL_SERVICE="+BigdataZooDefs.LOCKS_CREATE_PHYSICAL_SERVICE+", className="+config.className+", UNDERSCORE, logicalServiceZNode="+logicalServiceZNode+"] ---> lockNodeZPath = "+lockNodeZPath); zookeeper.create(lockNodeZPath, SerializerUtil .serialize(logicalServiceZPath), fed .getZooConfig().acl, CreateMode.PERSISTENT); +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.balancePhysicalServices: *** CREATED ZNODE logicalServiceZNode under lockNodeZPath ---> logicalServiceZPath="+logicalServiceZPath+", lockNodeZPath="+lockNodeZPath); if (log.isInfoEnabled()) log.info("Created lock node: " + lockNodeZPath); @@ -396,7 +420,8 @@ // ignore. } - +}else{ +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.balancePhysicalServices: (config.replicationCount NOT GREATER THAN children.size()) ["+config.replicationCount+" <= "+children.size()+"]"); } default: @@ -468,6 +493,7 @@ .getType(serviceConfigZPath, zpath)) { case ServiceConfiguration: { +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.handleEvent - CASE = ServiceConfiguration: HANDLE EVENT [event="+e+"]"); // Get the service configuration. final ManagedServiceConfiguration config = (ManagedServiceConfiguration) SerializerUtil @@ -481,6 +507,7 @@ } case LogicalService: { +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.handleEvent - CASE = LogicalService: HANDLE EVENT [event="+e+"]"); // Get the service configuration. final ManagedServiceConfiguration config = (ManagedServiceConfiguration) SerializerUtil @@ -494,12 +521,14 @@ } case PhysicalServicesContainer: { +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.handleEvent - CASE = PhysicalServiceContainter: HANDLE EVENT [event="+e+"]"); // Get the service configuration. final ManagedServiceConfiguration config = (ManagedServiceConfiguration) SerializerUtil .deserialize(zookeeper.getData(serviceConfigZPath, false, new Stat())); +System.out.println("GGGG ServiceConfigurationZNodeMonitorTask.handleEvent - CASE = PhysicalServiceContainter >>> balancePhysicalServices [event="+e+"]"); balancePhysicalServices(zookeeper, config, watchedSet); break; Modified: branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/ServicesManagerServer.java =================================================================== --- branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/ServicesManagerServer.java 2010-07-23 11:04:00 UTC (rev 3268) +++ branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/ServicesManagerServer.java 2010-07-23 12:19:14 UTC (rev 3269) @@ -58,7 +58,7 @@ import com.bigdata.service.DataService; import com.bigdata.service.DefaultServiceFederationDelegate; import com.bigdata.service.IDataService; -import com.bigdata.service.ILoadBalancerService; +//BTM import com.bigdata.service.ILoadBalancerService; import com.bigdata.service.IMetadataService; import com.bigdata.service.MetadataService; import com.bigdata.service.jini.AbstractServer; @@ -70,6 +70,9 @@ import com.sun.jini.start.ServiceDescriptor; import com.sun.jini.start.ServiceStarter; +//BTM +import com.bigdata.service.LoadBalancer; + /** * A class for bootstrapping a {@link JiniFederation} across a cluster based on * a {@link Configuration} file describing some basic configuration parameters @@ -215,7 +218,8 @@ * The two main services which require failover are the * {@link ITransactionService} and the {@link IDataService} (which includes the * {@link IMetadataService} as a special case). The loss of the - * {@link ILoadBalancerService} is normally not critical as only history about +BTM * {@link ILoadBalancerService} is normally not critical as only history about +* {@link LoadBalancer} service is normally not critical as only history about * the system load over time is lost. * * <h4>Transaction service</h4> @@ -295,7 +299,8 @@ * and supports transactions over operations on the space. Gigaspaces has * defined a variety of extensions that provide FIFO queues. * - * @todo The {@link MetadataService}, the {@link ILoadBalancerService}, and +BTM * @todo The {@link MetadataService}, the {@link ILoadBalancerService}, and +* @todo The {@link MetadataService}, the {@link LoadBalancer} service, and * the {@link ITransactionService} MUST NOT have more than one logical * instance in a federation. They can (eventually) have failover * instances, but not peers. The {@link DataService} is the only one that @@ -617,11 +622,42 @@ @Override synchronized public void shutdownNow() { +try { + net.jini.lookup.ServiceDiscoveryManager sdm = (server.getClient().getFederation()).getServiceDiscoveryManager(); + net.jini.core.lookup.ServiceTemplate tmpl = new net.jini.core.lookup.ServiceTemplate(null, new Class[] {com.bigdata.service.Service.class}, null); + net.jini.core.lookup.ServiceItem[] serviceItems = sdm.lookup(tmpl, Integer.MAX_VALUE, Integer.MAX_VALUE, null, 5000L); + if(serviceItems.length > 0) { + for(int i=0; i<serviceItems.length; i++) { + Object srvcRef = serviceItems[i].service; + if(srvcRef == null) continue; + if(srvcRef instanceof net.jini.admin.Administrable) { + try { + Object srvcRefAdmin = ((net.jini.admin.Administrable)srvcRef).getAdmin(); + if(srvcRefAdmin instanceof com.sun.jini.admin.DestroyAdmin) { + try { + ((com.sun.jini.admin.DestroyAdmin)srvcRefAdmin).destroy(); + } catch(Throwable t) { } + } else { +System.out.println("\nAAAA*** ServicesManagerService.shutdownNow: SERVICE ADMIN NOT INSTANCE OF DestroyAdmin ["+srvcRef+"]"); + }//endif + } catch(Throwable t) { + t.printStackTrace(); + } + } else { +System.out.println("\nAAAA*** ServicesManagerService.shutdownNow: SERVICE NOT Administrable ["+srvcRef+"]"); + } + } + } +} catch(Throwable t) { + t.printStackTrace(); +} + // immediate service shutdown (blocks). super.shutdownNow(); // jini service and server shutdown. server.shutdownNow(false/*destroy*/); + } @@ -678,6 +714,7 @@ final ConfigurationFile config = (ConfigurationFile) ConfigurationProvider .getInstance(server.args); +System.out.println("\nAAAA*** ServicesManagerService.AdministrableServicesManagerService: sighup() - fed.submitMonitoredTask(new ServicesManagerStartupTask() ***\n"); fed.submitMonitoredTask(new ServicesManagerStartupTask(fed, config, pushConfig, restartServices, this)); Modified: branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/ServicesManagerStartupTask.java =================================================================== --- branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/ServicesManagerStartupTask.java 2010-07-23 11:04:00 UTC (rev 3268) +++ branches/dev-btm/bigdata-jini/src/java/com/bigdata/jini/start/ServicesManagerStartupTask.java 2010-07-23 12:19:14 UTC (rev 3269) @@ -139,6 +139,7 @@ for (ServiceConfiguration serviceConfig : serviceConfigurations) { if (serviceConfig instanceof ZookeeperServerConfiguration) { +System.out.println("\n---- ServicesManagerStartupTask.doStartup: startZookeeperService() ----"); startZookeeperService(config); @@ -153,6 +154,7 @@ if (serviceConfig instanceof JiniCoreServicesConfiguration) { +System.out.println("\n---- ServicesManagerStartupTask.doStartup: startJiniCoreServices() ----"); startJiniCoreServices(config); } @@ -169,10 +171,11 @@ final long begin = System.nanoTime(); - long nanos = TimeUnit.MILLISECONDS - .toNanos(selfConfig.zookeeperDiscoveryTimeoutNanos); - +//BTM long nanos = TimeUnit.MILLISECONDS +//BTm .toNanos(selfConfig.zookeeperDiscoveryTimeoutNanos); +long nanos = selfConfig.zookeeperDiscoveryTimeoutNanos; // await zookeeper connection. +System.out.println("\n*** ServicesManagerStartupTask.doStartup: WAIT FOR ZOOKEEPER [zookeeperDiscoveryTimeoutNanos="+selfConfig.zookeeperDiscoveryTimeoutNanos+", nanos="+nanos+"] ***"); if (!fed.getZookeeperAccessor().awaitZookeeperConnected(nanos, TimeUnit.NANOSECONDS)) { @@ -189,6 +192,7 @@ * discovered and you can kill it if there is a problem. */ // await jini registrar(s) +System.out.println("\n*** ServicesManagerStartupTask.doStartup: WAIT FOR LOOKUP ["+nanos+" nanoseconds] ***"); if (!fed.awaitJiniRegistrars(nanos, TimeUnit.NANOSECONDS)) { throw new Exception( @@ -197,6 +201,7 @@ } } +System.out.println("\n*** ServicesManagerStartupTask.doStartup: Lookup Service DISCOVERED *... [truncated message content] |
From: <mar...@us...> - 2010-07-23 11:04:06
|
Revision: 3268 http://bigdata.svn.sourceforge.net/bigdata/?rev=3268&view=rev Author: martyncutcher Date: 2010-07-23 11:04:00 +0000 (Fri, 23 Jul 2010) Log Message: ----------- add commit override to ensure writeCache is flushed Modified Paths: -------------- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/DiskOnlyStrategy.java Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/DiskOnlyStrategy.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/DiskOnlyStrategy.java 2010-07-23 11:02:24 UTC (rev 3267) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/DiskOnlyStrategy.java 2010-07-23 11:04:00 UTC (rev 3268) @@ -472,6 +472,15 @@ } /** + * Flushes the write cache (if enabled). + */ + public void commit() { + + flushWriteCache(); + + } + + /** * Writes the {@link #writeCache} through to the disk and its position is * reset to zero. * <p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2010-07-23 11:02:31
|
Revision: 3267 http://bigdata.svn.sourceforge.net/bigdata/?rev=3267&view=rev Author: martyncutcher Date: 2010-07-23 11:02:24 +0000 (Fri, 23 Jul 2010) Log Message: ----------- add commit override to ensure buffer is flushed Modified Paths: -------------- trunk/bigdata/src/java/com/bigdata/journal/DiskOnlyStrategy.java Modified: trunk/bigdata/src/java/com/bigdata/journal/DiskOnlyStrategy.java =================================================================== --- trunk/bigdata/src/java/com/bigdata/journal/DiskOnlyStrategy.java 2010-07-22 20:30:34 UTC (rev 3266) +++ trunk/bigdata/src/java/com/bigdata/journal/DiskOnlyStrategy.java 2010-07-23 11:02:24 UTC (rev 3267) @@ -470,6 +470,15 @@ } /** + * Flushes the write cache (if enabled). + */ + public void commit() { + + flushWriteCache(); + + } + + /** * Writes the {@link #writeCache} through to the disk and its position is * reset to zero. * <p> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <btm...@us...> - 2010-07-22 20:30:40
|
Revision: 3266 http://bigdata.svn.sourceforge.net/bigdata/?rev=3266&view=rev Author: btmurphy Date: 2010-07-22 20:30:34 +0000 (Thu, 22 Jul 2010) Log Message: ----------- [trunk]: trac #115 - Provide a means to setup and tear down a federation running on a single server to support operator directed benchmarking and CI performance tests. Modified Paths: -------------- trunk/build.xml Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2010-07-22 14:37:05 UTC (rev 3265) +++ trunk/build.xml 2010-07-22 20:30:34 UTC (rev 3266) @@ -852,56 +852,37 @@ <!-- STANDALONE FEDERATION TARGETS --> <!-- (test/benchamarking) --> -<target name="standalone-setup" description="Setup properties used by the standalone federation and LUS start/stop."> +<target name="generateLookupStarterJar" unless="lookupStarterJarAvailable"> + <antcall target="testCompile" /> +</target> + +<target name="testLookupStarterJarAvailability"> + <property name="bigdata-test.lib" location="${bigdata.dir}/bigdata-test/lib" /> + <condition property="lookupStarterJarAvailable"> + <available file="${bigdata-test.lib}/lookupstarter.jar"/> + </condition> +</target> + +<target name="standalone-setup" depends="testLookupStarterJarAvailability,generateLookupStarterJar" description="Setup properties used by standalone federation and LUS start/stop."> <property name="app.home" location="${bigdata.dir}" /> <property name="test.codebase.port" value="23333"/> - <property name="jini.lib" location="${bigdata.dir}/bigdata-jini/lib/jini/lib" /> - <property name="jini.lib.dl" location="${bigdata.dir}/bigdata-jini/lib/jini/lib-dl" /> + <property name="test.codebase.dir" location="${bigdata.dir}/bigdata-jini/lib/jini/lib-dl"/> + <property name="dist.lib" location="${bigdata.dir}/bigdata-jini/lib/jini/lib" /> + <property name="dist.lib.dl" location="${bigdata.dir}/bigdata-jini/lib/jini/lib-dl" /> <property name="test.codebase" value="http://${this.hostname}:${test.codebase.port}/jsk-dl.jar"/> <property name="java.security.policy" value="${bigdata.dir}/policy.all"/> - <property name="log4j.configuration" value="${bigdata.dir}/src/resources/config/standalone/log4j.properties"/> + <property name="log4j.configuration" value="resources/logging/log4j.properties"/> <property name="java.net.preferIPv4Stack" value="true"/> <property name="bigdata.fedname" value="${standalone.fed}"/> </target> -<target name="standalone-startLookup" depends="jar,standalone-setup" description="Start the lookup service for the standalone federation."> - <java classname="com.bigdata.service.jini.util.LookupStarter" - fork="true" spawn="false"> - <classpath refid="runtime.classpath" /> - <sysproperty key="app.home" value="${app.home}"/> - <sysproperty key="jini.lib" value="${jini.lib}"/> - <sysproperty key="jini.lib.dl" value="${jini.lib.dl}"/> - <sysproperty key="java.security.policy" value="${java.security.policy}"/> - <sysproperty key="java.security.debug" value="off"/> - <sysproperty key="java.protocol.handler.pkgs" value="net.jini.url"/> - <sysproperty key="log4j.configuration" value="${log4j.configuration}"/> - <sysproperty key="codebase.port" value="${test.codebase.port}"/> - <sysproperty key="java.net.preferIPv4Stack" value="${java.net.preferIPv4Stack}"/> - <sysproperty key="bigdata.fedname" value="${bigdata.fedname}"/> - </java> -</target> - -<target name="standalone-stopLookup" depends="jar,standalone-setup" description="Stop the lookup service for the standalone federation."> - <java classname="com.bigdata.service.jini.util.LookupStarter" - failonerror="true" fork="true" logerror="true"> - <classpath refid="runtime.classpath" /> - <sysproperty key="app.home" value="${app.home}"/> - <sysproperty key="jini.lib" value="${dist.lib}"/> - <sysproperty key="jini.lib.dl" value="${dist.lib.dl}"/> - <sysproperty key="java.security.policy" value="${java.security.policy}"/> - <sysproperty key="log4j.configuration" value="${log4j.configuration}"/> - <sysproperty key="java.net.preferIPv4Stack" value="${java.net.preferIPv4Stack}"/> - <sysproperty key="bigdata.fedname" value="${bigdata.fedname}"/> - <arg value="-stop" /> - </java> -</target> - <!-- Note: You should 'nohup' this, e.g., "nohup ant standalone-start" to avoid taking down the ServicesManagerServer if you are disconnected from a terminal. --> <target name="standalone-start" depends="jar,standalone-setup" description="Start the standalone federation."> <!-- Start the lookup service. --> - <antcall target="standalone-startLookup" /> + <antcall target="startHttpd" /> + <antcall target="startLookup" /> <java classname="com.bigdata.jini.start.ServicesManagerServer" failonerror="true" fork="true" logerror="true"> <classpath refid="runtime.classpath" /> @@ -932,7 +913,8 @@ <arg value="src/resources/config/standalone/bigdataStandalone.config" /> </java> <!-- Then take down the lookup service as well. --> - <antcall target="standalone-stopLookup" /> + <antcall target="stopLookup" /> + <antcall target="stopHttpd" /> </target> <target name="standalone-start-nano-server" depends="jar" description="Start a small http server fronting for a bigdata database instance."> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <btm...@us...> - 2010-07-22 14:37:12
|
Revision: 3265 http://bigdata.svn.sourceforge.net/bigdata/?rev=3265&view=rev Author: btmurphy Date: 2010-07-22 14:37:05 +0000 (Thu, 22 Jul 2010) Log Message: ----------- [trunk]: additional changes to NicUtil to address trac #108 as well as new targets added to build.xml to allow one to use bigdataCluster.config to run a federation on a single node using the current ServicesManagerService & ant install mechanism Modified Paths: -------------- trunk/bigdata/src/java/com/bigdata/util/config/NicUtil.java trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/LookupStarter.java trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/config/lookup.config trunk/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config trunk/bigdata-jini/src/test/com/bigdata/jini/start/testReggie.config trunk/bigdata-jini/src/test/com/bigdata/jini/start/testStartJini.config trunk/bigdata-jini/src/test/com/bigdata/zookeeper/testzoo.config trunk/build.properties trunk/build.xml trunk/src/resources/config/bigdataCluster.config trunk/src/resources/config/jini/reggie.config trunk/src/resources/config/jini/startAll.config trunk/src/resources/config/logging.properties Modified: trunk/bigdata/src/java/com/bigdata/util/config/NicUtil.java =================================================================== --- trunk/bigdata/src/java/com/bigdata/util/config/NicUtil.java 2010-07-22 14:29:54 UTC (rev 3264) +++ trunk/bigdata/src/java/com/bigdata/util/config/NicUtil.java 2010-07-22 14:37:05 UTC (rev 3265) @@ -505,6 +505,141 @@ } /** + * Special-purpose convenience method that returns a + * <code>String</code> value representing the ip address of + * the current node; where the value that is returned is + * determined according to following criteria: + * <p> + * <ul> + * <li> If a non-<code>null</code> value is input for the + * <code>systemPropertyName</code> parameter, then + * this is viewed as a declaration by the caller that + * that the system property with that given value + * should take precedence over all other means of + * determining the desired ip address. As such, this + * method determines if a system property having the + * given has indeed been set and, if it has, returns + * the ip address of the nic having that name; or + * <code>null</code> if there is no nic with the + * desired name installed on the node. + * <li> If a non-<code>null</code> value is input for the + * <code>systemPropertyName</code> parameter, but + * no system property with that name has been set, + * and <code>true</code> has been passed in for + * the <code>fallbackOk</code> parameter, then this + * method will return the IPV4 based address of the + * first reachable nic that is found on the node. + * Upon failing to find such an address, if the + * <code>loopbackOk</code> parameter is also + * <code>true</code>, then this method will return + * the <i>loop back</i> address of the node; otherwise + * <code>null</code> is returned. + * <li> If <code>null</code> is input for the + * <code>systemPropertyName</code> parameter, but + * a non-<code>null</code> value is input for the + * <code>defaultNic</code> parameter, then this + * method returns the ip address of the nic having + * that name; or <code>null</code> if there is no + * nic with the desired default name installed on the + * node. + * <li> If <code>null</code> is input for both the + * <code>systemPropertyName</code> parameter and the + * <code>defaultNic</code> parameter, and if the + * <code>fallbackOk</code> parameter is <code>true</code>, + * then this method will return the IPV4 based address + * of the first reachable nic that is found on the node. + * Upon failing to find such an address, if the + * <code>loopbackOk</code> parameter is also + * <code>true</code>, then this method will return + * the <i>loop back</i> address of the node; otherwise + * <code>null</code> is returned. + * </ul> + * <p> + * This method can be called from within a configuration + * as well as from within program control. + * + * @param systemPropertyName <code>String</code> value containing + * the name of a system property whose + * value is the network interface name + * whose ip address should be returned. + * May be <code>null</code>. + * + * @param defaultNic <code>String</code> value containing + * the name of the network interface + * whose ip address should be returned + * if <code>null</code> is input for the + * <code>systemPropertyName</code> parameter. + * + * @param fallbackOk if <code>true</code>, then if either + * no system property is set having the + * name referenced by the + * <code>systemPropertyName</code> parameter, + * or if <code>null</code> is input for both + * the <code>systemPropertyName</code> + * parameter and the <code>defaultNic</code> + * parameter, return the IPV4 based address + * of the first reachable network interface + * that can be found on the node. + * + * @param loopbackOk if <code>true</code>, and if <code>true</code> + * is also input for the <code>fallbackOk</code> + * parameter, then if this method attempts, + * but fails, to find a valid IPV4 fallback + * address, then the node's <i>loop back</i> + * address is returned. + * + * @return a <code>String</code> representing an ip address associated + * with the current node; where the value that is returned is + * determined according to the criteria described above. + */ + public static String getIpAddress(String systemPropertyName, + String defaultNic, + boolean fallbackOk, + boolean loopbackOk) + throws SocketException, IOException + { + if(systemPropertyName != null) {//system property takes precedence + String nicName = System.getProperty(systemPropertyName); + boolean propSet = true; + if(nicName == null) { + propSet = false; + } else { + // handle ant script case where the system property + // may not have been set on the command line, but + // was still set to "${<systemPropertyName>}" using + // ant <sysproperty> tag + String rawProp = "${" + systemPropertyName + "}"; + if( rawProp.equals(nicName) ) propSet = false; + } + if(propSet) { + return getIpAddress(nicName, 0, loopbackOk); + } else {//desired system property not set, try fallback + if(fallbackOk) { + return getDefaultIpv4Address(loopbackOk); + } else { + return null; + } + } + } else {//no system property name provided, try default nic + if(defaultNic != null) { + return getIpAddress(defaultNic, 0, loopbackOk); + } else {//no default nic provided, try fallback + if(fallbackOk) { + return getDefaultIpv4Address(loopbackOk); + } else { + return null; + } + } + } + } + + public static String getIpAddress() + throws SocketException, IOException + { + return getIpAddress(null, null, true, true); + } + + /** * Examines each address associated with each network interface * card (nic) installed on the current node, and returns the * <code>String</code> value of the first such address that is @@ -617,73 +752,6 @@ } /** - * Special-purpose convenience method that will return the - * value of the system property named <code>default.nic</code> - * if that property has been set on the current VM to any - * non-<code>null</code> value other than the value, - * <code>${default.nic}</code>; otherwise returns the value - * input for the <code>defaultVal</code> parameter. - * <p> - * This method can be called from within a configuration - * as well as from within program control. It is provided - * as a way to allow mechanisms that are not able to - * conditionally set system properties to always set the - * system property named <code>default.nic</code> to some - * value -- either valid or invalid -- depending on whether - * that property is set as a system property on the command - * line. - * <p> - * For example, the <code>java</code> ant task used to exec - * java based programs does not allow one to set a system - * property on that program's VM when that property is set - * on the command line used to execute ant, but leave that - * property un-set when ant's command line does not specify - * a value for that property. That is, although ant allows - * one to retrieve the value of a system property that is - * specified on ant's command line and substitute that value - * (using Java's '${}' token-substitution mechanism) into - * a system property set on the program's VM, ant does not - * allow one to leave that property un-set when the system - * property is not specified on ant's command line; the - * property must either always be set on the VM, or never - * set. If the ant script then is written to always set the - * system property on the exec'd program's VM to the - * value of the system property expected on ant's command - * line, then whenever that system property is not set on - * ant's command line, the value that is substituted into - * the system property when the program is exec-ed will be - * of the form, <code>${default.nic}</code>. If the program - * that is exec'd then attempts to call - * <code>System.getProperty("default.nic")</code>, that - * call will return the non-<code>null</code> value, - * <code>${default.nic}</code>; which is typically not - * what is desired. - * - * @param defaultVal <code>String</code> value that this method - * returns if the system property named - * <code>default.nic</code> is either not - * set or is equal to the value - * <code>${default.nic}</code>. - * - * @return a <code>String</code> value equal to the value of - * the system property named <code>${default.nic}</code> - * if that system property is set to any value except - * <code>null</code> or the value <code>${default.nic}</code>; - * otherwise, returns the value input for the - * <code>defaultVal</code> parameter. - */ - public static String getDefaultNic(String defaultVal) { - String defaultNic = System.getProperty("default.nic"); - if( ("${default.nic}").equals(defaultNic) ) defaultNic = null; - if(defaultNic == null) defaultNic = defaultVal; - return defaultNic; - } - - public static String getDefaultNic() { - return getDefaultNic(null); - } - - /** * Intended for use by scripts. */ public static void main(String[] args) { Modified: trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/LookupStarter.java =================================================================== --- trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/LookupStarter.java 2010-07-22 14:29:54 UTC (rev 3264) +++ trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/LookupStarter.java 2010-07-22 14:37:05 UTC (rev 3265) @@ -74,10 +74,8 @@ private static String defaultGroup = null; static { try { - thisHost = - NicUtil.getIpAddress - ( NicUtil.getDefaultNic - ( NicUtil.getDefaultIpv4Address(true) ) ); + thisHost = NicUtil.getIpAddress + ("default.nic", null, true, true); defaultGroup = System.getProperty("bigdata.fedname", "bigdata.test.group-"+thisHost); Modified: trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/config/lookup.config =================================================================== --- trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/config/lookup.config 2010-07-22 14:29:54 UTC (rev 3264) +++ trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/config/lookup.config 2010-07-22 14:37:05 UTC (rev 3265) @@ -10,8 +10,7 @@ com.sun.jini.reggie { private static exportPort = 0;//randomly chosen port private static exportIpAddr = - NicUtil.getDefaultNic - ( NicUtil.getDefaultIpv4Address(true) ); + NicUtil.getIpAddress("default.nic", null, true, true); private static codebasePort = 23333;//value used if not set by system prop // Public configuration entries Modified: trunk/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config =================================================================== --- trunk/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config 2010-07-22 14:29:54 UTC (rev 3264) +++ trunk/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config 2010-07-22 14:37:05 UTC (rev 3265) @@ -77,8 +77,7 @@ static serviceDir = ConfigMath.getAbsoluteFile(new File(fedname)); private static localIpAddr = - NicUtil.getDefaultNic - ( NicUtil.getDefaultIpv4Address(true) ); + NicUtil.getIpAddress("default.nic", null, true, true); /* * Example cluster configuration. Modified: trunk/bigdata-jini/src/test/com/bigdata/jini/start/testReggie.config =================================================================== --- trunk/bigdata-jini/src/test/com/bigdata/jini/start/testReggie.config 2010-07-22 14:29:54 UTC (rev 3264) +++ trunk/bigdata-jini/src/test/com/bigdata/jini/start/testReggie.config 2010-07-22 14:37:05 UTC (rev 3265) @@ -15,8 +15,7 @@ com.sun.jini.reggie { private static exportIpAddr = - NicUtil.getDefaultNic - ( NicUtil.getDefaultIpv4Address(true) ); + NicUtil.getIpAddress("default.nic", null, true, true); private static exportPort = Integer.parseInt("0"); private static serverILFactory = Modified: trunk/bigdata-jini/src/test/com/bigdata/jini/start/testStartJini.config =================================================================== --- trunk/bigdata-jini/src/test/com/bigdata/jini/start/testStartJini.config 2010-07-22 14:29:54 UTC (rev 3264) +++ trunk/bigdata-jini/src/test/com/bigdata/jini/start/testStartJini.config 2010-07-22 14:37:05 UTC (rev 3265) @@ -15,8 +15,7 @@ private static appHome = System.getProperty("app.home", ConfigMath.getAbsolutePath(new File(".")) ); private static codebaseHost = - NicUtil.getDefaultNic - ( NicUtil.getDefaultIpv4Address(true) ); + NicUtil.getIpAddress("default.nic", null, true, true); private static codebasePort = "23334"; private static defaultCodebaseRootDir = ConfigUtil.concat( new String[] { appHome, "${/}bigdata-jini${/}lib${/}jini${/}lib-dl" } ); Modified: trunk/bigdata-jini/src/test/com/bigdata/zookeeper/testzoo.config =================================================================== --- trunk/bigdata-jini/src/test/com/bigdata/zookeeper/testzoo.config 2010-07-22 14:29:54 UTC (rev 3264) +++ trunk/bigdata-jini/src/test/com/bigdata/zookeeper/testzoo.config 2010-07-22 14:37:05 UTC (rev 3265) @@ -34,8 +34,7 @@ private static appHome = System.getProperty("app.home", ConfigMath.getAbsolutePath(new File(".")) ); private static localIpAddr = - NicUtil.getDefaultNic - ( NicUtil.getDefaultIpv4Address(true) ); + NicUtil.getIpAddress("default.nic", null, true, true); /* A comma delimited list of the known zookeeper servers together * with their assigned "myid". Modified: trunk/build.properties =================================================================== --- trunk/build.properties 2010-07-22 14:29:54 UTC (rev 3264) +++ trunk/build.properties 2010-07-22 14:37:05 UTC (rev 3265) @@ -131,6 +131,9 @@ # Where to write the log files. install.log.dir=${NAS}/log +# Where to write the deployment distribution. +install.dist.dir=${NAS}/dist + # The 'install-as' user (defaults to the user running the installer). # # @TODO ant lacks sufficient mechanisms to set the user (chown). Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2010-07-22 14:29:54 UTC (rev 3264) +++ trunk/build.xml 2010-07-22 14:37:05 UTC (rev 3265) @@ -493,6 +493,7 @@ <mkdir dir="${install.lib.dir}" /> <mkdir dir="${install.bin.dir}" /> <mkdir dir="${install.log.dir}" /> +<mkdir dir="${install.dist.dir}" /> <!-- install configuration files. --> <copy toDir="${install.config.dir}"> <fileset dir="${bigdata.dir}/src/resources/config"> @@ -1064,10 +1065,9 @@ </java> </target> - <!-- --> - <!-- UNIT TESTS ONLY BELOW HERE --> - <!-- --> - + <!-- --> + <!-- STAGING --> + <!-- --> <target name="stage" description="stages resources (jar, config, policy, logging files) needed to package or execute the bigdata distribution." depends="jar"> @@ -1085,7 +1085,6 @@ <property name="dist.var.config" location="${dist.var}/config" /> <property name="dist.var.config.policy" location="${dist.var.config}/policy" /> <property name="dist.var.config.logging" location="${dist.var.config}/logging" /> - <property name="dist.var.config.zookeeper" location="${dist.var.config}/zookeeper" /> <property name="dist.var.config.jini" location="${dist.var.config}/jini" /> <delete dir="${dist.dir}" quiet="true"/> @@ -1098,7 +1097,6 @@ <mkdir dir="${dist.var.config}"/> <mkdir dir="${dist.var.config.policy}"/> <mkdir dir="${dist.var.config.logging}"/> - <mkdir dir="${dist.var.config.zookeeper}"/> <mkdir dir="${dist.var.config.jini}"/> <!-- Copy build.properties to the top-level config file --> @@ -1168,10 +1166,6 @@ <!-- Zookeeper library --> <copy file="${bigdata-zookeeper.lib}/zookeeper-3.2.1.jar" tofile="${dist.lib}/zookeeper.jar"/> -<!-- - <copy file="/home/brmurphy/zookeeper/cdd99c5/build/zookeeper-3.3.0.jar" - tofile="${dist.lib}/zookeeper.jar"/> ---> <!-- Jini library --> @@ -1231,8 +1225,6 @@ todir="${dist.bin.config}"/> <copy file="${src.resources}/bin/config/serviceStarter.config" todir="${dist.bin.config}"/> - <copy file="${src.resources}/bin/config/zookeeper.config" - todir="${dist.bin.config}"/> <!-- Stage security policy (config) files --> <copy file="${src.resources.config}/policy.all" @@ -1285,6 +1277,329 @@ todir="${dist.var.config.jini}"/> </target> + <!-- --> + <!-- RELEASE --> + <!-- --> + <target name="deploy-artifact" depends="clean, stage" + description="Create compressed tar file for deployment."> + <tar destfile="${bigdata.dir}/REL.${version}.tgz" + compression="gzip"> + + <tarfileset dir="${bigdata.dir}/dist"> + <include name="bigdata/**" /> + + <exclude name="bigdata/bin/pstart" /> + + </tarfileset> + + <!-- Add scripts separately, making them executable --> + + <tarfileset dir="${bigdata.dir}/dist" filemode="755"> + <include name="bigdata/bin/pstart" /> + + </tarfileset> + </tar> + </target> + + <target name="ant-install-prepare" depends="jar, bundle" + description="Stage all files (src, lib, config, etc.) needed for ant based install."> + <copy toDir="${build.dir}/bigdata/src"> + <fileset dir="${bigdata.dir}/bigdata/src" /> + </copy> + <copy toDir="${build.dir}/bigdata-jini/src"> + <fileset dir="${bigdata.dir}/bigdata-jini/src" /> + </copy> + <copy toDir="${build.dir}/bigdata-rdf/src"> + <fileset dir="${bigdata.dir}/bigdata-rdf/src" /> + </copy> + <copy toDir="${build.dir}/bigdata-sails/src"> + <fileset dir="${bigdata.dir}/bigdata-sails/src" /> + </copy> + <copy toDir="${build.dir}/lgpl-utils/src"> + <fileset dir="${bigdata.dir}/lgpl-utils/src" /> + </copy> + + <mkdir dir="${build.dir}/bigdata/lib" /> + <copy toDir="${build.dir}/bigdata/lib"> + <fileset dir="${bigdata.dir}/bigdata/lib" /> + </copy> + + <mkdir dir="${build.dir}/bigdata-jini/lib" /> + <copy toDir="${build.dir}/bigdata-jini/lib"> + <fileset dir="${bigdata.dir}/bigdata-jini/lib" /> + </copy> + <mkdir dir="${build.dir}/bigdata-rdf/lib" /> + <copy toDir="${build.dir}/bigdata-rdf/lib"> + <fileset dir="${bigdata.dir}/bigdata-rdf/lib" /> + </copy> + + <mkdir dir="${build.dir}/bigdata-sails/lib" /> + <copy toDir="${build.dir}/bigdata-sails/lib"> + <fileset dir="${bigdata.dir}/bigdata-sails/lib" /> + </copy> + + <mkdir dir="${build.dir}/src" /> + <mkdir dir="${build.dir}/src/resources" /> + <mkdir dir="${build.dir}/src/resources/config" /> + <copy toDir="${build.dir}/src/resources/config"> + <fileset dir="${bigdata.dir}/src/resources/config" /> + </copy> + + <mkdir dir="${build.dir}/src/resources/scripts" /> + <copy toDir="${build.dir}/src/resources/scripts"> + <fileset dir="${bigdata.dir}/src/resources/scripts" /> + </copy> + + <copy tofile="${build.dir}/build.properties" file="build.properties" /> + <copy tofile="${build.dir}/build.xml" file="build.xml" /> + <copy tofile="${build.dir}/LICENSE.txt" file="LICENSE.txt" /> + <copy tofile="${build.dir}/overview.html" file="overview.html" /> + <copy tofile="${build.dir}/README-JINI" file="README-JINI" /> + <copy toDir="${build.dir}/LEGAL" flatten="true"> + <fileset dir="${bigdata.dir}"> + <include name="**/LEGAL/*" /> + </fileset> + </copy> + </target> + + <target name="ant-install-artifact" depends="clean, ant-install-prepare, stage" + description="Create complete source tar file for ant based install."> + <mkdir dir="${release.dir}" /> + <tar destfile="${bigdata.dir}/DIST.${version}.tgz" compression="gzip"> + <tarfileset dir="${build.dir}" prefix="${version}"> + <include name="build.properties" /> + <include name="build.xml" /> + <include name="LICENSE.txt" /> + <include name="overview.html" /> + <include name="README-JINI" /> + <include name="LEGAL/*" /> + + <include name="bigdata/src/**" /> + <include name="bigdata-jini/src/**" /> + <include name="bigdata-rdf/src/**" /> + <include name="bigdata-sails/src/**" /> + <include name="lgpl-utils/src/**" /> + <include name="bigdata/lib/**" /> + <include name="bigdata-jini/lib/**" /> + <include name="bigdata-rdf/lib/**" /> + <include name="bigdata-sails/lib/**" /> + <include name="src/**" /> + <exclude name="classes/**" /> + <exclude name="${version}.jar" /> + <exclude name="lib/**" /> + <exclude name="docs/**" /> + + <exclude name="dist/bigdata/**" /> + + </tarfileset> + + <!-- Add dist files separately, minus scripts --> + + <tarfileset dir="${bigdata.dir}" prefix="${version}"> + <include name="dist/bigdata/**" /> + + <exclude name="dist/bigdata/bin/pstart" /> + </tarfileset> + + <!-- Add dist scripts separately, making them executable --> + + <tarfileset dir="${bigdata.dir}" prefix="${version}" filemode="755"> + <include name="dist/bigdata/bin/pstart" /> + </tarfileset> + </tar> + + <tar destfile="${bigdata.dir}/REL.${version}.tgz" + basedir="${bigdata.dir}/dist" + compression="gzip"> + </tar> + </target> + + <target name="ant-install" depends="jar, banner, bundle" description="Ant based install on a node."> + <mkdir dir="${NAS}" /> + <mkdir dir="${LAS}" /> + <chmod perm="ug+rw,o-rw"> + <fileset dir="${NAS}" /> + </chmod> + <chmod perm="ug+rw,o-rw"> + <fileset dir="${LAS}" /> + </chmod> + <mkdir dir="${install.config.dir}" /> + <mkdir dir="${install.doc.dir}" /> + <mkdir dir="${install.lib.dir}" /> + <mkdir dir="${install.bin.dir}" /> + <mkdir dir="${install.log.dir}" /> + <mkdir dir="${install.dist.dir}" /> + <copy toDir="${install.config.dir}"> + <fileset dir="${bigdata.dir}/src/resources/config" /> + </copy> + <copy toDir="${install.doc.dir}"> + <fileset dir="${bigdata.dir}"> + <include name="LICENSE.txt" /> + <include name="overview.html" /> + <include name="README-JINI" /> + <include name="bigdata/LEGAL/*" /> + <include name="bigdata-jini/LEGAL/*" /> + <include name="bigdata-rdf/LEGAL/*" /> + <include name="bigdata-sails/LEGAL/*" /> + </fileset> + </copy> + + <copy toDir="${install.lib.dir}"> + <fileset dir="${build.dir}/lib" /> + <fileset file="${build.dir}/${version}.jar" /> + </copy> + + <copy toDir="${install.bin.dir}"> + <fileset dir="src/resources/scripts" /> + </copy> + + <copy toDir="${install.dist.dir}"> + <fileset dir="${bigdata.dir}/dist"> + <include name="bigdata/**" /> + </fileset> + </copy> + + <!-- parameter substitution. --> + <property name="myclasspath" refid="install.classpath" /> + <replace dir="${install.bin.dir}" summary="true"> + <replacefilter token="@FED@" value="${FED}" /> + <replacefilter token="@NAS@" value="${NAS}" /> + <replacefilter token="@LAS@" value="${LAS}" /> + <replacefilter token="@JAVA_HOME@" value="${JAVA_HOME}" /> + <replacefilter token="@JINI_CLASS_SERVER_PORT@" value="${JINI_CLASS_SERVER_PORT}" /> + <replacefilter token="@LOAD_BALANCER_PORT@" value="${LOAD_BALANCER_PORT}" /> + <replacefilter token="@SYSSTAT_HOME@" value="${SYSSTAT_HOME}" /> + <replacefilter token="@USE_NIO@" value="${USE_NIO}" /> + <replacefilter token="@BIN_DIR@" value="${install.bin.dir}" /> + <replacefilter token="@LIB_DIR@" value="${install.lib.dir}" /> + <replacefilter token="@LOG_DIR@" value="${install.log.dir}" /> + <replacefilter token="@CONFIG_DIR@" value="${install.config.dir}" /> + <replacefilter token="@INSTALL_USER@" value="${install.user}" /> + <replacefilter token="@INSTALL_GROUP@" value="${install.group}" /> + <replacefilter token="@LOCK_FILE@" value="${LOCK_FILE}" /> + <replacefilter token="@BIGDATA_CONFIG@" value="${bigdata.config}" /> + <replacefilter token="@JINI_CONFIG@" value="${jini.config}" /> + <replacefilter token="@POLICY_FILE@" value="${policyFile}" /> + <replacefilter token="@LOG4J_SOCKET_LOGGER_HOST@" value="${LOG4J_SOCKET_LOGGER_HOST}" /> + <replacefilter token="@LOG4J_SOCKET_LOGGER_PORT@" value="${LOG4J_SOCKET_LOGGER_PORT}" /> + <replacefilter token="@LOG4J_SOCKET_LOGGER_CONFIG@" value="${log4jServer.config}" /> + <replacefilter token="@LOG4J_DATE_PATTERN@" value="${LOG4J_DATE_PATTERN}" /> + <replacefilter token="@LOG4J_CONFIG@" value="${log4j.config}" /> + <replacefilter token="@LOGGING_CONFIG@" value="${logging.config}" /> + <replacefilter token="@ERROR_LOG@" value="${errorLog}" /> + <replacefilter token="@DETAIL_LOG@" value="${detailLog}" /> + <replacefilter token="@EVENT_LOG@" value="${eventLog}" /> + <replacefilter token="@RULE_LOG@" value="${ruleLog}" /> + <replacefilter token="@STATE_LOG@" value="${stateLog}" /> + <replacefilter token="@STATE_FILE@" value="${stateFile}" /> + <replacefilter token="@FORCE_KILL_ALL@" value="${forceKillAll}" /> + <replacefilter token="@NTP_MASTER@" value="${NTP_MASTER}" /> + <replacefilter token="@NTP_NETWORK@" value="${NTP_NETWORK}" /> + <replacefilter token="@NTP_NETMASK@" value="${NTP_NETMASK}" /> + <replacefilter token="@CLASSPATH@" value="${myclasspath}" /> + </replace> + + <replace dir="${install.config.dir}" summary="true"> + <replacefilter token="@FED@" value="${FED}" /> + <replacefilter token="@NAS@" value="${NAS}" /> + <replacefilter token="@LAS@" value="${LAS}" /> + <replacefilter token="@LOG4J_SOCKET_LOGGER_HOST@" value="${LOG4J_SOCKET_LOGGER_HOST}" /> + <replacefilter token="@JAVA_HOME@" value="${JAVA_HOME}" /> + <replacefilter token="@JINI_CLASS_SERVER_PORT@" value="${JINI_CLASS_SERVER_PORT}" /> + <replacefilter token="@LOAD_BALANCER_PORT@" value="${LOAD_BALANCER_PORT}" /> + <replacefilter token="@SYSSTAT_HOME@" value="${SYSSTAT_HOME}" /> + <replacefilter token="@USE_NIO@" value="${USE_NIO}" /> + <replacefilter token="@BIN_DIR@" value="${install.bin.dir}" /> + <replacefilter token="@LIB_DIR@" value="${install.lib.dir}" /> + <replacefilter token="@LOG_DIR@" value="${install.log.dir}" /> + <replacefilter token="@CONFIG_DIR@" value="${install.config.dir}" /> + <replacefilter token="@INSTALL_USER@" value="${install.user}" /> + <replacefilter token="@INSTALL_GROUP@" value="${install.group}" /> + <replacefilter token="@LOCK_FILE@" value="${LOCK_FILE}" /> + <replacefilter token="@BIGDATA_CONFIG@" value="${bigdata.config}" /> + <replacefilter token="@JINI_CONFIG@" value="${jini.config}" /> + <replacefilter token="@POLICY_FILE@" value="${policyFile}" /> + <replacefilter token="@LOG4J_SOCKET_LOGGER_HOST@" value="${LOG4J_SOCKET_LOGGER_HOST}" /> + <replacefilter token="@LOG4J_SOCKET_LOGGER_PORT@" value="${LOG4J_SOCKET_LOGGER_PORT}" /> + <replacefilter token="@LOG4J_SOCKET_LOGGER_CONFIG@" value="${log4jServer.config}" /> + <replacefilter token="@LOG4J_DATE_PATTERN@" value="${LOG4J_DATE_PATTERN}" /> + <replacefilter token="@LOG4J_CONFIG@" value="${log4j.config}" /> + <replacefilter token="@LOGGING_CONFIG@" value="${logging.config}" /> + <replacefilter token="@ERROR_LOG@" value="${errorLog}" /> + <replacefilter token="@DETAIL_LOG@" value="${detailLog}" /> + <replacefilter token="@EVENT_LOG@" value="${eventLog}" /> + <replacefilter token="@RULE_LOG@" value="${ruleLog}" /> + <replacefilter token="@STATE_LOG@" value="${stateLog}" /> + <replacefilter token="@STATE_FILE@" value="${stateFile}" /> + <replacefilter token="@FORCE_KILL_ALL@" value="${forceKillAll}" /> + <replacefilter token="@NTP_MASTER@" value="${NTP_MASTER}" /> + <replacefilter token="@NTP_NETWORK@" value="${NTP_NETWORK}" /> + <replacefilter token="@NTP_NETMASK@" value="${NTP_NETMASK}" /> + <replacefilter token="@CLASSPATH@" value="${myclasspath}" /> + <!-- updates the configuration file to locate the lubm ontology. --> + <replacefilter token="@install.lubm.config.dir@" value="${install.lubm.config.dir}" /> + </replace> + + <!-- fix newlines (otherwise substitutions cause things to break). --> + <fixcrlf srcDir="${install.config.dir}" /> + <fixcrlf srcDir="${install.bin.dir}" /> + + <!-- set execute bit for scripts in this directory (must be the last step). --> + <chmod perm="u+x,g+rx,o-rwx"> + <fileset dir="${install.bin.dir}"> + <exclude name="README"/> + <exclude name="POST-INSTALL"/> + </fileset> + </chmod> + + <!-- Setup the status file which will be read by the bigdata script and + the log on which that script will write its output. This is used + if cron, or a similar process, will execute the script on a periodic + basis. The initial state is always 'status'. The initial stateLog + is always empty. The state file must be readable by the group, but + could be restricted to write by a specific user. The stateLog must be + read/write for the group. --> + +<echo file="${stateFile}">status</echo> +<echo file="${stateLog}"> +</echo> + + <chmod perm="g+rw,o-rw" file="${stateFile}" /> + <chmod perm="g+rw,o-rw" file="${stateLog}" /> + + <!-- Make sure that the entire shared directory structure is read/write for the group. --> + <chmod perm="g+rwx" type="both" dir="${NAS}" verbose="true"/> + +<!-- Make sure that it is all accessible to the install group (ant 1.6+ plus extension module required). + <chown file="${NAS}" type="both" owner="${install.user}.${install.group}" verbose="true"/> +--> + + <!-- Works for earlier versions of ant LT 1.6 which do not bundle "chown". --> + <apply executable="chown" description="set owner on NAS files" os="Linux"> + <arg value="-R"/> + <arg value="${install.user}.${install.group}"/> + <dirset dir="${NAS}"/> + </apply> + + <!-- @todo check the installed configuration file (after parameter substitution). --> + <!-- @todo also check the installed jini configuration files. --> + <java classname="com.bigdata.jini.util.CheckConfiguration" + failonerror="true" fork="true" logerror="true"> + <classpath refid="install.classpath" /> + <arg value="${bigdata.config}" /> + </java> + + <loadfile property="postInstallMessage" srcFile="${install.bin.dir}/POST-INSTALL" /> + +<echo> + +${postInstallMessage}</echo> + + </target> + + <!-- --> + <!-- UNIT TESTS --> + <!-- --> <target name="testCompile" description="compiles the test source and generates the appropriate jar files." depends="stage"> Modified: trunk/src/resources/config/bigdataCluster.config =================================================================== --- trunk/src/resources/config/bigdataCluster.config 2010-07-22 14:29:54 UTC (rev 3264) +++ trunk/src/resources/config/bigdataCluster.config 2010-07-22 14:37:05 UTC (rev 3265) @@ -378,6 +378,9 @@ "-Xmx400m", "-Djava.security.policy="+bigdata.policy, "-Djava.util.logging.config.file="+bigdata.logging, + "-Dlog4j.configuration="+bigdata.log4j, + "-Dlog4j.primary.configuration="+bigdata.log4j, + "-DinitialMemberGroups="+bigdata.fedname }; Modified: trunk/src/resources/config/jini/reggie.config =================================================================== --- trunk/src/resources/config/jini/reggie.config 2010-07-22 14:29:54 UTC (rev 3264) +++ trunk/src/resources/config/jini/reggie.config 2010-07-22 14:37:05 UTC (rev 3265) @@ -1,3 +1,52 @@ + +import java.net.NetworkInterface; + +import com.sun.jini.config.ConfigUtil; +import net.jini.constraint.BasicMethodConstraints; +import net.jini.core.constraint.ConnectionRelativeTime; +import net.jini.core.constraint.InvocationConstraints; +import net.jini.jeri.BasicILFactory; +import net.jini.jeri.BasicJeriExporter; +import net.jini.jeri.tcp.TcpServerEndpoint; +import net.jini.core.discovery.LookupLocator; + +import com.bigdata.util.config.NicUtil; + com.sun.jini.reggie { - initialMemberGroups = new String[] { System.getProperty("user.name") + "InstallVerifyGroup" }; + + private static exportIpAddr = NicUtil.getIpAddress(null, null, true, true); + + private static exportPort = + Integer.parseInt( System.getProperty("exportPort", "0") ); + + private static serverILFactory = + new BasicILFactory( + new BasicMethodConstraints( + new InvocationConstraints( + new ConnectionRelativeTime(10000L), + null)), + null); + + serverExporter = new BasicJeriExporter(TcpServerEndpoint.getInstance(exportIpAddr,exportPort), + serverILFactory, + false, + true); + + initialMemberGroups = new String[] { System.getProperty("initialMemberGroups", System.getProperty("user.name")+"InstallVerifyGroup" ) }; + initialLookupGroups = initialMemberGroups; + initialLookupLocators = new LookupLocator[] { }; + + unicastDiscoveryHost = exportIpAddr; + multicastInterfaces = new NetworkInterface[] { + NicUtil.getNetworkInterface(exportIpAddr) + }; + + minMaxServiceLease = 60000L; } + +net.jini.discovery.LookupDiscovery { + multicastRequestHost = com.sun.jini.reggie.exportIpAddr; + multicastInterfaces = new NetworkInterface[] { + NicUtil.getNetworkInterface(com.sun.jini.reggie.exportIpAddr) + }; +} Modified: trunk/src/resources/config/jini/startAll.config =================================================================== --- trunk/src/resources/config/jini/startAll.config 2010-07-22 14:29:54 UTC (rev 3264) +++ trunk/src/resources/config/jini/startAll.config 2010-07-22 14:37:05 UTC (rev 3265) @@ -19,11 +19,6 @@ browser: A visualization tool for exploring Jini(TM) Network Technology communities. reggie: Provides implementations of ServiceRegistrar. - fiddler: Provides the server side of an implementation of the lookup discovery service. - mahalo: Provides implementations of the TransactionManager service. - mercury: Provides implementations of the EventMailbox service. - norm: Provides implementations of LeaseRenewalService. -outrigger: Provides implementation of a JavaSpaces(TM) technology-enabled service. */ com.sun.jini.start { @@ -63,41 +58,6 @@ policyFile, libDir+"reggie.jar", "com.sun.jini.reggie.TransientRegistrarImpl", - new String[] { configDir+"reggie.config" }), - - new NonActivatableServiceDescriptor( - "http://" + host + ":" + port + "/fiddler-dl.jar" + jskdl, - policyFile, - libDir+"fiddler.jar", - "com.sun.jini.fiddler.TransientFiddlerImpl", - new String[] { configDir+"fiddler.config" }), - - new NonActivatableServiceDescriptor( - "http://" + host + ":" + port + "/mahalo-dl.jar" + jskdl, - policyFile, - libDir+"mahalo.jar", - "com.sun.jini.mahalo.TransientMahaloImpl", - new String[] { configDir+"mahalo.config" }), - - new NonActivatableServiceDescriptor( - "http://" + host + ":" + port + "/mercury-dl.jar" + jskdl, - policyFile, - libDir+"mercury.jar", - "com.sun.jini.mercury.TransientMercuryImpl", - new String[] { configDir+"mercury.config" }), - - new NonActivatableServiceDescriptor( - "http://" + host + ":" + port + "/norm-dl.jar" + jskdl, - policyFile, - libDir+"norm.jar", - "com.sun.jini.norm.TransientNormServerImpl", - new String[] { configDir+"norm.config" }), - - new NonActivatableServiceDescriptor( - "http://" + host + ":" + port + "/outrigger-dl.jar" + jskdl, - policyFile, - libDir+"outrigger.jar", - "com.sun.jini.outrigger.TransientOutriggerImpl", - new String[] { configDir+"outrigger.config" }) + new String[] { configDir+"reggie.config" }) }; } Modified: trunk/src/resources/config/logging.properties =================================================================== --- trunk/src/resources/config/logging.properties 2010-07-22 14:29:54 UTC (rev 3264) +++ trunk/src/resources/config/logging.properties 2010-07-22 14:37:05 UTC (rev 3265) @@ -40,7 +40,7 @@ java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter # Limit the message that are printed on the console to INFO and above. -java.util.logging.ConsoleHandler.level = INFO +java.util.logging.ConsoleHandler.level = FINEST java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter @@ -51,11 +51,18 @@ # For example, set the com.xyz.foo logger to only log SEVERE # messages: -com.xyz.foo.level = SEVERE +# com.xyz.foo.level = SEVERE # This turns off the annoying stack trace when we probe to determine # whether or not jini is already running on a specific host (unicast # discovery). Of course, it could also hide other things so you may # want to comment this out. -net.jini.discovery.LookupLocatorDiscovery = WARN +net.jini.discovery.LookupLocatorDiscovery.level = WARNING + +#com.sun.jini.start.level = FINEST +#com.sun.jini.reggie.level = FINEST +#net.jini.discovery.level = FINEST +#net.jini.config.level = FINEST +#net.jini.lookup.JoinManager.level = FINEST +#net.jini.lookup.ServiceDiscoveryManager.level = FINEST This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2010-07-22 14:30:01
|
Revision: 3264 http://bigdata.svn.sourceforge.net/bigdata/?rev=3264&view=rev Author: martyncutcher Date: 2010-07-22 14:29:54 +0000 (Thu, 22 Jul 2010) Log Message: ----------- Provide implementations to support BigDecimal keys Modified Paths: -------------- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/keys/KeyBuilder.java branches/LEXICON_REFACTOR_BRANCH/bigdata/src/test/com/bigdata/btree/keys/TestKeyBuilder.java Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/keys/KeyBuilder.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/keys/KeyBuilder.java 2010-07-21 19:53:42 UTC (rev 3263) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/keys/KeyBuilder.java 2010-07-22 14:29:54 UTC (rev 3264) @@ -945,10 +945,44 @@ } - // FIXME append(BigDecimal) + // The encoding ot a BigDecimal requires the expression + // of scale and length + // BigDecimal.scale indicates the precision of the number, where + // '3' is three decimal places and '-3' rounded to '000' + // BigDecimal.precision() is the number of unscaled digits + // therefore the precision - scale is an expression of the + // exponent of the normalised number. + // This means that the exponent could be zero or negative so the sign of the + // number cannot be indicated by adding to the exponent. + // Instead an explicit sign byte,'0' or '1' is used. + // The actual BigDecimal serialization uses the String conversions + // supported by BigDecimal, less the '-' sign character if applicable. + // The length of this data is terminated by a zero byte. + // + // The variable encoding of BigNumbers requires this String representation + // and negative representations are further encoded using flipDigits + // for the equivalent of 2s compliment negative representation. + public KeyBuilder append(final BigDecimal d) { -// throw new UnsupportedOperationException(); - return append(d.doubleValue()); + int sign = d.signum(); + int precision = d.precision(); + int scale = d.scale(); + int exponent = precision - scale; + if (sign == -1) { + exponent = -exponent; + } + + append((byte) sign); + append(exponent); + + String unscaledStr = d.unscaledValue().toString(); + if (sign == -1) { + unscaledStr = flipDigits(unscaledStr); + } + appendASCII(unscaledStr); // the unscaled BigInteger representation + append((byte) 0); + + return this; } /* @@ -1386,13 +1420,55 @@ } + static final byte eos = decodeByte(0); + static final byte negSign = decodeByte(-1); + // FIXME decodeBigDecimal(int, byte[]) static public BigDecimal decodeBigDecimal(final int offset, final byte[] key) { -// throw new UnsupportedOperationException(); - final double d = decodeDouble(key, offset); - return new BigDecimal(d); + int curs = offset; + byte sign = key[curs++]; + int exponent = decodeInt(key, curs); + boolean neg = sign == negSign; + if (neg) { + exponent = -exponent; + } + curs += 4; + int len = 0; + for (int i = curs; key[i] != eos; i++) len++; + String unscaledStr = decodeASCII(key, curs, len); + if (neg) { + unscaledStr = flipDigits(unscaledStr); + } + + BigInteger unscaled = new BigInteger(unscaledStr); + + int precision = len; + int scale = precision - exponent - (neg ? 1 : 0); + + BigDecimal ret = new BigDecimal(unscaled, scale); + + return ret; // relative scale adjustment } + static final char[] flipMap = {'0', '1', '2', '3', '4', + '5', '6', '7', '8', '9' + }; + + /* + * Flip numbers such that 0/9,1/8,2/7,3/6,4/5 + */ + static private String flipDigits(String str) { + char[] chrs = str.toCharArray(); + for (int i = 0; i < chrs.length; i++) { + int flip = '9' - chrs[i]; + if (flip >= 0 && flip < 10) { + chrs[i] = flipMap[flip]; + } + } + + return new String(chrs); + } + public static IKeyBuilder newInstance() { return newInstance(DEFAULT_INITIAL_CAPACITY); Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/test/com/bigdata/btree/keys/TestKeyBuilder.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/test/com/bigdata/btree/keys/TestKeyBuilder.java 2010-07-21 19:53:42 UTC (rev 3263) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/test/com/bigdata/btree/keys/TestKeyBuilder.java 2010-07-22 14:29:54 UTC (rev 3264) @@ -1718,8 +1718,8 @@ public void test_BigDecimal_383() { - final BigDecimal v1 = BigDecimal.valueOf(383.0000000000000001); - final BigDecimal v2 = BigDecimal.valueOf(383.0000000000000002); + final BigDecimal v1 = new BigDecimal("383.00000000000001"); + final BigDecimal v2 = new BigDecimal("383.00000000000002"); doLTTest(v1,v2); } @@ -1734,7 +1734,7 @@ public void test_BigDecimal_m1() { - final BigDecimal v = BigDecimal.valueOf(-1.0000000000000001); + final BigDecimal v = BigDecimal.valueOf(-1.00000000001); doEncodeDecodeTest(v); @@ -1810,19 +1810,23 @@ doEncodeDecodeTest(BigDecimal.valueOf(0)); - doEncodeDecodeTest(BigDecimal.valueOf(1.00000000001)); - doEncodeDecodeTest(BigDecimal.valueOf(8.00000000001)); - doEncodeDecodeTest(BigDecimal.valueOf(255.00000000001)); - doEncodeDecodeTest(BigDecimal.valueOf(256.00000000001)); - doEncodeDecodeTest(BigDecimal.valueOf(512.00000000001)); - doEncodeDecodeTest(BigDecimal.valueOf(1028.00000000001)); + doEncodeDecodeTest(BigDecimal.valueOf(-123450)); + doEncodeDecodeTest(BigDecimal.valueOf(-99)); + doEncodeDecodeTest(BigDecimal.valueOf(-9)); + + doEncodeDecodeTest(BigDecimal.valueOf(1.001)); + doEncodeDecodeTest(BigDecimal.valueOf(8.0001)); + doEncodeDecodeTest(BigDecimal.valueOf(255.0001)); + doEncodeDecodeTest(BigDecimal.valueOf(256.0001)); + doEncodeDecodeTest(BigDecimal.valueOf(512.0001)); + doEncodeDecodeTest(BigDecimal.valueOf(1028.001)); - doEncodeDecodeTest(BigDecimal.valueOf(-1.00000000001)); - doEncodeDecodeTest(BigDecimal.valueOf(-8.00000000001)); - doEncodeDecodeTest(BigDecimal.valueOf(-255.00000000001)); - doEncodeDecodeTest(BigDecimal.valueOf(-256.00000000001)); - doEncodeDecodeTest(BigDecimal.valueOf(-512.00000000001)); - doEncodeDecodeTest(BigDecimal.valueOf(-1028.00000000001)); + doEncodeDecodeTest(BigDecimal.valueOf(-1.0001)); + doEncodeDecodeTest(BigDecimal.valueOf(-8.0001)); + doEncodeDecodeTest(BigDecimal.valueOf(-255.0001)); + doEncodeDecodeTest(BigDecimal.valueOf(-256.0001)); + doEncodeDecodeTest(BigDecimal.valueOf(-512.0001)); + doEncodeDecodeTest(BigDecimal.valueOf(-1028.001)); doEncodeDecodeTest(BigDecimal.valueOf(Double.MIN_VALUE)); doEncodeDecodeTest(BigDecimal.valueOf(Double.MAX_VALUE)); @@ -1926,7 +1930,7 @@ /** * Stress test with random <code>double</code> values. */ - public void test_BigDecimal_stress_long_values() { + public void test_BigDecimal_stress_double_values() { final Random r = new Random(); @@ -2059,7 +2063,88 @@ } } + /** + * Stress test with random byte[]s from which we then construct + * {@link BigDecimal}s. + * + * FIXME: At present the comparisons fail proably due to a failure to + * understand the limits of the BigDecimal representations - so this + * test has been deactivated by name prefix. + */ + public void badTest_BigDecimal_stress_byteArray_values() { + + final Random r = new Random(); + + final int maxlen = 64; + + for (int i = 0; i < 100000; i++) { + final int len1 = r.nextInt(maxlen) + 1; + + final int len2 = r.nextInt(maxlen) + 1; + + final byte[] b1 = new byte[len1]; + + final byte[] b2 = new byte[len2]; + + r.nextBytes(b1); + + r.nextBytes(b2); + + // final BigDecimal t1 = new BigDecimal(new BigInteger(b1), -100 + r.nextInt(200)); + final BigDecimal t1 = new BigDecimal(new BigInteger(b1)); + + final BigDecimal v2 = BigDecimal.valueOf(Math.abs(r.nextDouble())); + + // final BigDecimal v4 = new BigDecimal(new BigInteger(b2), -100 + r.nextInt(200)); + final BigDecimal v4 = new BigDecimal(new BigInteger(b2)); + + // x LT t1 + final BigDecimal t2 = t1.subtract(v2); + final BigDecimal t4 = t1.subtract(BigDecimal.valueOf(5)); + final BigDecimal t5 = t1.subtract(BigDecimal.valueOf(9)); + + // t1 LT x + final BigDecimal t3 = t1.add(v2); + final BigDecimal t6 = t1.add(BigDecimal.valueOf(5)); + final BigDecimal t7 = t1.add(BigDecimal.valueOf(9)); + + doEncodeDecodeTest(t1); + doEncodeDecodeTest(t2); + doEncodeDecodeTest(t3); + doEncodeDecodeTest(t4); + doEncodeDecodeTest(t5); + doEncodeDecodeTest(t6); + doEncodeDecodeTest(t7); + + doLTTest(t2, t1); + doLTTest(t4, t1); + doLTTest(t5, t1); + + doLTTest(t1, t3); + doLTTest(t1, t6); + doLTTest(t1, t7); + + final int ret = t1.compareTo(v4); + + if (ret < 0) { + + doLTTest(t1, v4); + + } else if (ret > 0) { + + doLTTest(v4, t1); + + } else { + + // equal + + } + + } + + } + // /* // * BigDecimal (w/o precision). // */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-07-21 19:53:49
|
Revision: 3263 http://bigdata.svn.sourceforge.net/bigdata/?rev=3263&view=rev Author: mrpersonick Date: 2010-07-21 19:53:42 +0000 (Wed, 21 Jul 2010) Log Message: ----------- adding support for inline bnodes, BigDecimal, and test cases Modified Paths: -------------- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOKeyOrder.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/internal/TestEncodeDecodeKeys.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestAddTerms.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestAll.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreWithoutInlining.java branches/LEXICON_REFACTOR_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSail.java branches/LEXICON_REFACTOR_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoinsWithoutInlining.java branches/LEXICON_REFACTOR_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSidsWithoutInlining.java branches/LEXICON_REFACTOR_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java Added Paths: ----------- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestInlining.java Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java 2010-07-21 19:50:11 UTC (rev 3262) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java 2010-07-21 19:53:42 UTC (rev 3263) @@ -81,17 +81,20 @@ import com.bigdata.rdf.internal.IV; import com.bigdata.rdf.internal.IVUtility; import com.bigdata.rdf.internal.LexiconConfiguration; +import com.bigdata.rdf.internal.NumericBNodeIV; import com.bigdata.rdf.internal.TermId; -import com.bigdata.rdf.internal.UUIDInternalValue; -import com.bigdata.rdf.internal.XSDBooleanInternalValue; -import com.bigdata.rdf.internal.XSDByteInternalValue; -import com.bigdata.rdf.internal.XSDDecimalInternalValue; -import com.bigdata.rdf.internal.XSDDoubleInternalValue; -import com.bigdata.rdf.internal.XSDFloatInternalValue; -import com.bigdata.rdf.internal.XSDIntInternalValue; -import com.bigdata.rdf.internal.XSDIntegerInternalValue; -import com.bigdata.rdf.internal.XSDLongInternalValue; -import com.bigdata.rdf.internal.XSDShortInternalValue; +import com.bigdata.rdf.internal.UUIDBNodeIV; +import com.bigdata.rdf.internal.UUIDLiteralIV; +import com.bigdata.rdf.internal.VTE; +import com.bigdata.rdf.internal.XSDBooleanIV; +import com.bigdata.rdf.internal.XSDByteIV; +import com.bigdata.rdf.internal.XSDDecimalIV; +import com.bigdata.rdf.internal.XSDDoubleIV; +import com.bigdata.rdf.internal.XSDFloatIV; +import com.bigdata.rdf.internal.XSDIntIV; +import com.bigdata.rdf.internal.XSDIntegerIV; +import com.bigdata.rdf.internal.XSDLongIV; +import com.bigdata.rdf.internal.XSDShortIV; import com.bigdata.rdf.lexicon.Term2IdWriteProc.Term2IdWriteProcConstructor; import com.bigdata.rdf.model.BigdataBNode; import com.bigdata.rdf.model.BigdataValue; @@ -105,6 +108,7 @@ import com.bigdata.rdf.spo.SPOComparator; import com.bigdata.rdf.store.AbstractTripleStore; import com.bigdata.rdf.store.IRawTripleStore; +import com.bigdata.rdf.store.AbstractTripleStore.Options; import com.bigdata.relation.AbstractRelation; import com.bigdata.relation.accesspath.IAccessPath; import com.bigdata.relation.accesspath.IElementFilter; @@ -364,12 +368,17 @@ { - final boolean inlineTerms = Boolean.parseBoolean(getProperty( - AbstractTripleStore.Options.INLINE_TERMS, - AbstractTripleStore.Options.DEFAULT_INLINE_TERMS)); + inlineLiterals = Boolean.parseBoolean(getProperty( + AbstractTripleStore.Options.INLINE_LITERALS, + AbstractTripleStore.Options.DEFAULT_INLINE_LITERALS)); - lexiconConfiguration = new LexiconConfiguration(inlineTerms); + inlineBNodes = storeBlankNodes && Boolean.parseBoolean(getProperty( + AbstractTripleStore.Options.INLINE_LITERALS, + AbstractTripleStore.Options.DEFAULT_INLINE_LITERALS)); + lexiconConfiguration = + new LexiconConfiguration(inlineLiterals, inlineBNodes); + } } @@ -503,7 +512,33 @@ private final boolean textIndex; final boolean storeBlankNodes; final int termIdBitsToReverse; + + /** + * Are datatyped literals being inlined into the statement indices. + * + * {@link AbstractTripleStore.Options#INLINE_LITERALS} + */ + final private boolean inlineLiterals; + + /** + * Are bnodes being inlined into the statement indices. + * + * {@link AbstractTripleStore.Options#INLINE_BNODES} + */ + final private boolean inlineBNodes; + + + /** + * Return <code>true</code> if datatype literals are being inlined into + * the statement indices. + */ + final public boolean isInlineLiterals() { + + return inlineLiterals; + + } + /** * The #of low bits from the term identifier that are reversed and * rotated into the high bits when it is assigned. @@ -2214,9 +2249,12 @@ final DTE dte = datatype == null ? null : DTE.valueOf(datatype); - if (dte == null || !getLexiconConfiguration().isInline(dte)) + if (dte == null) return null; + if (!getLexiconConfiguration().isInline(VTE.LITERAL, dte)) + return null; + final String v = value.stringValue(); IV iv = null; @@ -2225,34 +2263,34 @@ switch(dte) { case XSDBoolean: - iv = new XSDBooleanInternalValue(XMLDatatypeUtil.parseBoolean(v)); + iv = new XSDBooleanIV(XMLDatatypeUtil.parseBoolean(v)); break; case XSDByte: - iv = new XSDByteInternalValue(XMLDatatypeUtil.parseByte(v)); + iv = new XSDByteIV(XMLDatatypeUtil.parseByte(v)); break; case XSDShort: - iv = new XSDShortInternalValue(XMLDatatypeUtil.parseShort(v)); + iv = new XSDShortIV(XMLDatatypeUtil.parseShort(v)); break; case XSDInt: - iv = new XSDIntInternalValue(XMLDatatypeUtil.parseInt(v)); + iv = new XSDIntIV(XMLDatatypeUtil.parseInt(v)); break; case XSDLong: - iv = new XSDLongInternalValue(XMLDatatypeUtil.parseLong(v)); + iv = new XSDLongIV(XMLDatatypeUtil.parseLong(v)); break; case XSDFloat: - iv = new XSDFloatInternalValue(XMLDatatypeUtil.parseFloat(v)); + iv = new XSDFloatIV(XMLDatatypeUtil.parseFloat(v)); break; case XSDDouble: - iv = new XSDDoubleInternalValue(XMLDatatypeUtil.parseDouble(v)); + iv = new XSDDoubleIV(XMLDatatypeUtil.parseDouble(v)); break; case XSDInteger: - iv = new XSDIntegerInternalValue(XMLDatatypeUtil.parseInteger(v)); + iv = new XSDIntegerIV(XMLDatatypeUtil.parseInteger(v)); break; -// case XSDDecimal: -// iv = new XSDDecimalInternalValue(XMLDatatypeUtil.parseDecimal(v)); -// break; + case XSDDecimal: + iv = new XSDDecimalIV(XMLDatatypeUtil.parseDecimal(v)); + break; case UUID: - iv = new UUIDInternalValue(UUID.fromString(v)); + iv = new UUIDLiteralIV(UUID.fromString(v)); break; default: iv = null; @@ -2276,8 +2314,55 @@ final String id = b.getID(); - // FIXME how do we inline this?? + final char c = id.charAt(0); + try { + + final UUID uuid = UUID.fromString(id); + + if (!uuid.toString().equals(id)) + return null; + + if (!getLexiconConfiguration().isInline(VTE.BNODE, DTE.UUID)) + return null; + + final IV iv = new UUIDBNodeIV(uuid); + + if (value instanceof BigdataValue) + ((BigdataValue) value).setIV(iv); + + return iv; + + } catch (Exception ex) { + + // string id could not be converted to a UUID + + } + + try { + + final Integer i = Integer.valueOf(id); + + // cannot normalize id, needs to remain syntactically identical + if (!i.toString().equals(id)) + return null; + + if (!getLexiconConfiguration().isInline(VTE.BNODE, DTE.XSDInt)) + return null; + + final IV iv = new NumericBNodeIV(i); + + if (value instanceof BigdataValue) + ((BigdataValue) value).setIV(iv); + + return iv; + + } catch (Exception ex) { + + // string id could not be converted to an Integer + + } + } return null; Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOKeyOrder.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOKeyOrder.java 2010-07-21 19:50:11 UTC (rev 3262) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPOKeyOrder.java 2010-07-21 19:53:42 UTC (rev 3263) @@ -41,23 +41,23 @@ import com.bigdata.btree.keys.KeyBuilder; import com.bigdata.btree.keys.SuccessorUtil; import com.bigdata.rawstore.Bytes; -import com.bigdata.rdf.internal.AbstractDatatypeLiteralInternalValue; -import com.bigdata.rdf.internal.AbstractInternalValue; +import com.bigdata.rdf.internal.AbstractLiteralIV; +import com.bigdata.rdf.internal.AbstractIV; import com.bigdata.rdf.internal.DTE; import com.bigdata.rdf.internal.IV; import com.bigdata.rdf.internal.IVUtility; import com.bigdata.rdf.internal.NullIV; import com.bigdata.rdf.internal.TermId; -import com.bigdata.rdf.internal.UUIDInternalValue; +import com.bigdata.rdf.internal.UUIDLiteralIV; import com.bigdata.rdf.internal.VTE; -import com.bigdata.rdf.internal.XSDBooleanInternalValue; -import com.bigdata.rdf.internal.XSDByteInternalValue; -import com.bigdata.rdf.internal.XSDDoubleInternalValue; -import com.bigdata.rdf.internal.XSDFloatInternalValue; -import com.bigdata.rdf.internal.XSDIntInternalValue; -import com.bigdata.rdf.internal.XSDIntegerInternalValue; -import com.bigdata.rdf.internal.XSDLongInternalValue; -import com.bigdata.rdf.internal.XSDShortInternalValue; +import com.bigdata.rdf.internal.XSDBooleanIV; +import com.bigdata.rdf.internal.XSDByteIV; +import com.bigdata.rdf.internal.XSDDoubleIV; +import com.bigdata.rdf.internal.XSDFloatIV; +import com.bigdata.rdf.internal.XSDIntIV; +import com.bigdata.rdf.internal.XSDIntegerIV; +import com.bigdata.rdf.internal.XSDLongIV; +import com.bigdata.rdf.internal.XSDShortIV; import com.bigdata.rdf.model.BigdataLiteral; import com.bigdata.rdf.model.StatementEnum; import com.bigdata.rdf.store.IRawTripleStore; @@ -677,160 +677,7 @@ return new SPO(s, p, o, c); } - - /** - * Decode a key from one of the statement indices. The components of the key - * are returned in the order in which they appear in the key. The caller - * must reorder those components using their knowledge of which index is - * being decoded in order to reconstruct the corresponding RDF statement. - * The returned array will always have 4 components. However, the last key - * component will be <code>null</code> if there are only three components in - * the <i>key</i>. - * - * @param key - * The key. - * - * @return An ordered array of the {@link IV}s for that key. - * - * FIXME handle all of the inline value types. - * - * FIXME Construct the InternalValue objects using factory since we - * will have to scope how the RDF Value is represented to the - * lexicon relation with which it is associated. - */ - public IV[] decodeStatementKey(final byte[] key) { - - final IV[] a = new IV[4]; - // The byte offset into the key. - int offset = 0; - - for (int i = 0; i < 4; i++) { - - final byte flags = KeyBuilder.decodeByte(key[offset]); - offset++; - - if(!AbstractInternalValue.isInline(flags)) { - - /* - * Handle a term identifier (versus an inline value). - */ - - // decode the term identifier. - final long termId = KeyBuilder.decodeLong(key, offset); - offset += Bytes.SIZEOF_LONG; - - a[i] = new TermId(flags, termId); - - continue; - - } - - /* - * Handle an inline value. - */ - // The value type (URI, Literal, BNode, SID) - final VTE vte = AbstractInternalValue - .getInternalValueTypeEnum(flags); - - // The data type - final DTE dte = AbstractInternalValue - .getInternalDataTypeEnum(flags); - - final IV<?,?> v; - switch (dte) { - case XSDBoolean: { - final byte x = KeyBuilder.decodeByte(key[offset++]); - if (x == 0) { - v = XSDBooleanInternalValue.FALSE; - } else { - v = XSDBooleanInternalValue.TRUE; - } - break; - } - case XSDByte: { - final byte x = KeyBuilder.decodeByte(key[offset++]); - v = new XSDByteInternalValue<BigdataLiteral>(x); - break; - } - case XSDShort: { - final short x = KeyBuilder.decodeShort(key, offset); - offset += Bytes.SIZEOF_SHORT; - v = new XSDShortInternalValue<BigdataLiteral>(x); - break; - } - case XSDInt: { - final int x = KeyBuilder.decodeInt(key, offset); - offset += Bytes.SIZEOF_INT; - v = new XSDIntInternalValue<BigdataLiteral>(x); - break; - } - case XSDLong: { - final long x = KeyBuilder.decodeLong(key, offset); - offset += Bytes.SIZEOF_LONG; - v = new XSDLongInternalValue<BigdataLiteral>(x); - break; - } - case XSDFloat: { - final float x = KeyBuilder.decodeFloat(key, offset); - offset += Bytes.SIZEOF_FLOAT; - v = new XSDFloatInternalValue<BigdataLiteral>(x); - break; - } - case XSDDouble: { - final double x = KeyBuilder.decodeDouble(key, offset); - offset += Bytes.SIZEOF_DOUBLE; - v = new XSDDoubleInternalValue<BigdataLiteral>(x); - break; - } - case UUID: { - final UUID x = KeyBuilder.decodeUUID(key, offset); - offset += Bytes.SIZEOF_UUID; - v = new UUIDInternalValue<BigdataLiteral>(x); - break; - } - case XSDInteger: { - final byte[] b = KeyBuilder.decodeBigInteger2(offset, key); - offset += 2 + b.length; - final BigInteger x = new BigInteger(b); - v = new XSDIntegerInternalValue<BigdataLiteral>(x); - break; - } -// case XSDDecimal: -// keyBuilder.append(t.decimalValue()); -// break; -// case XSDUnsignedByte: -// keyBuilder.appendUnsigned(t.byteValue()); -// break; -// case XSDUnsignedShort: -// keyBuilder.appendUnsigned(t.shortValue()); -// break; -// case XSDUnsignedInt: -// keyBuilder.appendUnsigned(t.intValue()); -// break; -// case XSDUnsignedLong: -// keyBuilder.appendUnsigned(t.longValue()); -// break; - default: - throw new UnsupportedOperationException("vte=" + vte + ", dte=" - + dte); - } - - a[i] = v; - - if (i == 2 && offset == key.length) { - // We have three components and the key is exhausted. - break; - } - - } - - return a; - - } - - - /** * Imposes the canonicalizing mapping during object de-serialization. * <p> Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java 2010-07-21 19:50:11 UTC (rev 3262) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java 2010-07-21 19:53:42 UTC (rev 3263) @@ -295,13 +295,6 @@ final private Class<? extends BaseClosure> closureClass; /** - * Are terms being inlined into the statement indices. - * - * @see Options#INLINE_TERMS - */ - final private boolean inlineTerms; - - /** * Return an instance of the class that is used to compute the closure of * the database. */ @@ -365,9 +358,9 @@ * into the statement indices rather than being mapped to and from term * identifiers in the lexicon. */ - public boolean isInlineTerms() { + public boolean isInlineLiterals() { - return inlineTerms; + return getLexiconRelation().isInlineLiterals(); } @@ -863,15 +856,27 @@ .getName(); /** - * Set up database to inline numerics directly into the statement - * indices rather than using the lexicon to map them to term + * Set up database to inline certain datatype literals directly into the + * statement indices rather than using the lexicon to map them to term * identifiers and back. */ - String INLINE_TERMS = AbstractTripleStore.class.getName() - + ".inlineTerms"; + String INLINE_LITERALS = AbstractTripleStore.class.getName() + + ".inlineLiterals"; - String DEFAULT_INLINE_TERMS = "true"; + String DEFAULT_INLINE_LITERALS = "true"; + /** + * Set up database to inline bnodes directly into the statement indices + * rather than using the lexicon to map them to term identifiers and + * back. This is only compatible with told bnodes mode. + * <p> + * See {@link Options#STORE_BLANK_NODES}. + */ + String INLINE_BNODES = AbstractTripleStore.class.getName() + + ".inlineBNodes"; + + String DEFAULT_INLINE_BNODES = "false"; + } protected Class determineAxiomClass() { @@ -1093,10 +1098,6 @@ } - this.inlineTerms = Boolean.parseBoolean(getProperty( - Options.INLINE_TERMS, - Options.DEFAULT_INLINE_TERMS)); - // setup namespace mapping for serialization utility methods. addNamespace(RDF.NAMESPACE, "rdf"); addNamespace(RDFS.NAMESPACE, "rdfs"); Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/internal/TestEncodeDecodeKeys.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/internal/TestEncodeDecodeKeys.java 2010-07-21 19:50:11 UTC (rev 3262) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/internal/TestEncodeDecodeKeys.java 2010-07-21 19:53:42 UTC (rev 3263) @@ -230,7 +230,7 @@ // // 64 bit random term identifier. // final long termId = r.nextLong(); - final IV<?, ?> v = new AbstractInternalValue(vte, + final IV<?, ?> v = new AbstractIV(vte, true/* inline */, false/* extension */, dte) { @Override @@ -655,13 +655,13 @@ final IV<?, ?>[] e = {// new TermId<BigdataURI>(VTE.URI, 1L),// new TermId<BigdataURI>(VTE.URI, 2L),// - new XSDBooleanInternalValue<BigdataLiteral>(true),// + new XSDBooleanIV<BigdataLiteral>(true),// new TermId<BigdataURI>(VTE.URI, 4L) // }; doEncodeDecodeTest(e); - e[2] = new XSDBooleanInternalValue<BigdataLiteral>(false); + e[2] = new XSDBooleanIV<BigdataLiteral>(false); doEncodeDecodeTest(e); @@ -675,25 +675,25 @@ final IV<?, ?>[] e = {// new TermId<BigdataURI>(VTE.URI, 1L),// new TermId<BigdataURI>(VTE.URI, 2L),// - new XSDByteInternalValue<BigdataLiteral>((byte)1),// + new XSDByteIV<BigdataLiteral>((byte)1),// new TermId<BigdataURI>(VTE.URI, 4L) // }; doEncodeDecodeTest(e); - e[2] = new XSDByteInternalValue<BigdataLiteral>((byte) -1); + e[2] = new XSDByteIV<BigdataLiteral>((byte) -1); doEncodeDecodeTest(e); - e[2] = new XSDByteInternalValue<BigdataLiteral>((byte) 0); + e[2] = new XSDByteIV<BigdataLiteral>((byte) 0); doEncodeDecodeTest(e); - e[2] = new XSDByteInternalValue<BigdataLiteral>(Byte.MAX_VALUE); + e[2] = new XSDByteIV<BigdataLiteral>(Byte.MAX_VALUE); doEncodeDecodeTest(e); - e[2] = new XSDByteInternalValue<BigdataLiteral>(Byte.MIN_VALUE); + e[2] = new XSDByteIV<BigdataLiteral>(Byte.MIN_VALUE); doEncodeDecodeTest(e); @@ -707,25 +707,25 @@ final IV<?, ?>[] e = {// new TermId<BigdataURI>(VTE.URI, 1L),// new TermId<BigdataURI>(VTE.URI, 2L),// - new XSDShortInternalValue<BigdataLiteral>((short)1),// + new XSDShortIV<BigdataLiteral>((short)1),// new TermId<BigdataURI>(VTE.URI, 4L) // }; doEncodeDecodeTest(e); - e[2] = new XSDShortInternalValue<BigdataLiteral>((short) -1); + e[2] = new XSDShortIV<BigdataLiteral>((short) -1); doEncodeDecodeTest(e); - e[2] = new XSDShortInternalValue<BigdataLiteral>((short) 0); + e[2] = new XSDShortIV<BigdataLiteral>((short) 0); doEncodeDecodeTest(e); - e[2] = new XSDShortInternalValue<BigdataLiteral>(Short.MAX_VALUE); + e[2] = new XSDShortIV<BigdataLiteral>(Short.MAX_VALUE); doEncodeDecodeTest(e); - e[2] = new XSDShortInternalValue<BigdataLiteral>(Short.MIN_VALUE); + e[2] = new XSDShortIV<BigdataLiteral>(Short.MIN_VALUE); doEncodeDecodeTest(e); @@ -739,25 +739,25 @@ final IV<?, ?>[] e = {// new TermId<BigdataURI>(VTE.URI, 1L),// new TermId<BigdataURI>(VTE.URI, 2L),// - new XSDIntInternalValue<BigdataLiteral>(1),// + new XSDIntIV<BigdataLiteral>(1),// new TermId<BigdataURI>(VTE.URI, 4L) // }; doEncodeDecodeTest(e); - e[2] = new XSDIntInternalValue<BigdataLiteral>(-1); + e[2] = new XSDIntIV<BigdataLiteral>(-1); doEncodeDecodeTest(e); - e[2] = new XSDIntInternalValue<BigdataLiteral>(0); + e[2] = new XSDIntIV<BigdataLiteral>(0); doEncodeDecodeTest(e); - e[2] = new XSDIntInternalValue<BigdataLiteral>(Integer.MAX_VALUE); + e[2] = new XSDIntIV<BigdataLiteral>(Integer.MAX_VALUE); doEncodeDecodeTest(e); - e[2] = new XSDIntInternalValue<BigdataLiteral>(Integer.MIN_VALUE); + e[2] = new XSDIntIV<BigdataLiteral>(Integer.MIN_VALUE); doEncodeDecodeTest(e); @@ -771,25 +771,25 @@ final IV<?, ?>[] e = {// new TermId<BigdataURI>(VTE.URI, 1L),// new TermId<BigdataURI>(VTE.URI, 2L),// - new XSDLongInternalValue<BigdataLiteral>(1L),// + new XSDLongIV<BigdataLiteral>(1L),// new TermId<BigdataURI>(VTE.URI, 4L) // }; doEncodeDecodeTest(e); - e[2] = new XSDLongInternalValue<BigdataLiteral>(-1L); + e[2] = new XSDLongIV<BigdataLiteral>(-1L); doEncodeDecodeTest(e); - e[2] = new XSDLongInternalValue<BigdataLiteral>(0L); + e[2] = new XSDLongIV<BigdataLiteral>(0L); doEncodeDecodeTest(e); - e[2] = new XSDLongInternalValue<BigdataLiteral>(Long.MAX_VALUE); + e[2] = new XSDLongIV<BigdataLiteral>(Long.MAX_VALUE); doEncodeDecodeTest(e); - e[2] = new XSDLongInternalValue<BigdataLiteral>(Long.MIN_VALUE); + e[2] = new XSDLongIV<BigdataLiteral>(Long.MIN_VALUE); doEncodeDecodeTest(e); @@ -803,41 +803,41 @@ final IV<?, ?>[] e = {// new TermId<BigdataURI>(VTE.URI, 1L),// new TermId<BigdataURI>(VTE.URI, 2L),// - new XSDFloatInternalValue<BigdataLiteral>(1f),// + new XSDFloatIV<BigdataLiteral>(1f),// new TermId<BigdataURI>(VTE.URI, 4L) // }; doEncodeDecodeTest(e); - e[2] = new XSDFloatInternalValue<BigdataLiteral>(-1f); + e[2] = new XSDFloatIV<BigdataLiteral>(-1f); doEncodeDecodeTest(e); - e[2] = new XSDFloatInternalValue<BigdataLiteral>(+0f); + e[2] = new XSDFloatIV<BigdataLiteral>(+0f); doEncodeDecodeTest(e); - e[2] = new XSDFloatInternalValue<BigdataLiteral>(-0f); + e[2] = new XSDFloatIV<BigdataLiteral>(-0f); doEncodeDecodeTest(e); - e[2] = new XSDFloatInternalValue<BigdataLiteral>(Float.MAX_VALUE); + e[2] = new XSDFloatIV<BigdataLiteral>(Float.MAX_VALUE); doEncodeDecodeTest(e); - e[2] = new XSDFloatInternalValue<BigdataLiteral>(Float.MIN_VALUE); + e[2] = new XSDFloatIV<BigdataLiteral>(Float.MIN_VALUE); doEncodeDecodeTest(e); - e[2] = new XSDFloatInternalValue<BigdataLiteral>(Float.MIN_NORMAL); + e[2] = new XSDFloatIV<BigdataLiteral>(Float.MIN_NORMAL); doEncodeDecodeTest(e); - e[2] = new XSDFloatInternalValue<BigdataLiteral>(Float.POSITIVE_INFINITY); + e[2] = new XSDFloatIV<BigdataLiteral>(Float.POSITIVE_INFINITY); doEncodeDecodeTest(e); - e[2] = new XSDFloatInternalValue<BigdataLiteral>(Float.NEGATIVE_INFINITY); + e[2] = new XSDFloatIV<BigdataLiteral>(Float.NEGATIVE_INFINITY); doEncodeDecodeTest(e); @@ -851,41 +851,41 @@ final IV<?, ?>[] e = {// new TermId<BigdataURI>(VTE.URI, 1L),// new TermId<BigdataURI>(VTE.URI, 2L),// - new XSDDoubleInternalValue<BigdataLiteral>(1d),// + new XSDDoubleIV<BigdataLiteral>(1d),// new TermId<BigdataURI>(VTE.URI, 4L) // }; doEncodeDecodeTest(e); - e[2] = new XSDDoubleInternalValue<BigdataLiteral>(-1d); + e[2] = new XSDDoubleIV<BigdataLiteral>(-1d); doEncodeDecodeTest(e); - e[2] = new XSDDoubleInternalValue<BigdataLiteral>(-0d); + e[2] = new XSDDoubleIV<BigdataLiteral>(-0d); doEncodeDecodeTest(e); - e[2] = new XSDDoubleInternalValue<BigdataLiteral>(+0d); + e[2] = new XSDDoubleIV<BigdataLiteral>(+0d); doEncodeDecodeTest(e); - e[2] = new XSDDoubleInternalValue<BigdataLiteral>(Double.MAX_VALUE); + e[2] = new XSDDoubleIV<BigdataLiteral>(Double.MAX_VALUE); doEncodeDecodeTest(e); - e[2] = new XSDDoubleInternalValue<BigdataLiteral>(Double.MIN_VALUE); + e[2] = new XSDDoubleIV<BigdataLiteral>(Double.MIN_VALUE); doEncodeDecodeTest(e); - e[2] = new XSDDoubleInternalValue<BigdataLiteral>(Double.MIN_NORMAL); + e[2] = new XSDDoubleIV<BigdataLiteral>(Double.MIN_NORMAL); doEncodeDecodeTest(e); - e[2] = new XSDDoubleInternalValue<BigdataLiteral>(Double.POSITIVE_INFINITY); + e[2] = new XSDDoubleIV<BigdataLiteral>(Double.POSITIVE_INFINITY); doEncodeDecodeTest(e); - e[2] = new XSDDoubleInternalValue<BigdataLiteral>(Double.NEGATIVE_INFINITY); + e[2] = new XSDDoubleIV<BigdataLiteral>(Double.NEGATIVE_INFINITY); doEncodeDecodeTest(e); @@ -910,7 +910,7 @@ final IV<?, ?>[] e = {// new TermId<BigdataURI>(VTE.URI, 1L),// new TermId<BigdataURI>(VTE.URI, 2L),// - new XSDFloatInternalValue<BigdataLiteral>(Float.NaN),// + new XSDFloatIV<BigdataLiteral>(Float.NaN),// new TermId<BigdataURI>(VTE.URI, 4L) // }; @@ -937,11 +937,11 @@ final IV<?, ?>[] e = {// new TermId<BigdataURI>(VTE.URI, 1L),// new TermId<BigdataURI>(VTE.URI, 2L),// - new XSDDoubleInternalValue<BigdataLiteral>(Double.NaN),// + new XSDDoubleIV<BigdataLiteral>(Double.NaN),// new TermId<BigdataURI>(VTE.URI, 4L) // }; - e[2] = new XSDDoubleInternalValue<BigdataLiteral>(Double.NaN); + e[2] = new XSDDoubleIV<BigdataLiteral>(Double.NaN); doEncodeDecodeTest(e); @@ -955,7 +955,7 @@ final IV<?, ?>[] e = {// new TermId<BigdataURI>(VTE.URI, 1L),// new TermId<BigdataURI>(VTE.URI, 2L),// - new UUIDInternalValue<BigdataLiteral>(UUID.randomUUID()),// + new UUIDLiteralIV<BigdataLiteral>(UUID.randomUUID()),// new TermId<BigdataURI>(VTE.URI, 4L) // }; @@ -963,7 +963,7 @@ for (int i = 0; i < 1000; i++) { - e[2] = new UUIDInternalValue<BigdataLiteral>(UUID.randomUUID()); + e[2] = new UUIDLiteralIV<BigdataLiteral>(UUID.randomUUID()); doEncodeDecodeTest(e); @@ -979,7 +979,7 @@ final IV<?, ?>[] e = {// new TermId<BigdataURI>(VTE.URI, 1L),// new TermId<BigdataURI>(VTE.URI, 2L),// - new XSDIntegerInternalValue<BigdataLiteral>(BigInteger + new XSDIntegerIV<BigdataLiteral>(BigInteger .valueOf(3L)),// new TermId<BigdataURI>(VTE.URI, 4L) // }; @@ -990,12 +990,13 @@ /** * Unit test where the RDF Object position is an xsd:decimal. + */ public void test_SPO_encodeDecode_XSDDecimal() { final IV<?, ?>[] e = {// new TermId<BigdataURI>(VTE.URI, 1L),// new TermId<BigdataURI>(VTE.URI, 2L),// - new XSDDecimalInternalValue<BigdataLiteral>(BigDecimal + new XSDDecimalIV<BigdataLiteral>(BigDecimal .valueOf(3.3d)),// new TermId<BigdataURI>(VTE.URI, 4L) // }; @@ -1003,6 +1004,5 @@ doEncodeDecodeTest(e); } - */ } Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestAddTerms.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestAddTerms.java 2010-07-21 19:50:11 UTC (rev 3262) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestAddTerms.java 2010-07-21 19:53:42 UTC (rev 3263) @@ -81,7 +81,7 @@ properties.setProperty(Options.TEXT_INDEX, "false"); // test w/o inlining - properties.setProperty(Options.INLINE_TERMS, "false"); + properties.setProperty(Options.INLINE_LITERALS, "false"); AbstractTripleStore store = getStore(properties); Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestAll.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestAll.java 2010-07-21 19:50:11 UTC (rev 3262) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestAll.java 2010-07-21 19:53:42 UTC (rev 3263) @@ -83,6 +83,9 @@ // test suite for the full-text indexer integration. suite.addTestSuite(TestFullTextIndex.class); + // test suite for inlining + suite.addTestSuite(TestInlining.class); + return suite; } Added: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestInlining.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestInlining.java (rev 0) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestInlining.java 2010-07-21 19:53:42 UTC (rev 3263) @@ -0,0 +1,309 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2007. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +/* + * Created on Nov 6, 2007 + */ + +package com.bigdata.rdf.lexicon; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; +import org.openrdf.model.vocabulary.RDF; +import com.bigdata.rdf.axioms.NoAxioms; +import com.bigdata.rdf.internal.IV; +import com.bigdata.rdf.internal.XSD; +import com.bigdata.rdf.model.BigdataBNode; +import com.bigdata.rdf.model.BigdataValue; +import com.bigdata.rdf.model.BigdataValueFactory; +import com.bigdata.rdf.store.AbstractTripleStore; +import com.bigdata.rdf.store.AbstractTripleStoreTestCase; +import com.bigdata.rdf.store.AbstractTripleStore.Options; +import com.bigdata.rdf.vocab.NoVocabulary; + +/** + * Test suite for adding terms to the lexicon. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + */ +public class TestInlining extends AbstractTripleStoreTestCase { + + /** + * + */ + public TestInlining() { + super(); + + } + + /** + * @param name + */ + public TestInlining(String name) { + super(name); + + } + + /** + * Unsigned numerics should not be inlined at this time. + */ + public void test_unsigned() { + + final Properties properties = getProperties(); + + // test w/o predefined vocab. + properties.setProperty(Options.VOCABULARY_CLASS, NoVocabulary.class + .getName()); + + // test w/o axioms - they imply a predefined vocab. + properties.setProperty(Options.AXIOMS_CLASS, NoAxioms.class.getName()); + + // test w/o the full text index. + properties.setProperty(Options.TEXT_INDEX, "false"); + + AbstractTripleStore store = getStore(properties); + + try { + + final Collection<BigdataValue> terms = new HashSet<BigdataValue>(); + + // lookup/add some values. + final BigdataValueFactory f = store.getValueFactory(); + + terms.add(f.createLiteral("10", f + .createURI(XSD.UNSIGNED_INT.toString()))); + + terms.add(f.createLiteral("12", f + .createURI(XSD.UNSIGNED_SHORT.toString()))); + + terms.add(f.createLiteral("14", f + .createURI(XSD.UNSIGNED_LONG.toString()))); + + /* + * Note: Blank nodes will not round trip through the lexicon unless + * the "told bnodes" is enabled. + */ +// terms.add(f.createBNode()); +// terms.add(f.createBNode("a")); + + final Map<IV, BigdataValue> ids = doAddTermsTest(store, terms); + + if (store.isStable()) { + + store.commit(); + + store = reopenStore(store); + + // verify same reverse mappings. + + final Map<IV, BigdataValue> ids2 = store.getLexiconRelation() + .getTerms(ids.keySet()); + + assertEquals(ids.size(),ids2.size()); + + for (IV id : ids.keySet()) { + + assertTrue(id.isTermId()); + + assertEquals("Id mapped to a different term? : termId=" + + id, ids.get(id), ids2.get(id)); + + } + + } + + } finally { + + store.__tearDownUnitTest(); + + } + + } + + /** + * The "told bnodes" mode uses the blank node ID as specified rather than + * assigning one based on a UUID. For this case, we need to store the blank + * nodes in the reverse index (T2ID) so we can translate a blank node back + * to a specific identifier. + */ + public void test_inlineBNodes() { + + final Properties properties = getProperties(); + + // test w/o predefined vocab. + properties.setProperty(Options.VOCABULARY_CLASS, NoVocabulary.class + .getName()); + + // test w/o axioms - they imply a predefined vocab. + properties.setProperty(Options.AXIOMS_CLASS, NoAxioms.class.getName()); + + // test w/o the full text index. + properties.setProperty(Options.TEXT_INDEX, "false"); + + // this is the "told bnodes" mode. + properties.setProperty(Options.STORE_BLANK_NODES, "true"); + + // inline the bnodes + properties.setProperty(Options.INLINE_BNODES, "true"); + + AbstractTripleStore store = getStore(properties); + + try { + + if (!store.isStable()) { + + /* + * We need a restart safe store to test this since otherwise a + * term cache could give us a false positive. + */ + + return; + + } + + final Collection<BigdataValue> terms = new HashSet<BigdataValue>(); + + // lookup/add some values. + final BigdataValueFactory f = store.getValueFactory(); + + final BigdataBNode b1 = f.createBNode("1"); + final BigdataBNode b01 = f.createBNode("01"); + final BigdataBNode b2 = f.createBNode(UUID.randomUUID().toString()); + final BigdataBNode b3 = f.createBNode("foo"); + final BigdataBNode b4 = f.createBNode("foo12345"); + + terms.add(b1); + terms.add(b01); + terms.add(b2); + terms.add(b3); + terms.add(b4); + + final Map<IV, BigdataValue> ids = doAddTermsTest(store, terms); + + assertTrue(b1.getIV().isInline()); + assertFalse(b01.getIV().isInline()); + assertTrue(b2.getIV().isInline()); + assertFalse(b3.getIV().isInline()); + assertFalse(b4.getIV().isInline()); + + if (store.isStable()) { + + store.commit(); + + store = reopenStore(store); + + // verify same reverse mappings. + + final Map<IV, BigdataValue> ids2 = store.getLexiconRelation() + .getTerms(ids.keySet()); + + assertEquals(ids.size(),ids2.size()); + + for (IV iv : ids.keySet()) { + + System.err.println(iv); + + assertEquals("Id mapped to a different term? : iv=" + + iv, ids.get(iv), ids2.get(iv)); + + } + + } + + } finally { + + store.__tearDownUnitTest(); + + } + + } + + /** + * @param store + * @param terms + * @return + */ + private Map<IV, BigdataValue> doAddTermsTest( + final AbstractTripleStore store, + final Collection<BigdataValue> terms) { + + final int size = terms.size(); + + final BigdataValue[] a = terms.toArray(new BigdataValue[size]); + + // resolve term ids. + store + .getLexiconRelation() + .addTerms(a, size, false/* readOnly */); + + // populate map w/ the assigned term identifiers. + final Collection<IV> ids = new ArrayList<IV>(); + + for(BigdataValue t : a) { + + ids.add(t.getIV()); + + } + + /* + * Resolve the assigned term identifiers against the lexicon. + */ + final Map<IV, BigdataValue> tmp = store.getLexiconRelation() + .getTerms(ids); + + assertEquals(size,tmp.size()); + + /* + * Verify that the lexicon reports the same RDF Values for those term + * identifiers (they will be "equals()" to the values that we added to + * the lexicon). + */ + for(BigdataValue expected : a) { + + assertNotSame("Did not assign internal value? : " + expected, + null, expected.getIV()); + + final BigdataValue actual = tmp.get(expected.getIV()); + + if (actual == null) { + + fail("Lexicon does not have value: iv=" + + expected.getIV() + ", term=" + expected); + + } + + assertEquals("IV mapped to a different term? iv=" + + expected.getIV(), expected, actual); + + } + + return tmp; + + } + +} Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreWithoutInlining.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreWithoutInlining.java 2010-07-21 19:50:11 UTC (rev 3262) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreWithoutInlining.java 2010-07-21 19:53:42 UTC (rev 3263) @@ -113,7 +113,7 @@ // do not inline anything. properties.setProperty( - com.bigdata.rdf.store.AbstractTripleStore.Options.INLINE_TERMS, + com.bigdata.rdf.store.AbstractTripleStore.Options.INLINE_LITERALS, "false"); // properties.setProperty( Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSail.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSail.java 2010-07-21 19:50:11 UTC (rev 3262) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSail.java 2010-07-21 19:53:42 UTC (rev 3263) @@ -2914,7 +2914,7 @@ final BigdataEvaluationStrategyImpl2 strategy = new BigdataEvaluationStrategyImpl2( (BigdataTripleSource) tripleSource, dataset, - nativeJoins, starJoins, database.isInlineTerms()); + nativeJoins, starJoins, database.isInlineLiterals()); final QueryOptimizerList optimizerList = new QueryOptimizerList(); optimizerList.add(new BindingAssigner()); @@ -2993,7 +2993,7 @@ final BigdataEvaluationStrategyImpl2 strategy = new BigdataEvaluationStrategyImpl2( (BigdataTripleSource) tripleSource, dataset, - nativeJoins, starJoins, database.isInlineTerms()); + nativeJoins, starJoins, database.isInlineLiterals()); final QueryOptimizerList optimizerList = new QueryOptimizerList(); optimizerList.add(new BindingAssigner()); Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoinsWithoutInlining.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoinsWithoutInlining.java 2010-07-21 19:50:11 UTC (rev 3262) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuadsAndPipelineJoinsWithoutInlining.java 2010-07-21 19:53:42 UTC (rev 3263) @@ -143,7 +143,7 @@ properties.setProperty(AbstractResource.Options.NESTED_SUBQUERY, "false"); - properties.setProperty(Options.INLINE_TERMS, "false"); + properties.setProperty(Options.INLINE_LITERALS, "false"); return properties; Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSidsWithoutInlining.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSidsWithoutInlining.java 2010-07-21 19:50:11 UTC (rev 3262) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithSidsWithoutInlining.java 2010-07-21 19:53:42 UTC (rev 3263) @@ -98,7 +98,7 @@ */ properties.setProperty(Options.TRIPLES_MODE_WITH_PROVENANCE, "true"); - properties.setProperty(Options.INLINE_TERMS, "false"); + properties.setProperty(Options.INLINE_LITERALS, "false"); return properties; Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java 2010-07-21 19:50:11 UTC (rev 3262) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/tck/BigdataSparqlTest.java 2010-07-21 19:53:42 UTC (rev 3263) @@ -308,7 +308,7 @@ final Properties props = getProperties(); if (cannotInlineTests.contains(testURI)) - props.setProperty(Options.INLINE_TERMS, "false"); + props.setProperty(Options.INLINE_LITERALS, "false"); final BigdataSail sail = new BigdataSail(props); return new DatasetRepository(new BigdataSailRepository(sail)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-07-21 19:50:17
|
Revision: 3262 http://bigdata.svn.sourceforge.net/bigdata/?rev=3262&view=rev Author: mrpersonick Date: 2010-07-21 19:50:11 +0000 (Wed, 21 Jul 2010) Log Message: ----------- temporary implementation for BigDecimal Modified Paths: -------------- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/keys/KeyBuilder.java Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/keys/KeyBuilder.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/keys/KeyBuilder.java 2010-07-21 19:49:10 UTC (rev 3261) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/keys/KeyBuilder.java 2010-07-21 19:50:11 UTC (rev 3262) @@ -947,7 +947,8 @@ // FIXME append(BigDecimal) public KeyBuilder append(final BigDecimal d) { - throw new UnsupportedOperationException(); +// throw new UnsupportedOperationException(); + return append(d.doubleValue()); } /* @@ -1061,6 +1062,10 @@ append((BigInteger) val); + } else if (val instanceof BigDecimal) { + + append((BigDecimal) val); + } else if (val instanceof Float) { append(((Float) val).floatValue()); @@ -1383,7 +1388,9 @@ // FIXME decodeBigDecimal(int, byte[]) static public BigDecimal decodeBigDecimal(final int offset, final byte[] key) { - throw new UnsupportedOperationException(); +// throw new UnsupportedOperationException(); + final double d = decodeDouble(key, offset); + return new BigDecimal(d); } public static IKeyBuilder newInstance() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-07-21 19:49:16
|
Revision: 3261 http://bigdata.svn.sourceforge.net/bigdata/?rev=3261&view=rev Author: mrpersonick Date: 2010-07-21 19:49:10 +0000 (Wed, 21 Jul 2010) Log Message: ----------- renamed a bunch of stuff and added support for inline bnodes Added Paths: ----------- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractBNodeIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/NumericBNodeIV.java Added: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractBNodeIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractBNodeIV.java (rev 0) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractBNodeIV.java 2010-07-21 19:49:10 UTC (rev 3261) @@ -0,0 +1,68 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2010. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +package com.bigdata.rdf.internal; + +import com.bigdata.rdf.model.BigdataBNode; +import com.bigdata.rdf.model.BigdataValueFactory; +import com.bigdata.rdf.store.AbstractTripleStore; + +/** + * Class for inline RDF blank nodes. Blank nodes MUST be based on UUIDs or + * some other numeric in order to be inlined. + * <p> + * {@inheritDoc} + * + * @author <a href="mailto:tho...@us...">Bryan + * Thompson</a> + * @version $Id: TestEncodeDecodeKeys.java 2753 2010-05-01 16:36:59Z + * thompsonbry $ + * + * @see AbstractTripleStore.Options + */ +abstract public class AbstractBNodeIV<V extends BigdataBNode, T> extends + AbstractInlineIV<V, T> { + + /** + * + */ + private static final long serialVersionUID = -4560216387427028030L; + + public AbstractBNodeIV(DTE dte) { + + super(VTE.BNODE, dte); + + } + + final public long getTermId() { + throw new UnsupportedOperationException(); + } + + public V asValue(BigdataValueFactory f) + throws UnsupportedOperationException { + final V bnode = (V) f.createBNode(stringValue()); + bnode.setIV(this); + return bnode; + } + +} \ No newline at end of file Added: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/NumericBNodeIV.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/NumericBNodeIV.java (rev 0) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/NumericBNodeIV.java 2010-07-21 19:49:10 UTC (rev 3261) @@ -0,0 +1,87 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2010. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +package com.bigdata.rdf.internal; + +import com.bigdata.rawstore.Bytes; +import com.bigdata.rdf.model.BigdataBNode; +import com.bigdata.rdf.store.AbstractTripleStore; + +/** + * Class for inline RDF blank nodes. Blank nodes MUST be based on a numeric + * value to be inlined with this class. + * <p> + * {@inheritDoc} + * + * @author <a href="mailto:tho...@us...">Bryan + * Thompson</a> + * @version $Id: TestEncodeDecodeKeys.java 2753 2010-05-01 16:36:59Z + * thompsonbry $ + * + * @see AbstractTripleStore.Options + */ +public class NumericBNodeIV<V extends BigdataBNode> extends + AbstractBNodeIV<V, Integer> { + + /** + * + */ + private static final long serialVersionUID = -2057725744604560753L; + + private final int id; + + public NumericBNodeIV(final int id) { + + super(DTE.XSDInt); + + this.id = id; + + } + + @Override + public String stringValue() { + return String.valueOf(id); + } + + final public Integer getInlineValue() { + return id; + } + + public boolean equals(Object o) { + if (this == o) + return true; + if (o instanceof NumericBNodeIV<?>) { + return this.id == ((NumericBNodeIV<?>) o).id; + } + return false; + } + + public int hashCode() { + return id; + } + + public int byteLength() { + return 1 + Bytes.SIZEOF_INT; + } + +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-07-21 19:48:49
|
Revision: 3260 http://bigdata.svn.sourceforge.net/bigdata/?rev=3260&view=rev Author: mrpersonick Date: 2010-07-21 19:48:42 +0000 (Wed, 21 Jul 2010) Log Message: ----------- renamed a bunch of stuff and added support for inline bnodes Modified Paths: -------------- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/DTE.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/DummyIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/ILexiconConfiguration.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/IVUtility.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LegacyTermIdUtility.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/TermId.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/VTE.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSD.java Added Paths: ----------- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInlineIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractLiteralIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/UUIDBNodeIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/UUIDLiteralIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDBooleanIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDByteIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDDecimalIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDDoubleIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDFloatIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDIntIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDIntegerIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDLongIV.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDShortIV.java Removed Paths: ------------- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractDatatypeLiteralInternalValue.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInlineInternalValue.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInternalValue.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractLiteralInternalValue.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/BNodeInternalValue.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/UUIDInternalValue.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDBooleanInternalValue.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDByteInternalValue.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDDecimalInternalValue.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDDoubleInternalValue.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDFloatInternalValue.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDIntInternalValue.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDIntegerInternalValue.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDLongInternalValue.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/XSDShortInternalValue.java Deleted: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractDatatypeLiteralInternalValue.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractDatatypeLiteralInternalValue.java 2010-07-21 18:04:22 UTC (rev 3259) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractDatatypeLiteralInternalValue.java 2010-07-21 19:48:42 UTC (rev 3260) @@ -1,128 +0,0 @@ -/** - -Copyright (C) SYSTAP, LLC 2006-2010. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -package com.bigdata.rdf.internal; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import com.bigdata.rdf.model.BigdataLiteral; - -/** - * Abstract base class for RDF datatype literals adds primitive data type - * value access methods. - * <p> - * {@inheritDoc} - * - * @todo What are the SPARQL semantics for casting among these datatypes? - * They should probably be reflected here since that is the real use - * case. I believe that those casts also require failing a solution if - * the cast is not legal, in which case these methods might not be all - * that useful. - * <p> - * Also see BigdataLiteralImpl and XMLDatatypeUtil. It handles the - * conversions by reparsing, but there is no reason to do that here - * since we have the canonical point in the value space. - * - * @see http://www.w3.org/TR/rdf-sparql-query/#FunctionMapping, The casting - * rules for SPARQL - * - * @author <a href="mailto:tho...@us...">Bryan - * Thompson</a> - * @version $Id: TestEncodeDecodeKeys.java 2753 2010-05-01 16:36:59Z - * thompsonbry $ - */ -abstract public class AbstractDatatypeLiteralInternalValue<V extends BigdataLiteral, T> - extends AbstractLiteralInternalValue<V, T> { - - /** - * - */ - private static final long serialVersionUID = 5962615541158537189L; - - protected AbstractDatatypeLiteralInternalValue(final DTE dte) { - - super(dte); - - } - - final public long getTermId() { - throw new UnsupportedOperationException(); - } - - /** Return the <code>boolean</code> value of <i>this</i> value. */ - abstract public boolean booleanValue(); - - /** - * Return the <code>byte</code> value of <i>this</i> value. - * <p> - * Note: Java lacks unsigned data types. For safety, operations on - * unsigned XSD data types should be conducted after a widening - * conversion. For example, operations on <code>xsd:unsignedByte</code> - * should be performed using {@link #shortValue()}. - */ - abstract public byte byteValue(); - - /** - * Return the <code>short</code> value of <i>this</i> value. - * <p> - * Note: Java lacks unsigned data types. For safety, operations on - * unsigned XSD data types should be conducted after a widening - * conversion. For example, operations on <code>xsd:unsignedShort</code> - * should be performed using {@link #intValue()}. - */ - abstract public short shortValue(); - - /** - * Return the <code>int</code> value of <i>this</i> value. - * <p> - * Note: Java lacks unsigned data types. For safety, operations on - * unsigned XSD data types should be conducted after a widening - * conversion. For example, operations on <code>xsd:unsignedInt</code> - * should be performed using {@link #longValue()}. - */ - abstract public int intValue(); - - /** - * Return the <code>long</code> value of <i>this</i> value. - * <p> - * Note: Java lacks unsigned data types. For safety, operations on - * unsigned XSD data types should be conducted after a widening - * conversion. For example, operations on <code>xsd:unsignedLong</code> - * should be performed using {@link #integerValue()}. - */ - abstract public long longValue(); - - /** Return the <code>float</code> value of <i>this</i> value. */ - abstract public float floatValue(); - - /** Return the <code>double</code> value of <i>this</i> value. */ - abstract public double doubleValue(); - - /** Return the {@link BigInteger} value of <i>this</i> value. */ - abstract public BigInteger integerValue(); - - /** Return the {@link BigDecimal} value of <i>this</i> value. */ - abstract public BigDecimal decimalValue(); - -} \ No newline at end of file Copied: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractIV.java (from rev 3258, branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInternalValue.java) =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractIV.java (rev 0) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractIV.java 2010-07-21 19:48:42 UTC (rev 3260) @@ -0,0 +1,680 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2010. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +/* + * Created on May 3, 2010 + */ + +package com.bigdata.rdf.internal; + +import java.io.DataOutput; +import java.io.IOException; +import java.util.UUID; +import org.deri.iris.basics.Literal; +import org.openrdf.model.Value; +import com.bigdata.btree.keys.IKeyBuilder; +import com.bigdata.btree.keys.KeyBuilder; +import com.bigdata.rdf.model.BigdataValue; + +/** + * Abstract base class for the inline representation of an RDF Value (the + * representation which is encoded in to the keys of the statement indices). + * This class is responsible for combining the {@link VTE} and the {@link DTE} + * together into the flags byte used as a common prefix for all keys formed from + * RDF Values regardless of whether they are based on an assigned term + * identifier or the inlining of the RDF Value. + * + * <h3>Binary record format</h3> + * + * We currently have 14 built-in (or intrinsic) data types (see {@link DTE}). + * Each of those types has a natural order which we can encode and decode from + * the B+Tree key. In general, there is a relatively limited set of interesting + * intrinsic codings, which is important since we will dedicate just 4 bits for + * to code the natural order of the value space, which is just only 16 + * distinctions. Given that we have 14 intrinsic data types, that leaves room + * for just two more. One of those bits is reserved against (see + * {@link DTE#Reserved1}). The other bit is reserved for extensibility in the + * framework itself as described below (see {@link DTE#Extension}). + * <p> + * The header byte contains various bit flags which are laid out as follows: + * + * <pre> + * [valueType] : 2 bits + * [inline] : 1 bit + * [extension] : 1 bit + * [dataTypeCode] : 4 bits + * </pre> + * + * <dl> + * <dt>valueType</dt> + * <dd>These 2 bits distinguish between URIs, Literals, Blank Nodes, and + * statement identifiers (SIDs). These bits are up front and therefore partition + * the key space first by the RDF Value type. See {@link VTE} which governs + * these bits.</dd> + * <dt>inline</dt> + * <dd>This bit indicates whether the value is inline or represented by a term + * identifier in the key. This bit is set based on how a given triple store or + * quad store instance is configured. However, because the bit is present in the + * flags, we know how to decode the key without reference to this configuration + * metadata.</dd> + * <dt>extension</dt> + * <dd>This bit is ignored (and should be zero) unless the RDF Value is a + * Literal with a data type URI which is being inlined. For data type literals, + * this bit is set if the actual data type is not one of those which we handle + * intrinsically but is one of those which has been registered (by the + * application) as an "extended" data type projected onto one of the intrinsic + * data types. Thus, this bit partitions the key space into the intrinsic data + * types and the extended data types.<br/> + * When <code>true</code>, this bit signals that information about the actual + * RDF Value data type will follow (see below). When <code>false</code>, the + * datatype URI is directly recoverable (for a data type Literal) from the + * <code>dataTypeCode</code>.</dd> + * <dt>dataTypeCode</dt> + * <dd>These 4 bits indicate the intrinsic data type for the inline value and + * are ignored (and should be zero) unless a data type Literal is being inlined. + * These bits partition the key space. However, since <code>extension</code> bit + * comes first this will not interleave inline values for intrinsic and extended + * data types having the same <code>dataTypeCode</code>. <br/> + * Note: The <code>dataTypeCode</code> <code>0xf</code> ({@link DTE#Extension)} + * is reserved for extending the set of intrinsic data types. When the code is + * <code>0xf</code> the next byte must be considered as well to determine the + * actual intrinsic data type code.</dd> + * </dl> + * + * <pre> + * ---------- byte boundary ---------- + * </pre> + * + * If <code>extension</code> was true, then then the next byte(s) encode + * information about the source data type URI and the key space will be + * partitioned based on the extended data type URI [the precise format of that + * data has not yet been decided -- see below]. + * + * <pre> + * ---------- byte boundary ---------- + * </pre> + * + * The unsigned byte[] representation of the value in the value space for one of + * the intrinsic types. The length of this byte[] may be directly determined + * from the [dataTypeCode] for most data types. However, for xsd:integer and + * xsd:decimal, the length is part of the representation. + * + * <pre> + * ---------- byte boundary and end of the record ---------- + * </pre> + * + * <h3>Extensibility</h3> + * + * There are three core use cases for extensibility: + * <dl> + * <dt>projections</dt> + * <dd>A projection takes an application specific data type and maps it onto one + * of the intrinsic data types (int, float, double, etc). Projections provide an + * extensible mechanism which allows an application to benefit from inline + * representation of RDF Values and allows the query optimizer to chose + * key-range scans for application defined data types if they can be projected + * onto intrinsic data types. For example, if you define an application specific + * data type <code>foo:milliseconds</code> representing milliseconds since the + * epoch, then the value space of that data type can be projected onto an + * <code>xsd:long</code>.</dd> + * <dt>enumerations</dt> + * <dd>An enumeration is an application specific data type having a specific set + * of values. Those values are then projected onto an intrinsic data type such + * as <code>byte</code> (256 distinctions) or <code>short</code> (64k + * distinctions). Enumerations make it possible to inline application specific + * data types while benefiting from XSD validation of those RDF Values. When an + * enumeration is registered, the order in which the members of the enumeration + * are given may optionally specify the natural order of that enumeration. The + * natural order is imposed by projecting the first member of the enumeration + * one ZERO, the second member onto ONE, etc. An enumeration with a natural + * order will be sorted based on that defined order and query optimizations may + * perform key-range scans informed by that natural order.<br/> + * Enumerations may be used in cases where you might otherwise use short + * character codes. For example, an enumeration could be defined for the two + * character abbreviations for the 50 US States. That enumeration could be + * mapped onto a single byte.</dd> + * <dt>custom indices</dt> + * <dd>The best example here is spatial data, which requires literals which + * represent points, rectangles, circles, arcs, clouds, etc to be inserted into + * special spatial indices. Queries must be aware of spatial data and must be + * rewritten to run against the appropriate spatial indices.<br/> + * Another use case would be carrying specialized indices for bioinformatics or + * genomics data.</dd> + * </dl> + * Note: Both projected and enumerated extensible data types MAY map many RDF + * Values onto the same internal value but each internal value MUST map onto a + * single RDF Value (materialization must be deterministic). This can be seen as + * normalization imposed by the database. + * + * @todo Note: There can be more than one URI for the same XSD datatype (there + * is more than one accepted namespace - see <a + * href="http://www.w3.org/TR/xmlschema-2/#namespaces"> XML Schema + * Datatypes namespaces </a>). I propose that we collapse these by default + * onto a canonical datatype URI. + * + * @todo For a extensible data type which is being projected onto an intrinsic + * data type we would need both (a) a method to project the RDF Value onto + * the appropriate intrinsic data type; and (b) a method to materialize an + * RDF Value from the inline representation. + * <p> + * If we put the registrations into their own index, then we could use a + * more compact representation (the term identifier of the datatype URI is + * 8 bytes, but we could do with 2 or 4 bytes). Alternatively, we could + * use the LongPacker to pack an unsigned long integer into as few bytes + * as possible. This would break the natural ordering across the + * dataTypeIds, but I can not see how that would matter since the term + * identifiers are essentially arbitrary anyway so their order has little + * value. + * + * @todo Can we inline the language code for a literal? I think that the + * language code must be ASCII and might be restricted to two characters. + * This might use up our {@link DTE#Reserved1} bit. + * + * @todo One consequences of this refactor is that you must use equals() rather + * than == to compare internal values, including term identifiers. This + * boils down to verifying that the two internal values are the same type + * (same VTE, DTE, etc) and have the same value (termId, long, etc). That + * can all be done rather quickly, but it is more overhead than testing a + * == b. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id: TestEncodeDecodeKeys.java 2753 2010-05-01 16:36:59Z thompsonbry + * $ + * @param <V> + * The generic type for the RDF {@link Value} implementation. + * @param <T> + * The generic type for the inline value. + */ +public abstract class AbstractIV<V extends BigdataValue, T> + implements IV<V, T> { + + /** + * + */ + private static final long serialVersionUID = 4710700756635103123L; + + /** + * Bit flags indicating the kind of RDF Value ({@link VTE}), whether the RDF + * Value is inline, whether this is an extension datatype, and the natural + * order and binary representation of the inline value ({@link See #DTE}). + * + * @see VTE + * @see DTE + */ + private final byte flags; + + /** + * The RDF Value type (URI, BNode, Literal or Statement) and the data type + * are combined and stored in a single byte together with whether the RDF + * value has been inlined (an <i>inline</i> bit) and whether the RDF Value + * is an extended data type (the <i>extension</> bit). The <i>vte</i> has 4 + * distinctions and is thus TWO (2) bits wide. The <i>dte</i> allows for up + * to 16 distinctions and is SIX (6) bits wide. The bits allocated to these + * sets of distinctions are combined within a single byte as follows: + * + * <pre> + * [vviedddd] + * </pre> + * + * where <code>v</code> is a {@link VTE} bit, <code>i</code> is the + * <i>inline</i> bit, <code>e</code> is the extension bit, and + * <code>d</code> is a {@link DTE} bit. + * + * @param vte + * The RDF Value type (URI, BNode, Literal, or Statement). + * @param inline + * <code>true</code> iff the RDF value will be represented inline + * in the key. When <code>false</code>, the term identifier of + * the RDF Value will be represented inline instead of its actual + * value. + * @param extension + * When <code>true</code>, the actual RDF data type URI differs + * from the intrinsic data type (the {@link DTE}) but has been + * projected onto the natural order of the intrinsic data type. + * @param dte + * The internal datatype for the RDF value (termId, xsd:int, + * xsd:long, xsd:float, xsd:double, etc). + * + * @see VTE + * @see DTE + */ + protected AbstractIV(final VTE vte, final boolean inline, + final boolean extension, final DTE dte) { + + // vte << 6 bits (it is in the high 2 bits). + // inline << 5 bits + // extension << 4 bits + // dte is in the low 4 bits. + this( (byte) ((// + (((int) vte.v) << VTE_SHIFT)// + | ((inline ? 1 : 0) << INLINE_SHIFT)// + | ((extension ? 1 : 0) << EXTENSION_SHIFT) // + | (dte.v)// + ) & 0xff)); + + } + + /** + * Constructor used when decoding since you already have the flags. + * + * @param flags + * The flags. + */ + protected AbstractIV(final byte flags) { + + this.flags = flags; + + } + + final public byte flags() { + + return flags; + + } + + /** + * The #of bits (SIX) that the {@link VTE} is shifted to + * the left when encoding it into the {@link #flags}. + */ + private final static int VTE_SHIFT = 6; + + /** + * The bit mask that is bit-wise ANDed with the flags in order to reveal the + * {@link VTE}. The high TWO (2) bits of the low byte in the mask are set. + */ + private final static int VTE_MASK = 0xC0; + + /** + * The #of bits (FIVE) that the <i>inline</i> flag is shifted to the left + * when encoding it into the {@link #flags}. + */ + private final static int INLINE_SHIFT = 5; + + /** + * The bit mask that is bit-wise ANDed with the flags in order to reveal + * the <code>inline</code> bit. + */ + private final static int INLINE_MASK = 0x20; + + /** + * The #of bits (FOUR) that the <i>extension</i> flag is shifted to the left + * when encoding it into the {@link #flags}. + */ + private final static int EXTENSION_SHIFT = 4; + + /** + * The bit mask that is bit-wise ANDed with the flags in order to reveal + * the <code>inline</code> bit. + */ + private final static int EXTENSION_MASK = 0x10; + + /** + * The bit mask that is bit-wise ANDed with the flags in order to reveal the + * {@link DTE}. The low FOUR (4) bits in the mask are set. + */ + private final static int DTE_MASK = 0x0f; + + /** + * Return <code>true</code> if the flags byte has its <code>inline</code> + * bit set. + * + * @param flags + * The flags byte. + */ + static public boolean isInline(final byte flags) { + + return (flags & INLINE_MASK) != 0; + + } + + /** + * FIXME I think we really need to be able to say from the flags whether + * an IV is null or non-null. The context position of statements can + * often be null. + * + * @param flags + * The flags byte. + */ + static public boolean isNull(final byte flags) { + + return false; + + } + + /** + * Return <code>true</code> if the flags byte has its <code>extension</code> + * bit set. + * + * @param flags + * The flags byte. + * + * @todo unit test for this. + */ + static public boolean isExtension(final byte flags) { + + return (flags & EXTENSION_MASK) != 0; + + } + + final public VTE getVTE() { + + return VTE + .valueOf((byte) (((flags & VTE_MASK) >>> VTE_SHIFT) & 0xff)); + + } + + /** + * Return the {@link DTE} for this {@link IV}. + */ + final public DTE getDTE() { + + return DTE.valueOf((byte) ((flags & DTE_MASK) & 0xff)); + + } + + /** + * Helper method decodes a flags byte as found in a statement index key to + * an {@link VTE}. + * + * @param flags + * The flags byte. + * + * @return The {@link VTE} + */ + static final public VTE getInternalValueTypeEnum( + final byte flags) { + + return VTE + .valueOf((byte) (((flags & VTE_MASK) >>> VTE_SHIFT) & 0xff)); + + } + + /** + * Helper method decodes a flags byte as found in a statement index key to + * an {@link DTE}. + * + * @param flags + * The flags byte. + * @return The {@link DTE} + */ + static public DTE getInternalDataTypeEnum(final byte flags) { + + return DTE.valueOf((byte) ((flags & DTE_MASK) & 0xff)); + + } + + final public boolean isLiteral() { + + return (flags & VTE_MASK) >>> VTE_SHIFT == VTE.LITERAL.v; + + } + + final public boolean isBNode() { + + return (flags & VTE_MASK) >>> VTE_SHIFT == VTE.BNODE.v; + + } + + final public boolean isURI() { + + return (flags & VTE_MASK) >>> VTE_SHIFT == VTE.URI.v; + + } + + final public boolean isStatement() { + + return (flags & VTE_MASK) >>> VTE_SHIFT == VTE.STATEMENT.v; + + } + + /** + * {@inheritDoc} + * <p> + * This implementation based on the <code>inline</code> bit flag. This can + * be overridden in many derived classes which have compile time knowledge + * of whether the RDF value is inline or not. + */ + public boolean isInline() { + return isInline(flags); + } + + /** + * {@inheritDoc} + * <p> + * This implementation based on the <code>extension</code> bit flag. Since + * the extension flag is only used for datatype literals, this method can be + * overridden in many derived classes which have compile time knowledge of + * whether the value is an RDF {@link Literal} or not. + */ + public boolean isExtension() { + return isExtension(flags); + } + + /** + * {@inheritDoc} + * <p> + * This implementation based on the <code>inline</code> bit flag. This can + * be overridden in many derived classes which have compile time knowledge + * of whether the RDF value is inline or not. + */ + public boolean isTermId() { + return !isInline(); + } + + final public boolean isNumeric() { + return isInline() && getDTE().isNumeric(); + } + + final public boolean isSignedNumeric() { + return isInline() && getDTE().isSignedNumeric(); + } + + final public boolean isUnsignedNumeric() { + return isInline() && getDTE().isUnsignedNumeric(); + } + + final public boolean isFixedNumeric() { + return isInline() && getDTE().isFixedNumeric(); + } + + final public boolean isBigNumeric() { + return isInline() && getDTE().isBigNumeric(); + } + + final public boolean isFloatingPointNumeric() { + return isInline() && getDTE().isFloatingPointNumeric(); + } + + /** + * Return a hash code based on the value of the point in the value space. + */ + abstract public int hashCode(); + + /** + * Return true iff the two values are the same point in the same value + * space. Points in different value spaces (as identified by different + * datatype URIs) are NOT equal even if they have the same value in the + * corresponding primitive data type. + */ + abstract public boolean equals(Object o); + + /** + * Imposes an ordering of IVs based on their natural sort ordering in the + * index as unsigned byte[]s. + */ + public int compareTo(final IV o) { + + if (this == o) + return 0; + + if (o == null) + return 1; + + /* + * First order based on the flags byte. This is the first byte of the + * key, so it always partitions the key space and hence provides the + * initial dimension of the total IV ordering. + * + * Note: This comparison will always sort out things such that URIs, + * Literals, BNodes, and SIDs will never compare as equals. It will also + * sort out extension types and datatype literals with a natural + * datatype. + */ + int ret = (int) flags - (int) o.flags(); + + if (ret < 0) + return -1; + + if (ret > 0) + return 1; + + if(this instanceof TermId) { + + final long tid1 = ((TermId<?>) this).getTermId(); + final long tid2 = ((TermId<?>) o).getTermId(); + + /* + * Note: logic avoids possible overflow of [long] by not computing + * the difference between two longs. + */ + + ret = tid1 < tid2 ? -1 : tid1 > tid2 ? 1 : 0; + + return ret; + + } + + if(isExtension()) { + /* + * @todo we may need to handle extension types here explicitly once + * their semantics are firmed up further. + */ + throw new UnsupportedOperationException(); + } + + /* + * At this point we are comparing two IVs of the same intrinsic + * datatype. That is, they are both datatype literals expressed using + * one of the predefined datatypes. These can be compared by directly + * comparing their primitive values. E.g., long to long, int to int, + * etc. + */ + return _compareTo(o); + + } + + /** + * Compare two {@link IV}s having the same intrinsic datatype. + * + * @todo This should probably be moved to + * {@link AbstractInlineIV} and implementations provided + * for each concrete instance of that abstract class. + */ + protected int _compareTo(IV o) { + + throw new UnsupportedOperationException(getClass().toString()); + + } + + /** + * {@inheritDoc} + * + * FIXME Handle extension types, probably in a subclass, and maybe requiring + * the caller to pass in an object with the context for the extension types. + */ + public IKeyBuilder encode(final IKeyBuilder keyBuilder) { + + // First emit the flags byte. + keyBuilder.append(flags); + + if (!isInline()) { + /* + * Since the RDF Value is not inline, it will be represented as a + * term identifier. + */ + keyBuilder.append(getTermId()); + return keyBuilder; + } + + /* + * Append the natural value type representation. + * + * Note: We have to handle the unsigned byte, short, int and long values + * specially to get the correct total key order. + */ + final DTE dte = getDTE(); + + final AbstractLiteralIV<?, ?> t = (AbstractLiteralIV<?, ?>) this; + + switch (dte) { + case XSDBoolean: + keyBuilder.append((byte) (t.booleanValue() ? 1 : 0)); + break; + case XSDByte: + keyBuilder.append(t.byteValue()); + break; + case XSDShort: + keyBuilder.append(t.shortValue()); + break; + case XSDInt: + keyBuilder.append(t.intValue()); + break; + case XSDLong: + keyBuilder.append(t.longValue()); + break; + case XSDFloat: + keyBuilder.append(t.floatValue()); + break; + case XSDDouble: + keyBuilder.append(t.doubleValue()); + break; + case XSDInteger: + keyBuilder.append(t.integerValue()); + break; + case XSDDecimal: + keyBuilder.append(t.decimalValue()); + break; + case UUID: + keyBuilder.append((UUID)t.getInlineValue()); + break; +// case XSDUnsignedByte: +// keyBuilder.appendUnsigned(t.byteValue()); +// break; +// case XSDUnsignedShort: +// keyBuilder.appendUnsigned(t.shortValue()); +// break; +// case XSDUnsignedInt: +// keyBuilder.appendUnsigned(t.intValue()); +// break; +// case XSDUnsignedLong: +// keyBuilder.appendUnsigned(t.longValue()); +// break; + default: + throw new AssertionError(toString()); + } + + return keyBuilder; + + } + +} Copied: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInlineIV.java (from rev 3258, branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInlineInternalValue.java) =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInlineIV.java (rev 0) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInlineIV.java 2010-07-21 19:48:42 UTC (rev 3260) @@ -0,0 +1,91 @@ +/** + +Copyright (C) SYSTAP, LLC 2006-2010. All rights reserved. + +Contact: + SYSTAP, LLC + 4501 Tower Road + Greensboro, NC 27410 + lic...@bi... + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +*/ +package com.bigdata.rdf.internal; + +import org.openrdf.model.Value; + +import com.bigdata.rdf.model.BigdataValue; + +/** + * Abstract base class for inline RDF values (literals, blank nodes, and + * statement identifiers can be inlined). + * <p> + * {@inheritDoc} + * + * @author <a href="mailto:tho...@us...">Bryan + * Thompson</a> + * @version $Id: TestEncodeDecodeKeys.java 2753 2010-05-01 16:36:59Z + * thompsonbry $ + */ +abstract public class AbstractInlineIV<V extends BigdataValue, T> + extends AbstractIV<V, T> { + + /** + * + */ + private static final long serialVersionUID = -2847844163772097836L; + + protected AbstractInlineIV(final VTE vte, + final DTE dte) { + + super(vte, true/* inline */, false/* extension */, dte); + + } + + /** + * Returns the String-value of a Value object. This returns either a + * Literal's label, a URI's URI or a BNode's ID. + * + * @see Value#stringValue() + */ + abstract public String stringValue(); + + /** + * Always returns <code>true</code> since the value is inline. + */ + final public boolean isInline() { + return true; + } + + /** + * Always returns <code>false</code> since the value is inline. + */ + final public boolean isTermId() { + return false; + } + + /** + * Always returns <code>false</code> since the value is inline. + */ + final public boolean isNull() { + return false; + } + + public String toString() { + + return super.getDTE() + "(" + stringValue() + ")"; + + } + +} \ No newline at end of file Deleted: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInlineInternalValue.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInlineInternalValue.java 2010-07-21 18:04:22 UTC (rev 3259) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInlineInternalValue.java 2010-07-21 19:48:42 UTC (rev 3260) @@ -1,91 +0,0 @@ -/** - -Copyright (C) SYSTAP, LLC 2006-2010. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -package com.bigdata.rdf.internal; - -import org.openrdf.model.Value; - -import com.bigdata.rdf.model.BigdataValue; - -/** - * Abstract base class for inline RDF values (literals, blank nodes, and - * statement identifiers can be inlined). - * <p> - * {@inheritDoc} - * - * @author <a href="mailto:tho...@us...">Bryan - * Thompson</a> - * @version $Id: TestEncodeDecodeKeys.java 2753 2010-05-01 16:36:59Z - * thompsonbry $ - */ -abstract public class AbstractInlineInternalValue<V extends BigdataValue, T> - extends AbstractInternalValue<V, T> { - - /** - * - */ - private static final long serialVersionUID = -2847844163772097836L; - - protected AbstractInlineInternalValue(final VTE vte, - final DTE dte) { - - super(vte, true/* inline */, false/* extension */, dte); - - } - - /** - * Returns the String-value of a Value object. This returns either a - * Literal's label, a URI's URI or a BNode's ID. - * - * @see Value#stringValue() - */ - abstract public String stringValue(); - - /** - * Always returns <code>true</code> since the value is inline. - */ - final public boolean isInline() { - return true; - } - - /** - * Always returns <code>false</code> since the value is inline. - */ - final public boolean isTermId() { - return false; - } - - /** - * Always returns <code>false</code> since the value is inline. - */ - final public boolean isNull() { - return false; - } - - public String toString() { - - return super.getDTE() + "(" + stringValue() + ")"; - - } - -} \ No newline at end of file Deleted: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInternalValue.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInternalValue.java 2010-07-21 18:04:22 UTC (rev 3259) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/AbstractInternalValue.java 2010-07-21 19:48:42 UTC (rev 3260) @@ -1,680 +0,0 @@ -/** - -Copyright (C) SYSTAP, LLC 2006-2010. All rights reserved. - -Contact: - SYSTAP, LLC - 4501 Tower Road - Greensboro, NC 27410 - lic...@bi... - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ -/* - * Created on May 3, 2010 - */ - -package com.bigdata.rdf.internal; - -import java.io.DataOutput; -import java.io.IOException; -import java.util.UUID; -import org.deri.iris.basics.Literal; -import org.openrdf.model.Value; -import com.bigdata.btree.keys.IKeyBuilder; -import com.bigdata.btree.keys.KeyBuilder; -import com.bigdata.rdf.model.BigdataValue; - -/** - * Abstract base class for the inline representation of an RDF Value (the - * representation which is encoded in to the keys of the statement indices). - * This class is responsible for combining the {@link VTE} and the {@link DTE} - * together into the flags byte used as a common prefix for all keys formed from - * RDF Values regardless of whether they are based on an assigned term - * identifier or the inlining of the RDF Value. - * - * <h3>Binary record format</h3> - * - * We currently have 14 built-in (or intrinsic) data types (see {@link DTE}). - * Each of those types has a natural order which we can encode and decode from - * the B+Tree key. In general, there is a relatively limited set of interesting - * intrinsic codings, which is important since we will dedicate just 4 bits for - * to code the natural order of the value space, which is just only 16 - * distinctions. Given that we have 14 intrinsic data types, that leaves room - * for just two more. One of those bits is reserved against (see - * {@link DTE#Reserved1}). The other bit is reserved for extensibility in the - * framework itself as described below (see {@link DTE#Extension}). - * <p> - * The header byte contains various bit flags which are laid out as follows: - * - * <pre> - * [valueType] : 2 bits - * [inline] : 1 bit - * [extension] : 1 bit - * [dataTypeCode] : 4 bits - * </pre> - * - * <dl> - * <dt>valueType</dt> - * <dd>These 2 bits distinguish between URIs, Literals, Blank Nodes, and - * statement identifiers (SIDs). These bits are up front and therefore partition - * the key space first by the RDF Value type. See {@link VTE} which governs - * these bits.</dd> - * <dt>inline</dt> - * <dd>This bit indicates whether the value is inline or represented by a term - * identifier in the key. This bit is set based on how a given triple store or - * quad store instance is configured. However, because the bit is present in the - * flags, we know how to decode the key without reference to this configuration - * metadata.</dd> - * <dt>extension</dt> - * <dd>This bit is ignored (and should be zero) unless the RDF Value is a - * Literal with a data type URI which is being inlined. For data type literals, - * this bit is set if the actual data type is not one of those which we handle - * intrinsically but is one of those which has been registered (by the - * application) as an "extended" data type projected onto one of the intrinsic - * data types. Thus, this bit partitions the key space into the intrinsic data - * types and the extended data types.<br/> - * When <code>true</code>, this bit signals that information about the actual - * RDF Value data type will follow (see below). When <code>false</code>, the - * datatype URI is directly recoverable (for a data type Literal) from the - * <code>dataTypeCode</code>.</dd> - * <dt>dataTypeCode</dt> - * <dd>These 4 bits indicate the intrinsic data type for the inline value and - * are ignored (and should be zero) unless a data type Literal is being inlined. - * These bits partition the key space. However, since <code>extension</code> bit - * comes first this will not interleave inline values for intrinsic and extended - * data types having the same <code>dataTypeCode</code>. <br/> - * Note: The <code>dataTypeCode</code> <code>0xf</code> ({@link DTE#Extension)} - * is reserved for extending the set of intrinsic data types. When the code is - * <code>0xf</code> the next byte must be considered as well to determine the - * actual intrinsic data type code.</dd> - * </dl> - * - * <pre> - * ---------- byte boundary ---------- - * </pre> - * - * If <code>extension</code> was true, then then the next byte(s) encode - * information about the source data type URI and the key space will be - * partitioned based on the extended data type URI [the precise format of that - * data has not yet been decided -- see below]. - * - * <pre> - * ---------- byte boundary ---------- - * </pre> - * - * The unsigned byte[] representation of the value in the value space for one of - * the intrinsic types. The length of this byte[] may be directly determined - * from the [dataTypeCode] for most data types. However, for xsd:integer and - * xsd:decimal, the length is part of the representation. - * - * <pre> - * ---------- byte boundary and end of the record ---------- - * </pre> - * - * <h3>Extensibility</h3> - * - * There are three core use cases for extensibility: - * <dl> - * <dt>projections</dt> - * <dd>A projection takes an application specific data type and maps it onto one - * of the intrinsic data types (int, float, double, etc). Projections provide an - * extensible mechanism which allows an application to benefit from inline - * representation of RDF Values and allows the query optimizer to chose - * key-range scans for application defined data types if they can be projected - * onto intrinsic data types. For example, if you define an application specific - * data type <code>foo:milliseconds</code> representing milliseconds since the - * epoch, then the value space of that data type can be projected onto an - * <code>xsd:long</code>.</dd> - * <dt>enumerations</dt> - * <dd>An enumeration is an application specific data type having a specific set - * of values. Those values are then projected onto an intrinsic data type such - * as <code>byte</code> (256 distinctions) or <code>short</code> (64k - * distinctions). Enumerations make it possible to inline application specific - * data types while benefiting from XSD validation of those RDF Values. When an - * enumeration is registered, the order in which the members of the enumeration - * are given may optionally specify the natural order of that enumeration. The - * natural order is imposed by projecting the first member of the enumeration - * one ZERO, the second member onto ONE, etc. An enumeration with a natural - * order will be sorted based on that defined order and query optimizations may - * perform key-range scans informed by that natural order.<br/> - * Enumerations may be used in cases where you might otherwise use short - * character codes. For example, an enumeration could be defined for the two - * character abbreviations for the 50 US States. That enumeration could be - * mapped onto a single byte.</dd> - * <dt>custom indices</dt> - * <dd>The best example here is spatial data, which requires literals which - * represent points, rectangles, circles, arcs, clouds, etc to be inserted into - * special spatial indices. Queries must be aware of spatial data and must be - * rewritten to run against the appropriate spatial indices.<br/> - * Another use case would be carrying specialized indices for bioinformatics or - * genomics data.</dd> - * </dl> - * Note: Both projected and enumerated extensible data types MAY map many RDF - * Values onto the same internal value but each internal value MUST map onto a - * single RDF Value (materialization must be deterministic). This can be seen as - * normalization imposed by the database. - * - * @todo Note: There can be more than one URI for the same XSD datatype (there - * is more than one accepted namespace - see <a - * href="http://www.w3.org/TR/xmlschema-2/#namespaces"> XML Schema - * Datatypes namespaces </a>). I propose that we collapse these by default - * onto a canonical datatype URI. - * - * @todo For a extensible data type which is being projected onto an intrinsic - * data type we would need both (a) a method to project the RDF Value onto - * the appropriate intrinsic data type; and (b) a method to materialize an - * RDF Value from the inline representation. - * <p> - * If we put the registrations into their own index, then we could use a - * more compact representation (the term identifier of the datatype URI is - * 8 bytes, but we could do with 2 or 4 bytes). Alternatively, we could - * use the LongPacker to pack an unsigned long integer into as few bytes - * as possible. This would break the natural ordering across the - * dataTypeIds, but I can not see how that would matter since the term - * identifiers are essentially arbitrary anyway so their order has little - * value. - * - * @todo Can we inline the language code for a literal? I think that the - * language code must be ASCII and might be restricted to two characters. - * This might use up our {@link DTE#Reserved1} bit. - * - * @todo One consequences of this refactor is that you must use equals() rather - * than == to compare internal values, including term identifiers. This - * boils down to verifying that the two internal values are the same type - * (same VTE, DTE, etc) and have the same value (termId, long, etc). That - * can all be done rather quickly, but it is more overhead than testing a - * == b. - * - * @author <a href="mailto:tho...@us...">Bryan Thompson</a> - * @version $Id: TestEncodeDecodeKeys.java 2753 2010-05-01 16:36:59Z thompsonbry - * $ - * @param <V> - * The generic type for the RDF {@link Value} implementation. - * @param <T> - * The generic type for the inline value. - */ -public abstract class AbstractInternalValue<V extends BigdataValue, T> - implements IV<V, T> { - - /** - * - */ - private static final long serialVersionUID = 4710700756635103123L; - - /** - * Bit flags indicating the kind of RDF Value ({@link VTE}), whether the RDF - * Value is inline, whether this is an extension datatype, and the natural - * order and binary representation of the inline value ({@link See #DTE}). - * - * @see VTE - * @see DTE - */ - private final byte flags; - - /** - * The RDF Value type (URI, BNode, Literal or Statement) and the data type - * are combined and stored in a single byte together with whether the RDF - * value has been inlined (an <i>inline</i> bit) and whether the RDF Value - * is an extended data type (the <i>extension</> bit). The <i>vte</i> has 4 - * distinctions and is thus TWO (2) bits wide. The <i>dte</i> allows for up - * to 16 distinctions and is SIX (6) bits wide. The bits allocated to these - * sets of distinctions are combined within a single byte as follows: - * - * <pre> - * [vviedddd] - * </pre> - * - * where <code>v</code> is a {@link VTE} bit, <code>i</code> is the - * <i>inline</i> bit, <code>e</code> is the extension bit, and - * <code>d</code> is a {@link DTE} bit. - * - * @param vte - * The RDF Value type (URI, BNode, Literal, or Statement). - * @param inline - * <code>true</code> iff the RDF value will be represented inline - * in the key. When <code>false</code>, the term identifier of - * the RDF Value will be represented inline instead of its actual - * value. - * @param extension - * When <code>true</code>, the actual RDF data type URI differs - * from the intrinsic data type (the {@link DTE}) but has been - * projected onto the natural order of the intrinsic data type. - * @param dte - * The internal datatype for the RDF value (termId, xsd:int, - * xsd:long, xsd:float, xsd:double, etc). - * - * @see VTE - * @see DTE - */ - protected AbstractInternalValue(final VTE vte, final boolean inline, - final boolean extension, final DTE dte) { - - // vte << 6 bits (it is in the high 2 bits). - // inline << 5 bits - // extension << 4 bits - // dte is in the low 4 bits. - this( (byte) ((// - (((int) vte.v) << VTE_SHIFT)// - | ((inline ? 1 : 0) << INLINE_SHIFT)// - | ((extension ? 1 : 0) << EXTENSION_SHIFT) // - | (dte.v)// - ) & 0xff)); - - } - - /** - * Constructor used when decoding since you already have the flags. - * - * @param flags - * The flags. - */ - protected AbstractInternalValue(final byte flags) { - - this.flags = flags; - - } - - final public byte flags() { - - return flags; - - } - - /** - * The #of bits (SIX) that the {@link VTE} is shifted to - * the left when encoding it into the {@link #flags}. - */ - private final static int VTE_SHIFT = 6; - - /** - * The bit mask that is bit-wise ANDed with the flags in order to reveal the - * {@link VTE}. The high TWO (2) bits of the low byte in the mask are set. - */ - private final static int VTE_MASK = 0xC0; - - /** - * The #of bits (FIVE) that the <i>inline</i> flag is shifted to the left - * when encoding it into the {@link #flags}. - */ - private final static int INLINE_SHIFT = 5; - - /** - * The bit mask that is bit-wise ANDed with the flags in order to reveal - * the <code>inline</code> bit. - */ - private final static int INLINE_MASK = 0x20; - - /** - * The #of bits (FOUR) that the <i>extension</i> flag is shifted to the left - * when encoding it into the {@link #flags}. - */ - private final static int EXTENSION_SHIFT = 4; - - /** - * The bit mask that is bit-wise ANDed with the flags in order to reveal - * the <code>inline</code> bit. - */ - private final static int EXTENSION_MASK = 0x10; - - /** - * The bit mask that is bit-wise ANDed with the flags in order to reveal the - * {@link DTE}. The low FOUR (4) bits in the mask are set. - */ - private final static int DTE_MASK = 0x0f; - - /** - * Return <code>true</code> if the flags byte has its <code>inline</code> - * bit set. - * - * @param flags - * The flags byte. - */ - static public boolean isInline(final byte flags) { - - return (flags & INLINE_MASK) != 0; - - } - - /** - * FIXME I think we really need to be able to say from the flags whether - * an IV is null or non-null. The context position of statements can - * often be null. - * - * @param flags - * The flags byte. - */ - static public boolean isNull(final byte flags) { - - return false; - - } - - /** - * Return <code>true</code> if the flags byte has its <code>extension</code> - * bit set. - * - * @param flags - * The flags byte. - * - * @todo unit test for this. - */ - static public boolean isExtension(final byte flags) { - - return (flags & EXTENSION_MASK) != 0; - - } - - final public VTE getVTE() { - - return VTE - .valueOf((byte) (((flags & VTE_MASK) >>> VTE_SHIFT) & 0xff)); - - } - - /** - * Return the {@link DTE} for this {@link IV}. - */ - final public DTE getDTE() { - - return DTE.valueOf((byte) ((flags & DTE_MASK) & 0xff)); - - } - - /** - * Helper method decodes a flags byte as found in a statement index key to - * an {@link VTE}. - * - * @param flags - * The flags byte. - * - * @return The {@link VTE} - */ - static final public VTE getInternalValueTypeEnum( - final byte flags) { - - return VTE - .valueOf((byte) (((flags & VTE_MASK) >>> VTE_SHIFT) & 0xff)); - - } - - /** - * Helper method decodes a flags byte as found in a statement index key to - * an {@link DTE}. - * - * @param flags - * The flags byte. - * @return The {@link DTE} - */ - static public DTE getInternalDataTypeEnum(final byte flags) { - - return DTE.valueOf((byte) ((flags & DTE_MASK) & 0xff)); - - } - - final public boolean isLiteral() { - - return (flags & VTE_MASK) >>> VTE_SHIFT == VTE.LITERAL.v; - - } - - final public boolean isBNode() { - - return (flags & VTE_MASK) >>> VTE_SHIFT == VTE.BNODE.v; - - } - - final public boolean isURI() { - - return (flags & VTE_MASK) >>> VTE_SHIFT == VTE.URI.v; - - } - - final public boolean isStatement() { - - return (flags & VTE_MASK) >>> VTE_SHIFT == VTE.STATEMENT.v; - - } - - /** - * {@inheritDoc} - * <p> - * This implementation based on the <code>inline</code> bit flag. This can - * be overridden in many derived classes which have compile time knowledge - * of whether the RDF value is inline or not. - */ - public boolean isInline() { - return isInline(flags); - } - - /** - * {@inheritDoc} - * <p> - * This implementation based on the <code>extension</code> bit flag. Since - * the extension flag is only used for datatype literals, this method can be - * overridden in many derived classes which have compile time knowledge of - * whether the value is an RDF {@link Literal} or not. - */ - public boolean isExtension() { - return isExtension(flags); - } - - /** - * {@inheritDoc} - * <p> - * This implementation based on the <code>inline</code> bit flag. This can - * be overridden in many derived classes which have compile time knowledge - * of whether the RDF value is inline or not. - */ - public boolean isTermId() { - return !isInline(); - } - - final public boolean isNumeric() { - return isInline() && getDTE().isNumeric(); - } - - final public boolean isSignedNumeric() { - return isInline() && getDTE().isSignedNumeric(); - } - - final public boolean isUnsignedNumeric() { - return isInline() && getDTE().isUnsignedNumeric(); - } - - final public boolean isFixedNumeric() { - return isInline() && getDTE().isFixedNumeric(); - } - - final public boolean isBigNumeric() { - return isInline() && g... [truncated message content] |
From: <mrp...@us...> - 2010-07-21 18:04:29
|
Revision: 3259 http://bigdata.svn.sourceforge.net/bigdata/?rev=3259&view=rev Author: mrpersonick Date: 2010-07-21 18:04:22 +0000 (Wed, 21 Jul 2010) Log Message: ----------- test cases for BigDecimal Modified Paths: -------------- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/keys/IKeyBuilder.java branches/LEXICON_REFACTOR_BRANCH/bigdata/src/test/com/bigdata/btree/keys/TestKeyBuilder.java Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/keys/IKeyBuilder.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/keys/IKeyBuilder.java 2010-07-21 15:00:16 UTC (rev 3258) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/keys/IKeyBuilder.java 2010-07-21 18:04:22 UTC (rev 3259) @@ -28,11 +28,11 @@ package com.bigdata.btree.keys; +import java.math.BigDecimal; import java.math.BigInteger; import java.util.Locale; import java.util.Properties; import java.util.UUID; - import com.bigdata.btree.BytesUtil; import com.bigdata.btree.keys.KeyBuilder.Options; @@ -446,6 +446,17 @@ public IKeyBuilder append(final BigInteger i); /** + * Encode a {@link BigDecimal} into an unsigned byte[] and append it into + * the key buffer. + * + * @param The + * {@link BigDecimal} value. + * + * @return The unsigned byte[]. + */ + public IKeyBuilder append(final BigDecimal d); + + /** * Append the value to the buffer, encoding it as appropriate based on the * class of the object. This method handles all of the primitive data types * plus {@link UUID} and Unicode {@link String}s. Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/test/com/bigdata/btree/keys/TestKeyBuilder.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/test/com/bigdata/btree/keys/TestKeyBuilder.java 2010-07-21 15:00:16 UTC (rev 3258) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/test/com/bigdata/btree/keys/TestKeyBuilder.java 2010-07-21 18:04:22 UTC (rev 3259) @@ -27,6 +27,7 @@ package com.bigdata.btree.keys; +import java.math.BigDecimal; import java.math.BigInteger; import java.util.Arrays; import java.util.Comparator; @@ -37,9 +38,7 @@ import java.util.Set; import java.util.TreeMap; import java.util.UUID; - import junit.framework.TestCase2; - import com.bigdata.btree.BytesUtil; import com.bigdata.btree.BytesUtil.UnsignedByteArrayComparator; @@ -1527,6 +1526,11 @@ } + private BigDecimal decodeBigDecimal(final byte[] key) { + + return KeyBuilder.decodeBigDecimal(0/*offset*/, key); + } + /** * FIXME The 2 byte run length limits the maximum key length for a * BigInteger to ~32k. Write unit tests which verify that we detect and @@ -1552,6 +1556,12 @@ } + private byte[] encodeBigDecimal(final BigDecimal d) { + + return new KeyBuilder().append(d).getKey(); + + } + protected void doEncodeDecodeTest(final BigInteger expected) { byte[] encoded = null; @@ -1599,6 +1609,53 @@ } + protected void doEncodeDecodeTest(final BigDecimal expected) { + + byte[] encoded = null; + BigDecimal actual = null; + Throwable cause = null; + try { + + encoded = encodeBigDecimal(expected); + + actual = decodeBigDecimal(encoded); + + } catch (Throwable t) { + + cause = t; + + } + + if (cause != null || !expected.equals(actual)) { + + final String msg = "BigDecimal" + // + "\nexpected=" + expected + // +// "\nsigned =" + Arrays.toString(expected.toByteArray())+// +// "\nunsigned=" + BytesUtil.toString(expected.toByteArray())+// + "\nencoded =" + BytesUtil.toString(encoded) + // + "\nactual =" + actual// +// +(actual != null ? "\nactualS =" +// + Arrays.toString(actual.toByteArray()) +// + // +// "\nactualU =" +// + BytesUtil.toString(actual.toByteArray()) // +// : "") + ; + + if (cause == null) { + + fail(msg); + + } else { + + fail(msg, cause); + + } + + } + + } + protected void doLTTest(final BigInteger i1, final BigInteger i2) { final byte[] k1 = encodeBigInteger(i1); @@ -1625,6 +1682,32 @@ } + protected void doLTTest(final BigDecimal i1, final BigDecimal i2) { + + final byte[] k1 = encodeBigDecimal(i1); + + final byte[] k2 = encodeBigDecimal(i2); + + final int ret = BytesUtil.compareBytes(k1, k2); + + if (ret >= 0) { + + fail("BigDecimal" + // + "\ni1=" + i1 + // + "\ni2=" + i2 + // +// "\ns1=" + Arrays.toString(i1.toByteArray())+// +// "\ns2=" + Arrays.toString(i2.toByteArray())+// +// "\nu1=" + BytesUtil.toString(i1.toByteArray())+// +// "\nu2=" + BytesUtil.toString(i2.toByteArray())+// + "\nk1=" + BytesUtil.toString(k1) + // + "\nk2=" + BytesUtil.toString(k2) + // + "\nret=" + (ret == 0 ? "EQ" : (ret < 0 ? "LT" : "GT"))// + ); + + } + + } + public void test_BigInteger_383() { final BigInteger v1 = BigInteger.valueOf(383); @@ -1633,6 +1716,14 @@ } + public void test_BigDecimal_383() { + + final BigDecimal v1 = BigDecimal.valueOf(383.0000000000000001); + final BigDecimal v2 = BigDecimal.valueOf(383.0000000000000002); + doLTTest(v1,v2); + + } + public void test_BigInteger_m1() { final BigInteger v = BigInteger.valueOf(-1); @@ -1641,6 +1732,14 @@ } + public void test_BigDecimal_m1() { + + final BigDecimal v = BigDecimal.valueOf(-1.0000000000000001); + + doEncodeDecodeTest(v); + + } + /** * Unit tests for encoding {@link BigInteger} keys. */ @@ -1705,6 +1804,65 @@ } /** + * Unit tests for encoding {@link BigDecimal} keys. + */ + public void test_bigDecimalKey() { + + doEncodeDecodeTest(BigDecimal.valueOf(0)); + + doEncodeDecodeTest(BigDecimal.valueOf(1.00000000001)); + doEncodeDecodeTest(BigDecimal.valueOf(8.00000000001)); + doEncodeDecodeTest(BigDecimal.valueOf(255.00000000001)); + doEncodeDecodeTest(BigDecimal.valueOf(256.00000000001)); + doEncodeDecodeTest(BigDecimal.valueOf(512.00000000001)); + doEncodeDecodeTest(BigDecimal.valueOf(1028.00000000001)); + + doEncodeDecodeTest(BigDecimal.valueOf(-1.00000000001)); + doEncodeDecodeTest(BigDecimal.valueOf(-8.00000000001)); + doEncodeDecodeTest(BigDecimal.valueOf(-255.00000000001)); + doEncodeDecodeTest(BigDecimal.valueOf(-256.00000000001)); + doEncodeDecodeTest(BigDecimal.valueOf(-512.00000000001)); + doEncodeDecodeTest(BigDecimal.valueOf(-1028.00000000001)); + + doEncodeDecodeTest(BigDecimal.valueOf(Double.MIN_VALUE)); + doEncodeDecodeTest(BigDecimal.valueOf(Double.MAX_VALUE)); + doEncodeDecodeTest(BigDecimal.valueOf(Double.MIN_VALUE - 1)); + doEncodeDecodeTest(BigDecimal.valueOf(Double.MAX_VALUE + 1)); + + doLTTest(BigDecimal.valueOf(1.01), BigDecimal.valueOf(2.01)); + + doLTTest(BigDecimal.valueOf(0.01), BigDecimal.valueOf(1.01)); + + doLTTest(BigDecimal.valueOf(-1.01), BigDecimal.valueOf(0.01)); + + doLTTest(BigDecimal.valueOf(-2.01), BigDecimal.valueOf(-1.01)); + + doLTTest(BigDecimal.valueOf(10.01), BigDecimal.valueOf(11.01)); + + doLTTest(BigDecimal.valueOf(258.01), BigDecimal.valueOf(259.01)); + + doLTTest(BigDecimal.valueOf(3.01), BigDecimal.valueOf(259.01)); + + doLTTest(BigDecimal.valueOf(383.01), BigDecimal.valueOf(383.02)); + + for (int i = 0; i <= 516; i++) { + + doEncodeDecodeTest(BigDecimal.valueOf(i)); + + doLTTest(BigDecimal.valueOf(i), BigDecimal.valueOf(i + 1)); + + } + for (int i = 0; i >= -516; i--) { + + doEncodeDecodeTest(BigDecimal.valueOf(i)); + + doLTTest(BigDecimal.valueOf(i), BigDecimal.valueOf(i + 1)); + + } + + } + + /** * Stress test with random <code>long</code> values. */ public void test_BigInteger_stress_long_values() { @@ -1766,6 +1924,67 @@ } /** + * Stress test with random <code>double</code> values. + */ + public void test_BigDecimal_stress_long_values() { + + final Random r = new Random(); + + for (int i = 0; i < 100000; i++) { + + final BigDecimal t1 = BigDecimal.valueOf(r.nextDouble()); + + final BigDecimal v2 = BigDecimal.valueOf(Math.abs(r.nextDouble())); + + final BigDecimal v4 = BigDecimal.valueOf(r.nextDouble()); + + // x LT t1 + final BigDecimal t2 = t1.subtract(v2); + final BigDecimal t4 = t1.subtract(BigDecimal.valueOf(5)); + final BigDecimal t5 = t1.subtract(BigDecimal.valueOf(9)); + + // t1 LT x + final BigDecimal t3 = t1.add(v2); + final BigDecimal t6 = t1.add(BigDecimal.valueOf(5)); + final BigDecimal t7 = t1.add(BigDecimal.valueOf(9)); + + doEncodeDecodeTest(t1); + doEncodeDecodeTest(t2); + doEncodeDecodeTest(t3); + doEncodeDecodeTest(t4); + doEncodeDecodeTest(t5); + doEncodeDecodeTest(t6); + doEncodeDecodeTest(t7); + + doLTTest(t2, t1); + doLTTest(t4, t1); + doLTTest(t5, t1); + + doLTTest(t1, t3); + doLTTest(t1, t6); + doLTTest(t1, t7); + + final int ret = t1.compareTo(v4); + + if (ret < 0) { + + doLTTest(t1, v4); + + } else if (ret > 0) { + + doLTTest(v4, t1); + + } else { + + // equal + + } + + } + + } + + /** * Stress test with random byte[]s from which we then construct * {@link BigInteger}s. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-07-21 15:00:24
|
Revision: 3258 http://bigdata.svn.sourceforge.net/bigdata/?rev=3258&view=rev Author: mrpersonick Date: 2010-07-21 15:00:16 +0000 (Wed, 21 Jul 2010) Log Message: ----------- stubs for BigDecimal Modified Paths: -------------- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/keys/KeyBuilder.java Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/keys/KeyBuilder.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/keys/KeyBuilder.java 2010-07-21 12:59:52 UTC (rev 3257) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/btree/keys/KeyBuilder.java 2010-07-21 15:00:16 UTC (rev 3258) @@ -28,14 +28,13 @@ package com.bigdata.btree.keys; import java.io.UnsupportedEncodingException; +import java.math.BigDecimal; import java.math.BigInteger; import java.text.Collator; import java.util.Locale; import java.util.Properties; import java.util.UUID; - import org.apache.log4j.Logger; - import com.bigdata.btree.BytesUtil; import com.bigdata.btree.ITuple; import com.bigdata.btree.ITupleSerializer; @@ -946,6 +945,11 @@ } + // FIXME append(BigDecimal) + public KeyBuilder append(final BigDecimal d) { + throw new UnsupportedOperationException(); + } + /* * static helper methods. */ @@ -1377,6 +1381,11 @@ } + // FIXME decodeBigDecimal(int, byte[]) + static public BigDecimal decodeBigDecimal(final int offset, final byte[] key) { + throw new UnsupportedOperationException(); + } + public static IKeyBuilder newInstance() { return newInstance(DEFAULT_INITIAL_CAPACITY); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2010-07-21 13:00:04
|
Revision: 3257 http://bigdata.svn.sourceforge.net/bigdata/?rev=3257&view=rev Author: thompsonbry Date: 2010-07-21 12:59:52 +0000 (Wed, 21 Jul 2010) Log Message: ----------- Merged updates from BrianM and attempted to reconcile the standalone-XXX targets for benchmarking a federation running on a single machine with the LookupStarter as used by the unit tests. I am still missing something critical about how to setup the LUS as it fails with exceptions such as below. standalone-setup: standalone-startLookup: [java] Jul 21, 2010 8:58:57 AM com.sun.jini.start.HTTPDStatus httpdWarning [java] WARNING: Problem accessing desired URL[http://192.168.1.102:23333/reggie-dl.jar]: java.net.ConnectException: Connection refused: connect. [java] Jul 21, 2010 8:58:58 AM com.sun.jini.start.HTTPDStatus httpdWarning [java] WARNING: Problem accessing desired URL[http://192.168.1.102:23333/jsk-dl.jar]: java.net.ConnectException: Connection refused: connect. [java] Jul 21, 2010 8:59:00 AM com.sun.jini.reggie.RegistrarImpl init [java] INFO: started Reggie: c8778e6d-8df4-468b-bf41-96167ed1a2d5, [testFed], ConstrainableLookupLocator[[jini://192.168.1.102/], [null]] [java] java.lang.ClassNotFoundException: com.sun.jini.reggie.ConstrainableRegistrarProxy (could not determine preferred setting; original codebase: "http://192.168.1.102:23333/reggie-dl.jar http://192.168.1.102:23333/jsk-dl.jar") [java] at net.jini.loader.pref.PreferredClassProvider.loadClass(PreferredClassProvider.java:580) [java] at java.rmi.server.RMIClassLoader.loadClass(RMIClassLoader.java:247) [java] at sun.rmi.server.MarshalInputStream.resolveClass(MarshalInputStream.java:197) [java] at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575) [java] at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496) [java] at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732) [java] at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329) [java] at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351) [java] at java.rmi.MarshalledObject.get(MarshalledObject.java:142) [java] at com.sun.jini.start.NonActivatableServiceDescriptor.create(NonActivatableServiceDescriptor.java:644) [java] at com.bigdata.service.jini.util.LookupStarter.startLookupService(LookupStarter.java:228) [java] at com.bigdata.service.jini.util.LookupStarter.access$100(LookupStarter.java:58) [java] at com.bigdata.service.jini.util.LookupStarter$LookupStartThread.run(LookupStarter.java:152) [java] Caused by: java.net.ConnectException: Connection refused: connect [java] at java.net.PlainSocketImpl.socketConnect(Native Method) [java] at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) [java] at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) [java] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) [java] at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) [java] at java.net.Socket.connect(Socket.java:525) [java] at java.net.Socket.connect(Socket.java:475) [java] at sun.net.NetworkClient.doConnect(NetworkClient.java:163) [java] at sun.net.www.http.HttpClient.openServer(HttpClient.java:394) [java] at sun.net.www.http.HttpClient.openServer(HttpClient.java:529) [java] at sun.net.www.http.HttpClient.<init>(HttpClient.java:233) [java] at sun.net.www.http.HttpClient.New(HttpClient.java:306) [java] at sun.net.www.http.HttpClient.New(HttpClient.java:323) [java] at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:860) [java] at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:801) [java] at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:726) [java] at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1049) [java] at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:373) [java] at net.jini.loader.pref.PreferredClassLoader.getPreferredConnection(PreferredClassLoader.java:656) [java] at net.jini.loader.pref.PreferredClassLoader.jarExists(PreferredClassLoader.java:584) [java] at net.jini.loader.pref.PreferredClassLoader.getPreferredInputStream(PreferredClassLoader.java:534) [java] at net.jini.loader.pref.PreferredClassLoader.initializePreferredResources(PreferredClassLoader.java:482) [java] at net.jini.loader.pref.PreferredClassLoader.isPreferredResource0(PreferredClassLoader.java:760) [java] at net.jini.loader.pref.PreferredClassLoader.access$100(PreferredClassLoader.java:226) [java] at net.jini.loader.pref.PreferredClassLoader$3.run(PreferredClassLoader.java:742) [java] at java.security.AccessController.doPrivileged(Native Method) [java] at net.jini.loader.pref.PreferredClassLoader.isPreferredResource(PreferredClassLoader.java:739) [java] at net.jini.loader.pref.PreferredClassProvider.loadClass(PreferredClassProvider.java:576) [java] ... 12 more [java] Java Result: -2 Modified Paths: -------------- trunk/build.xml Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2010-07-20 22:31:05 UTC (rev 3256) +++ trunk/build.xml 2010-07-21 12:59:52 UTC (rev 3257) @@ -849,12 +849,13 @@ <!-- --> <!-- STANDALONE FEDERATION TARGETS --> - <!-- --> + <!-- (test/benchamarking) --> <target name="standalone-setup" description="Setup properties used by the standalone federation and LUS start/stop."> <property name="app.home" location="${bigdata.dir}" /> <property name="test.codebase.port" value="23333"/> - <property name="test.codebase.dir" location="${bigdata.dir}/bigdata-jini/lib/jini/lib-dl" /> + <property name="jini.lib" location="${bigdata.dir}/bigdata-jini/lib/jini/lib" /> + <property name="jini.lib.dl" location="${bigdata.dir}/bigdata-jini/lib/jini/lib-dl" /> <property name="test.codebase" value="http://${this.hostname}:${test.codebase.port}/jsk-dl.jar"/> <property name="java.security.policy" value="${bigdata.dir}/policy.all"/> <property name="log4j.configuration" value="${bigdata.dir}/src/resources/config/standalone/log4j.properties"/> @@ -864,11 +865,11 @@ <target name="standalone-startLookup" depends="jar,standalone-setup" description="Start the lookup service for the standalone federation."> <java classname="com.bigdata.service.jini.util.LookupStarter" - fork="true" spawn="true"> + fork="true" spawn="false"> <classpath refid="runtime.classpath" /> <sysproperty key="app.home" value="${app.home}"/> - <sysproperty key="jini.lib" value="${dist.lib}"/> - <sysproperty key="jini.lib.dl" value="${dist.lib.dl}"/> + <sysproperty key="jini.lib" value="${jini.lib}"/> + <sysproperty key="jini.lib.dl" value="${jini.lib.dl}"/> <sysproperty key="java.security.policy" value="${java.security.policy}"/> <sysproperty key="java.security.debug" value="off"/> <sysproperty key="java.protocol.handler.pkgs" value="net.jini.url"/> @@ -933,25 +934,22 @@ <antcall target="standalone-stopLookup" /> </target> -<!-- @todo Add target to stand up a SPARQL endpoint for a KB namespace. Could be - Sesame Server or bigdata REST API. --> - -<!-- Note: The source files must be "reasonable" for the bulk loader. Each file - will be fully parsed into memory before writing onto the database. Very - large source files must be split into smaller files. See the 'split' - command under unix, but be aware that it will not generate more than 576 - output files (24 x 24 = 576) and only 100 if you are using number suffixes. - For example, split an NT file into files of 200000 lines each: - - mkdir splits; cd splits - split -l 200000 ../dataset.nt dataset - - You will also have to fix up the file extensions. You can do this using - bash as follows: - - for file in *; do mv $file $file.nt; done - - --> +<target name="standalone-start-nano-server" depends="jar" description="Start a small http server fronting for a bigdata database instance."> + <java classname="com.bigdata.rdf.sail.bench.NanoSparqlServer" fork="true" failonerror="true"> + <arg line="${standalone.nanoServerPort} ${standalone.namespace} src/resources/config/standalone/bigdataStandalone.config" /> + <jvmarg line="-server"/> + <jvmarg line="-Xmx200M"/> + <classpath refid="runtime.classpath" /> + </java> +</target> + +<target name="standalone-stop-nano-server" depends="jar" description="Stop the small http server running at the configured port."> + <java classname="com.bigdata.rdf.sail.bench.NanoSparqlServer" fork="true" failonerror="true"> + <arg line="${standalone.nanoServerPort} -stop" /> + <classpath refid="runtime.classpath" /> + </java> +</target> + <target name="standalone-bulk-load" depends="jar" description="Bulk load RDF data into the standalone federation."> <java classname="com.bigdata.rdf.load.MappedRDFDataLoadMaster" failonerror="true" fork="true" logerror="true"> @@ -967,30 +965,14 @@ <!-- --> <!-- Per job parameters --> <!-- --> - <!-- The KB namespace ("kb" is a common default). --> - <jvmarg value="-Dbigdata.rdf.namespace=U10"/> + <!-- The namespace of the target KB. --> + <jvmarg value="-Dbigdata.rdf.namespace=${standalone.namespace}"/> <!-- The job name (same as the KB namespace is a common default). --> - <jvmarg value="-Dbigdata.rdf.job.name=bulk-load-kb"/> - <!-- The file or directory containing RDF data to be loaded. - - Possible interesting data: - - d:/bigdata-perf-analysis/lubm/U10 - d:/bigdata-perf-analysis/bsbm/bsbm_2785/dataset.nt - --> - <jvmarg value="-Dbigdata.rdf.data=d:/bigdata-perf-analysis/lubm/U10"/> - <!-- The file or directory containing zero or more RDF ontology files to be loaded. - - Note: If you do not want to load any "ontology" data you can point this at an - empty directory. "ontology" data is loaded once - when a new KB instance is - created. - - Possible interesting ontologies: - - bigdata-rdf/src/resources/data/lehigh/univ-bench.owl - d:/bigdata-perf-analysis/emptyDir - --> - <jvmarg value="-Dbigdata.rdf.ontology=bigdata-rdf/src/resources/data/lehigh/univ-bench.owl"/> + <jvmarg value="-Dbigdata.rdf.job.name=bulk-load-kb-${standalone-namespace}"/> + <!-- The file or directory containing zero or more files to be loaded first. --> + <jvmarg value="-Dbigdata.rdf.ontology=${standalone.bulkLoad.ontology}"/> + <!-- The file or directory containing RDF data to be loaded. --> + <jvmarg value="-Dbigdata.rdf.data=${standalone.bulkLoad.data}"/> <!-- The main configuration file. --> <arg value="src/resources/config/standalone/bigdataStandalone.config" /> </java> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <btm...@us...> - 2010-07-20 22:31:12
|
Revision: 3256 http://bigdata.svn.sourceforge.net/bigdata/?rev=3256&view=rev Author: btmurphy Date: 2010-07-20 22:31:05 +0000 (Tue, 20 Jul 2010) Log Message: ----------- [trunk - merged from branch bugfix-btm]: trac #108 - Update NicUtil and the build.xml file to parameterize them for the ethernet interface Modified Paths: -------------- trunk/bigdata/src/java/com/bigdata/util/config/NicUtil.java trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/LookupStarter.java trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/config/lookup.config trunk/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config trunk/bigdata-jini/src/test/com/bigdata/jini/start/testReggie.config trunk/bigdata-jini/src/test/com/bigdata/jini/start/testStartJini.config trunk/bigdata-jini/src/test/com/bigdata/zookeeper/testzoo.config trunk/build.xml Property Changed: ---------------- trunk/ Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo - /branches/BTREE_BUFFER_BRANCH:2004-2045 /branches/DEV_BRANCH_27_OCT_2009:2270-2546,2548-2782 /branches/bugfix-btm:2594-2779 /branches/dev-btm:2574-2730 /branches/fko:3150-3194 + /branches/BTREE_BUFFER_BRANCH:2004-2045 /branches/DEV_BRANCH_27_OCT_2009:2270-2546,2548-2782 /branches/bugfix-btm:2594-3237 /branches/dev-btm:2574-2730 /branches/fko:3150-3194 Modified: trunk/bigdata/src/java/com/bigdata/util/config/NicUtil.java =================================================================== --- trunk/bigdata/src/java/com/bigdata/util/config/NicUtil.java 2010-07-20 22:28:30 UTC (rev 3255) +++ trunk/bigdata/src/java/com/bigdata/util/config/NicUtil.java 2010-07-20 22:31:05 UTC (rev 3256) @@ -505,6 +505,185 @@ } /** + * Examines each address associated with each network interface + * card (nic) installed on the current node, and returns the + * <code>String</code> value of the first such address that is + * determined to be both <i>reachable</i> and an address type + * that represents an <i>IPv4</i> address. + * + * This method will always first examine addresses that are + * <i>not</i> the <i>loopback</i> address (<i>local host</i>); + * returning a loopback adddress only if <code>true</code> + * is input for the <code>loopbackOk</code> parameter, and + * none of the non-loopback addresses satisfy this method's + * search criteria. + * + * If this method fails to find any address that satisfies the + * above criteria, then this method returns <code>null</code>. + * + * @param loopbackOk if <code>true</code>, then upon failure + * find an non-<i>loopback</i> address that + * satisfies this method's search criteria + * (an IPv4 type address and reachable), the + * first loopback address that is found to be + * reachable is returned. + * + * If <code>false</code> is input for this + * parameter, then this method will examine + * only those addresses that do <i>not</i> + * correspond to the corresponding nic's + * loopback address. + * + * @return a <code>String</code> value representing the first + * network interface address installed on the current + * node that is determined to be both <i>reachable</i> + * and an IPv4 type address; where the return value + * corresponds to a <i>loopback</i> address only if + * <code>true</code> is input for the <code>loopbackOk</code> + * parameter, and no non-loopback address satisfying + * the desired criteria can be found. If this method + * fails to find any address that satisfies the desired + * criteria, then <code>null</code> is returned. + * + * @throws SocketException if there is an error in the underlying + * I/O subsystem and/or protocol while retrieving the + * the network interfaces currently installed on the + * node. + * + * @throws IOException if a network error occurs while determining + * if a candidate return address is <i>reachable</i>. + */ + public static String getDefaultIpv4Address(boolean loopbackOk) + throws SocketException, IOException + { + //get all nics on the current node + Enumeration<NetworkInterface> nics = + NetworkInterface.getNetworkInterfaces(); + while( nics.hasMoreElements() ) { + NetworkInterface curNic = nics.nextElement(); + List<InterfaceAddress> interfaceAddrs = + curNic.getInterfaceAddresses(); + for(InterfaceAddress interfaceAddr : interfaceAddrs) { + InetAddress inetAddr = interfaceAddr.getAddress(); + boolean isIpv4 = inetAddr instanceof Inet4Address; + boolean isLoopbackAddress = inetAddr.isLoopbackAddress(); + if(isIpv4) { + if(isLoopbackAddress) continue; + boolean isReachable = inetAddr.isReachable(3*1000); + Inet4Address inet4Addr = (Inet4Address)inetAddr; + String retVal = inet4Addr.getHostAddress(); + + jiniConfigLogger.log + (CONFIG, "default IPv4 address: "+retVal); + utilLogger.log + (Level.TRACE, "default IPv4 address: "+retVal); + return retVal; + } + } + } + + if(!loopbackOk) return null; + + nics = NetworkInterface.getNetworkInterfaces(); + while( nics.hasMoreElements() ) { + NetworkInterface curNic = nics.nextElement(); + List<InterfaceAddress> interfaceAddrs = + curNic.getInterfaceAddresses(); + for(InterfaceAddress interfaceAddr : interfaceAddrs) { + InetAddress inetAddr = interfaceAddr.getAddress(); + boolean isIpv4 = inetAddr instanceof Inet4Address; + boolean isLoopbackAddress = inetAddr.isLoopbackAddress(); + if(isIpv4) { + if(!isLoopbackAddress) continue; + boolean isReachable = inetAddr.isReachable(3*1000); + Inet4Address inet4Addr = (Inet4Address)inetAddr; + String retVal = inet4Addr.getHostAddress(); + + jiniConfigLogger.log + (CONFIG, "default IPv4 address: "+retVal); + utilLogger.log + (Level.TRACE, "default IPv4 address: "+retVal); + return retVal; + } + } + } + return null; + } + + public static String getDefaultIpv4Address() + throws SocketException, IOException + { + return getDefaultIpv4Address(false);//localhost NOT ok + } + + /** + * Special-purpose convenience method that will return the + * value of the system property named <code>default.nic</code> + * if that property has been set on the current VM to any + * non-<code>null</code> value other than the value, + * <code>${default.nic}</code>; otherwise returns the value + * input for the <code>defaultVal</code> parameter. + * <p> + * This method can be called from within a configuration + * as well as from within program control. It is provided + * as a way to allow mechanisms that are not able to + * conditionally set system properties to always set the + * system property named <code>default.nic</code> to some + * value -- either valid or invalid -- depending on whether + * that property is set as a system property on the command + * line. + * <p> + * For example, the <code>java</code> ant task used to exec + * java based programs does not allow one to set a system + * property on that program's VM when that property is set + * on the command line used to execute ant, but leave that + * property un-set when ant's command line does not specify + * a value for that property. That is, although ant allows + * one to retrieve the value of a system property that is + * specified on ant's command line and substitute that value + * (using Java's '${}' token-substitution mechanism) into + * a system property set on the program's VM, ant does not + * allow one to leave that property un-set when the system + * property is not specified on ant's command line; the + * property must either always be set on the VM, or never + * set. If the ant script then is written to always set the + * system property on the exec'd program's VM to the + * value of the system property expected on ant's command + * line, then whenever that system property is not set on + * ant's command line, the value that is substituted into + * the system property when the program is exec-ed will be + * of the form, <code>${default.nic}</code>. If the program + * that is exec'd then attempts to call + * <code>System.getProperty("default.nic")</code>, that + * call will return the non-<code>null</code> value, + * <code>${default.nic}</code>; which is typically not + * what is desired. + * + * @param defaultVal <code>String</code> value that this method + * returns if the system property named + * <code>default.nic</code> is either not + * set or is equal to the value + * <code>${default.nic}</code>. + * + * @return a <code>String</code> value equal to the value of + * the system property named <code>${default.nic}</code> + * if that system property is set to any value except + * <code>null</code> or the value <code>${default.nic}</code>; + * otherwise, returns the value input for the + * <code>defaultVal</code> parameter. + */ + public static String getDefaultNic(String defaultVal) { + String defaultNic = System.getProperty("default.nic"); + if( ("${default.nic}").equals(defaultNic) ) defaultNic = null; + if(defaultNic == null) defaultNic = defaultVal; + return defaultNic; + } + + public static String getDefaultNic() { + return getDefaultNic(null); + } + + /** * Intended for use by scripts. */ public static void main(String[] args) { Modified: trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/LookupStarter.java =================================================================== --- trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/LookupStarter.java 2010-07-20 22:28:30 UTC (rev 3255) +++ trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/LookupStarter.java 2010-07-20 22:31:05 UTC (rev 3256) @@ -70,8 +70,19 @@ private String jiniLibDl = System.getProperty("jini.lib.dl"); private String localPolicy = System.getProperty("java.security.policy"); - private static String thisHost = NicUtil.getIpAddress("eth0"); - private static String defaultGroup = "bigdata.fedname-"+thisHost; + private static String thisHost = null; + private static String defaultGroup = null; + static { + try { + thisHost = + NicUtil.getIpAddress + ( NicUtil.getDefaultNic + ( NicUtil.getDefaultIpv4Address(true) ) ); + defaultGroup = + System.getProperty("bigdata.fedname", + "bigdata.test.group-"+thisHost); + } catch (Throwable t) { /* swallow */ } + } private static String defaultCodebasePort = "23333"; private static String group = Modified: trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/config/lookup.config =================================================================== --- trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/config/lookup.config 2010-07-20 22:28:30 UTC (rev 3255) +++ trunk/bigdata-jini/src/java/com/bigdata/service/jini/util/config/lookup.config 2010-07-20 22:31:05 UTC (rev 3256) @@ -8,10 +8,10 @@ import com.bigdata.util.config.NicUtil; com.sun.jini.reggie { - private static exportNic = "eth0"; private static exportPort = 0;//randomly chosen port - private static exportHost = NicUtil.getIpAddress(exportNic); - private static exportIpAddr = NicUtil.getIpAddress(exportNic,0,exportHost); + private static exportIpAddr = + NicUtil.getDefaultNic + ( NicUtil.getDefaultIpv4Address(true) ); private static codebasePort = 23333;//value used if not set by system prop // Public configuration entries @@ -21,7 +21,9 @@ new BasicILFactory(), false, true); initialMemberGroups = - new String[] {"bigdata.test.group-"+exportHost};//use if no sys prop + new String[] { System.getProperty + ("bigdata.fedname", + "bigdata.test.group-"+exportIpAddr ) }; unicastDiscoveryHost = exportIpAddr; } Modified: trunk/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config =================================================================== --- trunk/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config 2010-07-20 22:28:30 UTC (rev 3255) +++ trunk/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config 2010-07-20 22:31:05 UTC (rev 3256) @@ -76,7 +76,9 @@ // The default root for all persistent state. static serviceDir = ConfigMath.getAbsoluteFile(new File(fedname)); - private static localIpAddr = NicUtil.getIpAddress("eth0", 0, null, true); + private static localIpAddr = + NicUtil.getDefaultNic + ( NicUtil.getDefaultIpv4Address(true) ); /* * Example cluster configuration. Modified: trunk/bigdata-jini/src/test/com/bigdata/jini/start/testReggie.config =================================================================== --- trunk/bigdata-jini/src/test/com/bigdata/jini/start/testReggie.config 2010-07-20 22:28:30 UTC (rev 3255) +++ trunk/bigdata-jini/src/test/com/bigdata/jini/start/testReggie.config 2010-07-20 22:31:05 UTC (rev 3256) @@ -14,7 +14,9 @@ com.sun.jini.reggie { - private static exportIpAddr = NicUtil.getIpAddress("eth0", 0, null, true); + private static exportIpAddr = + NicUtil.getDefaultNic + ( NicUtil.getDefaultIpv4Address(true) ); private static exportPort = Integer.parseInt("0"); private static serverILFactory = Modified: trunk/bigdata-jini/src/test/com/bigdata/jini/start/testStartJini.config =================================================================== --- trunk/bigdata-jini/src/test/com/bigdata/jini/start/testStartJini.config 2010-07-20 22:28:30 UTC (rev 3255) +++ trunk/bigdata-jini/src/test/com/bigdata/jini/start/testStartJini.config 2010-07-20 22:31:05 UTC (rev 3256) @@ -14,7 +14,9 @@ com.sun.jini.start { private static appHome = System.getProperty("app.home", ConfigMath.getAbsolutePath(new File(".")) ); - private static codebaseHost = NicUtil.getIpAddress("eth0", 0, null, true); + private static codebaseHost = + NicUtil.getDefaultNic + ( NicUtil.getDefaultIpv4Address(true) ); private static codebasePort = "23334"; private static defaultCodebaseRootDir = ConfigUtil.concat( new String[] { appHome, "${/}bigdata-jini${/}lib${/}jini${/}lib-dl" } ); Modified: trunk/bigdata-jini/src/test/com/bigdata/zookeeper/testzoo.config =================================================================== --- trunk/bigdata-jini/src/test/com/bigdata/zookeeper/testzoo.config 2010-07-20 22:28:30 UTC (rev 3255) +++ trunk/bigdata-jini/src/test/com/bigdata/zookeeper/testzoo.config 2010-07-20 22:31:05 UTC (rev 3256) @@ -33,7 +33,9 @@ private static appHome = System.getProperty("app.home", ConfigMath.getAbsolutePath(new File(".")) ); - private static localIpAddr = NicUtil.getIpAddress("eth0", 0, null, true); + private static localIpAddr = + NicUtil.getDefaultNic + ( NicUtil.getDefaultIpv4Address(true) ); /* A comma delimited list of the known zookeeper servers together * with their assigned "myid". Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2010-07-20 22:28:30 UTC (rev 3255) +++ trunk/build.xml 2010-07-20 22:31:05 UTC (rev 3256) @@ -1345,7 +1345,7 @@ <mkdir dir="${bigdata-test.lib}"/> <property name="bigdata-test.jar" location="${bigdata-test.lib}/bigdata-test.jar" /> - <property name="javac.test.classpath" value="${classes.dir}:${junit.jar}:${cweb-junit-ext.jar}:${sesame-sparql-test.jar}:${sesame-store-test.jar}:${dist.lib}/classserver.jar:${dist.lib}/ctc_utils.jar:${dist.lib}/cweb-commons.jar:${dist.lib}/cweb-extser.jar:${dist.lib}/highscalelib.jar:${dist.lib}/dsiutils.jar:${dist.lib}/lgplutils.jar:${dist.lib}/fastutil.jar:${dist.lib}/icu4j.jar:${dist.lib}/iris.jar:${dist.lib}/log4j.jar:${dist.lib}/openrdf-sesame.jar:${dist.lib}/slf4j.jar:${dist.lib}/jsk-lib.jar:${dist.lib}/jsk-platform.jar:${dist.lib}/nxparser.jar:${dist.lib}/zookeeper.jar"/> + <property name="javac.test.classpath" value="${classes.dir}${path.separator}${junit.jar}${path.separator}${cweb-junit-ext.jar}${path.separator}${sesame-sparql-test.jar}${path.separator}${sesame-store-test.jar}${path.separator}${dist.lib}/classserver.jar${path.separator}${dist.lib}/ctc_utils.jar${path.separator}${dist.lib}/cweb-commons.jar${path.separator}${dist.lib}/cweb-extser.jar${path.separator}${dist.lib}/highscalelib.jar${path.separator}${dist.lib}/dsiutils.jar${path.separator}${dist.lib}/lgplutils.jar${path.separator}${dist.lib}/fastutil.jar${path.separator}${dist.lib}/icu4j.jar${path.separator}${dist.lib}/iris.jar${path.separator}${dist.lib}/log4j.jar${path.separator}${dist.lib}/openrdf-sesame.jar${path.separator}${dist.lib}/slf4j.jar${path.separator}${dist.lib}/jsk-lib.jar${path.separator}${dist.lib}/jsk-platform.jar${path.separator}${dist.lib}/nxparser.jar${path.separator}${dist.lib}/zookeeper.jar"/> <echo>javac </echo> @@ -1533,7 +1533,7 @@ </target> <target name="startLookup"> - <echo>java -Dapp.home=${app.home} -Djini.lib=${dist.lib} -Djini.lib.dl=${dist.lib.dl} -Djava.security.policy=${java.security.policy} -Djava.security.debug=off -Djava.protocol.handler.pkgs=net.jini.url -Dlog4j.configuration=${log4j.configuration} -Dcodebase.port=${test.codebase.port} -Djava.net.preferIPv4Stack=${java.net.preferIPv4Stack} -Dbigdata.fedname=${bigdata.fedname} -jar ${bigdata-test.lib}/lookupstarter.jar + <echo>java -Dapp.home=${app.home} -Djini.lib=${dist.lib} -Djini.lib.dl=${dist.lib.dl} -Djava.security.policy=${java.security.policy} -Djava.security.debug=off -Djava.protocol.handler.pkgs=net.jini.url -Dlog4j.configuration=${log4j.configuration} -Dcodebase.port=${test.codebase.port} -Djava.net.preferIPv4Stack=${java.net.preferIPv4Stack} -Dbigdata.fedname=${bigdata.fedname} -Ddefault.nic=${default.nic} -jar ${bigdata-test.lib}/lookupstarter.jar </echo> <echo> </echo> @@ -1551,11 +1551,12 @@ <sysproperty key="codebase.port" value="${test.codebase.port}"/> <sysproperty key="java.net.preferIPv4Stack" value="${java.net.preferIPv4Stack}"/> <sysproperty key="bigdata.fedname" value="${bigdata.fedname}"/> + <sysproperty key="default.nic" value="${default.nic}"/> </java> </target> <target name="stopLookup"> - <echo>java -Dapp.home=${app.home} -Djini.lib=${dist.lib} -Djini.lib.dl=${dist.lib.dl} -Djava.security.policy=${java.security.policy} -Dlog4j.configuration=${log4j.configuration} -Djava.net.preferIPv4Stack=${java.net.preferIPv4Stack} -Dbigdata.fedname=${bigdata.fedname} -jar ${bigdata-test.lib}/lookupstarter.jar -stop + <echo>java -Dapp.home=${app.home} -Djini.lib=${dist.lib} -Djini.lib.dl=${dist.lib.dl} -Djava.security.policy=${java.security.policy} -Dlog4j.configuration=${log4j.configuration} -Djava.net.preferIPv4Stack=${java.net.preferIPv4Stack} -Dbigdata.fedname=${bigdata.fedname} -Ddefault.nic=${default.nic} -jar ${bigdata-test.lib}/lookupstarter.jar -stop </echo> <echo> </echo> @@ -1569,6 +1570,7 @@ <sysproperty key="log4j.configuration" value="${log4j.configuration}"/> <sysproperty key="java.net.preferIPv4Stack" value="${java.net.preferIPv4Stack}"/> <sysproperty key="bigdata.fedname" value="${bigdata.fedname}"/> + <sysproperty key="default.nic" value="${default.nic}"/> <arg value="-stop" /> </java> </target> @@ -1607,7 +1609,7 @@ <pathelement location="${dist.lib}/zookeeper.jar"/> </path> - <property name="run.class.path" value="${junit.jar}:${bigdata-test.jar}:${cweb-junit-ext.jar}:${sesame-sparql-test.jar}:${sesame-store-test.jar}:${dist.lib}/bigdata.jar:${dist.lib}/colt.jar:${dist.lib}/cweb-commons.jar:${dist.lib}/cweb-extser.jar:${dist.lib}/ctc_utils.jar:${dist.lib}/highscalelib.jar:${dist.lib}/dsiutils.jar:${dist.lib}/lgplutils.jar:${dist.lib}/fastutil.jar:${dist.lib}/icu4j.jar:${dist.lib}/iris.jar:${dist.lib}/jsk-lib.jar:${dist.lib}/jsk-platform.jar:${dist.lib}/log4j.jar:${dist.lib}/lucene-analyzer.jar:${dist.lib}/lucene-core.jar:${dist.lib}/openrdf-sesame.jar:${dist.lib}/slf4j.jar:${dist.lib}/slf4j-log4j.jar:${dist.lib}/nxparser.jar:${dist.lib}/zookeeper.jar"/> + <property name="run.class.path" value="${junit.jar}${path.separator}${bigdata-test.jar}${path.separator}${cweb-junit-ext.jar}${path.separator}${sesame-sparql-test.jar}${path.separator}${sesame-store-test.jar}${path.separator}${dist.lib}/bigdata.jar${path.separator}${dist.lib}/colt.jar${path.separator}${dist.lib}/cweb-commons.jar${path.separator}${dist.lib}/cweb-extser.jar${path.separator}${dist.lib}/ctc_utils.jar${path.separator}${dist.lib}/highscalelib.jar${path.separator}${dist.lib}/dsiutils.jar${path.separator}${dist.lib}/lgplutils.jar${path.separator}${dist.lib}/fastutil.jar${path.separator}${dist.lib}/icu4j.jar${path.separator}${dist.lib}/iris.jar${path.separator}${dist.lib}/jsk-lib.jar${path.separator}${dist.lib}/jsk-platform.jar${path.separator}${dist.lib}/log4j.jar${path.separator}${dist.lib}/lucene-analyzer.jar${path.separator}${dist.lib}/lucene-core.jar${path.separator}${dist.lib}/openrdf-sesame.jar${path.separator}${dist.lib}/slf4j.jar${path.separator}${dist.lib}/slf4j-log4j.jar${path.separator}${dist.lib}/nxparser.jar${path.separator}${dist.lib}/zookeeper.jar"/> <echo> classpath: ${run.class.path} </echo> @@ -1806,7 +1808,7 @@ <pathelement location="${dist.lib}/nxparser.jar"/> <pathelement location="${dist.lib}/zookeeper.jar"/> </path> - <property name="run.class.path" value="${junit.jar}:${bigdata-test.jar}:${cweb-junit-ext.jar}:${sesame-sparql-test.jar}:${sesame-store-test.jar}:${dist.lib}/bigdata.jar:${dist.lib}/colt.jar:${dist.lib}/cweb-commons.jar:${dist.lib}/cweb-extser.jar:${dist.lib}/ctc_utils.jar:${dist.lib}/highscalelib.jar:${dist.lib}/dsiutils.jar:${dist.lib}/lgplutils.jar:${dist.lib}/fastutil.jar:${dist.lib}/icu4j.jar:${dist.lib}/iris.jar:${dist.lib}/jsk-lib.jar:${dist.lib}/jsk-platform.jar:${dist.lib}/log4j.jar:${dist.lib}/lucene-analyzer.jar:${dist.lib}/lucene-core.jar:${dist.lib}/openrdf-sesame.jar:${dist.lib}/slf4j.jar:${dist.lib}/slf4j-log4j.jar:${dist.lib}/nxparser.jar:${dist.lib}/zookeeper.jar"/> + <property name="run.class.path" value="${junit.jar}${path.separator}${bigdata-test.jar}${path.separator}${cweb-junit-ext.jar}${path.separator}${sesame-sparql-test.jar}${path.separator}${sesame-store-test.jar}${path.separator}${dist.lib}/bigdata.jar${path.separator}${dist.lib}/colt.jar${path.separator}${dist.lib}/cweb-commons.jar${path.separator}${dist.lib}/cweb-extser.jar${path.separator}${dist.lib}/ctc_utils.jar${path.separator}${dist.lib}/highscalelib.jar${path.separator}${dist.lib}/dsiutils.jar${path.separator}${dist.lib}/lgplutils.jar${path.separator}${dist.lib}/fastutil.jar${path.separator}${dist.lib}/icu4j.jar${path.separator}${dist.lib}/iris.jar${path.separator}${dist.lib}/jsk-lib.jar${path.separator}${dist.lib}/jsk-platform.jar${path.separator}${dist.lib}/log4j.jar${path.separator}${dist.lib}/lucene-analyzer.jar${path.separator}${dist.lib}/lucene-core.jar${path.separator}${dist.lib}/openrdf-sesame.jar${path.separator}${dist.lib}/slf4j.jar${path.separator}${dist.lib}/slf4j-log4j.jar${path.separator}${dist.lib}/nxparser.jar${path.separator}${dist.lib}/zookeeper.jar"/> <!-- Generate the LUBM dataset. <mkdir dir="${data}"/> <java classname="edu.lehigh.swat.bench.uba.Generator" dir="${data}" fork="yes"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <btm...@us...> - 2010-07-20 22:28:36
|
Revision: 3255 http://bigdata.svn.sourceforge.net/bigdata/?rev=3255&view=rev Author: btmurphy Date: 2010-07-20 22:28:30 +0000 (Tue, 20 Jul 2010) Log Message: ----------- [branch bugfix-btm]: trac #108 - Update NicUtil and the build.xml file to parameterize them for the ethernet interface (changed path separators in the build.xml from the unix-based ':' to ant's system property ${path.separator}, so the tests can be executed from the command line on windows) Modified Paths: -------------- branches/bugfix-btm/build.xml Modified: branches/bugfix-btm/build.xml =================================================================== --- branches/bugfix-btm/build.xml 2010-07-20 20:13:15 UTC (rev 3254) +++ branches/bugfix-btm/build.xml 2010-07-20 22:28:30 UTC (rev 3255) @@ -1345,7 +1345,7 @@ <mkdir dir="${bigdata-test.lib}"/> <property name="bigdata-test.jar" location="${bigdata-test.lib}/bigdata-test.jar" /> - <property name="javac.test.classpath" value="${classes.dir}:${junit.jar}:${cweb-junit-ext.jar}:${sesame-sparql-test.jar}:${sesame-store-test.jar}:${dist.lib}/classserver.jar:${dist.lib}/ctc_utils.jar:${dist.lib}/cweb-commons.jar:${dist.lib}/cweb-extser.jar:${dist.lib}/highscalelib.jar:${dist.lib}/dsiutils.jar:${dist.lib}/lgplutils.jar:${dist.lib}/fastutil.jar:${dist.lib}/icu4j.jar:${dist.lib}/iris.jar:${dist.lib}/log4j.jar:${dist.lib}/openrdf-sesame.jar:${dist.lib}/slf4j.jar:${dist.lib}/jsk-lib.jar:${dist.lib}/jsk-platform.jar:${dist.lib}/nxparser.jar:${dist.lib}/zookeeper.jar"/> + <property name="javac.test.classpath" value="${classes.dir}${path.separator}${junit.jar}${path.separator}${cweb-junit-ext.jar}${path.separator}${sesame-sparql-test.jar}${path.separator}${sesame-store-test.jar}${path.separator}${dist.lib}/classserver.jar${path.separator}${dist.lib}/ctc_utils.jar${path.separator}${dist.lib}/cweb-commons.jar${path.separator}${dist.lib}/cweb-extser.jar${path.separator}${dist.lib}/highscalelib.jar${path.separator}${dist.lib}/dsiutils.jar${path.separator}${dist.lib}/lgplutils.jar${path.separator}${dist.lib}/fastutil.jar${path.separator}${dist.lib}/icu4j.jar${path.separator}${dist.lib}/iris.jar${path.separator}${dist.lib}/log4j.jar${path.separator}${dist.lib}/openrdf-sesame.jar${path.separator}${dist.lib}/slf4j.jar${path.separator}${dist.lib}/jsk-lib.jar${path.separator}${dist.lib}/jsk-platform.jar${path.separator}${dist.lib}/nxparser.jar${path.separator}${dist.lib}/zookeeper.jar"/> <echo>javac </echo> @@ -1609,7 +1609,7 @@ <pathelement location="${dist.lib}/zookeeper.jar"/> </path> - <property name="run.class.path" value="${junit.jar}:${bigdata-test.jar}:${cweb-junit-ext.jar}:${sesame-sparql-test.jar}:${sesame-store-test.jar}:${dist.lib}/bigdata.jar:${dist.lib}/colt.jar:${dist.lib}/cweb-commons.jar:${dist.lib}/cweb-extser.jar:${dist.lib}/ctc_utils.jar:${dist.lib}/highscalelib.jar:${dist.lib}/dsiutils.jar:${dist.lib}/lgplutils.jar:${dist.lib}/fastutil.jar:${dist.lib}/icu4j.jar:${dist.lib}/iris.jar:${dist.lib}/jsk-lib.jar:${dist.lib}/jsk-platform.jar:${dist.lib}/log4j.jar:${dist.lib}/lucene-analyzer.jar:${dist.lib}/lucene-core.jar:${dist.lib}/openrdf-sesame.jar:${dist.lib}/slf4j.jar:${dist.lib}/slf4j-log4j.jar:${dist.lib}/nxparser.jar:${dist.lib}/zookeeper.jar"/> + <property name="run.class.path" value="${junit.jar}${path.separator}${bigdata-test.jar}${path.separator}${cweb-junit-ext.jar}${path.separator}${sesame-sparql-test.jar}${path.separator}${sesame-store-test.jar}${path.separator}${dist.lib}/bigdata.jar${path.separator}${dist.lib}/colt.jar${path.separator}${dist.lib}/cweb-commons.jar${path.separator}${dist.lib}/cweb-extser.jar${path.separator}${dist.lib}/ctc_utils.jar${path.separator}${dist.lib}/highscalelib.jar${path.separator}${dist.lib}/dsiutils.jar${path.separator}${dist.lib}/lgplutils.jar${path.separator}${dist.lib}/fastutil.jar${path.separator}${dist.lib}/icu4j.jar${path.separator}${dist.lib}/iris.jar${path.separator}${dist.lib}/jsk-lib.jar${path.separator}${dist.lib}/jsk-platform.jar${path.separator}${dist.lib}/log4j.jar${path.separator}${dist.lib}/lucene-analyzer.jar${path.separator}${dist.lib}/lucene-core.jar${path.separator}${dist.lib}/openrdf-sesame.jar${path.separator}${dist.lib}/slf4j.jar${path.separator}${dist.lib}/slf4j-log4j.jar${path.separator}${dist.lib}/nxparser.jar${path.separator}${dist.lib}/zookeeper.jar"/> <echo> classpath: ${run.class.path} </echo> @@ -1808,7 +1808,7 @@ <pathelement location="${dist.lib}/nxparser.jar"/> <pathelement location="${dist.lib}/zookeeper.jar"/> </path> - <property name="run.class.path" value="${junit.jar}:${bigdata-test.jar}:${cweb-junit-ext.jar}:${sesame-sparql-test.jar}:${sesame-store-test.jar}:${dist.lib}/bigdata.jar:${dist.lib}/colt.jar:${dist.lib}/cweb-commons.jar:${dist.lib}/cweb-extser.jar:${dist.lib}/ctc_utils.jar:${dist.lib}/highscalelib.jar:${dist.lib}/dsiutils.jar:${dist.lib}/lgplutils.jar:${dist.lib}/fastutil.jar:${dist.lib}/icu4j.jar:${dist.lib}/iris.jar:${dist.lib}/jsk-lib.jar:${dist.lib}/jsk-platform.jar:${dist.lib}/log4j.jar:${dist.lib}/lucene-analyzer.jar:${dist.lib}/lucene-core.jar:${dist.lib}/openrdf-sesame.jar:${dist.lib}/slf4j.jar:${dist.lib}/slf4j-log4j.jar:${dist.lib}/nxparser.jar:${dist.lib}/zookeeper.jar"/> + <property name="run.class.path" value="${junit.jar}${path.separator}${bigdata-test.jar}${path.separator}${cweb-junit-ext.jar}${path.separator}${sesame-sparql-test.jar}${path.separator}${sesame-store-test.jar}${path.separator}${dist.lib}/bigdata.jar${path.separator}${dist.lib}/colt.jar${path.separator}${dist.lib}/cweb-commons.jar${path.separator}${dist.lib}/cweb-extser.jar${path.separator}${dist.lib}/ctc_utils.jar${path.separator}${dist.lib}/highscalelib.jar${path.separator}${dist.lib}/dsiutils.jar${path.separator}${dist.lib}/lgplutils.jar${path.separator}${dist.lib}/fastutil.jar${path.separator}${dist.lib}/icu4j.jar${path.separator}${dist.lib}/iris.jar${path.separator}${dist.lib}/jsk-lib.jar${path.separator}${dist.lib}/jsk-platform.jar${path.separator}${dist.lib}/log4j.jar${path.separator}${dist.lib}/lucene-analyzer.jar${path.separator}${dist.lib}/lucene-core.jar${path.separator}${dist.lib}/openrdf-sesame.jar${path.separator}${dist.lib}/slf4j.jar${path.separator}${dist.lib}/slf4j-log4j.jar${path.separator}${dist.lib}/nxparser.jar${path.separator}${dist.lib}/zookeeper.jar"/> <!-- Generate the LUBM dataset. <mkdir dir="${data}"/> <java classname="edu.lehigh.swat.bench.uba.Generator" dir="${data}" fork="yes"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2010-07-20 20:13:21
|
Revision: 3254 http://bigdata.svn.sourceforge.net/bigdata/?rev=3254&view=rev Author: thompsonbry Date: 2010-07-20 20:13:15 +0000 (Tue, 20 Jul 2010) Log Message: ----------- LexiconConfiguration is transient for now. It is created at runtime from the properties in the global row store. Modified Paths: -------------- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java 2010-07-20 20:12:42 UTC (rev 3253) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java 2010-07-20 20:13:15 UTC (rev 3254) @@ -27,7 +27,6 @@ package com.bigdata.rdf.internal; -import java.io.Serializable; /** * An object which describes which kinds of RDF Values are inlined into the @@ -36,16 +35,11 @@ * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ * - * FIXME Version information in serialization format. - * * @todo large literal size boundary. * @todo other configuration options. */ -public class LexiconConfiguration implements Serializable, - ILexiconConfiguration { +public class LexiconConfiguration implements ILexiconConfiguration { - private static final long serialVersionUID = -817370708683316807L; - private boolean inlineTerms; public LexiconConfiguration() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fko...@us...> - 2010-07-20 20:12:49
|
Revision: 3253 http://bigdata.svn.sourceforge.net/bigdata/?rev=3253&view=rev Author: fkoliver Date: 2010-07-20 20:12:42 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Change default collator to ICU in standalone configuration. Modified Paths: -------------- trunk/src/resources/config/standalone/bigdataStandalone.config Modified: trunk/src/resources/config/standalone/bigdataStandalone.config =================================================================== --- trunk/src/resources/config/standalone/bigdataStandalone.config 2010-07-20 19:50:22 UTC (rev 3252) +++ trunk/src/resources/config/standalone/bigdataStandalone.config 2010-07-20 20:12:42 UTC (rev 3253) @@ -30,6 +30,7 @@ // imports for various options. import com.bigdata.btree.IndexMetadata; +import com.bigdata.btree.keys.KeyBuilder; import com.bigdata.rdf.sail.BigdataSail; import com.bigdata.rdf.spo.SPORelation; import com.bigdata.rdf.spo.SPOKeyOrder; @@ -1221,7 +1222,10 @@ * * @see com.bigdata.btree.keys.CollatorEnum */ - new NV(BigdataSail.Options.COLLATOR,"ASCII"), + new NV(KeyBuilder.Options.COLLATOR,"ICU"), + new NV(KeyBuilder.Options.USER_LANGUAGE,"en"), + new NV(KeyBuilder.Options.USER_COUNTRY,"US"), + new NV(KeyBuilder.Options.USER_VARIANT,""), /* * Turn off the full text index (search for literals by keyword). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2010-07-20 19:50:29
|
Revision: 3252 http://bigdata.svn.sourceforge.net/bigdata/?rev=3252&view=rev Author: thompsonbry Date: 2010-07-20 19:50:22 +0000 (Tue, 20 Jul 2010) Log Message: ----------- Added test suite for the non-inline mode. Made BufferMode#Disk a synonym for DiskWORM. Deprecated DiskOnlyStrategy. It has been replaced by WORMStrategy. Removed some dead code in LexiconKeyBuilder. Modified Paths: -------------- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractBufferStrategy.java branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractJournal.java branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/BufferMode.java branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/DiskOnlyStrategy.java branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/FileMetadata.java branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/Options.java branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/IRelation.java branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/rule/IPredicate.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconKeyBuilder.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/store/AbstractTripleStore.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/lexicon/TestTerm2IdTupleSerializer.java branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestAll.java Added Paths: ----------- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreWithoutInlining.java Removed Paths: ------------- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/test/com/bigdata/rdf/store/TestLocalTripleStoreWORM.java Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractBufferStrategy.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractBufferStrategy.java 2010-07-20 19:42:57 UTC (rev 3251) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractBufferStrategy.java 2010-07-20 19:50:22 UTC (rev 3252) @@ -421,7 +421,7 @@ * * @return The extent. */ - static long assertNonDiskExtent(long extent) { + static long assertNonDiskExtent(final long extent) { if( extent > Integer.MAX_VALUE ) { @@ -432,8 +432,9 @@ * disk-based strategy. */ - throw new RuntimeException("The extent requires the " - + BufferMode.Disk + " mode: extent=" + extent); + throw new RuntimeException( + "The extent requires a disk-backed buffer mode: extent=" + + extent); } Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractJournal.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractJournal.java 2010-07-20 19:42:57 UTC (rev 3251) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/AbstractJournal.java 2010-07-20 19:50:22 UTC (rev 3252) @@ -1027,32 +1027,33 @@ } - case Disk: { +// case Disk: { +// +// /* +// * Setup the buffer strategy. +// */ +// +// fileMetadata = new FileMetadata(file, BufferMode.Disk, +// useDirectBuffers, initialExtent, maximumExtent, create, +// isEmptyFile, deleteOnExit, readOnly, forceWrites, +// offsetBits, //readCacheCapacity, readCacheMaxRecordSize, +// //readOnly ? null : writeCache, +// writeCacheEnabled, +// validateChecksum, +// createTime, checker, alternateRootBlock); +// +// _bufferStrategy = new DiskOnlyStrategy( +// 0L/* soft limit for maximumExtent */, +//// minimumExtension, +// fileMetadata); +// +// this._rootBlock = fileMetadata.rootBlock; +// +// break; +// +// } - /* - * Setup the buffer strategy. - */ - - fileMetadata = new FileMetadata(file, BufferMode.Disk, - useDirectBuffers, initialExtent, maximumExtent, create, - isEmptyFile, deleteOnExit, readOnly, forceWrites, - offsetBits, //readCacheCapacity, readCacheMaxRecordSize, - //readOnly ? null : writeCache, - writeCacheEnabled, - validateChecksum, - createTime, checker, alternateRootBlock); - - _bufferStrategy = new DiskOnlyStrategy( - 0L/* soft limit for maximumExtent */, -// minimumExtension, - fileMetadata); - - this._rootBlock = fileMetadata.rootBlock; - - break; - - } - + case Disk: case DiskWORM: { /* Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/BufferMode.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/BufferMode.java 2010-07-20 19:42:57 UTC (rev 3251) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/BufferMode.java 2010-07-20 19:50:22 UTC (rev 3252) @@ -100,13 +100,10 @@ /** * <p> - * The journal is managed on disk. This option may be used with files of - * more than {@link Integer#MAX_VALUE} bytes in extent. Journal performance - * for large files should be fair on write, but performance will degrade as - * the journal is NOT optimized for random reads (poor locality). + * This is a synonym for {@link #DiskWORM}. * </p> * - * @see DiskOnlyStrategy + * @see WORMStrategy */ Disk(true/* stable */, false/* fullyBuffered */), @@ -119,12 +116,6 @@ * </p> * * @see WORMStrategy - * - * @deprecated This mode exists to test a new version of the - * {@link DiskOnlyStrategy} which does not require - * synchronization for disk read/write operations except when - * the file size is being changed. Once this is working properly - * it will replace the {@link DiskOnlyStrategy}. */ DiskWORM(true/* stable */, false/* fullyBuffered */), Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/DiskOnlyStrategy.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/DiskOnlyStrategy.java 2010-07-20 19:42:57 UTC (rev 3251) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/DiskOnlyStrategy.java 2010-07-20 19:50:22 UTC (rev 3252) @@ -155,6 +155,8 @@ * * @see BufferMode#Disk * @see BufferMode#Temporary + * + * @deprecated This has been replaced by {@link WORMStrategy}. */ public class DiskOnlyStrategy extends AbstractBufferStrategy implements IDiskBasedStrategy { Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/FileMetadata.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/FileMetadata.java 2010-07-20 19:42:57 UTC (rev 3251) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/FileMetadata.java 2010-07-20 19:50:22 UTC (rev 3252) @@ -582,8 +582,8 @@ break; } case Disk: - buffer = null; - break; +// buffer = null; +// break; case DiskWORM: buffer = null; break; @@ -757,8 +757,8 @@ buffer = null; break; case Disk: - buffer = null; - break; +// buffer = null; +// break; case DiskWORM: buffer = null; break; Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/Options.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/Options.java 2010-07-20 19:42:57 UTC (rev 3251) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/journal/Options.java 2010-07-20 19:50:22 UTC (rev 3252) @@ -495,7 +495,7 @@ /** * The default for the {@link #BUFFER_MODE}. */ - String DEFAULT_BUFFER_MODE = BufferMode.Disk.toString(); + String DEFAULT_BUFFER_MODE = BufferMode.DiskWORM.toString(); /** * The default for {@link #USE_DIRECT_BUFFERS}. Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/IRelation.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/IRelation.java 2010-07-20 19:42:57 UTC (rev 3251) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/IRelation.java 2010-07-20 19:50:22 UTC (rev 3252) @@ -123,6 +123,8 @@ * relation. * * @return An immutable set of the index names for the relation. + * + * @todo replace with getKeyOrders()? */ Set<String> getIndexNames(); @@ -157,6 +159,8 @@ // // /** // * Return the primary index for the relation. +// * +// * @todo how about getIndex(IKeyOrder) instead? // */ // IIndex getPrimaryIndex(); Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/rule/IPredicate.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/rule/IPredicate.java 2010-07-20 19:42:57 UTC (rev 3251) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata/src/java/com/bigdata/relation/rule/IPredicate.java 2010-07-20 19:50:22 UTC (rev 3252) @@ -171,6 +171,8 @@ /** * An optional constraint on the visitable elements. + * + * @todo rename as get(Element)Filter(). */ public IElementFilter<E> getConstraint(); Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java 2010-07-20 19:42:57 UTC (rev 3251) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/internal/LexiconConfiguration.java 2010-07-20 19:50:22 UTC (rev 3252) @@ -29,6 +29,18 @@ import java.io.Serializable; +/** + * An object which describes which kinds of RDF Values are inlined into the + * statement indices and how other RDF Values are coded into the lexicon. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + * + * FIXME Version information in serialization format. + * + * @todo large literal size boundary. + * @todo other configuration options. + */ public class LexiconConfiguration implements Serializable, ILexiconConfiguration { Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconKeyBuilder.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconKeyBuilder.java 2010-07-20 19:42:57 UTC (rev 3251) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconKeyBuilder.java 2010-07-20 19:50:22 UTC (rev 3252) @@ -1,18 +1,13 @@ package com.bigdata.rdf.lexicon; -import java.util.HashMap; -import java.util.Map; - import org.openrdf.model.BNode; import org.openrdf.model.Literal; import org.openrdf.model.URI; import org.openrdf.model.Value; -import org.openrdf.model.vocabulary.RDF; import org.openrdf.model.vocabulary.XMLSchema; import com.bigdata.btree.keys.IKeyBuilder; import com.bigdata.btree.keys.IKeyBuilderFactory; -import com.bigdata.btree.keys.KeyBuilder; import com.bigdata.btree.keys.StrengthEnum; /** @@ -78,257 +73,577 @@ public final IKeyBuilder keyBuilder; - /** - * Interface for classes encapsulating the logic to encode (and where - * possible, decode) datatype literals. - * - * @author <a href="mailto:tho...@us...">Bryan - * Thompson</a> - * @version $Id$ - */ - public static interface IDatatypeKeyCoder { - - /** - * Interpret the text as some specific data type and encode a - * representation of that data type value suitable for an index whose - * keys are unsigned byte[]s. - * - * @param keyBuilder - * The object used to build up the key. - * @param text - * A lexical representation of the value. - */ - void encode(IKeyBuilder keyBuilder, String text); - - /** - * Decode a slice of a byte[] containing a key formed by - * {@link #encode(IKeyBuilder, String)}. - * - * @param key - * The byte[]. - * @param off - * The first byte in the slice. - * @param len - * The length of the slice. - * - * @return A lexical representation of the decoded value. - * - * @throws UnsupportedOperationException - * If the keys for the datatype encoded by this interface - * can not be decoded without loss. For example, this is - * true of {@link XMLSchema#STRING} when compressed Unicode - * sort keys are used. - * - * @todo the [len] parameter is probably not necessary for most things, - * but there are some cool key types that are both variable length - * and totally ordered. E.g., eXist XML node identifiers. - */ - String decode(byte[] key, int off, int len); - - /** - * Return <code>true</code> if the implementation of this interface - * encodes keys which can be decoded without loss. "Loss" means that it - * is not possible to decode a value which correspond to the same point - * in the value space of the datatype. For example, <code>.5</code> and - * <code>0.5</code> both represent the same point in the - * {@link XMLSchema#FLOAT} value space. These values are therefore - * decodable without loss, even though the decoded value might not have - * the same lexical representation. - */ - boolean isDecodable(); - - /** - * Return the unique code designated for the primitive data type handled - * by this coder. Coders which self-report values for this method which - * are in conflict will be reported by a runtime exception. The - * appropriate code values are declared by this interface. The primitive - * datatypes include: - * - * <pre> - * 3.2.1 string - * 3.2.2 boolean - * 3.2.3 decimal - * 3.2.4 float - * 3.2.5 double - * 3.2.6 duration - * 3.2.7 dateTime - * 3.2.8 time - * 3.2.9 date - * 3.2.10 gYearMonth - * 3.2.11 gYear - * 3.2.12 gMonthDay - * 3.2.13 gDay - * 3.2.14 gMonth - * 3.2.15 hexBinary - * 3.2.16 base64Binary - * 3.2.17 anyURI - * 3.2.18 QName - * 3.2.19 NOTATION - * </pre> - * - * @see http://www.w3.org/TR/swbp-xsch-datatypes/ - * @see <a ref="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#built-in-primitive-datatypes>primitiv - * e data types.</a> - */ - int code(); - - /** - * Code used for unrecognized or otherwise unhandled data types. - */ - int CODE_OTHER = 0; - - int CODE_XSD_STRING = 1; - - int CODE_XSD_BOOLEAN = 2; - - /** - * Arbitrary magnitude decimal values with arbitrary digits after the - * decimal. - */ - int CODE_XSD_DECIMAL = 3; - - int CODE_XSD_FLOAT = 4; - - int CODE_XSD_DOUBLE = 5; - - /** @deprecated until good semantics have been developed. */ - int CODE_XSD_DURATION = 6; - - int CODE_XSD_DATETIME = 7; - - int CODE_XSD_TIME = 8; - - int CODE_XSD_DATE = 9; - - int CODE_XSD_GYEARMONTH = 10; - - int CODE_XSD_GYEAR = 11; - - int CODE_XSD_GMONTHDAY = 12; - - int CODE_XSD_HEXBINARY = 13; - - int CODE_XSD_BASE64BINARY = 14; - - int CODE_XSD_ANYURI = 15; - - int CODE_XSD_QNAME = 16; - - int CODE_XSD_NOTATION = 17; - - /* - * Arbitrary magnitude integers. - */ - int CODE_XSD_INTEGER = 18; - - /* - * Various signed fixed width integer types. - */ - int CODE_XSD_LONG = 32; - - int CODE_XSD_INT = 33; - - int CODE_XSD_SHORT = 34; - - int CODE_XSD_BYTE = 35; - - /* - * Various unsigned fixed with integer types. - */ - int CODE_XSD_ULONG = 36; - - int CODE_XSD_UINT = 37; - - int CODE_XSD_USHORT = 38; - - int CODE_XSD_UBYTE = 39; - - /** - * An {@link RDF#XMLLITERAL}. - */ - int CODE_XML_LITERAL = 40; - - } - - /** - * Handles anything derived from the primitive data type - * {@link XMLSchema#BOOLEAN}. All such values are coded in a single byte. - * - * @author <a href="mailto:tho...@us...">Bryan - * Thompson</a> - * @version $Id$ - */ - public static class XSDBooleanCoder implements IDatatypeKeyCoder { - - public static transient final IDatatypeKeyCoder INSTANCE = new XSDBooleanCoder(); - - public int code() { - - return CODE_XSD_BOOLEAN; - - } - - public String decode(byte[] buf, int off, int len) { - - return KeyBuilder.decodeByte(buf[off]) == 1 ? "true" : "false"; - - } - - public void encode(IKeyBuilder keyBuilder, String text) { - - text = text.trim(); - - final boolean t; - - if ("true".equalsIgnoreCase(text) || "1".equals(text)) { - - t = true; - - } else if ("false".equalsIgnoreCase(text) || "0".equals(text)) { - - t = false; - - } else { - - throw new RuntimeException("Does not match xsd:boolean : " - + text); - - } - - keyBuilder.append((byte) (t ? 1 : 0)); - - } - - /** Yes. */ - public boolean isDecodable() { - - return true; - - } - - } - // /** +// * Interface for classes encapsulating the logic to encode (and where +// * possible, decode) datatype literals. +// * +// * @author <a href="mailto:tho...@us...">Bryan +// * Thompson</a> +// * @version $Id$ +// */ +// public static interface IDatatypeKeyCoder { +// +// /** +// * Interpret the text as some specific data type and encode a +// * representation of that data type value suitable for an index whose +// * keys are unsigned byte[]s. +// * +// * @param keyBuilder +// * The object used to build up the key. +// * @param text +// * A lexical representation of the value. +// */ +// void encode(IKeyBuilder keyBuilder, String text); +// +// /** +// * Decode a slice of a byte[] containing a key formed by +// * {@link #encode(IKeyBuilder, String)}. +// * +// * @param key +// * The byte[]. +// * @param off +// * The first byte in the slice. +// * @param len +// * The length of the slice. +// * +// * @return A lexical representation of the decoded value. +// * +// * @throws UnsupportedOperationException +// * If the keys for the datatype encoded by this interface +// * can not be decoded without loss. For example, this is +// * true of {@link XMLSchema#STRING} when compressed Unicode +// * sort keys are used. +// * +// * @todo the [len] parameter is probably not necessary for most things, +// * but there are some cool key types that are both variable length +// * and totally ordered. E.g., eXist XML node identifiers. +// */ +// String decode(byte[] key, int off, int len); +// +// /** +// * Return <code>true</code> if the implementation of this interface +// * encodes keys which can be decoded without loss. "Loss" means that it +// * is not possible to decode a value which correspond to the same point +// * in the value space of the datatype. For example, <code>.5</code> and +// * <code>0.5</code> both represent the same point in the +// * {@link XMLSchema#FLOAT} value space. These values are therefore +// * decodable without loss, even though the decoded value might not have +// * the same lexical representation. +// */ +// boolean isDecodable(); +// +// /** +// * Return the unique code designated for the primitive data type handled +// * by this coder. Coders which self-report values for this method which +// * are in conflict will be reported by a runtime exception. The +// * appropriate code values are declared by this interface. The primitive +// * datatypes include: +// * +// * <pre> +// * 3.2.1 string +// * 3.2.2 boolean +// * 3.2.3 decimal +// * 3.2.4 float +// * 3.2.5 double +// * 3.2.6 duration +// * 3.2.7 dateTime +// * 3.2.8 time +// * 3.2.9 date +// * 3.2.10 gYearMonth +// * 3.2.11 gYear +// * 3.2.12 gMonthDay +// * 3.2.13 gDay +// * 3.2.14 gMonth +// * 3.2.15 hexBinary +// * 3.2.16 base64Binary +// * 3.2.17 anyURI +// * 3.2.18 QName +// * 3.2.19 NOTATION +// * </pre> +// * +// * @see http://www.w3.org/TR/swbp-xsch-datatypes/ +// * @see <a ref="http://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#built-in-primitive-datatypes>primitiv +// * e data types.</a> +// */ +// int code(); +// +// /** +// * Code used for unrecognized or otherwise unhandled data types. +// */ +// int CODE_OTHER = 0; +// +// int CODE_XSD_STRING = 1; +// +// int CODE_XSD_BOOLEAN = 2; +// +// /** +// * Arbitrary magnitude decimal values with arbitrary digits after the +// * decimal. +// */ +// int CODE_XSD_DECIMAL = 3; +// +// int CODE_XSD_FLOAT = 4; +// +// int CODE_XSD_DOUBLE = 5; +// +// /** @deprecated until good semantics have been developed. */ +// int CODE_XSD_DURATION = 6; +// +// int CODE_XSD_DATETIME = 7; +// +// int CODE_XSD_TIME = 8; +// +// int CODE_XSD_DATE = 9; +// +// int CODE_XSD_GYEARMONTH = 10; +// +// int CODE_XSD_GYEAR = 11; +// +// int CODE_XSD_GMONTHDAY = 12; +// +// int CODE_XSD_HEXBINARY = 13; +// +// int CODE_XSD_BASE64BINARY = 14; +// +// int CODE_XSD_ANYURI = 15; +// +// int CODE_XSD_QNAME = 16; +// +// int CODE_XSD_NOTATION = 17; +// +// /* +// * Arbitrary magnitude integers. +// */ +// int CODE_XSD_INTEGER = 18; +// +// /* +// * Various signed fixed width integer types. +// */ +// int CODE_XSD_LONG = 32; +// +// int CODE_XSD_INT = 33; +// +// int CODE_XSD_SHORT = 34; +// +// int CODE_XSD_BYTE = 35; +// +// /* +// * Various unsigned fixed with integer types. +// */ +// int CODE_XSD_ULONG = 36; +// +// int CODE_XSD_UINT = 37; +// +// int CODE_XSD_USHORT = 38; +// +// int CODE_XSD_UBYTE = 39; +// +// /** +// * An {@link RDF#XMLLITERAL}. +// */ +// int CODE_XML_LITERAL = 40; +// +// } +// +// /** // * Handles anything derived from the primitive data type -// * {@link XMLSchema#STRING}. Values are coded as Unicode sort keys and ARE -// * NOT decodable. +// * {@link XMLSchema#BOOLEAN}. All such values are coded in a single byte. // * // * @author <a href="mailto:tho...@us...">Bryan // * Thompson</a> // * @version $Id$ // */ -// public static class XSDStringCoder implements IDatatypeKeyCoder { +// public static class XSDBooleanCoder implements IDatatypeKeyCoder { // -// public static transient final IDatatypeKeyCoder INSTANCE = new XSDStringCoder(); +// public static transient final IDatatypeKeyCoder INSTANCE = new XSDBooleanCoder(); // // public int code() { // -// return CODE_XSD_STRING; +// return CODE_XSD_BOOLEAN; // // } // // public String decode(byte[] buf, int off, int len) { // +// return KeyBuilder.decodeByte(buf[off]) == 1 ? "true" : "false"; +// +// } +// +// public void encode(IKeyBuilder keyBuilder, String text) { +// +// text = text.trim(); +// +// final boolean t; +// +// if ("true".equalsIgnoreCase(text) || "1".equals(text)) { +// +// t = true; +// +// } else if ("false".equalsIgnoreCase(text) || "0".equals(text)) { +// +// t = false; +// +// } else { +// +// throw new RuntimeException("Does not match xsd:boolean : " +// + text); +// +// } +// +// keyBuilder.append((byte) (t ? 1 : 0)); +// +// } +// +// /** Yes. */ +// public boolean isDecodable() { +// +// return true; +// +// } +// +// } +// +//// /** +//// * Handles anything derived from the primitive data type +//// * {@link XMLSchema#STRING}. Values are coded as Unicode sort keys and ARE +//// * NOT decodable. +//// * +//// * @author <a href="mailto:tho...@us...">Bryan +//// * Thompson</a> +//// * @version $Id$ +//// */ +//// public static class XSDStringCoder implements IDatatypeKeyCoder { +//// +//// public static transient final IDatatypeKeyCoder INSTANCE = new XSDStringCoder(); +//// +//// public int code() { +//// +//// return CODE_XSD_STRING; +//// +//// } +//// +//// public String decode(byte[] buf, int off, int len) { +//// +//// throw new UnsupportedOperationException(); +//// +//// } +//// +//// public void encode(IKeyBuilder keyBuilder, String text) { +//// +//// keyBuilder.append(text); +//// +//// } +//// +//// /** No - this class uses Unicode sort keys, which are not decodable. */ +//// public boolean isDecodable() { +//// +//// return false; +//// +//// } +//// +//// } +// +// /** +// * Handles {@link XMLSchema#LONG}. All such values are coded as 64-bit +// * integers. +// * +// * @author <a href="mailto:tho...@us...">Bryan +// * Thompson</a> +// * @version $Id$ +// */ +// public static class XSDLongCoder implements IDatatypeKeyCoder { +// +// public static transient final IDatatypeKeyCoder INSTANCE = new XSDLongCoder(); +// +// public int code() { +// +// return CODE_XSD_LONG; +// +// } +// +// public String decode(byte[] buf, int off, int len) { +// +// return Long.toString(KeyBuilder.decodeLong(buf, off)); +// +// } +// +// public void encode(IKeyBuilder keyBuilder, String text) { +// +// keyBuilder.append(Long.valueOf(text).longValue()); +// +// } +// +// /** Yes. */ +// public boolean isDecodable() { +// +// return true; +// +// } +// +// } +// +// /** +// * Handles {@link XMLSchema#INT}. All such values are coded as 32-bit +// * integers. +// * +// * @author <a href="mailto:tho...@us...">Bryan +// * Thompson</a> +// * @version $Id$ +// */ +// public static class XSDIntCoder implements IDatatypeKeyCoder { +// +// public static transient final IDatatypeKeyCoder INSTANCE = new XSDIntCoder(); +// +// public int code() { +// +// return CODE_XSD_INT; +// +// } +// +// public String decode(byte[] buf, int off, int len) { +// +// return Integer.toString(KeyBuilder.decodeInt(buf, off)); +// +// } +// +// public void encode(IKeyBuilder keyBuilder, String text) { +// +// keyBuilder.append(Integer.valueOf(text).intValue()); +// +// } +// +// /** Yes. */ +// public boolean isDecodable() { +// +// return true; +// +// } +// +// } +// +// /** +// * Handles {@link XMLSchema#SHORT}. All such values are coded as 16-bit +// * integers. +// * +// * @author <a href="mailto:tho...@us...">Bryan +// * Thompson</a> +// * @version $Id$ +// */ +// public static class XSDShortCoder implements IDatatypeKeyCoder { +// +// public static transient final IDatatypeKeyCoder INSTANCE = new XSDShortCoder(); +// +// public int code() { +// +// return CODE_XSD_SHORT; +// +// } +// +// public String decode(byte[] buf, int off, int len) { +// +// return Short.toString(KeyBuilder.decodeShort(buf, off)); +// +// } +// +// public void encode(IKeyBuilder keyBuilder, String text) { +// +// keyBuilder.append(Short.valueOf(text).shortValue()); +// +// } +// +// /** Yes. */ +// public boolean isDecodable() { +// +// return true; +// +// } +// +// } +// +// /** +// * Handles {@link XMLSchema#BYTE}. All such values are coded as 8-bit +// * integers. +// * +// * @author <a href="mailto:tho...@us...">Bryan +// * Thompson</a> +// * @version $Id$ +// */ +// public static class XSDByteCoder implements IDatatypeKeyCoder { +// +// public static transient final IDatatypeKeyCoder INSTANCE = new XSDByteCoder(); +// +// public int code() { +// +// return CODE_XSD_BYTE; +// +// } +// +// public String decode(byte[] buf, int off, int len) { +// +// return Byte.toString(KeyBuilder.decodeByte(buf[off])); +// +// } +// +// public void encode(IKeyBuilder keyBuilder, String text) { +// +// keyBuilder.append(Byte.valueOf(text).byteValue()); +// +// } +// +// /** Yes. */ +// public boolean isDecodable() { +// +// return true; +// +// } +// +// } +// +// /** +// * Handles anything derived from the primitive data type +// * {@link XMLSchema#FLOAT}. All such values are coded as 32-bit integers. +// * +// * @author <a href="mailto:tho...@us...">Bryan +// * Thompson</a> +// * @version $Id$ +// */ +// public static class XSDFloatCoder implements IDatatypeKeyCoder { +// +// public static transient final IDatatypeKeyCoder INSTANCE = new XSDFloatCoder(); +// +// public int code() { +// +// return CODE_XSD_FLOAT; +// +// } +// +// public String decode(byte[] buf, int off, int len) { +// +// return Float.toString(KeyBuilder.decodeFloat(buf, off)); +// +// } +// +// public void encode(IKeyBuilder keyBuilder, String text) { +// +// keyBuilder.append(Float.valueOf(text).floatValue()); +// +// } +// +// /** Yes. */ +// public boolean isDecodable() { +// +// return true; +// +// } +// +// } +// +// /** +// * Handles anything derived from the primitive data type +// * {@link XMLSchema#DOUBLE}. All such values are coded as 64-bit integers. +// * +// * @author <a href="mailto:tho...@us...">Bryan +// * Thompson</a> +// * @version $Id$ +// */ +// public static class XSDDoubleCoder implements IDatatypeKeyCoder { +// +// public static transient final IDatatypeKeyCoder INSTANCE = new XSDDoubleCoder(); +// +// public int code() { +// +// return CODE_XSD_DOUBLE; +// +// } +// +// public String decode(byte[] buf, int off, int len) { +// +// return Double.toString(KeyBuilder.decodeDouble(buf, off)); +// +// } +// +// public void encode(IKeyBuilder keyBuilder, String text) { +// +// keyBuilder.append(Double.valueOf(text).doubleValue()); +// +// } +// +// /** Yes. */ +// public boolean isDecodable() { +// +// return true; +// +// } +// +// } +// +//// /** +//// * Handles anything derived from the primitive data type +//// * {@link XMLSchema#DATETIME}. +//// * +//// * @author <a href="mailto:tho...@us...">Bryan +//// * Thompson</a> +//// * @version $Id$ +//// */ +//// public static class XSDDateTimeCoder implements IDatatypeKeyCoder { +//// +//// public static transient final IDatatypeKeyCoder INSTANCE = new XSDDateTimeCoder(); +//// +//// public int code() { +//// +//// return CODE_XSD_DATETIME; +//// +//// } +//// +//// public String decode(byte[] buf, int off, int len) { +//// +//// throw new UnsupportedOperationException(); +////// return Double.toString(KeyBuilder.decodeDouble(buf, off)); +//// +//// } +//// +//// public void encode(IKeyBuilder keyBuilder, String text) { +//// +//// final XMLGregorianCalendar cal = XMLDatatypeUtil.parseCalendar(text); +//// +//// // FIXME normalize to UTC and encode as int64 seconds since epoch or what? +//// +////// keyBuilder.append(.doubleValue()); +//// +//// throw new UnsupportedOperationException(); +//// +//// } +//// +//// /** No. */ +//// public boolean isDecodable() { +//// +//// return false; +//// +//// } +//// +//// } +// +// /** +// * Handles anything derived from the primitive data type +// * {@link XMLSchema#STRING}. Values are coded as Unicode sort keys and +// * ARE NOT decodable. +// * +// * @author <a href="mailto:tho...@us...">Bryan +// * Thompson</a> +// * @version $Id$ +// */ +// public static class XSDAnyURICoder implements IDatatypeKeyCoder { +// +// public static transient final IDatatypeKeyCoder INSTANCE = new XSDAnyURICoder(); +// +// public int code() { +// +// return CODE_XSD_ANYURI; +// +// } +// +// public String decode(byte[] buf, int off, int len) { +// // throw new UnsupportedOperationException(); // // } @@ -347,529 +662,209 @@ // } // // } - - /** - * Handles {@link XMLSchema#LONG}. All such values are coded as 64-bit - * integers. - * - * @author <a href="mailto:tho...@us...">Bryan - * Thompson</a> - * @version $Id$ - */ - public static class XSDLongCoder implements IDatatypeKeyCoder { - - public static transient final IDatatypeKeyCoder INSTANCE = new XSDLongCoder(); - - public int code() { - - return CODE_XSD_LONG; - - } - - public String decode(byte[] buf, int off, int len) { - - return Long.toString(KeyBuilder.decodeLong(buf, off)); - - } - - public void encode(IKeyBuilder keyBuilder, String text) { - - keyBuilder.append(Long.valueOf(text).longValue()); - - } - - /** Yes. */ - public boolean isDecodable() { - - return true; - - } - - } - - /** - * Handles {@link XMLSchema#INT}. All such values are coded as 32-bit - * integers. - * - * @author <a href="mailto:tho...@us...">Bryan - * Thompson</a> - * @version $Id$ - */ - public static class XSDIntCoder implements IDatatypeKeyCoder { - - public static transient final IDatatypeKeyCoder INSTANCE = new XSDIntCoder(); - - public int code() { - - return CODE_XSD_INT; - - } - - public String decode(byte[] buf, int off, int len) { - - return Integer.toString(KeyBuilder.decodeInt(buf, off)); - - } - - public void encode(IKeyBuilder keyBuilder, String text) { - - keyBuilder.append(Integer.valueOf(text).intValue()); - - } - - /** Yes. */ - public boolean isDecodable() { - - return true; - - } - - } - - /** - * Handles {@link XMLSchema#SHORT}. All such values are coded as 16-bit - * integers. - * - * @author <a href="mailto:tho...@us...">Bryan - * Thompson</a> - * @version $Id$ - */ - public static class XSDShortCoder implements IDatatypeKeyCoder { - - public static transient final IDatatypeKeyCoder INSTANCE = new XSDShortCoder(); - - public int code() { - - return CODE_XSD_SHORT; - - } - - public String decode(byte[] buf, int off, int len) { - - return Short.toString(KeyBuilder.decodeShort(buf, off)); - - } - - public void encode(IKeyBuilder keyBuilder, String text) { - - keyBuilder.append(Short.valueOf(text).shortValue()); - - } - - /** Yes. */ - public boolean isDecodable() { - - return true; - - } - - } - - /** - * Handles {@link XMLSchema#BYTE}. All such values are coded as 8-bit - * integers. - * - * @author <a href="mailto:tho...@us...">Bryan - * Thompson</a> - * @version $Id$ - */ - public static class XSDByteCoder implements IDatatypeKeyCoder { - - public static transient final IDatatypeKeyCoder INSTANCE = new XSDByteCoder(); - - public int code() { - - return CODE_XSD_BYTE; - - } - - public String decode(byte[] buf, int off, int len) { - - return Byte.toString(KeyBuilder.decodeByte(buf[off])); - - } - - public void encode(IKeyBuilder keyBuilder, String text) { - - keyBuilder.append(Byte.valueOf(text).byteValue()); - - } - - /** Yes. */ - public boolean isDecodable() { - - return true; - - } - - } - - /** - * Handles anything derived from the primitive data type - * {@link XMLSchema#FLOAT}. All such values are coded as 32-bit integers. - * - * @author <a href="mailto:tho...@us...">Bryan - * Thompson</a> - * @version $Id$ - */ - public static class XSDFloatCoder implements IDatatypeKeyCoder { - - public static transient final IDatatypeKeyCoder INSTANCE = new XSDFloatCoder(); - - public int code() { - - return CODE_XSD_FLOAT; - - } - - public String decode(byte[] buf, int off, int len) { - - return Float.toString(KeyBuilder.decodeFloat(buf, off)); - - } - - public void encode(IKeyBuilder keyBuilder, String text) { - - keyBuilder.append(Float.valueOf(text).floatValue()); - - } - - /** Yes. */ - public boolean isDecodable() { - - return true; - - } - - } - - /** - * Handles anything derived from the primitive data type - * {@link XMLSchema#DOUBLE}. All such values are coded as 64-bit integers. - * - * @author <a href="mailto:tho...@us...">Bryan - * Thompson</a> - * @version $Id$ - */ - public static class XSDDoubleCoder implements IDatatypeKeyCoder { - - public static transient final IDatatypeKeyCoder INSTANCE = new XSDDoubleCoder(); - - public int code() { - - return CODE_XSD_DOUBLE; - - } - - public String decode(byte[] buf, int off, int len) { - - return Double.toString(KeyBuilder.decodeDouble(buf, off)); - - } - - public void encode(IKeyBuilder keyBuilder, String text) { - - keyBuilder.append(Double.valueOf(text).doubleValue()); - - } - - /** Yes. */ - public boolean isDecodable() { - - return true; - - } - - } - +// // /** // * Handles anything derived from the primitive data type -// * {@link XMLSchema#DATETIME}. +// * {@link RDF#XMLLITERAL}. Values are coded as Unicode sort keys and ARE NOT +// * decodable. // * // * @author <a href="mailto:tho...@us...">Bryan // * Thompson</a> // * @version $Id$ // */ -// public static class XSDDateTimeCoder implements IDatatypeKeyCoder { +// public static class XSDXmlLiteralCoder implements IDatatypeKeyCoder { // -// public static transient final IDatatypeKeyCoder INSTANCE = new XSDDateTimeCoder(); +// public static transient final IDatatypeKeyCoder INSTANCE = new XSDXmlLiteralCoder(); // // public int code() { // -// return CODE_XSD_DATETIME; +// return CODE_XML_LITERAL; // // } // // public String decode(byte[] buf, int off, int len) { // // throw new UnsupportedOperationException(); -//// return Double.toString(KeyBuilder.decodeDouble(buf, off)); // // } // // public void encode(IKeyBuilder keyBuilder, String text) { // -// final XMLGregorianCalendar cal = XMLDatatypeUtil.parseCalendar(text); +// keyBuilder.append(text); // -// // FIXME normalize to UTC and encode as int64 seconds since epoch or what? -// -//// keyBuilder.append(.doubleValue()); +// } // +// /** No - this class uses Unicode sort keys, which are not decodable. */ +// public boolean isDecodable() { +// +// return false; +// +// } +// +// } +// +// /** +// * Map from the specific datatype URI to the coder instance for that +// * datatype. +// */ +// private static final Map<URI/* datatype */, IDatatypeKeyCoder> coders; +// +// private static final Map<Integer, IDatatypeKeyCoder> codes; +// +// synchronized static private void registerCoder(final URI datatype, +// IDatatypeKeyCoder newCoder) { +// +// if (coders == null) // throw new UnsupportedOperationException(); +// +// if (newCoder == null) +// throw new IllegalArgumentException(); // +// final int code = newCoder.code(); +// +// if (codes.containsKey(code)) { +// +// throw new IllegalStateException( +// "Coder already registered for code: code=" + code +// + ", val=" + codes.get(code) + ", new=" + newCoder); +// // } // -// /** No. */ -// public boolean isDecodable() { +// if (coders.containsKey(code)) { // -// return false; +// throw new IllegalStateException( +// "Coder already registered for datatype: datatype=" +// + datatype + ", val=" + codes.get(code) + ", new=" +// + newCoder); // // } // +// coders.put(datatype, newCoder); +// +// codes.put(code, newCoder); +// // } +// +// static { +// +// if(true) { +// +// /* +// * Disable coders. +// * +// * FIXME configuration option for coders? Per triple store instance? +// * Or are the coders just not compatible with the SPARQL +// * specification? +// */ +// +// coders = null; +// +// codes = null; +// +// } else { +// +// // datatype URI to coder map. +// coders = new HashMap<URI, IDatatypeKeyCoder>(); +// +// // code to coder map. +// codes = new HashMap<Integer, IDatatypeKeyCoder>(); +// +// // 3.2.1 string and derived types. +// // Note: string is mapped onto plainLiteral by RDF Semantics. +//// registerCoder(XMLSchema.STRING, XSDStringCoder.INSTANCE); +//// registerCoder(XMLSchema.NORMALIZEDSTRING, XSDStringCoder.INSTANCE); +//// registerCoder(XMLSchema.TOKEN, XSDStringCoder.INSTANCE); +//// registerCoder(XMLSchema.LANGUAGE, XSDStringCoder.INSTANCE); +//// registerCoder(XMLSchema.NAME, XSDStringCoder.INSTANCE); +//// registerCoder(XMLSchema.NCNAME, XSDStringCoder.INSTANCE); +//// registerCoder(XMLSchema.ID, XSDStringCoder.INSTANCE); +//// registerCoder(XMLSchema.IDREF, XSDStringCoder.INSTANCE); +//// registerCoder(XMLSchema.IDREFS, XSDStringCoder.INSTANCE); +//// registerCoder(XMLSchema.ENTITY, XSDStringCoder.INSTANCE); +//// registerCoder(XMLSchema.ENTITIES, XSDStringCoder.INSTANCE); +//// registerCoder(XMLSchema.NMTOKEN, XSDStringCoder.INSTANCE); +//// registerCoder(XMLSchema.NMTOKENS, XSDStringCoder.INSTANCE); +// +// // 3.2.2 boolean +// registerCoder(XMLSchema.BOOLEAN, XSDBooleanCoder.INSTANCE); +// +// // 3.2.3 decimal and derived types. +// +// /* +// * @todo decimal really needs to be a BigDecimal representation if such +// * a thing can be mapped onto a totally ordered unsigned byte[] key. +// * Failing that, it needs to be projected to a maximum magnitude fixed +// * byte length representation. Failing that, all comparison of order +// * must be done by the SPARQL engine. +// */ +//// registerCoder(XMLSchema.DECIMAL, XSDDecimalCoder.INSTANCE); +// +// /* +// * @todo integer really needs to be a BigInteger representation if such +// * a thing can be mapped onto a totally ordered unsigned byte[] key +// * (negative integers always appear to be larger than positive integers +// * with naive encoding). Failing that, it needs to be projected to a +// * maximum magnitude fixed byte length representation. Failing that, all +// * comparison of order must be done by the SPARQL engine. +// */ +//// registerCoder(XMLSchema.INTEGER, XSDDecimalCoder.INSTANCE); +//// registerCoder(XMLSchema.POSITIVE_INTEGER, XSDDecimalCoder.INSTANCE); +//// registerCoder(XMLSchema.NON_POSITIVE_INTEGER, XSDDecimalCoder.INSTANCE); +//// registerCoder(XMLSchema.NON_NEGATIVE_INTEGER, XSDDecimalCoder.INSTANCE); +// +// /* +// * These are all fixed width signed datatypes. Each has its own code and +// * its own disjoint value space. +// */ +// registerCoder(XMLSchema.LONG, XSDLongCoder.INSTANCE); // 64-bits +// registerCoder(XMLSchema.INT, XSDIntCoder.INSTANCE); // 32-bits +// registerCoder(XMLSchema.SHORT, XSDShortCoder.INSTANCE); // 16-bits +// registerCoder(XMLSchema.BYTE, XSDByteCoder.INSTANCE); // 8 bits. +// /* +// * These are all fixed width unsigned datatypes. Each has its own code +// * and its own disjoint value space. +// * +// * @todo unsigned long +// * @todo unsigned int +// * @todo unsigned short +// * @todo unsigned byte +// */ +//// registerCoder(XMLSchema.UNSIGNED_LONG, XSDULongCoder.INSTANCE); // 64-bits +//// registerCoder(XMLSchema.UNSIGNED_INT, XSDUIntCoder.INSTANCE);// 32-bits +//// registerCoder(XMLSchema.UNSIGNED_SHORT, XSDUShortecimalCoder.INSTANCE); // 16-bits +//// registerCoder(XMLSchema.UNSIGNED_BYTE, XSDUByteCoder.INSTANCE); // 8-bits +// +// // 3.2.4 float +// registerCoder(XMLSchema.FLOAT, XSDFloatCoder.INSTANCE); +// +// // 3.2.5 double +// registerCoder(XMLSchema.DOUBLE, XSDDoubleCoder.INSTANCE); +// +// // 3.2.6 duration Note: not implemented yet per W3C Note. +// +// // @todo 3.2.7 dateTime +//// registerCoder(XMLSchema.DATETIME, XSDDateTimeCoder.INSTANCE); +// // @todo 3.2.8 time +// // @todo 3.2.9 date +// // @todo 3.2.10 gYearMonth +// // @todo 3.2.11 gYear +// // @todo 3.2.12 gMonthDay +// // @todo 3.2.13 gDay +// // @todo 3.2.14 gMonth +// // @todo 3.2.15 hexBinary +// // @todo 3.2.16 base64Binary +// // 3.2.17 anyURI +// registerCoder(XMLSchema.ANYURI, XSDAnyURICoder.INSTANCE); +// // @todo 3.2.18 QName +// // @todo 3.2.19 NOTATION +// +// registerCoder(RDF.XMLLITERAL, XSDXmlLiteralCoder.INSTANCE); +// +// } +// +// } /** - * Handles anything derived from the primitive data type - * {@link XMLSchema#STRING}. Values are coded as Unicode sort keys and - * ARE NOT decodable. - * - * @author <a href="mailto:tho...@us...">Bryan - * Thompson</a> - * @version $Id$ - */ - public static class XSDAnyURICoder implements IDatatypeKeyCoder { - - public static transient final IDatatypeKeyCoder INSTANCE = new XSDAnyURICoder(); - - public int code() { - - return CODE_XSD_ANYURI; - - } - - public String decode(byte[] buf, int off, int len) { - - throw new UnsupportedOperationException(); - - } - - public void encode(IKeyBuilder keyBuilder, String text) { - - keyBuilder.append(text); - - } - - /** No - this class uses Unicode sort keys, which are not decodable. */ - public boolean isDecodable() { - - return false; - - } - - } - - /** - * Handles anything derived from the primitive data type - * {@link RDF#XMLLITERAL}. Values are coded as Unicode sort keys and ARE NOT - * decodable. - * - * @author <a href="mailto:tho...@us...">Bryan - * Thompson</a> - * @version $Id$ - */ - public static class XSDXmlLiteralCoder implements IDatatypeKeyCoder { - - public static transient final IDatatypeKeyCoder INSTANCE = new XSDXmlLiteralCoder(); - - public int code() { - - return CODE_XML_LITERAL; - - } - - public String decode(byte[] buf, int off, int len) { - - throw new UnsupportedOperationException(); - - } - - public void encode(IKeyBuilder keyBuilder, String text) { - - keyBuilder.append(text); - - } - - /** No - this class uses Unicode sort keys, which are not decodable. */ - public boolean isDecodable() { - - return false; - - } - - } - - /** - * Map from the specific datatype URI to the coder instance for that - * datatype. - */ - private static final Map<URI/* datatype */, IDatatypeKeyCoder> coders; - - private static final Map<Integer, IDatatypeKeyCoder> codes; - - synchronized static private void registerCoder(final URI datatype, - IDatatypeKeyCoder newCoder) { - - if (coders == null) - throw new UnsupportedOperationException(); - - if (newCoder == null) - throw new IllegalArgumentException(); - - final int code = newCoder.code(); - - if (codes.containsKey(code)) { - - throw new IllegalStateException( - "Coder already registered for code: code=" + code - + ", val=" + codes.get(code) + ", new=" + newCoder); - - } - - if (coders.containsKey(code)) { - - throw new IllegalStateException( - "Coder already registered for datatype: datatype=" - + datatype + ", val=" + codes.get(code) + ", new=" - + newCoder); - - } - - coders.put(datatype, newCoder); - - codes.put(code, newCoder); - - } - - static { - - if(true) { - - /* - * Disable coders. - * - * FIXME configuration option for coders? Per triple store instance? - * Or are the coders just not compatible with the SPARQL - * specification? - */ - - coders = null; - - codes = null; - - } else { - - // datatype URI to coder map. - coders = new HashMap<URI, IDatatypeKeyCoder>(); - - // code to coder map. - codes = new HashMap<Integer, IDatatypeKeyCoder>(); - - // 3.2.1 string and derived types. - // Note: string is mapped onto plainLiteral by RDF Semantics. -// registerCoder(XMLSchema.STRING, XSDStringCoder.INSTANCE); -// registerCoder(XMLSchema.NORMALIZEDSTRING, XSDStringCoder.INSTANCE); -// registerCoder(XMLSchema.TOKEN, XSDStringCoder.INSTANCE); -// registerCoder(XMLSchema.LANGUAGE, XSDStringCoder.INSTANCE); -// registerCoder(XMLSchema.NAME, XSDStringCoder.INSTANCE); -// registerCoder(XMLSchema.NCNAME, XSDStringCoder.INSTANCE); -// registerCoder(XMLSchema.ID, XSDStringCoder.INSTANCE); -// registerCoder(XMLSchema.IDREF, XSDStringCoder.INSTANCE); -// registerCoder(XMLSchema.IDREFS, XSDStringCoder.INSTANCE); -// registerCoder(XMLSchema.ENTITY, XSDStringCoder.INSTANCE); -// registerCoder(XMLSchema.ENTITIES, XSDStringCoder.INSTANCE); -// registerCoder(XMLSchema.NMTOKEN, XSDStringCoder.INSTANCE); -// registerCoder(XMLSchema.NMTOKENS, XSDStringCoder.INSTANCE); - - // 3.2.2 boolean - registerCoder(XMLSchema.BOOLEAN, XSDBooleanCoder.INSTANCE); - - // 3.2.3 decimal and derived types. - - /* - * @todo decimal really needs to be a BigDecimal representation if such - * a thing can be mapped onto a totally ordered unsigned byte[] key. - * Failing that, it needs to be projected to a maximum magnitude fixed - * byte length representation. Failing that, all comparison of order - * must be done by the SPARQL engine. - */ -// registerCoder(XMLSchema.DECIMAL, XSDDecimalCoder.INSTANCE); - - /* - * @todo integer really needs to be a BigInteger representation if such - * a thing can be mapped onto a totally ordered unsigned byte[] key - * (negative integers always appear to be larger than positive integers - * with naive encoding). Failing that, it needs to be projected to a - * maximum magnitude fixed byte length representation. Failing that, all - * comparison of order must be done by the SPARQL engine. - */ -// registerCoder(XMLSchema.INTEGER, XSDDecimalCoder.INSTANCE); -// registerCoder(XMLSchema.POSITIVE_INTEGER, XSDDecimalCoder.INSTANCE); -// registerCoder(XMLSchema.NON_POSITIVE_INTEGER, XSDDecimalCoder.INSTANCE); -// registerCoder(XMLSchema.NON_NEGATIVE_INTEGER, XSDDecimalCoder.INSTANCE); - - /* - * These are all fixed width signed datatypes. Each has its own code and - * its own disjoint value space. - */ - registerCoder(XMLSchema.LONG, XSDLongCoder.INSTANCE); // 64-bits - registerCoder(XMLSchema.INT, XSDIntCoder.INSTANCE); // 32-bits - registerCoder(XMLSchema.SHORT, XSDShortCoder.INSTANCE); // 16-bits - registerCoder(XMLSchema.BYTE, XSDByteCoder.INSTANCE); // 8 bits. - /* - * These are all fixed width unsigned datatypes. Each has its own code - * and its own disjoint value space. - * - * @todo unsigned long - * @todo unsigned int - * @todo unsigned short - * @todo unsigned byte - */ -// registerCoder(XMLSchema.UNSIGNED_LONG, XSDULongCoder.INSTANCE); // 64-bits -// registerCoder(XMLSchema.UNSIGNED_INT, XSDUIntCoder.INSTANCE);// 32-bits -// registerCoder(XMLSchema.UNSIGNED_SHORT, XSDUShortecimalCoder.INSTANCE); // 16-bits -// registerCoder(XMLSchema.UNSIGNED_BYTE, XSDUByteCoder.INSTANCE); // 8-bits - - // 3.2.4 float - registerCoder(XMLSchema.FLOAT, XSDFloatCoder.INSTANCE); - - // 3.2.5 double - registerCoder(XMLSchema.DOUBLE, XSDDoubleCoder.INSTANCE); - - // 3.2.6 duration Note: not implemented yet per W3C Note. - - // @todo 3.2.7 dateTime -// registerCoder(XMLSchema.DATETIME, XSDDateTimeCoder.INSTANCE); - // @todo 3.2.8 time - // @todo 3.2.9 date - // @todo 3.2.10 gYearMonth - // @todo 3.2.11 gYear - // @todo 3.2.12 gMonthDay - // @todo 3.2.13 gDay - // @todo 3.2.14 gMonth - // @todo 3.2.15 hexBinary - // @todo 3.2.16 base64Binary - // 3.2.17 anyURI - registerCoder(XMLSchema.ANYURI, XSDAnyURICoder.INSTANCE); - // @todo 3.2.18 QName - // @todo 3.2.19 NOTATION - - registerCoder(RDF.XMLLITERAL, XSDXmlLiteralCoder.INSTANCE); - - } - - } - - /** * Normally invoked by {@link Term2IdTupleSerializer#getLexiconKeyBuilder()} * * @param keyBuilder @@ -972,7 +967,7 @@ } - if (coders == null) { +// if (coders == null) { /* * Note: This is the original DTL code space. The full lexical form @@ -995,52 +990,52 @@ return keyBuilder.getKey(); - } else { +// } else { +// +// // clear out any existing key and add prefix for the DTL space. +// keyBuilder.reset().append(TERM_CODE_DTL2); +// +// final IDatatypeKeyCoder coder = coders.get(datatype); +// +// if (coder == null) { +// +// /* +// * Unknown datatypes are placed into a disjoint space first, for +// * all unknown data types, and second, for the specific data +// * type using its URI encoded as a sort key. Finally, the +// * unknown data type value is encoded on the key. +// */ +// +// // disjoint value space for all unknown data type URIs. +// keyBuilder.append(IDatatypeKeyCoder.CODE_OTHER); +// +// // encode the datatype URI as Unicode sort key to make all +// ... [truncated message content] |
From: <mrp...@us...> - 2010-07-20 19:43:03
|
Revision: 3251 http://bigdata.svn.sourceforge.net/bigdata/?rev=3251&view=rev Author: mrpersonick Date: 2010-07-20 19:42:57 +0000 (Tue, 20 Jul 2010) Log Message: ----------- no longer needs the ILexiconConfiguration Modified Paths: -------------- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPORelation.java Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPORelation.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPORelation.java 2010-07-20 19:41:32 UTC (rev 3250) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/SPORelation.java 2010-07-20 19:42:57 UTC (rev 3251) @@ -127,8 +127,7 @@ * @author <a href="mailto:tho...@us...">Bryan Thompson</a> * @version $Id$ */ -public class SPORelation extends AbstractRelation<ISPO> - implements ILexiconConfiguration { +public class SPORelation extends AbstractRelation<ISPO> { protected static final transient Logger log = Logger .getLogger(SPORelation.class); @@ -327,15 +326,15 @@ // Note: Do not eagerly resolve the indices. - { - - final boolean inlineTerms = Boolean.parseBoolean(getProperty( - AbstractTripleStore.Options.INLINE_TERMS, - AbstractTripleStore.Options.DEFAULT_INLINE_TERMS)); - - lexiconConfiguration = new LexiconConfiguration(inlineTerms); - - } +// { +// +// final boolean inlineTerms = Boolean.parseBoolean(getProperty( +// AbstractTripleStore.Options.INLINE_TERMS, +// AbstractTripleStore.Options.DEFAULT_INLINE_TERMS)); +// +// lexiconConfiguration = new LexiconConfiguration(inlineTerms); +// +// } } @@ -2339,16 +2338,16 @@ /** * The {@link ILexiconConfiguration} instance, which will determine how * terms are encoded and decoded in the key space. - */ private ILexiconConfiguration lexiconConfiguration; + */ /** * See {@link ILexiconConfiguration#isInline(DTE)}. Delegates to the * {@link #lexiconConfiguration} instance. - */ public boolean isInline(DTE dte) { return lexiconConfiguration.isInline(dte); } + */ /** * See {@link ILexiconConfiguration#isLegacyEncoding()}. Delegates to the @@ -2361,9 +2360,9 @@ /** * Return the {@link #lexiconConfiguration} instance. Used to determine * how to encode and decode terms in the key space. - */ public ILexiconConfiguration getLexiconConfiguration() { return lexiconConfiguration; } + */ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-07-20 19:41:38
|
Revision: 3250 http://bigdata.svn.sourceforge.net/bigdata/?rev=3250&view=rev Author: mrpersonick Date: 2010-07-20 19:41:32 +0000 (Tue, 20 Jul 2010) Log Message: ----------- no longer implement ILexiconConfiguration Modified Paths: -------------- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java Modified: branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java =================================================================== --- branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java 2010-07-20 19:40:23 UTC (rev 3249) +++ branches/LEXICON_REFACTOR_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/LexiconRelation.java 2010-07-20 19:41:32 UTC (rev 3250) @@ -146,7 +146,7 @@ * @version $Id$ */ public class LexiconRelation extends AbstractRelation<BigdataValue> - implements ILexiconConfiguration { + /*implements ILexiconConfiguration*/ { final protected static Logger log = Logger.getLogger(LexiconRelation.class); @@ -2219,7 +2219,7 @@ final DTE dte = datatype == null ? null : DTE.valueOf(datatype); - if (dte == null || !isInline(dte)) + if (dte == null || !getLexiconConfiguration().isInline(dte)) return null; final String v = value.stringValue(); @@ -2580,10 +2580,10 @@ /** * See {@link ILexiconConfiguration#isInline(DTE)}. Delegates to the * {@link #lexiconConfiguration} instance. - */ public boolean isInline(DTE dte) { return lexiconConfiguration.isInline(dte); } + */ /** * See {@link ILexiconConfiguration#isLegacyEncoding()}. Delegates to the This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |