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-10-19 20:46:08
|
Revision: 3824 http://bigdata.svn.sourceforge.net/bigdata/?rev=3824&view=rev Author: mrpersonick Date: 2010-10-19 20:46:00 +0000 (Tue, 19 Oct 2010) Log Message: ----------- testing single tail rules Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpContext.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/Bigdata2Sesame2BindingSetIterator.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSingleTailRule.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpContext.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpContext.java 2010-10-19 17:29:08 UTC (rev 3823) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpContext.java 2010-10-19 20:46:00 UTC (rev 3824) @@ -279,6 +279,23 @@ } + } else { + + final IVariable<?> var = (IVariable<?>) t + .getProperty(Constant.Annotations.VAR); + + if (var != null) { + + final Object val = e.get(i); + + if (val != null) { + + bindingSet.set(var, new Constant(val)); + + } + + } + } } Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/Bigdata2Sesame2BindingSetIterator.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/Bigdata2Sesame2BindingSetIterator.java 2010-10-19 17:29:08 UTC (rev 3823) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/Bigdata2Sesame2BindingSetIterator.java 2010-10-19 20:46:00 UTC (rev 3824) @@ -42,6 +42,8 @@ */ private final ICloseableIterator<IBindingSet> src; + private final BindingSet constants; + /** * * @param src @@ -49,12 +51,19 @@ * closed). All bound values in the visited {@link IBindingSet}s * MUST be {@link BigdataValue}s. */ - public Bigdata2Sesame2BindingSetIterator(ICloseableIterator<IBindingSet> src) { + public Bigdata2Sesame2BindingSetIterator(final ICloseableIterator<IBindingSet> src) { + this(src, null); + } + + public Bigdata2Sesame2BindingSetIterator(final ICloseableIterator<IBindingSet> src, final BindingSet constants) { + if (src == null) throw new IllegalArgumentException(); this.src = src; + + this.constants = constants; } @@ -107,6 +116,17 @@ } + if (constants != null) { + + final Iterator<Binding> it = constants.iterator(); + while (it.hasNext()) { + final Binding b = it.next(); + bindingSet.addBinding(b.getName(), b.getValue()); +// bindingSet.addBinding(b); + } + + } + return bindingSet; } Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java 2010-10-19 17:29:08 UTC (rev 3823) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java 2010-10-19 20:46:00 UTC (rev 3824) @@ -464,7 +464,7 @@ return new EmptyIteration<BindingSet, QueryEvaluationException>(); } - return execute(query); + return execute(query, bindings); } catch (UnknownOperatorException ex) { @@ -575,7 +575,7 @@ return new EmptyIteration<BindingSet, QueryEvaluationException>(); } - return execute(query); + return execute(query, bindings); } catch (UnknownOperatorException ex) { @@ -681,7 +681,7 @@ return new EmptyIteration<BindingSet, QueryEvaluationException>(); } - return execute(query); + return execute(query, bindings); } catch (UnknownOperatorException ex) { @@ -1546,7 +1546,10 @@ } return null; } - result = new Constant<IV>(iv); + if (var.isAnonymous()) + result = new Constant<IV>(iv); + else + result = new Constant<IV>(com.bigdata.bop.Var.var(name), iv); } return result; } @@ -1663,8 +1666,16 @@ * * @throws QueryEvaluationException */ +// protected CloseableIteration<BindingSet, QueryEvaluationException> execute( +// final IStep step) +// throws Exception { +// +// return execute(step, null); +// +// } + protected CloseableIteration<BindingSet, QueryEvaluationException> execute( - final IStep step) + final IStep step, final BindingSet constants) throws Exception { final QueryEngine queryEngine = tripleSource.getSail().getQueryEngine(); @@ -1706,7 +1717,7 @@ CloseableIteration<BindingSet, QueryEvaluationException> result = new Bigdata2Sesame2BindingSetIterator<QueryEvaluationException>( new BigdataBindingSetResolverator(database, it2).start(database - .getExecutorService())); + .getExecutorService()), constants); try { // Wait for the Future (checks for errors). @@ -1882,7 +1893,7 @@ try { - return execute(query); + return execute(query, bindings); } catch (Exception ex) { Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSingleTailRule.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSingleTailRule.java 2010-10-19 17:29:08 UTC (rev 3823) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSingleTailRule.java 2010-10-19 20:46:00 UTC (rev 3824) @@ -27,9 +27,13 @@ package com.bigdata.rdf.sail; import info.aduna.iteration.CloseableIteration; +import java.util.Arrays; import java.util.Collection; +import java.util.HashSet; import java.util.LinkedList; +import java.util.List; import java.util.Properties; +import java.util.Set; import org.apache.log4j.Logger; import org.openrdf.model.Literal; import org.openrdf.model.Resource; @@ -49,6 +53,7 @@ import org.openrdf.query.impl.EmptyBindingSet; import org.openrdf.query.parser.ParsedTupleQuery; import org.openrdf.query.parser.QueryParserUtil; +import org.openrdf.repository.Repository; import org.openrdf.repository.RepositoryConnection; import org.openrdf.repository.sail.SailRepository; import org.openrdf.repository.sail.SailRepositoryConnection; @@ -77,7 +82,7 @@ props.setProperty(BigdataSail.Options.AXIOMS_CLASS, NoAxioms.class.getName()); props.setProperty(BigdataSail.Options.VOCABULARY_CLASS, NoVocabulary.class.getName()); props.setProperty(BigdataSail.Options.JUSTIFY, "false"); - props.setProperty(BigdataSail.Options.TEXT_INDEX, "false"); + props.setProperty(BigdataSail.Options.TEXT_INDEX, "true"); return props; @@ -96,7 +101,7 @@ super(arg0); } - public void testMultiGraphs() throws Exception { + public void testSingleTail() throws Exception { final BigdataSail sail = getSail(); final BigdataSailRepository repo = new BigdataSailRepository(sail); @@ -118,6 +123,10 @@ testValueRoundTrip(cxn.getSailConnection(), mike, likes, rdf); + if (log.isInfoEnabled()) { + log.info("\n" + ((BigdataSail)sail).getDatabase().dumpStore()); + } + } finally { cxn.close(); if (sail instanceof BigdataSail) @@ -126,6 +135,104 @@ } + public void testSingleTailSearch() throws Exception { + + final BigdataSail sail = getSail(); + final BigdataSailRepository repo = new BigdataSailRepository(sail); + repo.initialize(); + final BigdataSailRepositoryConnection cxn = repo.getConnection(); + cxn.setAutoCommit(false); + + try { + + final ValueFactory vf = sail.getValueFactory(); + + final String ns = BD.NAMESPACE; + + URI mike = vf.createURI(ns+"Mike"); + URI likes = vf.createURI(ns+"likes"); + URI rdf = vf.createURI(ns+"RDF"); + Literal l1 = vf.createLiteral("Mike"); +/**/ + cxn.setNamespace("ns", ns); + + cxn.add(mike, RDFS.LABEL, l1); + cxn.commit(); + + if (log.isInfoEnabled()) { + log.info("\n" + ((BigdataSail)sail).getDatabase().dumpStore()); + } + + { + + String query = + "PREFIX rdf: <"+RDF.NAMESPACE+"> " + + "PREFIX rdfs: <"+RDFS.NAMESPACE+"> " + + "PREFIX ns: <"+ns+"> " + + + "select ?s ?p ?o " + + "WHERE { " + + " ?s ?p ?o . " + + " filter(?p = <"+RDFS.LABEL+">) " + + "}"; + + final TupleQuery tupleQuery = + cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); + TupleQueryResult result = tupleQuery.evaluate(); + +// while (result.hasNext()) { +// System.err.println(result.next()); +// } + + Collection<BindingSet> solution = new LinkedList<BindingSet>(); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("s", mike), + new BindingImpl("p", RDFS.LABEL), + new BindingImpl("o", l1), + })); + + compare(result, solution); + + } + + { + + String query = + "PREFIX rdf: <"+RDF.NAMESPACE+"> " + + "PREFIX rdfs: <"+RDFS.NAMESPACE+"> " + + "PREFIX ns: <"+ns+"> " + + + "select ?s " + + "WHERE { " + + " ?s ns:search \"Mike\" . " + + "}"; + + final TupleQuery tupleQuery = + cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); + TupleQueryResult result = tupleQuery.evaluate(); + +// while (result.hasNext()) { +// System.err.println(result.next()); +// } + + Collection<BindingSet> solution = new LinkedList<BindingSet>(); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("s", l1), + })); + + compare(result, solution); + + } + + + } finally { + cxn.close(); + if (sail instanceof BigdataSail) + ((BigdataSail)sail).__tearDownUnitTest(); + } + + } + private void testValueRoundTrip(final SailConnection con, final Resource subj, final URI pred, final Value obj) throws Exception @@ -175,6 +282,68 @@ } } + public void testOptionalFilter() + throws Exception + { + final BigdataSail sail = getSail(); + final BigdataSailRepository repo = new BigdataSailRepository(sail); +// final Sail sail = new MemoryStore(); +// final Repository repo = new SailRepository(sail); + + repo.initialize(); + final RepositoryConnection cxn = repo.getConnection(); + cxn.setAutoCommit(false); + + try { + + final ValueFactory vf = sail.getValueFactory(); + URI s = vf.createURI("urn:test:s"); + URI p1 = vf.createURI("urn:test:p1"); + URI p2 = vf.createURI("urn:test:p2"); + Literal v1 = vf.createLiteral(1); + Literal v2 = vf.createLiteral(2); + Literal v3 = vf.createLiteral(3); + cxn.add(s, p1, v1); + cxn.add(s, p2, v2); + cxn.add(s, p1, v3); + cxn.commit(); + + String qry = + "PREFIX :<urn:test:> " + + "SELECT ?s ?v1 ?v2 " + + "WHERE { " + + " ?s :p1 ?v1 . " + + " OPTIONAL {?s :p2 ?v2 FILTER(?v1 < 3) } " + + "}"; + + TupleQuery query = cxn.prepareTupleQuery(QueryLanguage.SPARQL, qry); + TupleQueryResult result = query.evaluate(); + +// while (result.hasNext()) { +// System.err.println(result.next()); +// } + + Collection<BindingSet> solution = new LinkedList<BindingSet>(); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("s", s), + new BindingImpl("v1", v1), + new BindingImpl("v2", v2), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("s", s), + new BindingImpl("v1", v3), + })); + + compare(result, solution); + + } finally { + cxn.close(); + if (sail instanceof BigdataSail) + ((BigdataSail)sail).__tearDownUnitTest(); + } + + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2010-10-19 17:29:14
|
Revision: 3823 http://bigdata.svn.sourceforge.net/bigdata/?rev=3823&view=rev Author: thompsonbry Date: 2010-10-19 17:29:08 +0000 (Tue, 19 Oct 2010) Log Message: ----------- Added a Constant constructor variant which accept the name of the variable bound to that constant. BOpContext knows how to use this to insert the constant into the binding set in bind(...) [that will be in a separate commit]. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOp.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpBase.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/Constant.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOp.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOp.java 2010-10-19 16:24:57 UTC (rev 3822) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOp.java 2010-10-19 17:29:08 UTC (rev 3823) @@ -108,6 +108,18 @@ <T> T getProperty(final String name, final T defaultValue); /** + * Unconditionally sets the property. + * + * @param name + * The name. + * @param value + * The value. + * + * @return A copy of this {@link BOp} on which the property has been set. + */ + BOp setProperty(final String name, final Object value); + + /** * Return the value of the named annotation. * * @param name Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpBase.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpBase.java 2010-10-19 16:24:57 UTC (rev 3822) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpBase.java 2010-10-19 17:29:08 UTC (rev 3823) @@ -438,16 +438,6 @@ } - /** - * Unconditionally sets the property. - * - * @param name - * The name. - * @param value - * The value. - * - * @return A copy of this {@link BOp} on which the property has been set. - */ public BOpBase setProperty(final String name, final Object value) { final BOpBase tmp = this.clone(); Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/Constant.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/Constant.java 2010-10-19 16:24:57 UTC (rev 3822) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/Constant.java 2010-10-19 17:29:08 UTC (rev 3823) @@ -37,6 +37,16 @@ private static final long serialVersionUID = -2967861242470442497L; final private E value; + + public interface Annotations extends ImmutableBOp.Annotations { + + /** + * The {@link IVariable} which is bound to that constant value + * (optional). + */ + String VAR = Constant.class.getName() + ".var"; + + } final public boolean isVar() { @@ -72,18 +82,32 @@ this.value = op.value; } - + + public Constant(final IVariable<E> var, final E value) { + + super(NOARGS, NV.asMap(new NV(Annotations.VAR, var))); + + if (var == null) + throw new IllegalArgumentException(); + + if (value == null) + throw new IllegalArgumentException(); + + this.value = value; + + } + public Constant(final E value) { - + super(NOARGS, NOANNS); - + if (value == null) throw new IllegalArgumentException(); - + this.value = value; - + } - + /** * Clone is overridden to reduce heap churn. */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-10-19 16:25:03
|
Revision: 3822 http://bigdata.svn.sourceforge.net/bigdata/?rev=3822&view=rev Author: mrpersonick Date: 2010-10-19 16:24:57 +0000 (Tue, 19 Oct 2010) Log Message: ----------- fixed the sesame operator tree for this test Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSearchQuery.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSearchQuery.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSearchQuery.java 2010-10-19 16:02:18 UTC (rev 3821) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSearchQuery.java 2010-10-19 16:24:57 UTC (rev 3822) @@ -57,6 +57,10 @@ import org.openrdf.query.QueryLanguage; import org.openrdf.query.TupleQuery; import org.openrdf.query.TupleQueryResult; +import org.openrdf.query.algebra.Projection; +import org.openrdf.query.algebra.ProjectionElem; +import org.openrdf.query.algebra.ProjectionElemList; +import org.openrdf.query.algebra.QueryRoot; import org.openrdf.query.algebra.StatementPattern; import org.openrdf.query.algebra.TupleExpr; import org.openrdf.query.algebra.Var; @@ -246,11 +250,16 @@ try { - final TupleExpr tupleExpr = new StatementPattern(// + final StatementPattern sp = new StatementPattern(// new Var("X"),// new Var("1", BD.SEARCH),// new Var("2", new LiteralImpl("Yellow"))// ); + final TupleExpr tupleExpr = + new QueryRoot( + new Projection( + sp, + new ProjectionElemList(new ProjectionElem("X")))); /* * Create a data set consisting of the contexts to be queried. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-10-19 16:02:24
|
Revision: 3821 http://bigdata.svn.sourceforge.net/bigdata/?rev=3821&view=rev Author: mrpersonick Date: 2010-10-19 16:02:18 +0000 (Tue, 19 Oct 2010) Log Message: ----------- testing single tail rules Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/DefaultGraphSolutionExpander.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSailRepository.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestMultiGraphs.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/DefaultGraphSolutionExpander.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/DefaultGraphSolutionExpander.java 2010-10-19 15:56:02 UTC (rev 3820) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/spo/DefaultGraphSolutionExpander.java 2010-10-19 16:02:18 UTC (rev 3821) @@ -271,7 +271,7 @@ if(!(accessPath1 instanceof SPOAccessPath)) { // The logic relies on wrapping an SPOAccessPath, at least for now. - throw new IllegalArgumentException(); + throw new IllegalArgumentException(accessPath1.getClass().toString()); } Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java 2010-10-19 15:56:02 UTC (rev 3820) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataEvaluationStrategyImpl.java 2010-10-19 16:02:18 UTC (rev 3821) @@ -497,31 +497,6 @@ } - /** - * Override evaluation of StatementPatterns to recognize magic search - * predicate. - @Override - public CloseableIteration<BindingSet, QueryEvaluationException> evaluate( - final StatementPattern sp, final BindingSet bindings) - throws QueryEvaluationException { - - // no check against the nativeJoins property here because we are simply - // using the native execution model to take care of magic searches. - - if (log.isDebugEnabled()) { - log.debug("evaluating statement pattern:\n" + sp); - } - - IStep query = createNativeQuery(sp); - - if (query == null) { - return new EmptyIteration<BindingSet, QueryEvaluationException>(); - } - - return execute(query); - - } - */ /** * Translate top-level JOINs into native bigdata programs for execution. @@ -953,20 +928,20 @@ // } // } - if (log.isDebugEnabled()) { - for (IPredicate<ISPO> tail : tails) { - IAccessPathExpander<ISPO> expander = tail.getAccessPathExpander(); - if (expander != null) { - IAccessPath<ISPO> accessPath = database.getSPORelation() - .getAccessPath(tail); - accessPath = expander.getAccessPath(accessPath); - IChunkedOrderedIterator<ISPO> it = accessPath.iterator(); - while (it.hasNext()) { - log.debug(it.next().toString(database)); - } - } - } - } +// if (log.isDebugEnabled()) { +// for (IPredicate<ISPO> tail : tails) { +// IAccessPathExpander<ISPO> expander = tail.getAccessPathExpander(); +// if (expander != null) { +// IAccessPath<ISPO> accessPath = database.getSPORelation() +// .getAccessPath(tail); +// accessPath = expander.getAccessPath(accessPath); +// IChunkedOrderedIterator<ISPO> it = accessPath.iterator(); +// while (it.hasNext()) { +// log.debug(it.next().toString(database)); +// } +// } +// } +// } /* * Collect a set of variables required beyond just the join (i.e. @@ -1843,6 +1818,46 @@ } } +// /** +// * Override evaluation of StatementPatterns to recognize magic search +// * predicate. +// */ +// @Override +// public CloseableIteration<BindingSet, QueryEvaluationException> evaluate( +// final StatementPattern sp, final BindingSet bindings) +// throws QueryEvaluationException { +// +// if (log.isDebugEnabled()) { +// log.debug("evaluating statement pattern:\n" + sp); +// } +// +// // check for magic search +// final Var predVar = sp.getPredicateVar(); +// final Value predValue = getVarValue(predVar, bindings); +// if (BD.SEARCH.equals(predValue)) { +// final Var ovar = sp.getObjectVar(); +// final Value oval = getVarValue(ovar, bindings); +// if (oval == null) { +// throw new QueryEvaluationException(BD.SEARCH +// + " : object must be bound."); +// } +// if (!(oval instanceof Literal)) { +// throw new QueryEvaluationException(BD.SEARCH +// + " : object must be literal."); +// } +// final Literal lit = (Literal) oval; +// if (lit.getDatatype() != null) { +// throw new QueryEvaluationException(BD.SEARCH +// + " : object is datatype literal."); +// } +// return search(sp.getSubjectVar(), lit.getLanguage(), +// lit.getLabel(), bindings, sp.getScope()); +// } +// +// return super.evaluate(sp, bindings); +// +// } + /** * Override evaluation of StatementPatterns to recognize magic search * predicate. @@ -1852,34 +1867,28 @@ final StatementPattern sp, final BindingSet bindings) throws QueryEvaluationException { + // no check against the nativeJoins property here because we are simply + // using the native execution model to take care of magic searches. + if (log.isDebugEnabled()) { log.debug("evaluating statement pattern:\n" + sp); } - // check for magic search - final Var predVar = sp.getPredicateVar(); - final Value predValue = getVarValue(predVar, bindings); - if (BD.SEARCH.equals(predValue)) { - final Var ovar = sp.getObjectVar(); - final Value oval = getVarValue(ovar, bindings); - if (oval == null) { - throw new QueryEvaluationException(BD.SEARCH - + " : object must be bound."); - } - if (!(oval instanceof Literal)) { - throw new QueryEvaluationException(BD.SEARCH - + " : object must be literal."); - } - final Literal lit = (Literal) oval; - if (lit.getDatatype() != null) { - throw new QueryEvaluationException(BD.SEARCH - + " : object is datatype literal."); - } - return search(sp.getSubjectVar(), lit.getLanguage(), - lit.getLabel(), bindings, sp.getScope()); + final IStep query = createNativeQuery(sp); + + if (query == null) { + return new EmptyIteration<BindingSet, QueryEvaluationException>(); } + + try { - return super.evaluate(sp, bindings); + return execute(query); + + } catch (Exception ex) { + + throw new QueryEvaluationException(ex); + + } } Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSailRepository.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSailRepository.java 2010-10-19 15:56:02 UTC (rev 3820) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/java/com/bigdata/rdf/sail/BigdataSailRepository.java 2010-10-19 16:02:18 UTC (rev 3821) @@ -34,7 +34,8 @@ // } @Override - public SailRepositoryConnection getConnection() throws RepositoryException { + public BigdataSailRepositoryConnection getConnection() + throws RepositoryException { try { Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java 2010-10-19 15:56:02 UTC (rev 3820) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java 2010-10-19 16:02:18 UTC (rev 3821) @@ -97,6 +97,8 @@ suite.addTestSuite(TestDescribe.class); + suite.addTestSuite(TestMultiGraphs.class); + // The Sesame TCK, including the SPARQL test suite. { Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestMultiGraphs.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestMultiGraphs.java 2010-10-19 15:56:02 UTC (rev 3820) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestMultiGraphs.java 2010-10-19 16:02:18 UTC (rev 3821) @@ -99,8 +99,17 @@ * You'll get the same answer whether you run with Bigdata or Sesame. */ if (true) { - sail = getSail(); - repo = new BigdataSailRepository((BigdataSail) sail); + + final BigdataSail bdSail = getSail(); + sail = bdSail; + + if (bdSail.getDatabase().isQuads() == false) { + bdSail.__tearDownUnitTest(); + return; + } + + repo = new BigdataSailRepository(bdSail); + } else { sail = new MemoryStore(); repo = new SailRepository(sail); @@ -156,17 +165,17 @@ "select ?p ?o " + "WHERE { " + - " ?s rdf:type ns:Person . " + - " ?s ?p ?o . " + +// " ?s rdf:type ns:Person . " + + " ns:Mike ?p ?o . " + "}"; final TupleQuery tupleQuery = cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); TupleQueryResult result = tupleQuery.evaluate(); - while (result.hasNext()) { - System.err.println(result.next()); - } +// while (result.hasNext()) { +// System.err.println(result.next()); +// } Collection<BindingSet> solution = new LinkedList<BindingSet>(); solution.add(createBindingSet(new Binding[] { @@ -181,20 +190,8 @@ new BindingImpl("p", RDFS.LABEL), new BindingImpl("o", l1), })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", RDF.TYPE), - new BindingImpl("o", person), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", likes), - new BindingImpl("o", rdf), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", RDFS.LABEL), - new BindingImpl("o", l1), - })); -// compare(result, solution); + compare(result, solution); } @@ -216,9 +213,9 @@ cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); TupleQueryResult result = tupleQuery.evaluate(); - while (result.hasNext()) { - System.err.println(result.next()); - } +// while (result.hasNext()) { +// System.err.println(result.next()); +// } Collection<BindingSet> solution = new LinkedList<BindingSet>(); solution.add(createBindingSet(new Binding[] { @@ -233,20 +230,8 @@ new BindingImpl("p", RDFS.LABEL), new BindingImpl("o", l1), })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", RDF.TYPE), - new BindingImpl("o", person), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", likes), - new BindingImpl("o", rdf), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", RDFS.LABEL), - new BindingImpl("o", l1), - })); -// compare(result, solution); + compare(result, solution); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-10-19 15:56:14
|
Revision: 3820 http://bigdata.svn.sourceforge.net/bigdata/?rev=3820&view=rev Author: mrpersonick Date: 2010-10-19 15:56:02 +0000 (Tue, 19 Oct 2010) Log Message: ----------- testing single tail rules Added Paths: ----------- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSingleTailRule.java Added: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSingleTailRule.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSingleTailRule.java (rev 0) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestSingleTailRule.java 2010-10-19 15:56:02 UTC (rev 3820) @@ -0,0 +1,180 @@ +/** +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 Sep 16, 2009 + */ + +package com.bigdata.rdf.sail; + +import info.aduna.iteration.CloseableIteration; +import java.util.Collection; +import java.util.LinkedList; +import java.util.Properties; +import org.apache.log4j.Logger; +import org.openrdf.model.Literal; +import org.openrdf.model.Resource; +import org.openrdf.model.Statement; +import org.openrdf.model.URI; +import org.openrdf.model.Value; +import org.openrdf.model.ValueFactory; +import org.openrdf.model.vocabulary.RDF; +import org.openrdf.model.vocabulary.RDFS; +import org.openrdf.query.Binding; +import org.openrdf.query.BindingSet; +import org.openrdf.query.QueryEvaluationException; +import org.openrdf.query.QueryLanguage; +import org.openrdf.query.TupleQuery; +import org.openrdf.query.TupleQueryResult; +import org.openrdf.query.impl.BindingImpl; +import org.openrdf.query.impl.EmptyBindingSet; +import org.openrdf.query.parser.ParsedTupleQuery; +import org.openrdf.query.parser.QueryParserUtil; +import org.openrdf.repository.RepositoryConnection; +import org.openrdf.repository.sail.SailRepository; +import org.openrdf.repository.sail.SailRepositoryConnection; +import org.openrdf.sail.Sail; +import org.openrdf.sail.SailConnection; +import org.openrdf.sail.SailException; +import org.openrdf.sail.memory.MemoryStore; +import com.bigdata.rdf.axioms.NoAxioms; +import com.bigdata.rdf.store.BD; +import com.bigdata.rdf.vocab.NoVocabulary; + +/** + * @author <a href="mailto:mrp...@us...">Mike Personick</a> + * @version $Id$ + */ +public class TestSingleTailRule extends ProxyBigdataSailTestCase { + + protected static final Logger log = Logger.getLogger(TestSingleTailRule.class); + + @Override + public Properties getProperties() { + + Properties props = super.getProperties(); + + props.setProperty(BigdataSail.Options.TRUTH_MAINTENANCE, "false"); + props.setProperty(BigdataSail.Options.AXIOMS_CLASS, NoAxioms.class.getName()); + props.setProperty(BigdataSail.Options.VOCABULARY_CLASS, NoVocabulary.class.getName()); + props.setProperty(BigdataSail.Options.JUSTIFY, "false"); + props.setProperty(BigdataSail.Options.TEXT_INDEX, "false"); + + return props; + + } + + /** + * + */ + public TestSingleTailRule() { + } + + /** + * @param arg0 + */ + public TestSingleTailRule(String arg0) { + super(arg0); + } + + public void testMultiGraphs() throws Exception { + + final BigdataSail sail = getSail(); + final BigdataSailRepository repo = new BigdataSailRepository(sail); + repo.initialize(); + final BigdataSailRepositoryConnection cxn = repo.getConnection(); + cxn.setAutoCommit(false); + + try { + + final ValueFactory vf = sail.getValueFactory(); + + final String ns = BD.NAMESPACE; + + URI mike = vf.createURI(ns+"Mike"); + URI likes = vf.createURI(ns+"likes"); + URI rdf = vf.createURI(ns+"RDF"); +/**/ + cxn.setNamespace("ns", ns); + + testValueRoundTrip(cxn.getSailConnection(), mike, likes, rdf); + + } finally { + cxn.close(); + if (sail instanceof BigdataSail) + ((BigdataSail)sail).__tearDownUnitTest(); + } + + } + + private void testValueRoundTrip(final SailConnection con, + final Resource subj, final URI pred, final Value obj) + throws Exception + { + con.addStatement(subj, pred, obj); + con.commit(); + + CloseableIteration<? extends Statement, SailException> stIter = + con.getStatements(null, null, null, false); + + try { + assertTrue(stIter.hasNext()); + + Statement st = stIter.next(); + assertEquals(subj, st.getSubject()); + assertEquals(pred, st.getPredicate()); + assertEquals(obj, st.getObject()); + assertTrue(!stIter.hasNext()); + } + finally { + stIter.close(); + } + +// ParsedTupleQuery tupleQuery = QueryParserUtil.parseTupleQuery(QueryLanguage.SERQL, +// "SELECT S, P, O FROM {S} P {O} WHERE P = <" + pred.stringValue() + ">", null); + ParsedTupleQuery tupleQuery = QueryParserUtil.parseTupleQuery(QueryLanguage.SPARQL, + "SELECT ?S ?P ?O " + + "WHERE { " + + " ?S ?P ?O . " + + " FILTER( ?P = <" + pred.stringValue() + "> ) " + + "}", null); + + CloseableIteration<? extends BindingSet, QueryEvaluationException> iter; + iter = con.evaluate(tupleQuery.getTupleExpr(), null, EmptyBindingSet.getInstance(), false); + + try { + assertTrue(iter.hasNext()); + + BindingSet bindings = iter.next(); + assertEquals(subj, bindings.getValue("S")); + assertEquals(pred, bindings.getValue("P")); + assertEquals(obj, bindings.getValue("O")); + assertTrue(!iter.hasNext()); + } + finally { + iter.close(); + } + } + + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dm...@us...> - 2010-10-19 14:59:39
|
Revision: 3819 http://bigdata.svn.sourceforge.net/bigdata/?rev=3819&view=rev Author: dmacgbr Date: 2010-10-19 14:59:32 +0000 (Tue, 19 Oct 2010) Log Message: ----------- Cause com.bigdata.jini.TestAll to execute without error. In particular a) remove NESTED_SUBQUERY option from TestmappedRDFDataLoadMaster.config b) add timeout to bigdataStandaloneTesting.config (see Trac #183) Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/service/jini/master/TestMappedRDFDataLoadMaster.config Modified: branches/QUADS_QUERY_BRANCH/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config 2010-10-19 11:27:52 UTC (rev 3818) +++ branches/QUADS_QUERY_BRANCH/bigdata-jini/src/resources/config/bigdataStandaloneTesting.config 2010-10-19 14:59:32 UTC (rev 3819) @@ -204,6 +204,11 @@ jini { /** + * @see <a href="http://sourceforge.net/apps/trac/bigdata/ticket/183">trac 183</a> + */ + timeout = 20000 ; + + /** * Where jini was installed. */ serviceDir = bigdata.JINI_HOME; Modified: branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/service/jini/master/TestMappedRDFDataLoadMaster.config =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/service/jini/master/TestMappedRDFDataLoadMaster.config 2010-10-19 11:27:52 UTC (rev 3818) +++ branches/QUADS_QUERY_BRANCH/bigdata-jini/src/test/com/bigdata/service/jini/master/TestMappedRDFDataLoadMaster.config 2010-10-19 14:59:32 UTC (rev 3819) @@ -186,7 +186,7 @@ //new NV(BigdataSail.Options.JUSTIFY, "false"), - new NV(BigdataSail.Options.NESTED_SUBQUERY, "false"), + //new NV(BigdataSail.Options.NESTED_SUBQUERY, "false"), // new NV(BigdataSail.Options.MAX_PARALLEL_SUBQUERIES, "5"), new NV(BigdataSail.Options.MAX_PARALLEL_SUBQUERIES, "0"), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dm...@us...> - 2010-10-19 11:27:58
|
Revision: 3818 http://bigdata.svn.sourceforge.net/bigdata/?rev=3818&view=rev Author: dmacgbr Date: 2010-10-19 11:27:52 +0000 (Tue, 19 Oct 2010) Log Message: ----------- Fixed some tests based on re-reading of the spec Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java 2010-10-19 11:16:00 UTC (rev 3817) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java 2010-10-19 11:27:52 UTC (rev 3818) @@ -154,7 +154,7 @@ Resource graphs [] = new Resource [] { vf.createURI ( String.format ( "%sg1", ns ) ), vf.createURI ( String.format ( "%sg2", ns ) ) } ; - Collection<BindingSet> expected = getExpected ( createBindingSet ( new BindingImpl ( "s", new URIImpl ( String.format ( "%ss", ns ) ) ) ) ) ; + Collection<BindingSet> expected = getExpected () ; run ( sail, cxn, kb, graphs, qs, expected ) ; } @@ -177,7 +177,7 @@ Resource graphs [] = new Resource [] { vf.createURI ( String.format ( "%sg1", ns ) ), vf.createURI ( String.format ( "%sg2", ns ) ) } ; - Collection<BindingSet> expected = getExpected ( createBindingSet ( new BindingImpl ( "s", new URIImpl ( String.format ( "%ss", ns ) ) ) ) ) ; + Collection<BindingSet> expected = getExpected () ; run ( sail, cxn, kb, graphs, qs, expected ) ; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dm...@us...> - 2010-10-19 11:16:09
|
Revision: 3817 http://bigdata.svn.sourceforge.net/bigdata/?rev=3817&view=rev Author: dmacgbr Date: 2010-10-19 11:16:00 +0000 (Tue, 19 Oct 2010) Log Message: ----------- Add a few more tests in the area of default and named graph matching Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java 2010-10-19 08:50:30 UTC (rev 3816) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java 2010-10-19 11:16:00 UTC (rev 3817) @@ -87,7 +87,7 @@ super(arg0); } - public void testDefaultGraph () + public void testImplementationDefinedDefaultGraph () throws Exception { BigdataSail sail = getTheSail () ; @@ -111,6 +111,100 @@ run ( sail, cxn, kb, graphs, qs, expected ) ; } + public void testExplicitDefaultGraph () + throws Exception + { + BigdataSail sail = getTheSail () ; + if(!((BigdataSail)sail).isQuads()) { + log.info("This test requires quads."); + return; + } + + final ValueFactory vf = sail.getValueFactory(); + RepositoryConnection cxn = getRepositoryConnection ( sail ) ; + + String ns = "http://xyz.com/test#" ; + String kb = String.format ( "<%ss> <%sp> <%so> .", ns, ns, ns ) ; + String qs = String.format ( "select ?p ?o from <%sg1> from <%sg2> where { <%ss> ?p ?o .}", ns, ns, ns ) ; + + Resource graphs [] = new Resource [] { vf.createURI ( String.format ( "%sg1", ns ) ), vf.createURI ( String.format ( "%sg2", ns ) ) } ; + + Collection<BindingSet> expected = getExpected ( createBindingSet ( new BindingImpl ( "p", new URIImpl ( String.format ( "%sp", ns ) ) ) + , new BindingImpl ( "o", new URIImpl ( String.format ( "%so", ns ) ) ) + ) + ) ; + run ( sail, cxn, kb, graphs, qs, expected ) ; + } + + public void testNamedGraphNoGraphKeyword1 () + throws Exception + { + BigdataSail sail = getTheSail () ; + if(!((BigdataSail)sail).isQuads()) { + log.info("This test requires quads."); + return; + } + + final ValueFactory vf = sail.getValueFactory(); + RepositoryConnection cxn = getRepositoryConnection ( sail ) ; + + String ns = "http://xyz.com/test#" ; + String kb = String.format ( "<%ss> <%sp> <%so> .", ns, ns, ns ) ; + String qs = String.format ( "select ?s from named <%sg2> where { ?s ?p ?o .}", ns ) ; + + Resource graphs [] = new Resource [] { vf.createURI ( String.format ( "%sg1", ns ) ), vf.createURI ( String.format ( "%sg2", ns ) ) } ; + + Collection<BindingSet> expected = getExpected ( createBindingSet ( new BindingImpl ( "s", new URIImpl ( String.format ( "%ss", ns ) ) ) ) ) ; + + run ( sail, cxn, kb, graphs, qs, expected ) ; + } + + public void testNamedGraphNoGraphKeyword2 () + throws Exception + { + BigdataSail sail = getTheSail () ; + if(!((BigdataSail)sail).isQuads()) { + log.info("This test requires quads."); + return; + } + + final ValueFactory vf = sail.getValueFactory(); + RepositoryConnection cxn = getRepositoryConnection ( sail ) ; + + String ns = "http://xyz.com/test#" ; + String kb = String.format ( "<%ss> <%sp> <%so> .", ns, ns, ns ) ; + String qs = String.format ( "select ?s from named <%sg1> from named <%sg2> where { ?s ?p ?o .}", ns, ns ) ; + + Resource graphs [] = new Resource [] { vf.createURI ( String.format ( "%sg1", ns ) ), vf.createURI ( String.format ( "%sg2", ns ) ) } ; + + Collection<BindingSet> expected = getExpected ( createBindingSet ( new BindingImpl ( "s", new URIImpl ( String.format ( "%ss", ns ) ) ) ) ) ; + + run ( sail, cxn, kb, graphs, qs, expected ) ; + } + + public void testExplicitDefaultAndNamedGraphNoGraphKeyword () + throws Exception + { + BigdataSail sail = getTheSail () ; + if(!((BigdataSail)sail).isQuads()) { + log.info("This test requires quads."); + return; + } + + final ValueFactory vf = sail.getValueFactory(); + RepositoryConnection cxn = getRepositoryConnection ( sail ) ; + + String ns = "http://xyz.com/test#" ; + String kb = String.format ( "<%ss> <%sp> <%so> .", ns, ns, ns ) ; + String qs = String.format ( "select ?s from <%sg1> from named <%sg2> where { ?s ?p ?o .}", ns, ns ) ; + + Resource graphs [] = new Resource [] { vf.createURI ( String.format ( "%sg1", ns ) ), vf.createURI ( String.format ( "%sg2", ns ) ) } ; + + Collection<BindingSet> expected = getExpected ( createBindingSet ( new BindingImpl ( "s", new URIImpl ( String.format ( "%ss", ns ) ) ) ) ) ; + + run ( sail, cxn, kb, graphs, qs, expected ) ; + } + private BigdataSail getTheSail () throws SailException { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2010-10-19 08:50:37
|
Revision: 3816 http://bigdata.svn.sourceforge.net/bigdata/?rev=3816&view=rev Author: martyncutcher Date: 2010-10-19 08:50:30 +0000 (Tue, 19 Oct 2010) Log Message: ----------- merge range check code from trunk Modified Paths: -------------- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/btree/Leaf.java Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/btree/Leaf.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/btree/Leaf.java 2010-10-18 19:15:33 UTC (rev 3815) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/btree/Leaf.java 2010-10-19 08:50:30 UTC (rev 3816) @@ -744,17 +744,37 @@ @Override public byte[] keyAt(final int entryIndex) { + rangeCheck(entryIndex); + return getKeys().get(entryIndex); } @Override public void valueAt(final int entryIndex, final Tuple tuple) { + + rangeCheck(entryIndex); tuple.copy(entryIndex, this); - + } + final protected boolean rangeCheck(final int index) + throws IndexOutOfBoundsException { + + final int nkeys = data.getKeyCount(); + + if (index < 0 || index >= nkeys) { + + throw new IndexOutOfBoundsException("index=" + index + ", nkeys=" + + nkeys); + + } + + return true; + + } + /** * <p> * Split an over-capacity leaf (a leaf with <code>maxKeys+1</code> keys), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2010-10-18 19:15:39
|
Revision: 3815 http://bigdata.svn.sourceforge.net/bigdata/?rev=3815&view=rev Author: thompsonbry Date: 2010-10-18 19:15:33 +0000 (Mon, 18 Oct 2010) Log Message: ----------- Added TestOrderBy to the quads test suite (it looks like the proxy test suites for the sail are not uniformly captured for each of the different ways in which we run the tests). Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java 2010-10-18 19:14:41 UTC (rev 3814) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBigdataSailWithQuads.java 2010-10-18 19:15:33 UTC (rev 3815) @@ -91,6 +91,8 @@ // unit tests for custom evaluation of high-level query suite.addTestSuite(TestBigdataSailEvaluationStrategyImpl.class); + suite.addTestSuite(TestOrderBy.class); + suite.addTestSuite(TestUnions.class); suite.addTestSuite(TestDescribe.class); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2010-10-18 19:14:47
|
Revision: 3814 http://bigdata.svn.sourceforge.net/bigdata/?rev=3814&view=rev Author: thompsonbry Date: 2010-10-18 19:14:41 +0000 (Mon, 18 Oct 2010) Log Message: ----------- Added toString() method. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/BSBundle.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/BSBundle.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/BSBundle.java 2010-10-18 19:14:34 UTC (rev 3813) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/engine/BSBundle.java 2010-10-18 19:14:41 UTC (rev 3814) @@ -40,6 +40,13 @@ public final int shardId; + public String toString() { + + return super.toString() + "{bopId=" + bopId + ",shardId=" + shardId + + "}"; + + } + public BSBundle(final int bopId, final int shardId) { this.bopId = bopId; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2010-10-18 19:14:40
|
Revision: 3813 http://bigdata.svn.sourceforge.net/bigdata/?rev=3813&view=rev Author: thompsonbry Date: 2010-10-18 19:14:34 +0000 (Mon, 18 Oct 2010) Log Message: ----------- removed unused method. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpContext.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpContext.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpContext.java 2010-10-18 17:09:14 UTC (rev 3812) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/bop/BOpContext.java 2010-10-18 19:14:34 UTC (rev 3813) @@ -385,40 +385,40 @@ // // } - /** - * Copy data from the source to the sink. The sink will be flushed and - * closed. The source will be closed. - */ - public void copySourceToSink() { +// /** +// * Copy data from the source to the sink. The sink will be flushed and +// * closed. The source will be closed. +// */ +// public void copySourceToSink() { +// +// // source. +// final IAsynchronousIterator<IBindingSet[]> source = (IAsynchronousIterator) getSource(); +// +// // default sink +// final IBlockingBuffer<IBindingSet[]> sink = (IBlockingBuffer) getSink(); +// +// final BOpStats stats = getStats(); +// +// try { +// +// // copy binding sets from the source. +// BOpUtility.copy(source, sink, null/* sink2 */, +// null/* constraints */, stats); +// +// // flush the sink. +// sink.flush(); +// +// } finally { +// +// sink.close(); +// +// if (sink2 != null) +// sink2.close(); +// +// source.close(); +// +// } +// +// } - // source. - final IAsynchronousIterator<IBindingSet[]> source = (IAsynchronousIterator) getSource(); - - // default sink - final IBlockingBuffer<IBindingSet[]> sink = (IBlockingBuffer) getSink(); - - final BOpStats stats = getStats(); - - try { - - // copy binding sets from the source. - BOpUtility.copy(source, sink, null/* sink2 */, - null/* constraints */, stats); - - // flush the sink. - sink.flush(); - - } finally { - - sink.close(); - - if (sink2 != null) - sink2.close(); - - source.close(); - - } - - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ble...@us...> - 2010-10-18 17:09:20
|
Revision: 3812 http://bigdata.svn.sourceforge.net/bigdata/?rev=3812&view=rev Author: blevine218 Date: 2010-10-18 17:09:14 +0000 (Mon, 18 Oct 2010) Log Message: ----------- Filled out test_copyToSinkAndAltSink() to test this functionality against Tee class. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/bset/TestCopyBindingSets.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/bset/TestCopyBindingSets.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/bset/TestCopyBindingSets.java 2010-10-18 17:09:06 UTC (rev 3811) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/test/com/bigdata/bop/bset/TestCopyBindingSets.java 2010-10-18 17:09:14 UTC (rev 3812) @@ -178,14 +178,52 @@ } /** - * {@link Tee} is just a specialized {@link CopyOp} which requires - * that the alternate sink is also specified. Write a unit test of those - * semantics for {@link CopyOp}. + * Testing against {@link Tee} which is a specialized {@link CopyOp} which requires + * that the alternate sink is also specified. Gives us code coverage of {@link Tee} + * as well. */ - public void test_copyToSinkAndAltSink() { + public void test_copyToSinkAndAltSink() throws InterruptedException, ExecutionException { - fail("write test"); - + final int bopId = 1; + + final Tee query = new Tee(new BOp[] {}, NV + .asMap(new NV[] {// + new NV(BOp.Annotations.BOP_ID, bopId),// + new NV(CopyOp.Annotations.ALT_SINK_REF, 2), + })); + + // the expected solutions (default sink). + final IBindingSet[] expected = data.toArray(new IBindingSet[0]); + + final BOpStats stats = query.newStats(); + + final IAsynchronousIterator<IBindingSet[]> source = new ThickAsynchronousIterator<IBindingSet[]>( + new IBindingSet[][] { data.toArray(new IBindingSet[0]) }); + + final IBlockingBuffer<IBindingSet[]> sink = query.newBuffer(stats); + final IBlockingBuffer<IBindingSet[]> altSink = query.newBuffer(stats); + + final BOpContext<IBindingSet> context = new BOpContext<IBindingSet>( + new MockRunningQuery(null/* fed */, null/* indexManager */), + -1/* partitionId */, stats, source, sink, altSink); + + // get task. + final FutureTask<Void> ft = query.eval(context); + + // execute task. + ft.run(); + + TestQueryEngine.assertSameSolutions(expected, sink.iterator()); + TestQueryEngine.assertSameSolutions(expected, altSink.iterator()); + + assertTrue(ft.isDone()); + assertFalse(ft.isCancelled()); + ft.get(); // verify nothing thrown. + + assertEquals(1L, stats.chunksIn.get()); + assertEquals(6L, stats.unitsIn.get()); + assertEquals(12L, stats.unitsOut.get()); + assertEquals(2L, stats.chunksOut.get()); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2010-10-18 17:09:12
|
Revision: 3811 http://bigdata.svn.sourceforge.net/bigdata/?rev=3811&view=rev Author: thompsonbry Date: 2010-10-18 17:09:06 +0000 (Mon, 18 Oct 2010) Log Message: ----------- Changed logger name to class name. Modified to wrap and throw Exception in run(). Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java 2010-10-18 16:56:34 UTC (rev 3810) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java 2010-10-18 17:09:06 UTC (rev 3811) @@ -57,7 +57,7 @@ */ public class DavidsTestBOps extends ProxyBigdataSailTestCase { - protected static final Logger log = Logger.getLogger(TestBOps.class); + protected static final Logger log = Logger.getLogger(DavidsTestBOps.class); @Override public Properties getProperties() { @@ -91,6 +91,10 @@ throws Exception { BigdataSail sail = getTheSail () ; + if(!((BigdataSail)sail).isQuads()) { + log.info("This test requires quads."); + return; + } final ValueFactory vf = sail.getValueFactory(); RepositoryConnection cxn = getRepositoryConnection ( sail ) ; @@ -139,8 +143,11 @@ finally { try { if ( null != rc ) rc.close () ; } - catch ( Exception e ) {} - if ( null != sail ) sail.__tearDownUnitTest () ; + catch ( Exception e ) { + throw new RuntimeException(e); + } finally { + if ( null != sail ) sail.__tearDownUnitTest () ; + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-10-18 16:56:40
|
Revision: 3810 http://bigdata.svn.sourceforge.net/bigdata/?rev=3810&view=rev Author: mrpersonick Date: 2010-10-18 16:56:34 +0000 (Mon, 18 Oct 2010) Log Message: ----------- testing duplicate statements in multiple graphs Added Paths: ----------- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestMultiGraphs.java Added: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestMultiGraphs.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestMultiGraphs.java (rev 0) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestMultiGraphs.java 2010-10-18 16:56:34 UTC (rev 3810) @@ -0,0 +1,261 @@ +/** +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 Sep 16, 2009 + */ + +package com.bigdata.rdf.sail; + +import java.util.Collection; +import java.util.LinkedList; +import java.util.Properties; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.openrdf.model.Literal; +import org.openrdf.model.URI; +import org.openrdf.model.ValueFactory; +import org.openrdf.model.impl.LiteralImpl; +import org.openrdf.model.impl.URIImpl; +import org.openrdf.model.vocabulary.RDF; +import org.openrdf.model.vocabulary.RDFS; +import org.openrdf.query.Binding; +import org.openrdf.query.BindingSet; +import org.openrdf.query.QueryLanguage; +import org.openrdf.query.TupleQuery; +import org.openrdf.query.TupleQueryResult; +import org.openrdf.query.impl.BindingImpl; +import org.openrdf.repository.sail.SailRepository; +import org.openrdf.repository.sail.SailRepositoryConnection; +import org.openrdf.sail.Sail; +import org.openrdf.sail.memory.MemoryStore; +import com.bigdata.rdf.axioms.NoAxioms; +import com.bigdata.rdf.lexicon.LexiconRelation; +import com.bigdata.rdf.store.BD; +import com.bigdata.rdf.vocab.NoVocabulary; + +/** + * @author <a href="mailto:mrp...@us...">Mike Personick</a> + * @version $Id$ + */ +public class TestMultiGraphs extends ProxyBigdataSailTestCase { + + protected static final Logger log = Logger.getLogger(TestMultiGraphs.class); + + @Override + public Properties getProperties() { + + Properties props = super.getProperties(); + + props.setProperty(BigdataSail.Options.TRUTH_MAINTENANCE, "false"); + props.setProperty(BigdataSail.Options.AXIOMS_CLASS, NoAxioms.class.getName()); + props.setProperty(BigdataSail.Options.VOCABULARY_CLASS, NoVocabulary.class.getName()); + props.setProperty(BigdataSail.Options.JUSTIFY, "false"); + props.setProperty(BigdataSail.Options.TEXT_INDEX, "false"); + + return props; + + } + + /** + * + */ + public TestMultiGraphs() { + } + + /** + * @param arg0 + */ + public TestMultiGraphs(String arg0) { + super(arg0); + } + + public void testMultiGraphs() throws Exception { + + final Sail sail; + final SailRepository repo; + final SailRepositoryConnection cxn; + + /* + * You'll get the same answer whether you run with Bigdata or Sesame. + */ + if (true) { + sail = getSail(); + repo = new BigdataSailRepository((BigdataSail) sail); + } else { + sail = new MemoryStore(); + repo = new SailRepository(sail); + } + + repo.initialize(); + cxn = repo.getConnection(); + cxn.setAutoCommit(false); + + try { + + final ValueFactory vf = sail.getValueFactory(); + + final String ns = BD.NAMESPACE; + + URI mike = vf.createURI(ns+"Mike"); + URI bryan = vf.createURI(ns+"Bryan"); + URI person = vf.createURI(ns+"Person"); + URI likes = vf.createURI(ns+"likes"); + URI rdf = vf.createURI(ns+"RDF"); + Literal l1 = vf.createLiteral("Mike"); + Literal l2 = vf.createLiteral("Bryan"); + URI g1 = vf.createURI(ns+"graph1"); + URI g2 = vf.createURI(ns+"graph2"); +/**/ + cxn.setNamespace("ns", ns); + + cxn.add(mike, RDF.TYPE, person, g1, g2); + cxn.add(mike, likes, rdf, g1, g2); + cxn.add(mike, RDFS.LABEL, l1, g1, g2); +// cxn.add(bryan, RDF.TYPE, person, g1, g2); +// cxn.add(bryan, likes, rdf, g1, g2); +// cxn.add(bryan, RDFS.LABEL, l2, g1, g2); + + /* + * Note: The either flush() or commit() is required to flush the + * statement buffers to the database before executing any operations + * that go around the sail. + */ + cxn.commit();// + + if (log.isInfoEnabled()) { + if (sail instanceof BigdataSail) + log.info("\n" + ((BigdataSail)sail).getDatabase().dumpStore()); + } + + { + + String query = + "PREFIX rdf: <"+RDF.NAMESPACE+"> " + + "PREFIX rdfs: <"+RDFS.NAMESPACE+"> " + + "PREFIX ns: <"+ns+"> " + + + "select ?p ?o " + + "WHERE { " + + " ?s rdf:type ns:Person . " + + " ?s ?p ?o . " + + "}"; + + final TupleQuery tupleQuery = + cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); + TupleQueryResult result = tupleQuery.evaluate(); + + while (result.hasNext()) { + System.err.println(result.next()); + } + + Collection<BindingSet> solution = new LinkedList<BindingSet>(); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", RDF.TYPE), + new BindingImpl("o", person), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", likes), + new BindingImpl("o", rdf), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", RDFS.LABEL), + new BindingImpl("o", l1), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", RDF.TYPE), + new BindingImpl("o", person), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", likes), + new BindingImpl("o", rdf), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", RDFS.LABEL), + new BindingImpl("o", l1), + })); + +// compare(result, solution); + + } + + { + + String query = + "PREFIX rdf: <"+RDF.NAMESPACE+"> " + + "PREFIX rdfs: <"+RDFS.NAMESPACE+"> " + + "PREFIX ns: <"+ns+"> " + + + "select ?p ?o " + + "from <"+g1+">" + + "from <"+g2+">" + + "WHERE { " + + " ns:Mike ?p ?o . " + + "}"; + + final TupleQuery tupleQuery = + cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); + TupleQueryResult result = tupleQuery.evaluate(); + + while (result.hasNext()) { + System.err.println(result.next()); + } + + Collection<BindingSet> solution = new LinkedList<BindingSet>(); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", RDF.TYPE), + new BindingImpl("o", person), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", likes), + new BindingImpl("o", rdf), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", RDFS.LABEL), + new BindingImpl("o", l1), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", RDF.TYPE), + new BindingImpl("o", person), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", likes), + new BindingImpl("o", rdf), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", RDFS.LABEL), + new BindingImpl("o", l1), + })); + +// compare(result, solution); + + } + + } finally { + cxn.close(); + if (sail instanceof BigdataSail) + ((BigdataSail)sail).__tearDownUnitTest(); + } + + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mrp...@us...> - 2010-10-18 16:56:03
|
Revision: 3809 http://bigdata.svn.sourceforge.net/bigdata/?rev=3809&view=rev Author: mrpersonick Date: 2010-10-18 16:55:57 +0000 (Mon, 18 Oct 2010) Log Message: ----------- testing duplicate statements in multiple graphs Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBOps.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBOps.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBOps.java 2010-10-18 16:50:53 UTC (rev 3808) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBOps.java 2010-10-18 16:55:57 UTC (rev 3809) @@ -452,172 +452,4 @@ } - public void testMultiGraphs() throws Exception { - - final Sail sail; - final SailRepository repo; - final SailRepositoryConnection cxn; - - /* - * You'll get the same answer whether you run with Bigdata or Sesame. - */ - if (true) { - sail = getSail(); - repo = new BigdataSailRepository((BigdataSail) sail); - } else { - sail = new MemoryStore(); - repo = new SailRepository(sail); - } - - repo.initialize(); - cxn = repo.getConnection(); - cxn.setAutoCommit(false); - - try { - - final ValueFactory vf = sail.getValueFactory(); - - final String ns = BD.NAMESPACE; - - URI mike = vf.createURI(ns+"Mike"); - URI bryan = vf.createURI(ns+"Bryan"); - URI person = vf.createURI(ns+"Person"); - URI likes = vf.createURI(ns+"likes"); - URI rdf = vf.createURI(ns+"RDF"); - Literal l1 = vf.createLiteral("Mike"); - Literal l2 = vf.createLiteral("Bryan"); - URI g1 = vf.createURI(ns+"graph1"); - URI g2 = vf.createURI(ns+"graph2"); -/**/ - cxn.setNamespace("ns", ns); - - cxn.add(mike, RDF.TYPE, person, g1, g2); - cxn.add(mike, likes, rdf, g1, g2); - cxn.add(mike, RDFS.LABEL, l1, g1, g2); - cxn.add(bryan, RDF.TYPE, person, g1, g2); - cxn.add(bryan, likes, rdf, g1, g2); - cxn.add(bryan, RDFS.LABEL, l2, g1, g2); - - /* - * Note: The either flush() or commit() is required to flush the - * statement buffers to the database before executing any operations - * that go around the sail. - */ - cxn.commit();// - - if (log.isInfoEnabled()) { - if (sail instanceof BigdataSail) - log.info("\n" + ((BigdataSail)sail).getDatabase().dumpStore()); - } - - { - - String query = - "PREFIX rdf: <"+RDF.NAMESPACE+"> " + - "PREFIX rdfs: <"+RDFS.NAMESPACE+"> " + - "PREFIX ns: <"+ns+"> " + - - "select ?p ?o " + - "WHERE { " + - " ns:Mike ?p ?o . " + - "}"; - - final TupleQuery tupleQuery = - cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); - TupleQueryResult result = tupleQuery.evaluate(); - -// while (result.hasNext()) { -// System.err.println(result.next()); -// } - - Collection<BindingSet> solution = new LinkedList<BindingSet>(); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", RDF.TYPE), - new BindingImpl("o", person), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", likes), - new BindingImpl("o", rdf), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", RDFS.LABEL), - new BindingImpl("o", l1), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", RDF.TYPE), - new BindingImpl("o", person), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", likes), - new BindingImpl("o", rdf), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", RDFS.LABEL), - new BindingImpl("o", l1), - })); - - compare(result, solution); - - } - - { - - String query = - "PREFIX rdf: <"+RDF.NAMESPACE+"> " + - "PREFIX rdfs: <"+RDFS.NAMESPACE+"> " + - "PREFIX ns: <"+ns+"> " + - - "select ?p ?o " + - "from <"+g1+">" + - "from <"+g2+">" + - "WHERE { " + - " ns:Mike ?p ?o . " + - "}"; - - final TupleQuery tupleQuery = - cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); - TupleQueryResult result = tupleQuery.evaluate(); - -// while (result.hasNext()) { -// System.err.println(result.next()); -// } - - Collection<BindingSet> solution = new LinkedList<BindingSet>(); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", RDF.TYPE), - new BindingImpl("o", person), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", likes), - new BindingImpl("o", rdf), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", RDFS.LABEL), - new BindingImpl("o", l1), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", RDF.TYPE), - new BindingImpl("o", person), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", likes), - new BindingImpl("o", rdf), - })); - solution.add(createBindingSet(new Binding[] { - new BindingImpl("p", RDFS.LABEL), - new BindingImpl("o", l1), - })); - - compare(result, solution); - - } - - } finally { - cxn.close(); - if (sail instanceof BigdataSail) - ((BigdataSail)sail).__tearDownUnitTest(); - } - - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dm...@us...> - 2010-10-18 16:51:02
|
Revision: 3808 http://bigdata.svn.sourceforge.net/bigdata/?rev=3808&view=rev Author: dmacgbr Date: 2010-10-18 16:50:53 +0000 (Mon, 18 Oct 2010) Log Message: ----------- Test demonstrating problem with default graph matching Added Paths: ----------- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java Added: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java (rev 0) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/DavidsTestBOps.java 2010-10-18 16:50:53 UTC (rev 3808) @@ -0,0 +1,171 @@ +/** +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 Sep 16, 2009 + */ + +package com.bigdata.rdf.sail; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.util.Collection; +import java.util.LinkedList; +import java.util.Properties; + +import org.apache.log4j.Logger; +import org.openrdf.model.Resource; +import org.openrdf.model.ValueFactory; +import org.openrdf.model.impl.URIImpl; +import org.openrdf.query.BindingSet; +import org.openrdf.query.MalformedQueryException; +import org.openrdf.query.QueryEvaluationException; +import org.openrdf.query.QueryLanguage; +import org.openrdf.query.TupleQueryResult; +import org.openrdf.query.impl.BindingImpl; +import org.openrdf.repository.RepositoryConnection; +import org.openrdf.repository.RepositoryException; +import org.openrdf.rio.RDFFormat; +import org.openrdf.rio.RDFParseException; +import org.openrdf.sail.SailException; + +import com.bigdata.rdf.axioms.NoAxioms; +import com.bigdata.rdf.vocab.NoVocabulary; + +/** + * @author <a href="mailto:mrp...@us...">Mike Personick</a> + * @version $Id$ + */ +public class DavidsTestBOps extends ProxyBigdataSailTestCase { + + protected static final Logger log = Logger.getLogger(TestBOps.class); + + @Override + public Properties getProperties() { + + Properties props = super.getProperties(); + + props.setProperty(BigdataSail.Options.TRUTH_MAINTENANCE, "false"); + props.setProperty(BigdataSail.Options.AXIOMS_CLASS, NoAxioms.class.getName()); + props.setProperty(BigdataSail.Options.VOCABULARY_CLASS, NoVocabulary.class.getName()); + props.setProperty(BigdataSail.Options.JUSTIFY, "false"); + props.setProperty(BigdataSail.Options.TEXT_INDEX, "false"); + + return props; + + } + + /** + * + */ + public DavidsTestBOps() { + } + + /** + * @param arg0 + */ + public DavidsTestBOps(String arg0) { + super(arg0); + } + + public void testDefaultGraph () + throws Exception + { + BigdataSail sail = getTheSail () ; + final ValueFactory vf = sail.getValueFactory(); + RepositoryConnection cxn = getRepositoryConnection ( sail ) ; + + String ns = "http://xyz.com/test#" ; + String kb = String.format ( "<%ss> <%sp> <%so> .", ns, ns, ns ) ; + String qs = String.format ( "select ?p ?o where { <%ss> ?p ?o .}", ns ) ; + + Resource graphs [] = new Resource [] { vf.createURI ( String.format ( "%sg1", ns ) ), vf.createURI ( String.format ( "%sg2", ns ) ) } ; + + Collection<BindingSet> expected = getExpected ( createBindingSet ( new BindingImpl ( "p", new URIImpl ( String.format ( "%sp", ns ) ) ) + , new BindingImpl ( "o", new URIImpl ( String.format ( "%so", ns ) ) ) + ) + ) ; + run ( sail, cxn, kb, graphs, qs, expected ) ; + } + + private BigdataSail getTheSail () + throws SailException + { + BigdataSail sail = getSail () ; + sail.initialize () ; + return sail ; + } + + private RepositoryConnection getRepositoryConnection ( BigdataSail sail ) + throws RepositoryException + { + BigdataSailRepository repo = new BigdataSailRepository ( sail ) ; + BigdataSailRepositoryConnection cxn = ( BigdataSailRepositoryConnection )repo.getConnection () ; + cxn.setAutoCommit ( false ) ; + return cxn ; + } + + private void run ( BigdataSail sail, RepositoryConnection rc, String kb, Resource graphs [], String qs, Collection<BindingSet> expected ) + { + try + { + for ( Resource g : graphs ) + load ( rc, kb, g ) ; + compare ( query ( rc, qs ), expected ) ; + } + catch ( Exception e ) + { + e.printStackTrace () ; + } + finally + { + try { if ( null != rc ) rc.close () ; } + catch ( Exception e ) {} + if ( null != sail ) sail.__tearDownUnitTest () ; + } + } + + private void load ( RepositoryConnection rc, String kb, Resource g ) + throws RepositoryException, RDFParseException, IOException + { + rc.add ( new ByteArrayInputStream ( kb.toString ().getBytes ( "UTF-8" ) ) + , "http://xyz.com/test" + , RDFFormat.TURTLE + , g + ) ; + rc.commit () ; + } + + private TupleQueryResult query ( RepositoryConnection rc, String qs ) + throws RepositoryException, MalformedQueryException, QueryEvaluationException + { + return rc.prepareTupleQuery ( QueryLanguage.SPARQL, qs ).evaluate () ; + } + + private Collection<BindingSet> getExpected ( BindingSet... bindingSets ) + { + Collection<BindingSet> expected = new LinkedList<BindingSet> () ; + for ( BindingSet bs : bindingSets ) + expected.add ( bs ) ; + return expected ; + } +} \ 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-10-18 14:35:18
|
Revision: 3807 http://bigdata.svn.sourceforge.net/bigdata/?rev=3807&view=rev Author: mrpersonick Date: 2010-10-18 14:35:11 +0000 (Mon, 18 Oct 2010) Log Message: ----------- testing duplicate statements in multiple graphs Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBOps.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBOps.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBOps.java 2010-10-18 12:32:05 UTC (rev 3806) +++ branches/QUADS_QUERY_BRANCH/bigdata-sails/src/test/com/bigdata/rdf/sail/TestBOps.java 2010-10-18 14:35:11 UTC (rev 3807) @@ -44,6 +44,10 @@ import org.openrdf.query.TupleQuery; import org.openrdf.query.TupleQueryResult; import org.openrdf.query.impl.BindingImpl; +import org.openrdf.repository.sail.SailRepository; +import org.openrdf.repository.sail.SailRepositoryConnection; +import org.openrdf.sail.Sail; +import org.openrdf.sail.memory.MemoryStore; import com.bigdata.rdf.axioms.NoAxioms; import com.bigdata.rdf.lexicon.LexiconRelation; import com.bigdata.rdf.store.BD; @@ -448,4 +452,172 @@ } + public void testMultiGraphs() throws Exception { + + final Sail sail; + final SailRepository repo; + final SailRepositoryConnection cxn; + + /* + * You'll get the same answer whether you run with Bigdata or Sesame. + */ + if (true) { + sail = getSail(); + repo = new BigdataSailRepository((BigdataSail) sail); + } else { + sail = new MemoryStore(); + repo = new SailRepository(sail); + } + + repo.initialize(); + cxn = repo.getConnection(); + cxn.setAutoCommit(false); + + try { + + final ValueFactory vf = sail.getValueFactory(); + + final String ns = BD.NAMESPACE; + + URI mike = vf.createURI(ns+"Mike"); + URI bryan = vf.createURI(ns+"Bryan"); + URI person = vf.createURI(ns+"Person"); + URI likes = vf.createURI(ns+"likes"); + URI rdf = vf.createURI(ns+"RDF"); + Literal l1 = vf.createLiteral("Mike"); + Literal l2 = vf.createLiteral("Bryan"); + URI g1 = vf.createURI(ns+"graph1"); + URI g2 = vf.createURI(ns+"graph2"); +/**/ + cxn.setNamespace("ns", ns); + + cxn.add(mike, RDF.TYPE, person, g1, g2); + cxn.add(mike, likes, rdf, g1, g2); + cxn.add(mike, RDFS.LABEL, l1, g1, g2); + cxn.add(bryan, RDF.TYPE, person, g1, g2); + cxn.add(bryan, likes, rdf, g1, g2); + cxn.add(bryan, RDFS.LABEL, l2, g1, g2); + + /* + * Note: The either flush() or commit() is required to flush the + * statement buffers to the database before executing any operations + * that go around the sail. + */ + cxn.commit();// + + if (log.isInfoEnabled()) { + if (sail instanceof BigdataSail) + log.info("\n" + ((BigdataSail)sail).getDatabase().dumpStore()); + } + + { + + String query = + "PREFIX rdf: <"+RDF.NAMESPACE+"> " + + "PREFIX rdfs: <"+RDFS.NAMESPACE+"> " + + "PREFIX ns: <"+ns+"> " + + + "select ?p ?o " + + "WHERE { " + + " ns:Mike ?p ?o . " + + "}"; + + final TupleQuery tupleQuery = + cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); + TupleQueryResult result = tupleQuery.evaluate(); + +// while (result.hasNext()) { +// System.err.println(result.next()); +// } + + Collection<BindingSet> solution = new LinkedList<BindingSet>(); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", RDF.TYPE), + new BindingImpl("o", person), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", likes), + new BindingImpl("o", rdf), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", RDFS.LABEL), + new BindingImpl("o", l1), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", RDF.TYPE), + new BindingImpl("o", person), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", likes), + new BindingImpl("o", rdf), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", RDFS.LABEL), + new BindingImpl("o", l1), + })); + + compare(result, solution); + + } + + { + + String query = + "PREFIX rdf: <"+RDF.NAMESPACE+"> " + + "PREFIX rdfs: <"+RDFS.NAMESPACE+"> " + + "PREFIX ns: <"+ns+"> " + + + "select ?p ?o " + + "from <"+g1+">" + + "from <"+g2+">" + + "WHERE { " + + " ns:Mike ?p ?o . " + + "}"; + + final TupleQuery tupleQuery = + cxn.prepareTupleQuery(QueryLanguage.SPARQL, query); + TupleQueryResult result = tupleQuery.evaluate(); + +// while (result.hasNext()) { +// System.err.println(result.next()); +// } + + Collection<BindingSet> solution = new LinkedList<BindingSet>(); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", RDF.TYPE), + new BindingImpl("o", person), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", likes), + new BindingImpl("o", rdf), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", RDFS.LABEL), + new BindingImpl("o", l1), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", RDF.TYPE), + new BindingImpl("o", person), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", likes), + new BindingImpl("o", rdf), + })); + solution.add(createBindingSet(new Binding[] { + new BindingImpl("p", RDFS.LABEL), + new BindingImpl("o", l1), + })); + + compare(result, solution); + + } + + } finally { + cxn.close(); + if (sail instanceof BigdataSail) + ((BigdataSail)sail).__tearDownUnitTest(); + } + + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2010-10-18 12:32:11
|
Revision: 3806 http://bigdata.svn.sourceforge.net/bigdata/?rev=3806&view=rev Author: martyncutcher Date: 2010-10-18 12:32:05 +0000 (Mon, 18 Oct 2010) Log Message: ----------- Rationalise rootBlock syncronization to handle rollback correctly, and amend test code Modified Paths: -------------- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RWStrategy.java branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/journal/AbstractRestartSafeTestCase.java branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/rwstore/TestRWJournal.java Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RWStrategy.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RWStrategy.java 2010-10-18 12:03:54 UTC (rev 3805) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RWStrategy.java 2010-10-18 12:32:05 UTC (rev 3806) @@ -447,6 +447,10 @@ // Current rootBlock is retained m_rb = rootBlock; + if (m_rb.isRootBlock0()) + m_rb0 = m_rb; + else + m_rb1 = m_rb; } @@ -525,17 +529,6 @@ m_commitLock.lock(); try { m_store.commitChanges(); // includes a force(false) - IRootBlockView rb = getRootBlock(); - - writeRootBlock(rb, ForceEnum.No); - - m_rb = rb; - - if (m_rb.isRootBlock0()) { - m_rb0 = m_rb; - } else { - m_rb1 = m_rb; - } } finally { m_commitLock.unlock(); } Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/journal/AbstractRestartSafeTestCase.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/journal/AbstractRestartSafeTestCase.java 2010-10-18 12:03:54 UTC (rev 3805) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/journal/AbstractRestartSafeTestCase.java 2010-10-18 12:32:05 UTC (rev 3806) @@ -425,6 +425,9 @@ public void test_closeForWrites() { Journal store = (Journal) getStore(); + + if (store.getBufferStrategy() instanceof RWStrategy) + return; // void test try { Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/rwstore/TestRWJournal.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/rwstore/TestRWJournal.java 2010-10-18 12:03:54 UTC (rev 3805) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/rwstore/TestRWJournal.java 2010-10-18 12:32:05 UTC (rev 3806) @@ -791,7 +791,7 @@ System.out.println("Now commit to disk"); - bs.commit(); + store.commit(); // Now reset - clears writeCache and reinits from disk rw.reset(); @@ -836,7 +836,7 @@ System.out.println("Now commit to disk"); - bs.commit(); + store.commit(); // Now reset - clears writeCache and reinits from disk rw.reset(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2010-10-18 12:04:01
|
Revision: 3805 http://bigdata.svn.sourceforge.net/bigdata/?rev=3805&view=rev Author: thompsonbry Date: 2010-10-18 12:03:54 +0000 (Mon, 18 Oct 2010) Log Message: ----------- Resolution for https://sourceforge.net/apps/trac/bigdata/ticket/185. The zookeeper locks are not reentrant. Since the full text index is in the namespace of the lexicon relation, the full text index must not attempt to acquire the zlock for that relation when destroying the full text index. FullTextIndex#destroy() has been overridden in BigdataRDFFullTextIndex to avoid attempting to acquire a non-reentrant lock already held by the caller. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/BigdataRDFFullTextIndex.java Modified: branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/BigdataRDFFullTextIndex.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/BigdataRDFFullTextIndex.java 2010-10-17 13:10:51 UTC (rev 3804) +++ branches/QUADS_QUERY_BRANCH/bigdata-rdf/src/java/com/bigdata/rdf/lexicon/BigdataRDFFullTextIndex.java 2010-10-18 12:03:54 UTC (rev 3805) @@ -94,6 +94,26 @@ } + /** + * The full text index is currently located in the same namespace as the + * lexicon relation. However, the distributed zookeeper locks (ZLocks) + * are not reentrant. Therefore this method is overridden to NOT acquire + * the ZLock for the namespace of the relation when destroying the full + * text index -- that lock is already held for the same namespace by the + * {@link LexiconRelation}. + */ + @Override + public void destroy() { + + if (log.isInfoEnabled()) + log.info(""); + + assertWritable(); + + getIndexManager().dropIndex(getNamespace() + "." + NAME_SEARCH); + + } + public void index(int capacity, Iterator<BigdataValue> valuesIterator) { final TokenBuffer buffer = new TokenBuffer(capacity, this); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2010-10-17 13:10:57
|
Revision: 3804 http://bigdata.svn.sourceforge.net/bigdata/?rev=3804&view=rev Author: thompsonbry Date: 2010-10-17 13:10:51 +0000 (Sun, 17 Oct 2010) Log Message: ----------- Modified the transaction service to permit assignment of a read-only transaction identifier when given a timestamp which is GT the last commit time on the database but LT the last timestamp actually assigned by the transaction service using nextTimestamp(). This permits the use of valid timestamps beyond the last commit time on the database when requesting a read-only transaction. This also handles the edge case when a transaction is requested for a timestamp which is actually a read-only transaction reading from the last commit time on the database. This case was observed using the SAIL with the NanoSparqlServer. This commit provides a workaround. An issue has been filed to look into this further. See https://sourceforge.net/apps/trac/bigdata/ticket/187. Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/service/AbstractTransactionService.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/service/AbstractTransactionService.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/service/AbstractTransactionService.java 2010-10-17 11:09:45 UTC (rev 3803) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/service/AbstractTransactionService.java 2010-10-17 13:10:51 UTC (rev 3804) @@ -618,9 +618,11 @@ */ synchronized private final long _nextTimestamp() { - return MillisecondTimestampFactory.nextMillis(); + return lastTimestamp = MillisecondTimestampFactory.nextMillis(); } + /** The last timestamp issued. */ + private volatile long lastTimestamp; /** * Note: There is an upper bound of one read-write transaction that may be @@ -1232,16 +1234,18 @@ final long lastCommitTime = getLastCommitTime(); - if (timestamp > lastCommitTime) { +// if (timestamp > lastCommitTime) { + if (timestamp > lastTimestamp) { /* * You can't request a historical read for a timestamp which has not * yet been issued by this service! */ - throw new IllegalStateException( - "Timestamp is in the future: timestamp=" + timestamp - + ", lastCommitTime=" + lastCommitTime); + throw new IllegalStateException( + "Timestamp is in the future: timestamp=" + timestamp + + ", lastCommitTime=" + lastCommitTime + + ", lastTimestamp=" + lastTimestamp); } else if (timestamp == lastCommitTime) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2010-10-17 11:09:51
|
Revision: 3803 http://bigdata.svn.sourceforge.net/bigdata/?rev=3803&view=rev Author: thompsonbry Date: 2010-10-17 11:09:45 +0000 (Sun, 17 Oct 2010) Log Message: ----------- javadoc edits (spelling errors). Modified Paths: -------------- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/journal/ITransactionService.java branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/service/AbstractTransactionService.java Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/journal/ITransactionService.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/journal/ITransactionService.java 2010-10-15 12:17:18 UTC (rev 3802) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/journal/ITransactionService.java 2010-10-17 11:09:45 UTC (rev 3803) @@ -65,7 +65,7 @@ * global release time - the earliest commit time from which a transaction may * read. Under dire circumstances (disk shortage) the transaction manager MAY * choose to abort transactions and advance the release time in order to permit - * the release of locked resources and the reclaimation of their space on local + * the release of locked resources and the reclamation of their space on local * disk. * </p> * <h2>Centralized transaction manager service</h2> @@ -87,8 +87,8 @@ * time, rendering views of earlier states of the database unavailable. * </p> * <p> - * The transaction identifier is the transaction <em>start time</em>. The - * transaction start time is choosen from among those distinct timestamps + * The transaction identifier codes the transaction <em>start time</em>. The + * transaction start time is chosen from among those distinct timestamps * available between the specified commit time and the next commit time on the * database. Successive read-write transactions must be assigned transaction * identifiers whose absolute value is strictly increasing - this requirement is @@ -100,10 +100,10 @@ * identifiers may be directly used as commit times when reading on a local * store. Read-write transaction identifiers must have their sign bit cleared in * order to read from their ground state (the commit point corresponding to - * their transaction start time) and unmodified transaction identifier is used - * to access their mutable view (the view comprised of the write set of the + * their transaction start time) but the unmodified transaction identifier is + * used to access their mutable view (the view comprised of the write set of the * transaction super imposed on the ground state such that writes, overwrites, - * and deletes are visible to the view). + * and deletes are visible in the view). * </p> * <p> * The symbolic value {@link ITx#READ_COMMITTED} and any <code>startTime</code> @@ -257,7 +257,7 @@ * operation isolated by a read-write transaction to execute with access to * the named resources (this applies only to distributed databases). The * declared resources are used in the commit phase of the read-write tx to - * impose a partial order on commits. That partial order guarentees that + * impose a partial order on commits. That partial order guarantees that * commits do not deadlock in contention for the same resources. * * @param tx Modified: branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/service/AbstractTransactionService.java =================================================================== --- branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/service/AbstractTransactionService.java 2010-10-15 12:17:18 UTC (rev 3802) +++ branches/QUADS_QUERY_BRANCH/bigdata/src/java/com/bigdata/service/AbstractTransactionService.java 2010-10-17 11:09:45 UTC (rev 3803) @@ -633,7 +633,7 @@ * * @throws RuntimeException * Wrapping {@link TimeoutException} if a timeout occurs - * awaiting a start time which would satisify the request for a + * awaiting a start time which would satisfy the request for a * read-only transaction (this can occur only for read-only * transactions which must contend for start times which will * read from the appropriate historical commit point). @@ -658,7 +658,7 @@ * Higher concurrency will require relaxing constraints on atomic * state transitions governed by [lock]. Perhaps by introducing * additional locks that are more specific. I don't want to relax - * those constaints until I have a better sense of what must be + * those constraints until I have a better sense of what must be * exclusive operations. */ @@ -1115,7 +1115,7 @@ * (commitTime-1) then compute and set the new releaseTime. * <p> * Note: This method was historically part of {@link #notifyCommit(long)}. - * It was moved into its own method so it can be overriden for some unit + * It was moved into its own method so it can be overridden for some unit * tests. * * @throws IllegalMonitorStateException @@ -1203,10 +1203,10 @@ * * @throws InterruptedException * if interrupted while awaiting a start time which would - * satisify the request. + * satisfy the request. * @throws InterruptedException * if a timeout occurs while awaiting a start time which would - * satisify the request. + * satisfy the request. */ protected long assignTransactionIdentifier(final long timestamp) throws InterruptedException, TimeoutException { @@ -1217,7 +1217,7 @@ * When timestamp is ZERO (0L), this simply returns the next * distinct timestamp (with its sign bit flipped). * - * Note: This is guarenteed to be a valid start time since it is LT + * Note: This is guaranteed to be a valid start time since it is LT * the next possible commit point for the database. * * Note: When we validate, we will read from [-startTime] and the @@ -1338,7 +1338,7 @@ /* * Note: If there is no successor of the desired commit point then - * we can just return the next timestamp. It is guarenteed to be GT + * we can just return the next timestamp. It is guaranteed to be GT * the desired commit time and LT the next commit point. [Note: this * case is in fact handled above so you should not get here.] */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <tho...@us...> - 2010-10-15 12:17:24
|
Revision: 3802 http://bigdata.svn.sourceforge.net/bigdata/?rev=3802&view=rev Author: thompsonbry Date: 2010-10-15 12:17:18 +0000 (Fri, 15 Oct 2010) Log Message: ----------- Added note to the effect that you must run "ant bundleJar" in the top-level directory before using any of the ant scripts in the bigdata-perf module. Modified Paths: -------------- trunk/bigdata-perf/README.txt Modified: trunk/bigdata-perf/README.txt =================================================================== --- trunk/bigdata-perf/README.txt 2010-10-14 20:44:47 UTC (rev 3801) +++ trunk/bigdata-perf/README.txt 2010-10-15 12:17:18 UTC (rev 3802) @@ -1,2 +1,6 @@ This module contains drivers for a variety of data sets and benchmarks used as -part of a performance test suite. \ No newline at end of file +part of a performance test suite. + +Note: You must run "ant bundleJar" in the top-level directory first. This will +build the bigdata code base and bundle together the various dependencies so they +will be available for the ant scripts in this module. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fko...@us...> - 2010-10-14 20:44:56
|
Revision: 3801 http://bigdata.svn.sourceforge.net/bigdata/?rev=3801&view=rev Author: fkoliver Date: 2010-10-14 20:44:47 +0000 (Thu, 14 Oct 2010) Log Message: ----------- Revert r3761 which changed some subclasses of BTree into uses of BTree. Modified Paths: -------------- branches/maven_scaleout/bigdata-core/pom.xml branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BTree.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegment.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/MetadataIndex.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/MetadataIndexView.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/Node.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/ReadOnlyIndex.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/cache/HardReferenceGlobalLRURecycler.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/cache/LRUNexus.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/httpd/DummyEventReportingService.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/AbstractJournal.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/CommitRecordIndex.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/journal/DumpJournal.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/loadbalancer/EmbeddedLoadBalancer.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/IndexSegmentIndex.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/JournalIndex.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/ResourceEvents.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/resources/StoreManager.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/AbstractTransactionService.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/CommitTimeIndex.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/DistributedTransactionService.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/EventReceiver.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/LoadBalancerService.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/MetadataIndexCache.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/transaction/EmbeddedTransactionService.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/counters/TestAll.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/journal/TestCommitRecordIndex.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/TestDistributedTransactionServiceRestart.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/TestEventReceiver.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/service/TestSnapshotHelper.java Added Paths: ----------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/DelegateIndex.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/query/CounterSetBTreeSelector.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/query/CounterSetLoader.java branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/counters/store/CounterSetBTree.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/counters/store/TestAll.java branches/maven_scaleout/bigdata-core/src/test/java/com/bigdata/counters/store/TestCounterSetBTree.java Removed Paths: ------------- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/service/EventBTree.java Modified: branches/maven_scaleout/bigdata-core/pom.xml =================================================================== --- branches/maven_scaleout/bigdata-core/pom.xml 2010-10-14 16:19:22 UTC (rev 3800) +++ branches/maven_scaleout/bigdata-core/pom.xml 2010-10-14 20:44:47 UTC (rev 3801) @@ -60,8 +60,6 @@ java files were getting recompiled and put into the bigdata jar. This setting forces javac to only look for source in the current maven source directory. --> <sourcepath>${project.build.sourceDirectory}</sourcepath> - <!-- <Xlint></Xlint> --> - <!-- <Xlint:unchecked></Xlint:unchecked> --> </compilerArguments> </configuration> </plugin> @@ -162,7 +160,7 @@ <fastutil.jar>${deploy.lib}/fastutil.jar</fastutil.jar> <icu4j.jar>${deploy.lib}/icu4j.jar</icu4j.jar> <jsk-lib.jar>${deploy.lib}/jsk-lib.jar</jsk-lib.jar> - <jsk-platform.jar>${deploy.lib}/jsk-platform.jar</jsk-platform.jar> + <jsk-platform.jar>${deploy.lib}jsk-platform.jar</jsk-platform.jar> <log4j.jar>${deploy.lib}/log4j.jar</log4j.jar> <iris.jar>${deploy.lib}/iris.jar</iris.jar> <jgrapht.jar>${deploy.lib}/jgrapht.jar</jgrapht.jar> Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java 2010-10-14 16:19:22 UTC (rev 3800) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/AbstractBTree.java 2010-10-14 20:44:47 UTC (rev 3801) @@ -128,6 +128,7 @@ * </p> * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ * * @see KeyBuilder */ @@ -163,7 +164,7 @@ /** * Log for btree opeations. */ - private static final Logger log = Logger.getLogger(AbstractBTree.class); + protected static final Logger log = Logger.getLogger(AbstractBTree.class); /** * True iff the {@link #log} level is INFO or less. @@ -337,6 +338,7 @@ * * @author <a href="mailto:tho...@us...">Bryan * Thompson</a> + * @version $Id$ */ static class ChildMemoizer extends Memoizer<LoadChildRequest/* request */, AbstractNode<?>/* child */> { @@ -1360,6 +1362,7 @@ * Static class since must be {@link Serializable}. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ */ static final class TransientResourceMetadata implements IResourceMetadata { @@ -2585,7 +2588,6 @@ } - //fko ===== needs generic type ===== final public ITupleIterator rangeIterator() { return rangeIterator(null, null); @@ -2600,7 +2602,6 @@ * @param toKey * @return */ - //fko ===== needs generic type ===== final public ITupleIterator rangeIterator(Object fromKey, Object toKey) { fromKey = fromKey == null ? null : metadata.getTupleSerializer() @@ -2613,7 +2614,6 @@ } - //fko ===== needs generic type ===== final public ITupleIterator rangeIterator(byte[] fromKey, byte[] toKey) { return rangeIterator(fromKey, toKey, 0/* capacity */, @@ -2665,7 +2665,6 @@ * @param toKey * @return */ - //fko ===== needs generic type ===== final public ITupleIterator rangeIterator(Object fromKey, Object toKey, final int capacity,// final int flags,// @@ -2706,13 +2705,208 @@ * @todo add support to the iterator construct for filtering by a tuple * revision timestamp range. */ - //fko ===== needs generic type ===== - abstract public ITupleIterator rangeIterator(final byte[] fromKey, - final byte[] toKey, - final int capacityIsIgnored, - final int flags, - final IFilterConstructor filter); + public ITupleIterator rangeIterator(// + final byte[] fromKey,// + final byte[] toKey,// + final int capacityIsIgnored,// + final int flags,// + final IFilterConstructor filter// + ) { +// btreeCounters.nrangeIterator.incrementAndGet(); + + /* + * Does the iterator declare that it will not write back on the index? + */ + final boolean readOnly = ((flags & IRangeQuery.READONLY) != 0); + + if (readOnly && ((flags & IRangeQuery.REMOVEALL) != 0)) { + + throw new IllegalArgumentException(); + + } + + /* + * Note: this does not work out since it is not so easy to determine when + * the iterator is a point test as toKey is the exclusive upper bound. + */ +// * Note: this method will automatically apply the optional bloom filter to +// * reject range iterator requests that correspond to a point test. However +// * this can only be done when the fromKey and toKey are both non-null and +// * equals and further when the iterator was not requested with any options +// * that would permit concurrent modification of the index. +// if (isBloomFilter() +// && fromKey != null +// && toKey != null +// && (readOnly || (((flags & REMOVEALL) == 0) && ((flags & CURSOR) == 0))) +// && BytesUtil.bytesEqual(fromKey, toKey)) { +// +// /* +// * Do a fast rejection test using the bloom filter. +// */ +// if(!getBloomFilter().contains(fromKey)) { +// +// /* +// * The key is known to not be in the index so return an empty +// * iterator. +// */ +// return EmptyTupleIterator.INSTANCE; +// +// } +// +// /* +// * Since the bloom filter accepts the key we fall through into the +// * normal iterator logic. Using this code path is still possible +// * that the filter gave us a false positive and that the key is not +// * (in fact) in the index. Either way, the logic below will sort +// * things out. +// */ +// +// } + + /* + * Figure out what base iterator implementation to use. We will layer + * on the optional filter(s) below. + */ + ITupleIterator src; + + if ((this instanceof BTree) && ((flags & REVERSE) == 0) + && ((flags & REMOVEALL) == 0) && ((flags & CURSOR) == 0)) { + + /* + * Use the recursion-based striterator since it is faster for a + * BTree (but not for an IndexSegment). + * + * Note: The recursion-based striterator does not support remove()! + * + * @todo we could pass in the Tuple here to make the APIs a bit more + * consistent across the recursion-based and the cursor based + * iterators. + * + * @todo when the capacity is one and REVERSE is specified then we + * can optimize this using a reverse traversal striterator - this + * will have lower overhead than the cursor for the BTree (but not + * for an IndexSegment). + */ + +// src = fastForwardIterator(fromKey, toKey, capacity, flags); + + src = getRoot().rangeIterator(fromKey, toKey, flags); + + } else { + + final Tuple tuple = new Tuple(this, flags); + + if (this instanceof IndexSegment) { + + final IndexSegment seg = (IndexSegment) this; + + /* + * @todo we could scan the list of pools and chose the best fit + * pool and then allocate a buffer from that pool. Best fit + * would mean either the byte range fits without "too much" slop + * or the #of reads will have to perform is not too large. We + * might also want to limit the maximum size of the reads. + */ + +// final DirectBufferPool pool = DirectBufferPool.INSTANCE_10M; + final DirectBufferPool pool = DirectBufferPool.INSTANCE; + + if (true + && ((flags & REVERSE) == 0) + && ((flags & CURSOR) == 0) + && (seg.getStore().getCheckpoint().maxNodeOrLeafLength <= pool + .getBufferCapacity()) + && ((rangeCount(fromKey, toKey) / branchingFactor) > 2)) { + + src = new IndexSegmentMultiBlockIterator(seg, pool, + fromKey, toKey, flags); + + } else { + + src = new IndexSegmentTupleCursor(seg, tuple, fromKey, + toKey); + + } + + } else if (this instanceof BTree) { + + if (isReadOnly()) { + + // Note: this iterator does not allow removal. + src = new ReadOnlyBTreeTupleCursor(((BTree) this), tuple, + fromKey, toKey); + + } else { + + // Note: this iterator supports traversal with concurrent + // modification. + src = new MutableBTreeTupleCursor(((BTree) this), + new Tuple(this, flags), fromKey, toKey); + + } + + } else { + + throw new UnsupportedOperationException( + "Unknown B+Tree implementation: " + + this.getClass().getName()); + + } + + if ((flags & REVERSE) != 0) { + + /* + * Reverse scan iterator. + * + * Note: The reverse scan MUST be layered directly over the + * ITupleCursor. Most critically, REMOVEALL combined with a + * REVERSE scan needs to process the tuples in reverse index + * order and then delete them as it goes. + */ + + src = new Reverserator((ITupleCursor) src); + + } + + } + + if (filter != null) { + + /* + * Apply the optional filter. + * + * Note: This needs to be after the reverse scan and before + * REMOVEALL (those are the assumptions for the flags). + */ + + src = filter.newInstance(src); + + } + + if ((flags & REMOVEALL) != 0) { + + assertNotReadOnly(); + + /* + * Note: This iterator removes each tuple that it visits from the + * source iterator. + */ + + src = new TupleRemover() { + @Override + protected boolean remove(ITuple e) { + // remove all visited tuples. + return true; + } + }.filter(src); + + } + + return src; + + } + /** * Copy all data, including deleted index entry markers and timestamps iff * supported by the source and target. The goal is an exact copy of the data @@ -3699,6 +3893,7 @@ * {@link Reference} (a runtime security manager exception will result). * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ * * @param <T> */ Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BTree.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BTree.java 2010-10-14 16:19:22 UTC (rev 3800) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/BTree.java 2010-10-14 20:44:47 UTC (rev 3801) @@ -32,13 +32,9 @@ import com.bigdata.BigdataStatics; import com.bigdata.btree.AbstractBTreeTupleCursor.MutableBTreeTupleCursor; -import com.bigdata.btree.AbstractBTreeTupleCursor.ReadOnlyBTreeTupleCursor; import com.bigdata.btree.Leaf.ILeafListener; import com.bigdata.btree.data.ILeafData; import com.bigdata.btree.data.INodeData; -import com.bigdata.btree.filter.IFilterConstructor; -import com.bigdata.btree.filter.Reverserator; -import com.bigdata.btree.filter.TupleRemover; import com.bigdata.journal.AbstractJournal; import com.bigdata.journal.ICommitter; import com.bigdata.journal.IIndexManager; @@ -46,7 +42,6 @@ import com.bigdata.journal.Name2Addr.Entry; import com.bigdata.mdi.IResourceMetadata; import com.bigdata.rawstore.IRawStore; -import org.apache.log4j.Logger; /** * <p> @@ -156,14 +151,10 @@ * several published papers. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ */ public class BTree extends AbstractBTree implements ICommitter, ILocalBTreeView { - /** - * Log for btree operations. - */ - private static final Logger log = Logger.getLogger(BTree.class); - final public int getHeight() { return height; @@ -197,7 +188,6 @@ } - @Override public final IResourceMetadata[] getResourceMetadata() { //override to make final so sub-classes cannot modify behavior. return super.getResourceMetadata(); @@ -214,23 +204,23 @@ */ public ICounter getCounter() { - ICounter tmpCounter = new Counter(this); + ICounter counter = new Counter(this); final LocalPartitionMetadata pmd = metadata.getPartitionMetadata(); if (pmd != null) { - tmpCounter = new PartitionedCounter(pmd.getPartitionId(), tmpCounter); + counter = new PartitionedCounter(pmd.getPartitionId(), counter); } if (isReadOnly()) { - return new ReadOnlyCounter(tmpCounter); + return new ReadOnlyCounter(counter); } - return tmpCounter; + return counter; } @@ -403,7 +393,7 @@ * <p> * Note: The {@link #getCounter()} is NOT changed by this method. */ - private void newRootLeaf() { + final private void newRootLeaf() { height = 0; @@ -1349,8 +1339,14 @@ // view of this BTree. newResources[1] = new JournalMetadata((AbstractJournal) getStore(), priorCommitTime); - System.arraycopy(oldResources, 1, newResources, 2, oldResources.length - 1); + // any other stores in the view are copied. + for (int i = 1; i < oldResources.length; i++) { + + newResources[i + 1] = oldResources[i]; + + } + final LocalPartitionMetadata newPmd = new LocalPartitionMetadata( oldPmd.getPartitionId(), // partitionId -1, // sourcePartitionId @@ -1571,6 +1567,7 @@ * @throws IllegalArgumentException * if store is <code>null</code>. */ + @SuppressWarnings("unchecked") public static BTree load(final IRawStore store, final long addrCheckpoint, final boolean readOnly) { @@ -1656,147 +1653,6 @@ } /** - * Core implementation. - * <p> - * Note: If {@link IRangeQuery#CURSOR} is specified the returned iterator - * supports traversal with concurrent modification by a single-threaded - * process (the {@link BTree} is NOT thread-safe for writers). Write are - * permitted iff {@link AbstractBTree} allows writes. - * <p> - * Note: {@link IRangeQuery#REVERSE} is handled here by wrapping the - * underlying {@link ITupleCursor}. - * <p> - * Note: {@link IRangeQuery#REMOVEALL} is handled here by wrapping the - * iterator. - * <p> - * Note: - * {@link FusedView#rangeIterator(byte[], byte[], int, int, IFilterConstructor)} - * is also responsible for constructing an {@link ITupleIterator} in a - * manner similar to this method. If you are updating the logic here, then - * check the logic in that method as well! - * - * @todo add support to the iterator construct for filtering by a tuple - * revision timestamp range. - */ - public ITupleIterator rangeIterator(// - final byte[] fromKey,// - final byte[] toKey,// - final int capacityIsIgnored,// - final int flags,// - final IFilterConstructor filter// - ) { - - /* - * Does the iterator declare that it will not write back on the index? - */ - final boolean ro = ((flags & IRangeQuery.READONLY) != 0); - - if (ro && ((flags & IRangeQuery.REMOVEALL) != 0)) { - - throw new IllegalArgumentException(); - - } - - /* - * Figure out what base iterator implementation to use. We will layer - * on the optional filter(s) below. - */ - ITupleIterator src; - - if (((flags & REVERSE) == 0) && - ((flags & REMOVEALL) == 0) && - ((flags & CURSOR) == 0)) { - - /* - * Use the recursion-based striterator since it is faster for a - * BTree (but not for an IndexSegment). - * - * Note: The recursion-based striterator does not support remove()! - * - * @todo we could pass in the Tuple here to make the APIs a bit more - * consistent across the recursion-based and the cursor based - * iterators. - * - * @todo when the capacity is one and REVERSE is specified then we - * can optimize this using a reverse traversal striterator - this - * will have lower overhead than the cursor for the BTree (but not - * for an IndexSegment). - */ - src = getRoot().rangeIterator(fromKey, toKey, flags); - - } else { - - final Tuple tuple = new Tuple(this, flags); - - if (isReadOnly()) { - - // Note: this iterator does not allow removal. - src = new ReadOnlyBTreeTupleCursor(((BTree) this), tuple, - fromKey, toKey); - - } else { - - // Note: this iterator supports traversal with concurrent - // modification. - src = new MutableBTreeTupleCursor(((BTree) this), - new Tuple(this, flags), fromKey, toKey); - - } - - if ((flags & REVERSE) != 0) { - - /* - * Reverse scan iterator. - * - * Note: The reverse scan MUST be layered directly over the - * ITupleCursor. Most critically, REMOVEALL combined with a - * REVERSE scan needs to process the tuples in reverse index - * order and then delete them as it goes. - */ - - src = new Reverserator((ITupleCursor) src); - - } - - } - - if (filter != null) { - - /* - * Apply the optional filter. - * - * Note: This needs to be after the reverse scan and before - * REMOVEALL (those are the assumptions for the flags). - */ - - src = filter.newInstance(src); - - } - - if ((flags & REMOVEALL) != 0) { - - assertNotReadOnly(); - - /* - * Note: This iterator removes each tuple that it visits from the - * source iterator. - */ - - src = new TupleRemover() { - @Override - protected boolean remove(ITuple e) { - // remove all visited tuples. - return true; - } - }.filter(src); - - } - - return src; - - } - - /** * Factory for mutable nodes and leaves used by the {@link NodeSerializer}. */ protected static class NodeFactory implements INodeFactory { @@ -1826,6 +1682,7 @@ * Mutable counter. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ */ public static class Counter implements ICounter { @@ -1885,6 +1742,7 @@ * int32 word. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ */ public static class PartitionedCounter implements ICounter { @@ -1993,6 +1851,7 @@ * * @author <a href="mailto:tho...@us...">Bryan * Thompson</a> + * @version $Id$ */ protected static class Stack { @@ -2168,6 +2027,7 @@ * Note: The {@link MutableBTreeTupleCursor} does register such listeners. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ */ public class LeafCursor implements ILeafCursor<Leaf> { @@ -2265,7 +2125,6 @@ } - @Override public LeafCursor clone() { return new LeafCursor(this); @@ -2318,7 +2177,7 @@ } - final public Leaf first() { + public Leaf first() { stack.clear(); @@ -2339,7 +2198,7 @@ } - final public Leaf last() { + public Leaf last() { stack.clear(); @@ -2365,7 +2224,7 @@ * the leaf may not actually contain the key, in which case it is the * leaf that contains the insertion point for the key. */ - final public Leaf seek(final byte[] key) { + public Leaf seek(final byte[] key) { stack.clear(); Copied: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/DelegateIndex.java (from rev 3760, branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/DelegateIndex.java) =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/DelegateIndex.java (rev 0) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/DelegateIndex.java 2010-10-14 20:44:47 UTC (rev 3801) @@ -0,0 +1,169 @@ +/* + +Copyright (C) SYSTAP, LLC 2006-2008. 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 Feb 20, 2008 + */ + +package com.bigdata.btree; + +import com.bigdata.btree.filter.IFilterConstructor; +import com.bigdata.btree.proc.AbstractKeyArrayIndexProcedureConstructor; +import com.bigdata.btree.proc.IKeyRangeIndexProcedure; +import com.bigdata.btree.proc.IResultHandler; +import com.bigdata.btree.proc.ISimpleIndexProcedure; +import com.bigdata.counters.ICounterSet; +import com.bigdata.mdi.IResourceMetadata; + +/** + * An object that delegates its {@link IIndex} interface. + * + * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ + */ +public class DelegateIndex implements IIndex { + + private final IIndex delegate; + + /** + * @param delegate + * The delegate. + */ + public DelegateIndex(IIndex delegate) { + + if (delegate == null) { + + throw new IllegalArgumentException(); + + } + + this.delegate = delegate; + + } + + public String toString() { + + final StringBuilder sb = new StringBuilder(); + + sb.append(getClass().getSimpleName()); + + sb.append("{ "); + + sb.append(delegate.toString()); + + sb.append("}"); + + return sb.toString(); + + } + + public boolean contains(byte[] key) { + return delegate.contains(key); + } + + public ICounter getCounter() { + return delegate.getCounter(); + } + + public IndexMetadata getIndexMetadata() { + return delegate.getIndexMetadata(); + } + + public IResourceMetadata[] getResourceMetadata() { + return delegate.getResourceMetadata(); + } + + public ICounterSet getCounters() { + return delegate.getCounters(); + } + + public byte[] insert(byte[] key, byte[] value) { + return delegate.insert(key, value); + } + + public byte[] lookup(byte[] key) { + return delegate.lookup(key); + } + + public long rangeCount() { + return delegate.rangeCount(); + } + + public long rangeCount(byte[] fromKey, byte[] toKey) { + return delegate.rangeCount(fromKey, toKey); + } + + public long rangeCountExact(byte[] fromKey, byte[] toKey) { + return delegate.rangeCountExact(fromKey, toKey); + } + + public long rangeCountExactWithDeleted(byte[] fromKey, byte[] toKey) { + return delegate.rangeCountExactWithDeleted(fromKey, toKey); + } + + public ITupleIterator rangeIterator() { + return rangeIterator(null,null); + } + + public ITupleIterator rangeIterator(byte[] fromKey, byte[] toKey, int capacity, int flags, IFilterConstructor filter) { + return delegate.rangeIterator(fromKey, toKey, capacity, flags, filter); + } + + public ITupleIterator rangeIterator(byte[] fromKey, byte[] toKey) { + return delegate.rangeIterator(fromKey, toKey); + } + + public byte[] remove(byte[] key) { + return delegate.remove(key); + } + + public Object submit(byte[] key, ISimpleIndexProcedure proc) { + return delegate.submit(key, proc); + } + + public void submit(byte[] fromKey, byte[] toKey, IKeyRangeIndexProcedure proc, IResultHandler handler) { + delegate.submit(fromKey, toKey, proc, handler); + } + + public void submit(int fromIndex, int toIndex, byte[][] keys, byte[][] vals, AbstractKeyArrayIndexProcedureConstructor ctor, IResultHandler handler) { + delegate.submit(fromIndex, toIndex, keys, vals, ctor, handler); + } + + public boolean contains(Object key) { + return delegate.contains(key); + } + + public Object insert(Object key, Object value) { + return delegate.insert(key, value); + } + + public Object lookup(Object key) { + return delegate.lookup(key); + } + + public Object remove(Object key) { + return delegate.remove(key); + } + +} Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegment.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegment.java 2010-10-14 16:19:22 UTC (rev 3800) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/IndexSegment.java 2010-10-14 20:44:47 UTC (rev 3801) @@ -29,20 +29,15 @@ import com.bigdata.btree.IndexSegment.ImmutableNodeFactory.ImmutableLeaf; import com.bigdata.btree.data.ILeafData; import com.bigdata.btree.data.INodeData; -import com.bigdata.btree.filter.IFilterConstructor; -import com.bigdata.btree.filter.Reverserator; -import com.bigdata.btree.filter.TupleRemover; import com.bigdata.btree.raba.IRaba; import com.bigdata.btree.raba.ReadOnlyKeysRaba; import com.bigdata.btree.raba.ReadOnlyValuesRaba; import com.bigdata.io.AbstractFixedByteArrayBuffer; -import com.bigdata.io.DirectBufferPool; import com.bigdata.io.FixedByteArrayBuffer; import com.bigdata.mdi.IResourceMetadata; import com.bigdata.service.Event; import com.bigdata.service.EventResource; import com.bigdata.service.EventType; -import org.apache.log4j.Logger; /** * An index segment is read-only btree corresponding to some key range of a @@ -56,15 +51,11 @@ * leaves will all refuse mutation operations). * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ */ public class IndexSegment extends AbstractBTree { /** - * Log for btree opeations. - */ - private static final Logger log = Logger.getLogger(IndexSegment.class); - - /** * Type safe reference to the backing store. */ private final IndexSegmentStore fileStore; @@ -169,7 +160,6 @@ * {@link #getEntryCount()} uses the {@link IndexSegmentCheckpoint} and that * is only available while the {@link IndexSegmentStore} is open. */ - @Override public String toString() { // make sure the fileStore will remain open. @@ -313,7 +303,7 @@ } @Override - final protected void _reopen() { + protected void _reopen() { // prevent concurrent close. fileStore.lock.lock(); @@ -694,138 +684,6 @@ }; } - /** - * Core implementation. - * <p> - * Note: If {@link IRangeQuery#CURSOR} is specified the returned iterator - * supports traversal with concurrent modification by a single-threaded - * process (the {@link BTree} is NOT thread-safe for writers). Write are - * permitted iff {@link AbstractBTree} allows writes. - * <p> - * Note: {@link IRangeQuery#REVERSE} is handled here by wrapping the - * underlying {@link ITupleCursor}. - * <p> - * Note: {@link IRangeQuery#REMOVEALL} is handled here by wrapping the - * iterator. - * <p> - * Note: - * {@link FusedView#rangeIterator(byte[], byte[], int, int, IFilterConstructor)} - * is also responsible for constructing an {@link ITupleIterator} in a - * manner similar to this method. If you are updating the logic here, then - * check the logic in that method as well! - * - * @todo add support to the iterator construct for filtering by a tuple - * revision timestamp range. - */ - public ITupleIterator rangeIterator(// - final byte[] fromKey,// - final byte[] toKey,// - final int capacityIsIgnored,// - final int flags,// - final IFilterConstructor filter// - ) { - - /* - * Does the iterator declare that it will not write back on the index? - */ - final boolean readOnly = ((flags & IRangeQuery.READONLY) != 0); - - if (readOnly && ((flags & IRangeQuery.REMOVEALL) != 0)) { - - throw new IllegalArgumentException(); - - } - - /* - * Figure out what base iterator implementation to use. We will layer - * on the optional filter(s) below. - */ - ITupleIterator src; - - final Tuple tuple = new Tuple(this, flags); - - final IndexSegment seg = (IndexSegment) this; - - /* - * @todo we could scan the list of pools and chose the best fit - * pool and then allocate a buffer from that pool. Best fit - * would mean either the byte range fits without "too much" slop - * or the #of reads will have to perform is not too large. We - * might also want to limit the maximum size of the reads. - */ - -// final DirectBufferPool pool = DirectBufferPool.INSTANCE_10M; - final DirectBufferPool pool = DirectBufferPool.INSTANCE; - - if (true - && ((flags & REVERSE) == 0) - && ((flags & CURSOR) == 0) - && (seg.getStore().getCheckpoint().maxNodeOrLeafLength <= pool - .getBufferCapacity()) - && ((rangeCount(fromKey, toKey) / branchingFactor) > 2)) { - - src = new IndexSegmentMultiBlockIterator(seg, pool, - fromKey, toKey, flags); - - } else { - - src = new IndexSegmentTupleCursor(seg, tuple, fromKey, toKey); - - } - - - if ((flags & REVERSE) != 0) { - - /* - * Reverse scan iterator. - * - * Note: The reverse scan MUST be layered directly over the - * ITupleCursor. Most critically, REMOVEALL combined with a - * REVERSE scan needs to process the tuples in reverse index - * order and then delete them as it goes. - */ - - src = new Reverserator((ITupleCursor) src); - - } - - - if (filter != null) { - - /* - * Apply the optional filter. - * - * Note: This needs to be after the reverse scan and before - * REMOVEALL (those are the assumptions for the flags). - */ - - src = filter.newInstance(src); - - } - - if ((flags & REMOVEALL) != 0) { - - assertNotReadOnly(); - - /* - * Note: This iterator removes each tuple that it visits from the - * source iterator. - */ - - src = new TupleRemover() { - @Override - protected boolean remove(ITuple e) { - // remove all visited tuples. - return true; - } - }.filter(src); - - } - - return src; - - } - /* * INodeFactory */ @@ -861,6 +719,7 @@ * * @author <a href="mailto:tho...@us...">Bryan * Thompson</a> + * @version $Id$ */ public static class ImmutableNode extends Node { @@ -909,6 +768,8 @@ * * @author <a href="mailto:tho...@us...">Bryan * Thompson</a> + * @version $Id: IndexSegment.java 2265 2009-10-26 12:51:06Z thompsonbry + * $ */ private static class EmptyReadOnlyLeafData implements ILeafData { @@ -1008,6 +869,7 @@ * * @author <a href="mailto:tho...@us...">Bryan * Thompson</a> + * @version $Id$ */ public static class ImmutableLeaf extends Leaf { @@ -1145,6 +1007,7 @@ // * // * @author <a href="mailto:tho...@us...">Bryan // * Thompson</a> +// * @version $Id$ // */ // static public class ImmutableEmptyLastLeaf extends ImmutableLeaf { // @@ -1183,6 +1046,7 @@ * A position for the {@link IndexSegmentTupleCursor}. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ * @param <E> * The generic type for objects de-serialized from the values in * the index. @@ -1190,7 +1054,6 @@ static private class CursorPosition<E> extends AbstractCursorPosition<ImmutableLeaf,E> { @SuppressWarnings("unchecked") - @Override public IndexSegmentTupleCursor<E> getCursor() { return (IndexSegmentTupleCursor)cursor; @@ -1239,6 +1102,7 @@ * listeners for concurrent modifications. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ * @param <E> * The generic type for the objects de-serialized from the index. */ @@ -1401,6 +1265,7 @@ * Cursor using the double-linked leaves for efficient scans. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ */ public class ImmutableLeafCursor implements ILeafCursor<ImmutableLeaf> { @@ -1418,7 +1283,6 @@ } - @Override public ImmutableLeafCursor clone() { return new ImmutableLeafCursor(this); @@ -1469,7 +1333,7 @@ } - final public ImmutableLeaf seek(final byte[] key) { + public ImmutableLeaf seek(final byte[] key) { leaf = findLeaf(key); @@ -1499,7 +1363,7 @@ } - final public ImmutableLeaf first() { + public ImmutableLeaf first() { final long addr = getStore().getCheckpoint().addrFirstLeaf; @@ -1509,7 +1373,7 @@ } - final public ImmutableLeaf last() { + public ImmutableLeaf last() { final long addr = getStore().getCheckpoint().addrLastLeaf; Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/MetadataIndex.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/MetadataIndex.java 2010-10-14 16:19:22 UTC (rev 3800) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/MetadataIndex.java 2010-10-14 20:44:47 UTC (rev 3801) @@ -29,13 +29,13 @@ import java.io.ObjectOutput; import java.util.UUID; +import com.bigdata.mdi.PartitionLocator; import org.CognitiveWeb.extser.LongPacker; import com.bigdata.btree.keys.IKeyBuilderFactory; import com.bigdata.btree.view.FusedView; import com.bigdata.journal.ICommitter; import com.bigdata.journal.IResourceManager; -import com.bigdata.mdi.PartitionLocator; import com.bigdata.rawstore.IRawStore; import com.bigdata.service.MetadataService; @@ -44,7 +44,7 @@ * metadata index for each distributed index. The keys of the metadata index are * the first key that would be directed into the corresponding index segment, * e.g., a <em>separator key</em> (this is just the standard btree semantics). - * The values are serialized {@link PartitionLocator} objects. + * The values are serialized {@link com.bigdata.mdi.PartitionLocator} objects. * <p> * Note: At this time the recommended scale-out approach for the metadata index * is to place the metadata indices on a {@link MetadataService} (the same @@ -63,6 +63,7 @@ * taking the database offline. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ * * @todo The {@link MetadataIndex} does NOT support either overflow (it may NOT * be a {@link FusedView}) NOR key-range splits. There are several issues @@ -96,7 +97,6 @@ */ private transient final MetadataIndexView view; - @Override public MetadataIndexMetadata getIndexMetadata() { return (MetadataIndexMetadata) super.getIndexMetadata(); @@ -210,7 +210,6 @@ * Extended to require a checkpoint if {@link #incrementAndGetNextPartitionId()} has been * invoked. */ - @Override public boolean needsCheckpoint() { if(nextPartitionId != ((MetadataIndexCheckpoint)getCheckpoint()).getNextPartitionId()) { @@ -228,6 +227,7 @@ * identifier to be assigned by the metadata index. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ */ public static class MetadataIndexCheckpoint extends Checkpoint { @@ -329,6 +329,7 @@ * for the managed scale-out index. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ */ public static class MetadataIndexMetadata extends IndexMetadata implements Externalizable { @@ -380,7 +381,6 @@ private static final transient int VERSION0 = 0x0; - @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { @@ -398,7 +398,6 @@ } - @Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); @@ -431,6 +430,7 @@ * {@link MetadataIndex}. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ */ public static class PartitionLocatorTupleSerializer extends DefaultTupleSerializer<byte[]/*key*/, PartitionLocator/*val*/> { @@ -473,7 +473,6 @@ */ private final static transient byte VERSION = VERSION0; - @Override public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException { @@ -491,7 +490,6 @@ } - @Override public void writeExternal(final ObjectOutput out) throws IOException { super.writeExternal(out); Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/MetadataIndexView.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/MetadataIndexView.java 2010-10-14 16:19:22 UTC (rev 3800) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/MetadataIndexView.java 2010-10-14 20:44:47 UTC (rev 3801) @@ -28,27 +28,27 @@ package com.bigdata.btree; -import com.bigdata.btree.MetadataIndex.MetadataIndexMetadata; -import com.bigdata.btree.filter.IFilterConstructor; +import com.bigdata.mdi.PartitionLocator; import org.apache.log4j.Logger; import com.bigdata.cache.LRUCache; -import com.bigdata.mdi.PartitionLocator; +import com.bigdata.btree.MetadataIndex.MetadataIndexMetadata; /** * The extension semantics for the {@link IMetadataIndex} are implemented by * this class. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ */ -public class MetadataIndexView implements IMetadataIndex { +public class MetadataIndexView extends DelegateIndex implements IMetadataIndex { protected static final Logger log = Logger.getLogger(MetadataIndexView.class); // protected static final boolean INFO = log.isInfoEnabled(); // protected static final boolean DEBUG = log.isDebugEnabled(); - private final MetadataIndex metadataIndex; + private final AbstractBTree delegate; /** * <code>true</code> iff this is a read-only view. this is used to @@ -58,14 +58,19 @@ */ final private boolean readOnly; - public MetadataIndexView(MetadataIndex metadataIndex) { - this.metadataIndex = metadataIndex; - this.readOnly = metadataIndex.isReadOnly(); + public MetadataIndexView(AbstractBTree delegate) { + + super(delegate); + + this.delegate = delegate; + + this.readOnly = delegate.isReadOnly(); + } public MetadataIndexMetadata getIndexMetadata() { - return (MetadataIndexMetadata) metadataIndex.getIndexMetadata(); + return (MetadataIndexMetadata) super.getIndexMetadata(); } @@ -82,7 +87,7 @@ * de-serialization using the ITupleSerializer. */ - return (PartitionLocator) metadataIndex.lookup((Object) key); + return (PartitionLocator) delegate.lookup((Object) key); } @@ -107,7 +112,7 @@ */ private PartitionLocator find_with_iterator(byte[] key) { - final ITupleIterator<PartitionLocator> itr = metadataIndex.rangeIterator( + final ITupleIterator<PartitionLocator> itr = delegate.rangeIterator( null/* fromKey */, key/* toKey */, 1/* capacity */, IRangeQuery.VALS | IRangeQuery.REVERSE, null/* filter */); @@ -142,7 +147,7 @@ if (key == null) { // use the index of the last partition. - index = metadataIndex.getEntryCount() - 1; + index = delegate.getEntryCount() - 1; } else { @@ -207,7 +212,7 @@ /** * Remove the locator from the {@link #locatorCache}. It will be re-read on - * demand from the {@link #metadataIndex}. + * demand from the {@link #delegate}. */ public void staleLocator(PartitionLocator locator) { @@ -225,8 +230,8 @@ */ private PartitionLocator getLocatorAtIndex(int index) { - final ITuple<PartitionLocator> tuple = metadataIndex.valueAt(index, - metadataIndex.getLookupTuple()); + final ITuple<PartitionLocator> tuple = delegate.valueAt(index, + delegate.getLookupTuple()); return tuple.getObject(); @@ -247,7 +252,7 @@ */ private int findIndexOf(byte[] key) { - int pos = metadataIndex.indexOf(key); + int pos = delegate.indexOf(key); if (pos < 0) { @@ -261,7 +266,7 @@ if(pos == 0) { - if(metadataIndex.getEntryCount() != 0) { + if(delegate.getEntryCount() != 0) { throw new IllegalStateException( "Partition not defined for empty key."); @@ -289,34 +294,4 @@ } - public long rangeCount() { - return metadataIndex.rangeCount(); - } - - public long rangeCount(byte[] fromKey, byte[] toKey) { - return metadataIndex.rangeCount(fromKey, toKey); - } - - public long rangeCountExact(byte[] fromKey, byte[] toKey) { - return metadataIndex.rangeCountExact(fromKey, toKey); - } - - public long rangeCountExactWithDeleted(byte[] fromKey, byte[] toKey) { - return metadataIndex.rangeCountExactWithDeleted(fromKey, toKey); - } - - public ITupleIterator rangeIterator() { - return metadataIndex.rangeIterator(); - } - - public ITupleIterator rangeIterator(byte[] fromKey, byte[] toKey) { - return metadataIndex.rangeIterator(fromKey, toKey); - } - - public ITupleIterator rangeIterator(byte[] fromKey, byte[] toKey, - int capacity, int flags, - IFilterConstructor filterCtor) { - return metadataIndex.rangeIterator(fromKey, toKey, capacity, flags, filterCtor); - } - } Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/Node.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/Node.java 2010-10-14 16:19:22 UTC (rev 3800) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/Node.java 2010-10-14 20:44:47 UTC (rev 3801) @@ -56,7 +56,6 @@ import cutthecrap.utils.striterators.Expander; import cutthecrap.utils.striterators.SingleValueIterator; import cutthecrap.utils.striterators.Striterator; -import org.apache.log4j.Logger; /** * <p> @@ -83,15 +82,11 @@ * we can prune the search before we materialize the child. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ */ public class Node extends AbstractNode<Node> implements INodeData { /** - * Log for btree opeations. - */ - private static final Logger log = Logger.getLogger(Node.class); - - /** * The data record. {@link MutableNodeData} is used for all mutation * operations. {@link ReadOnlyNodeData} is used when the {@link Node} is * made persistent. A read-only data record is automatically converted into @@ -628,7 +623,7 @@ btree.getBtreeCounters().rootsSplit++; - if (log.isInfoEnabled() || BigdataStatics.debug) { + if (BTree.log.isInfoEnabled() || BigdataStatics.debug) { // Note: nnodes and nleaves might not reflect rightSibling yet. @@ -637,8 +632,8 @@ + ", m=" + btree.getBranchingFactor() + ", nentries=" + btree.nentries; - if (log.isInfoEnabled()) - log.info(msg); + if (BTree.log.isInfoEnabled()) + BTree.log.info(msg); if (BigdataStatics.debug) System.err.println(msg); @@ -2405,8 +2400,8 @@ // one less node in the tree. btree.nnodes--; - if (INFO) { - log.info("reduced tree height: height=" + if (BTree.INFO) { + BTree.log.info("reduced tree height: height=" + btree.height + ", newRoot=" + btree.root); } Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/ReadOnlyIndex.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/ReadOnlyIndex.java 2010-10-14 16:19:22 UTC (rev 3800) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/btree/ReadOnlyIndex.java 2010-10-14 20:44:47 UTC (rev 3801) @@ -27,9 +27,6 @@ package com.bigdata.btree; -import com.bigdata.btree.proc.IKeyRangeIndexProcedure; -import com.bigdata.btree.proc.ISimpleIndexProcedure; -import com.bigdata.counters.ICounterSet; import java.util.Iterator; import com.bigdata.btree.filter.IFilterConstructor; @@ -50,19 +47,20 @@ * @see {@link IResourceManager#getIndex(String, long)} * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ */ -public class ReadOnlyIndex implements IIndex { - - private IIndex src; +public class ReadOnlyIndex extends DelegateIndex { public ReadOnlyIndex(IIndex src) { - this.src = src; + + super(src); + } /** {@link IndexMetadata} is cloned to disallow modification. */ final public IndexMetadata getIndexMetadata() { - return src.getIndexMetadata().clone(); + return super.getIndexMetadata().clone(); } @@ -73,7 +71,7 @@ */ final public IResourceMetadata[] getResourceMetadata() { - return src.getResourceMetadata().clone(); + return super.getResourceMetadata().clone(); } @@ -82,7 +80,7 @@ */ final public ICounter getCounter() { - return new ReadOnlyCounter(src.getCounter()); + return new ReadOnlyCounter(super.getCounter()); } @@ -123,7 +121,7 @@ /* * Must explicitly disable Iterator#remove(). */ - return new ReadOnlyEntryIterator(src.rangeIterator(fromKey, toKey, + return new ReadOnlyEntryIterator(super.rangeIterator(fromKey, toKey, capacity, flags, filter)); } @@ -175,65 +173,4 @@ } - public ICounterSet getCounters() { - return src.getCounters(); - } - - public Object submit(byte[] key, ISimpleIndexProcedure proc) { - return src.submit(key, proc); - } - - public void submit(byte[] fromKey, byte[] toKey, - IKeyRangeIndexProcedure proc, IResultHandler handler) { - src.submit(fromKey, toKey, proc, handler); - } - - public byte[] lookup(byte[] key) { - return src.lookup(key); - } - - public boolean contains(byte[] key) { - return src.contains(key); - } - - public Object insert(Object key, Object value) { - return src.insert(key, value); - } - - public Object lookup(Object key) { - return src.lookup(key); - } - - public boolean contains(Object key) { - return src.contains(key); - } - - public Object remove(Object key) { - return src.remove(key); - } - - public long rangeCount() { - return src.rangeCount(); - } - - public long rangeCount(byte[] fromKey, byte[] toKey) { - return src.rangeCount(fromKey, toKey); - } - - public long rangeCountExact(byte[] fromKey, byte[] toKey) { - return src.rangeCountExact(fromKey, toKey); - } - - public long rangeCountExactWithDeleted(byte[] fromKey, byte[] toKey) { - return src.rangeCountExactWithDeleted(fromKey, toKey); - } - - public ITupleIterator rangeIterator() { - return src.rangeIterator(); - } - - public ITupleIterator rangeIterator(byte[] fromKey, byte[] toKey) { - return src.rangeIterator(fromKey, toKey); - } - } Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/cache/HardReferenceGlobalLRURecycler.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/cache/HardReferenceGlobalLRURecycler.java 2010-10-14 16:19:22 UTC (rev 3800) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/cache/HardReferenceGlobalLRURecycler.java 2010-10-14 20:44:47 UTC (rev 3801) @@ -618,7 +618,6 @@ e.prior = last; last = e; } - //System.err.println("++size"); size++; counters.bytesInMemory.addAndGet(e.bytesInMemory); counters.bytesOnDisk.addAndGet(e.bytesOnDisk); @@ -660,7 +659,6 @@ e.cache = null; // clear reference to the cache. e.k = null; // clear the key. e.v = null; // clear the value reference. - //System.err.println("--size"); size--; counters.bytesInMemory.addAndGet(-e.bytesInMemory); counters.bytesOnDisk.addAndGet(-e.bytesOnDisk); Modified: branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/cache/LRUNexus.java =================================================================== --- branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/cache/LRUNexus.java 2010-10-14 16:19:22 UTC (rev 3800) +++ branches/maven_scaleout/bigdata-core/src/main/java/com/bigdata/cache/LRUNexus.java 2010-10-14 20:44:47 UTC (rev 3801) @@ -47,6 +47,7 @@ * system properties defined by {@link Options}. * * @author <a href="mailto:tho...@us...">Bryan Thompson</a> + * @version $Id$ * * FIXME LRUNexus : writes MUST must be "isolated" until the commit. * Isolated indices MUST have their own cache backed by the shared LRU @@ -130,6 +131,7 @@ * * @author <a href="mailto:tho...@us...">Bryan * Thompson</a> + * @version $Id$ */ public static interface Options { @@ -341,13 +343,26 @@ } + /** + * Global instance. + * <p> + * Note: A <a href="http://bugs.sun.com/view_bug.do?bug_id=6880903">Sun G1 + * bug in JDK 1.6.0_16</a> provides a false estimate of the available + * memory. + * + * @see Options + */ + public static final IGlobalLRU<Long, Object> INSTANCE; + + /** * The access policy. Not all {@link IGlobalLRU} implementations support * multiple access policies. Check the specific implementation to see which * policies it supports. * * @author <a href="mailto:tho...@us...">Bryan * Thompson</a> + * @version $Id$ */ public static enum AccessPolicyEnum { @@ -380,6 +395,7 @@ * * @author <a href="mailto:tho...@us...">Bryan * Thompson</a> + * @version $Id$ */ public static class CacheSettings { @@ -531,8 +547,9 @@ Options.INDEX_SEGMENT_BUILD_POPULATES_CACHE, Options.DEFAULT_INDEX_SEGMENT_BUILD_POPULATES_CACHE)); ... [truncated message content] |
From: <mar...@us...> - 2010-10-14 16:19:29
|
Revision: 3800 http://bigdata.svn.sourceforge.net/bigdata/?rev=3800&view=rev Author: martyncutcher Date: 2010-10-14 16:19:22 +0000 (Thu, 14 Oct 2010) Log Message: ----------- Fix abort to ensure rootBlocks kept in sync and adjust stressTestAbort to reduce count until RWStore reopen can be faster Modified Paths: -------------- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RWStrategy.java branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/journal/TestAbort.java Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RWStrategy.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RWStrategy.java 2010-10-14 14:41:34 UTC (rev 3799) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/java/com/bigdata/journal/RWStrategy.java 2010-10-14 16:19:22 UTC (rev 3800) @@ -545,6 +545,8 @@ * Calls through to store and then to WriteCacheService.reset */ public void abort() { + m_store.checkRootBlock(m_rb); + m_store.reset(); } Modified: branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/journal/TestAbort.java =================================================================== --- branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/journal/TestAbort.java 2010-10-14 14:41:34 UTC (rev 3799) +++ branches/JOURNAL_HA_BRANCH/bigdata/src/test/com/bigdata/journal/TestAbort.java 2010-10-14 16:19:22 UTC (rev 3800) @@ -169,7 +169,6 @@ // make sure the offset has not been changed. assertEquals(firstOffset, store.getRootBlockView() .getNextOffset()); - // write some data onto the store. for (int i = 0; i < nrecs; i++) { @@ -268,7 +267,6 @@ // verify the write. assertEquals(new byte[] { 2, 4 }, ndx .lookup(new byte[] { 1, 3 })); - } finally { store.destroy(); @@ -283,10 +281,10 @@ */ public void test_stressTestAbort() { - final int LIMIT = 100; + final int LIMIT = 10; // temporary reduction while fix to RWStore reopen + // that currently takes too long for (int i = 0; i < LIMIT; i++) { - test_abort(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |