You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by rv...@apache.org on 2014/10/02 11:48:17 UTC
[08/50] [abbrv] git commit: Delete old classes
Delete old classes
git-svn-id: http://svn.apache.org/repos/asf/jena/Experimental/jena-csv@1611870 13f79535-47bb-0310-9956-ffa450edef68
Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/20cdd495
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/20cdd495
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/20cdd495
Branch: refs/heads/jena-csv
Commit: 20cdd495393f1d2b0a5b8b7f6102e927fd322d84
Parents: f2f32d7
Author: Ying Jiang <jp...@apache.org>
Authored: Sat Jul 19 09:45:43 2014 +0000
Committer: Ying Jiang <jp...@apache.org>
Committed: Sat Jul 19 09:45:43 2014 +0000
----------------------------------------------------------------------
.../com/hp/hpl/jena/propertytable/Column.java | 38 ---
.../hpl/jena/propertytable/PropertyTable.java | 109 -------
.../java/com/hp/hpl/jena/propertytable/Row.java | 75 -----
.../hpl/jena/propertytable/impl/ColumnImpl.java | 43 ---
.../hpl/jena/propertytable/impl/GraphCSV.java | 53 ---
.../propertytable/impl/GraphPropertyTable.java | 194 -----------
.../impl/PropertyTableArrayImpl.java | 272 ----------------
.../impl/PropertyTableBuilder.java | 113 -------
.../impl/PropertyTableHashMapImpl.java | 323 -------------------
.../impl/QueryIterPropertyTable.java | 102 ------
.../impl/QueryIterPropertyTableRow.java | 217 -------------
.../hpl/jena/propertytable/impl/RowMatch.java | 26 --
.../impl/StageGeneratorPropertyTable.java | 37 ---
.../jena/propertytable/impl/GraphCSVTest.java | 2 +
14 files changed, 2 insertions(+), 1602 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jena/blob/20cdd495/src/main/java/com/hp/hpl/jena/propertytable/Column.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/hp/hpl/jena/propertytable/Column.java b/src/main/java/com/hp/hpl/jena/propertytable/Column.java
deleted file mode 100644
index 7b2c6ba..0000000
--- a/src/main/java/com/hp/hpl/jena/propertytable/Column.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.hp.hpl.jena.propertytable;
-
-import com.hp.hpl.jena.graph.Node;
-
-/**
- * Each Column of the PropertyTable has an unique columnKey Node of the predicate (or p for short).
- *
- */
-public interface Column {
-
- /**
- * @return the PropertyTable it belongs to
- */
- PropertyTable getTable();
-
- /**
- * @return the columnKey Node of the predicate
- */
- Node getColumnKey();
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/20cdd495/src/main/java/com/hp/hpl/jena/propertytable/PropertyTable.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/hp/hpl/jena/propertytable/PropertyTable.java b/src/main/java/com/hp/hpl/jena/propertytable/PropertyTable.java
deleted file mode 100644
index 5d8905e..0000000
--- a/src/main/java/com/hp/hpl/jena/propertytable/PropertyTable.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.hp.hpl.jena.propertytable;
-
-import java.util.Collection;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.graph.Triple;
-import com.hp.hpl.jena.util.iterator.ExtendedIterator;
-
-/**
- * PropertyTable is designed to be a table of RDF terms, or Nodes in Jena.
- * Each Column of the PropertyTable has an unique columnKey Node of the predicate (or p for short).
- * Each Row of the PropertyTable has an unique rowKey Node of the subject (or s for short).
- * You can use getColumn() to get the Column by its columnKey Node of the predicate, while getRow() for Row.
- *
- */
-public interface PropertyTable {
-
- /**
- * Query for ?s <p> <o>
- * @param column, the Column with the columnKey Node of the predicate
- * @param value, the object (or value) Node
- * @return the ExtendedIterator of the matching Triples
- */
- ExtendedIterator<Triple> getTripleIterator(Column column, Node value);
-
- /**
- * Query for ?s <p> ?o
- * @param column, the Column with the columnKey Node of the predicate
- * @return the ExtendedIterator of the matching Triples
- */
- ExtendedIterator<Triple> getTripleIterator(Column column);
-
- /**
- * Query for ?s ?p <o>
- * @param value, the object (or value) Node
- * @return the ExtendedIterator of the matching Triples
- */
- ExtendedIterator<Triple> getTripleIterator(Node value);
-
- /**
- * Query for <s> ?p ?o
- * @param row, the Row with the rowKey Node of the subject
- * @return the ExtendedIterator of the matching Triples
- */
- ExtendedIterator<Triple> getTripleIterator(Row row);
-
- /**
- * Query for ?s ?p ?o
- * @return all of the Triples of the PropertyTable
- */
- ExtendedIterator<Triple> getTripleIterator();
-
- /**
- * @return all of the Columns of the PropertyTable
- */
- Collection<Column> getColumns();
-
- /**
- * Get Column by its columnKey Node of the predicate
- * @param p, columnKey Node of the predicate
- * @return the Column
- */
- Column getColumn(Node p);
-
- /**
- * Create a Column by its columnKey Node of the predicate
- * @param p
- */
- void createColumn(Node p);
-
- /**
- * Get Row by its rowKey Node of the subject
- * @param s, rowKey Node of the subject
- * @return the Row
- */
- Row getRow(Node s);
-
-
- /**
- * Create Row by its rowKey Node of the subject
- * @param s, rowKey Node of the subject
- * @return the Row created
- */
- Row createRow(Node s);
-
-
- /**
- * Get all of the rows as an iterator
- */
- ExtendedIterator<Row> getRowIterator();
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/20cdd495/src/main/java/com/hp/hpl/jena/propertytable/Row.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/hp/hpl/jena/propertytable/Row.java b/src/main/java/com/hp/hpl/jena/propertytable/Row.java
deleted file mode 100644
index 7394f6d..0000000
--- a/src/main/java/com/hp/hpl/jena/propertytable/Row.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.hp.hpl.jena.propertytable;
-
-import java.util.Collection;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.graph.Triple;
-import com.hp.hpl.jena.util.iterator.ExtendedIterator;
-
-/**
- * Each Row of the PropertyTable has an unique rowKey Node of the subject (or s for short).
- *
- */
-public interface Row {
-
- /**
- * @return the PropertyTable it belongs to
- */
- PropertyTable getTable();
-
- /**
- * Set the value of the Column in this Row
- * @param column
- * @param value
- */
- void setValue(Column column, Node value);
-
- /**
- * Get the value of the Column in this Row
- * @param column
- * @return value
- */
- Node getValue(Column column);
-
-
- /**
- * Get the value of the Column in this Row
- * @param ColumnKey
- * @return value
- */
- Node getValue(Node ColumnKey);
-
- /**
- * @return the rowKey Node of the subject
- */
- Node getRowKey();
-
- /**
- * @return the Triple Iterator over the values in this Row
- */
- ExtendedIterator<Triple> getTripleIterator();
-
- /**
- * @return all of the Columns of the PropertyTable
- */
- Collection<Column> getColumns();
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/20cdd495/src/main/java/com/hp/hpl/jena/propertytable/impl/ColumnImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/hp/hpl/jena/propertytable/impl/ColumnImpl.java b/src/main/java/com/hp/hpl/jena/propertytable/impl/ColumnImpl.java
deleted file mode 100644
index 718d9e7..0000000
--- a/src/main/java/com/hp/hpl/jena/propertytable/impl/ColumnImpl.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.hp.hpl.jena.propertytable.impl;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.propertytable.Column;
-import com.hp.hpl.jena.propertytable.PropertyTable;
-
-public class ColumnImpl implements Column {
- private final PropertyTable table;
- private Node p;
-
- ColumnImpl(PropertyTable table, Node p) {
- this.table = table;
- this.p = p;
- }
-
- @Override
- public PropertyTable getTable() {
- return table;
- }
-
- @Override
- public Node getColumnKey() {
- return p;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/20cdd495/src/main/java/com/hp/hpl/jena/propertytable/impl/GraphCSV.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/hp/hpl/jena/propertytable/impl/GraphCSV.java b/src/main/java/com/hp/hpl/jena/propertytable/impl/GraphCSV.java
deleted file mode 100644
index d8ef46f..0000000
--- a/src/main/java/com/hp/hpl/jena/propertytable/impl/GraphCSV.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.hp.hpl.jena.propertytable.impl;
-
-import com.hp.hpl.jena.propertytable.PropertyTable;
-
-public class GraphCSV extends GraphPropertyTable {
-
- public static GraphCSV createHashMapImpl( String csvFilePath ){
- return new GraphCSVHashMapImpl(csvFilePath);
- }
-
- public static GraphCSV createArrayImpl( String csvFilePath ){
- return new GraphCSVArrayImpl(csvFilePath);
- }
-
- protected GraphCSV (PropertyTable table) {
- super(table);
- }
-
- public GraphCSV ( String csvFilePath ){
- super(PropertyTableBuilder.buildPropetyTableArrayImplFromCsv(csvFilePath));
- }
-}
-
-
-class GraphCSVHashMapImpl extends GraphCSV{
- protected GraphCSVHashMapImpl(String csvFilePath){
- super(PropertyTableBuilder.buildPropetyTableHashMapImplFromCsv(csvFilePath));
- }
-}
-
-class GraphCSVArrayImpl extends GraphCSV{
- protected GraphCSVArrayImpl(String csvFilePath){
- super(PropertyTableBuilder.buildPropetyTableArrayImplFromCsv(csvFilePath));
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/20cdd495/src/main/java/com/hp/hpl/jena/propertytable/impl/GraphPropertyTable.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/hp/hpl/jena/propertytable/impl/GraphPropertyTable.java b/src/main/java/com/hp/hpl/jena/propertytable/impl/GraphPropertyTable.java
deleted file mode 100644
index 8cc0e19..0000000
--- a/src/main/java/com/hp/hpl/jena/propertytable/impl/GraphPropertyTable.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.hp.hpl.jena.propertytable.impl;
-
-import java.util.ArrayList;
-import java.util.Locale;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.graph.NodeFactory;
-import com.hp.hpl.jena.graph.Triple;
-import com.hp.hpl.jena.graph.TripleMatch;
-import com.hp.hpl.jena.graph.impl.GraphBase;
-import com.hp.hpl.jena.propertytable.Column;
-import com.hp.hpl.jena.propertytable.PropertyTable;
-import com.hp.hpl.jena.propertytable.Row;
-import com.hp.hpl.jena.sparql.core.BasicPattern;
-import com.hp.hpl.jena.util.iterator.ExtendedIterator;
-import com.hp.hpl.jena.util.iterator.Filter;
-import com.hp.hpl.jena.util.iterator.NullIterator;
-import com.hp.hpl.jena.util.iterator.WrappedIterator;
-
-public class GraphPropertyTable extends GraphBase {
-
- private PropertyTable pt;
-
- public GraphPropertyTable(PropertyTable pt) {
- this.pt = pt;
- }
-
- public PropertyTable getPropertyTable() {
- return pt;
- }
-
- @Override
- protected ExtendedIterator<Triple> graphBaseFind(TripleMatch m) {
- //System.out.println(m);
-
- if (this.pt == null) {
- return NullIterator.instance();
- }
-
- ExtendedIterator<Triple> iter = null;
-
- Node s = m.getMatchSubject();
- Node p = m.getMatchPredicate();
- Node o = m.getMatchObject();
-
- if (isConcrete(p) && isConcrete(o)) {
- //System.out.println("1");
- iter = pt.getTripleIterator(pt.getColumn(p), o);
- } else if (isConcrete(p)) {
- //System.out.println("2");
- Column column = this.pt.getColumn(p);
- if (column != null) {
- iter = pt.getTripleIterator(column);
- } else {
- return NullIterator.instance();
- }
- } else if (isConcrete(o)) {
- //System.out.println("3");
- iter = pt.getTripleIterator(o);
- } else{
- //System.out.println("4");
- iter = pt.getTripleIterator();
- }
-
- return iter.filterKeep(new TripleMatchFilterEquality(m.asTriple()));
-
- }
-
- protected ExtendedIterator<Row> propertyTableBaseFind(RowMatch m) {
-
- if (this.pt == null) {
- return NullIterator.instance();
- }
-
- ExtendedIterator<Row> iter = null;
-
- Node s = m.getMatchSubject();
-
- if ( isConcrete(s) ){
- Row row= pt.getRow(s);
- if (row == null){
- return NullIterator.instance();
- } else {
- ArrayList<Row> rows = new ArrayList<Row>();
- rows.add(row);
- return WrappedIterator.create(rows.iterator());
- }
- } else {
- iter = pt.getRowIterator();
- }
-
- return iter.filterKeep(new RowMatchFilterEquality( m ));
-
- }
-
- static class RowMatchFilterEquality extends Filter<Row> {
- final protected RowMatch rMatch;
-
- public RowMatchFilterEquality(RowMatch rMatch) {
- this.rMatch = rMatch;
- }
-
- @Override
- public boolean accept(Row r) {
- return rowContained(rMatch, r);
- }
-
- }
-
- static boolean rowContained(RowMatch rMatch, Row row) {
-
- boolean contained = equalNode(rMatch.getSubject(), row.getRowKey());
- if(contained){
- BasicPattern pattern =rMatch.getBasicPattern();
- for(Triple triple: pattern ){
- contained = equalNode(triple.getObject(), row.getValue( triple.getPredicate()) );
- if (! contained){
- break;
- }
- }
- }
- return contained;
- }
-
-
- static class TripleMatchFilterEquality extends Filter<Triple> {
- final protected Triple tMatch;
-
- /** Creates new TripleMatchFilter */
- public TripleMatchFilterEquality(Triple tMatch) {
- this.tMatch = tMatch;
- }
-
- @Override
- public boolean accept(Triple t) {
- return tripleContained(tMatch, t);
- }
-
- }
-
- static boolean tripleContained(Triple patternTriple, Triple dataTriple) {
- return equalNode(patternTriple.getSubject(), dataTriple.getSubject())
- && equalNode(patternTriple.getPredicate(),
- dataTriple.getPredicate())
- && equalNode(patternTriple.getObject(), dataTriple.getObject());
- }
-
- private static boolean equalNode(Node m, Node n) {
- // m should not be null unless .getMatchXXXX used to get the node.
- // Language tag canonicalization
- n = fixupNode(n);
- m = fixupNode(m);
- return (m == null) || (m == Node.ANY) || m.equals(n);
- }
-
- private static Node fixupNode(Node node) {
- if (node == null || node == Node.ANY)
- return node;
-
- // RDF says ... language tags should be canonicalized to lower case.
- if (node.isLiteral()) {
- String lang = node.getLiteralLanguage();
- if (lang != null && !lang.equals(""))
- node = NodeFactory.createLiteral(node.getLiteralLexicalForm(),
- lang.toLowerCase(Locale.ROOT),
- node.getLiteralDatatype());
- }
- return node;
- }
-
- private boolean isConcrete(Node node) {
- boolean wild = (node == null || node == Node.ANY);
- return !wild;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/20cdd495/src/main/java/com/hp/hpl/jena/propertytable/impl/PropertyTableArrayImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/hp/hpl/jena/propertytable/impl/PropertyTableArrayImpl.java b/src/main/java/com/hp/hpl/jena/propertytable/impl/PropertyTableArrayImpl.java
deleted file mode 100644
index 3bcc8ba..0000000
--- a/src/main/java/com/hp/hpl/jena/propertytable/impl/PropertyTableArrayImpl.java
+++ /dev/null
@@ -1,272 +0,0 @@
-package com.hp.hpl.jena.propertytable.impl;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.jena.atlas.iterator.Iter;
-import org.apache.jena.atlas.iterator.IteratorConcat;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.graph.Triple;
-import com.hp.hpl.jena.propertytable.Column;
-import com.hp.hpl.jena.propertytable.PropertyTable;
-import com.hp.hpl.jena.propertytable.Row;
-import com.hp.hpl.jena.util.iterator.ExtendedIterator;
-import com.hp.hpl.jena.util.iterator.WrappedIterator;
-
-public class PropertyTableArrayImpl implements PropertyTable {
-
- private final List<Node> rowList;
- private final List<Node> columnList;
-
- private final Map<Node, Integer> rowKeyToIndex;
- private final Map<Node, Integer> columnKeyToIndex;
- private final Node[][] array;
- private final int rowNum;
- private final int columnNum;
-
- public PropertyTableArrayImpl(int rowNum, int columnNum){
- rowList = new ArrayList<Node>(rowNum);
- columnList = new ArrayList<Node>(columnNum);
- rowKeyToIndex = new HashMap<Node, Integer>();
- columnKeyToIndex = new HashMap<Node, Integer>();
- this.rowNum = rowNum;
- this.columnNum = columnNum;
- array = new Node [rowNum][columnNum];
- }
-
- @Override
- public ExtendedIterator<Triple> getTripleIterator(Column column, Node value) {
- if (column == null || column.getColumnKey() == null)
- throw new NullPointerException("column is null");
-
- if (value == null){
- throw new NullPointerException("value is null");
- }
-
- ArrayList<Triple> triples = new ArrayList<Triple>();
-
- Node p = column.getColumnKey();
- Integer columnIndex = this.columnKeyToIndex.get(p);
- if (columnIndex != null){
- for(int rowIndex=0; rowIndex< rowList.size();rowIndex++){
- if ( value.equals( this.get(rowIndex, columnIndex))){
- triples.add(Triple.create(rowList.get(rowIndex), p, value));
- }
- }
- }
- return WrappedIterator.create(triples.iterator());
- }
-
- @Override
- public ExtendedIterator<Triple> getTripleIterator(Column column) {
-
- if (column == null || column.getColumnKey() == null)
- throw new NullPointerException("column is null");
-
- ArrayList<Triple> triples = new ArrayList<Triple>();
-
- Node p = column.getColumnKey();
- Integer columnIndex = this.columnKeyToIndex.get(p);
- if (columnIndex != null){
- for(int rowIndex=0; rowIndex< rowList.size();rowIndex++){
- triples.add(Triple.create(rowList.get(rowIndex), p, this.get(rowIndex, columnIndex)));
- }
- }
- return WrappedIterator.create(triples.iterator());
- }
-
- @Override
- public ExtendedIterator<Triple> getTripleIterator(Node value) {
- if (value == null)
- throw new NullPointerException("value is null");
-
- IteratorConcat<Triple> iter = new IteratorConcat<Triple>();
- for (Column column : this.getColumns()) {
- ExtendedIterator<Triple> eIter = getTripleIterator(column,value);
- iter.add(eIter);
- }
- return WrappedIterator.create(Iter.distinct(iter));
- }
-
- @Override
- public ExtendedIterator<Triple> getTripleIterator(Row row) {
- if (row == null || row.getRowKey() == null)
- throw new NullPointerException("row is null");
-
- ArrayList<Triple> triples = new ArrayList<Triple>();
- Integer rowIndex = this.rowKeyToIndex.get(row.getRowKey());
-
- if (rowIndex != null){
- for(int columnIndex=0; columnIndex < columnList.size(); columnIndex++){
- triples.add(Triple.create( row.getRowKey(), columnList.get(columnIndex), this.get(rowIndex, columnIndex)));
- }
- }
- return WrappedIterator.create(triples.iterator());
- }
-
- @Override
- public ExtendedIterator<Triple> getTripleIterator() {
-
- IteratorConcat<Triple> iter = new IteratorConcat<Triple>();
- for (Column column : getColumns()) {
- iter.add(getTripleIterator(column));
- }
- return WrappedIterator.create(Iter.distinct(iter));
- }
-
- @Override
- public Collection<Column> getColumns() {
- Collection<Column> columns = new ArrayList<Column>();
- for(Node p: columnKeyToIndex.keySet() ){
- columns.add(new ColumnImpl(this, p));
- }
- return columns;
- }
-
- @Override
- public Column getColumn(Node p) {
- if (p == null)
- throw new NullPointerException("column name is null");
- Integer columnIndex = columnKeyToIndex.get(p);
- return (columnIndex == null)
- ? null : new ColumnImpl(this, p);
- }
-
- @Override
- public void createColumn(Node p) {
- if (p == null)
- throw new NullPointerException("column name is null");
-
- if (columnKeyToIndex.containsKey(p))
- throw new IllegalArgumentException("column already exists: '"
- + p.toString());
-
- if (columnList.size()>= columnNum)
- throw new IllegalArgumentException("cannot create new column for max column count: " + columnNum);
-
- columnList.add(p);
- columnKeyToIndex.put(p, columnList.indexOf(p));
- }
-
- @Override
- public Row getRow(Node s) {
- if (s == null)
- throw new NullPointerException("subject node is null");
-
- Integer rowIndex = rowKeyToIndex.get(s);
- return (rowIndex == null) ? null : new InternalRow(rowIndex);
- }
-
- @Override
- public Row createRow(Node s) {
- Row row = this.getRow(s);
- if (row != null)
- return row;
-
- if (rowList.size()>= rowNum)
- throw new IllegalArgumentException("cannot create new row for max row count: " + rowNum);
-
- rowList.add(s);
- int rowIndex = rowList.indexOf(s);
- rowKeyToIndex.put(s, rowIndex);
-
- return new InternalRow(rowIndex);
- }
-
- private void set(int rowIndex, int columnIndex, Node value) {
-
- if (rowIndex >= rowList.size())
- throw new IllegalArgumentException("row index out of bound: " + rowList.size());
- if (columnIndex >= columnList.size())
- throw new IllegalArgumentException("column index out of bound: " + columnList.size());
- array[rowIndex][columnIndex] = value;
- }
-
- public Node get(int rowIndex, int columnIndex) {
- if (rowIndex >= rowList.size())
- throw new IllegalArgumentException("row index out of bound: " + rowList.size());
- if (columnIndex >= columnList.size())
- throw new IllegalArgumentException("column index out of bound: " + columnList.size());
- return array[rowIndex][columnIndex];
- }
-
- @Override
- public ExtendedIterator<Row> getRowIterator() {
- ArrayList<Row> rows = new ArrayList<Row>();
- for (int rowIndex=0;rowIndex<rowList.size();rowIndex++){
- rows.add( new InternalRow(rowIndex));
- }
- return WrappedIterator.create(rows.iterator());
- }
-
- private final class InternalRow implements Row {
-
- final int rowIndex;
-
- InternalRow(int rowIndex) {
- this.rowIndex = rowIndex;
- }
-
- @Override
- public PropertyTable getTable() {
- return PropertyTableArrayImpl.this;
- }
-
- @Override
- public void setValue(Column column, Node value) {
- if (column == null || column.getColumnKey() == null)
- throw new NullPointerException("column is null");
-
- Integer columnIndex = columnKeyToIndex.get(column.getColumnKey());
- if (columnIndex == null)
- throw new IllegalArgumentException("column index does not exist: " + column.getColumnKey());
-
- set(rowIndex, columnIndex, value);
-
- }
-
- @Override
- public Node getValue(Column column) {
- if (column == null)
- throw new NullPointerException("column is null");
- return this.getValue(column.getColumnKey());
- }
-
- @Override
- public Node getValue(Node columnKey) {
- if (columnKey == null)
- throw new NullPointerException("column key is null");
-
- Integer columnIndex = columnKeyToIndex.get(columnKey);
- if (columnIndex == null)
- throw new IllegalArgumentException("column index does not exist: " + columnKey);
-
- return get(rowIndex, columnIndex);
- }
-
- @Override
- public Node getRowKey() {
- return rowList.get(rowIndex);
- }
-
- @Override
- public ExtendedIterator<Triple> getTripleIterator() {
- ArrayList<Triple> triples = new ArrayList<Triple>();
- for (int columnIndex=0;columnIndex<columnList.size();columnIndex++) {
- triples.add(Triple.create(getRowKey(), columnList.get(columnIndex), get(rowIndex, columnIndex)));
- }
- return WrappedIterator.create(triples.iterator());
- }
-
- @Override
- public Collection<Column> getColumns() {
- return PropertyTableArrayImpl.this.getColumns();
- }
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/20cdd495/src/main/java/com/hp/hpl/jena/propertytable/impl/PropertyTableBuilder.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/hp/hpl/jena/propertytable/impl/PropertyTableBuilder.java b/src/main/java/com/hp/hpl/jena/propertytable/impl/PropertyTableBuilder.java
deleted file mode 100644
index 3dacf14..0000000
--- a/src/main/java/com/hp/hpl/jena/propertytable/impl/PropertyTableBuilder.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.hp.hpl.jena.propertytable.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.jena.atlas.csv.CSVParser;
-import org.apache.jena.riot.lang.LangCSV;
-import org.apache.jena.riot.system.IRIResolver;
-
-import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.graph.NodeFactory;
-import com.hp.hpl.jena.propertytable.PropertyTable;
-import com.hp.hpl.jena.propertytable.Row;
-
-public class PropertyTableBuilder {
-
- public static Node CSV_ROW_NODE = NodeFactory.createURI(LangCSV.CSV_ROW);
-
- public static PropertyTable buildPropetyTableHashMapImplFromCsv(String csvFilePath) {
- PropertyTable table = new PropertyTableHashMapImpl();
- return fillPropertyTable(table, csvFilePath);
- }
-
- public static PropertyTable buildPropetyTableArrayImplFromCsv(String csvFilePath) {
- PropertyTable table = createEmptyPropertyTableArrayImpl(csvFilePath);
- return fillPropertyTable(table, csvFilePath);
- }
-
- private static PropertyTable createEmptyPropertyTableArrayImpl (String csvFilePath) {
- CSVParser parser = CSVParser.create(csvFilePath);
- List<String> rowLine = null;
- int rowNum = 0;
- int columnNum = 0;
-
- while ((rowLine = parser.parse1()) != null) {
- if (rowNum == 0) {
- columnNum = rowLine.size();
- }
- rowNum++;
- }
- if (rowNum!=0 && columnNum!=0){
- return new PropertyTableArrayImpl(rowNum, columnNum+1);
- } else {
- return null;
- }
- }
-
-
- private static PropertyTable fillPropertyTable(PropertyTable table, String csvFilePath ){
- if (table == null){
- return null;
- }
- CSVParser parser = CSVParser.create(csvFilePath);
- List<String> rowLine = null;
- ArrayList<Node> predicates = new ArrayList<Node>();
- int rowNum = 0;
-
- while ((rowLine = parser.parse1()) != null) {
- if (rowNum == 0) {
- table.createColumn(CSV_ROW_NODE);
- for (String column : rowLine) {
- String uri = IRIResolver.resolveString(csvFilePath) + "#"
- + LangCSV.toSafeLocalname(column);
- Node p = NodeFactory.createURI(uri);
- predicates.add(p);
- table.createColumn(p);
- }
- } else {
- Node subject = LangCSV.caculateSubject(rowNum, csvFilePath);
- Row row = table.createRow(subject);
-
- row.setValue(table.getColumn(CSV_ROW_NODE), NodeFactory.createLiteral(
- (rowNum + ""), XSDDatatype.XSDinteger));
-
- for (int col = 0; col < rowLine.size(); col++) {
-
- String columnValue = rowLine.get(col).trim();
- Node o;
- try {
- // Try for a double.
- double d = Double.parseDouble(columnValue);
- o = NodeFactory.createLiteral(columnValue,
- XSDDatatype.XSDdouble);
- } catch (Exception e) {
- o = NodeFactory.createLiteral(columnValue);
- }
- row.setValue(table.getColumn(predicates.get(col)), o);
- }
- }
- rowNum++;
- }
- return table;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/20cdd495/src/main/java/com/hp/hpl/jena/propertytable/impl/PropertyTableHashMapImpl.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/hp/hpl/jena/propertytable/impl/PropertyTableHashMapImpl.java b/src/main/java/com/hp/hpl/jena/propertytable/impl/PropertyTableHashMapImpl.java
deleted file mode 100644
index 9ad261c..0000000
--- a/src/main/java/com/hp/hpl/jena/propertytable/impl/PropertyTableHashMapImpl.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.hp.hpl.jena.propertytable.impl;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import org.apache.jena.atlas.iterator.Iter;
-import org.apache.jena.atlas.iterator.IteratorConcat;
-
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.SetMultimap;
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.graph.Triple;
-import com.hp.hpl.jena.propertytable.Column;
-import com.hp.hpl.jena.propertytable.PropertyTable;
-import com.hp.hpl.jena.propertytable.Row;
-import com.hp.hpl.jena.util.iterator.ExtendedIterator;
-import com.hp.hpl.jena.util.iterator.WrappedIterator;
-
-/**
- * A PropertyTable Implementation using HashMap.
- * It contains PSO and POS indexes.
- *
- */
-public class PropertyTableHashMapImpl implements PropertyTable {
-
- private Map<Node, Column> columnIndex; // Maps property Node key to Column
- private List<Column> columnList; // Stores the list of columns in the table
- private Map<Node, Row> rowIndex; // Maps the subject Node key to Row.
- private List<Row> rowList; // Stores the list of rows in the table
-
- // PSO index
- private Map<Node, Map<Node, Node>> valueIndex; // Maps column Node to
- // (subject Node, value)
- // pairs
- // POS index
- private Map<Node, SetMultimap<Node, Node>> valueReverseIndex; // Maps column
- // Node to
- // (value,
- // subject
- // Node)
- // pairs
-
- PropertyTableHashMapImpl() {
- columnIndex = new HashMap<Node, Column>();
- columnList = new ArrayList<Column>();
- rowIndex = new HashMap<Node, Row>();
- rowList = new ArrayList<Row>();
- valueIndex = new HashMap<Node, Map<Node, Node>>();
- valueReverseIndex = new HashMap<Node, SetMultimap<Node, Node>>();
- }
-
- @Override
- public ExtendedIterator<Triple> getTripleIterator() {
-
- // use PSO index to scan all the table (slow)
- IteratorConcat<Triple> iter = new IteratorConcat<Triple>();
- for (Column column : getColumns()) {
- iter.add(getTripleIterator(column));
- }
- return WrappedIterator.create(Iter.distinct(iter));
- }
-
- @Override
- public ExtendedIterator<Triple> getTripleIterator(Column column) {
-
- // use PSO index directly (fast)
-
- if (column == null || column.getColumnKey() == null)
- throw new NullPointerException("column is null");
-
- ArrayList<Triple> triples = new ArrayList<Triple>();
- Map<Node, Node> values = valueIndex.get(column.getColumnKey());
-
- for (Entry<Node, Node> entry : values.entrySet()) {
- Node subject = entry.getKey();
- Node value = entry.getValue();
- triples.add(Triple.create(subject, column.getColumnKey(), value));
- }
- return WrappedIterator.create(triples.iterator());
- }
-
- @Override
- public ExtendedIterator<Triple> getTripleIterator(Node value) {
-
- // use POS index ( O(n), n= column count )
-
- if (value == null)
- throw new NullPointerException("value is null");
-
- IteratorConcat<Triple> iter = new IteratorConcat<Triple>();
- for (Column column : this.getColumns()) {
- ExtendedIterator<Triple> eIter = getTripleIterator(column,value);
- iter.add(eIter);
- }
- return WrappedIterator.create(Iter.distinct(iter));
- }
-
- @Override
- public ExtendedIterator<Triple> getTripleIterator(Column column, Node value) {
-
- // use POS index directly (fast)
-
- if (column == null || column.getColumnKey() == null)
- throw new NullPointerException("column is null");
-
- if (value == null)
- throw new NullPointerException("value is null");
-
-
- Node p = column.getColumnKey();
- final SetMultimap<Node, Node> valueToSubjectMap = valueReverseIndex
- .get(p);
- final Set<Node> subjects = valueToSubjectMap.get(value);
- ArrayList<Triple> triples = new ArrayList<Triple>();
- for (Node subject : subjects) {
- triples.add(Triple.create(subject, p, value));
- }
- return WrappedIterator.create(triples.iterator());
- }
-
-
- @Override
- public ExtendedIterator<Triple> getTripleIterator(Row row) {
- // use PSO index ( O(n), n= column count )
-
- if (row == null || row.getRowKey() == null)
- throw new NullPointerException("row is null");
-
- ArrayList<Triple> triples = new ArrayList<Triple>();
- for (Column column : getColumns()) {
- Node value = row.getValue(column);
- triples.add(Triple.create(row.getRowKey(), column.getColumnKey(), value));
- }
- return WrappedIterator.create(triples.iterator());
- }
-
- @Override
- public Collection<Column> getColumns() {
- return columnList;
- }
-
- @Override
- public Column getColumn(Node p) {
- if (p == null)
- throw new NullPointerException("column node is null");
- return columnIndex.get(p);
- }
-
- @Override
- public void createColumn(Node p) {
- if (p == null)
- throw new NullPointerException("column node is null");
-
- if (columnIndex.containsKey(p))
- throw new IllegalArgumentException("column already exists: '"
- + p.toString());
-
- columnIndex.put(p, new ColumnImpl(this, p));
- columnList.add(columnIndex.get(p));
- valueIndex.put(p, new HashMap<Node, Node>());
- valueReverseIndex.put(p, HashMultimap.<Node, Node> create());
- }
-
- @Override
- public Row getRow(final Node s) {
- if (s == null)
- throw new NullPointerException("subject node is null");
- Row row = rowIndex.get(s);
- return row;
-
- }
-
- @Override
- public Row createRow(final Node s){
- Row row = this.getRow(s);
- if (row != null)
- return row;
-
- row = new InternalRow(s);
- rowIndex.put(s, row);
- rowList.add(row);
-
- return row;
- }
-
- @Override
- public ExtendedIterator<Row> getRowIterator() {
- return WrappedIterator.create(rowList.iterator());
- }
-
- private final void setX(final Node s, final Node p, final Node value) {
- if (p == null)
- throw new NullPointerException("column Node must not be null.");
- if (value == null)
- throw new NullPointerException("value must not be null.");
-
- Map<Node, Node> subjectToValueMap = valueIndex.get(p);
- if (!columnIndex.containsKey(p) || subjectToValueMap == null)
- throw new IllegalArgumentException("column: '" + p
- + "' does not yet exist.");
-
- Node oldValue = subjectToValueMap.get(s);
- subjectToValueMap.put(s, value);
- addToReverseMap(p, s, oldValue, value);
- }
-
- private void addToReverseMap(final Node p, final Node s,
- final Node oldValue, final Node value) {
-
- final SetMultimap<Node, Node> valueToSubjectMap = valueReverseIndex
- .get(p);
- valueToSubjectMap.remove(oldValue, s);
- valueToSubjectMap.put(value, s);
- }
-
- private void unSetX(final Node s, final Node p) {
-
- final Map<Node, Node> subjectToValueMap = valueIndex.get(p);
- if (!columnIndex.containsKey(p) || subjectToValueMap == null)
- throw new IllegalArgumentException("column: '" + p
- + "' does not yet exist.");
-
- final Node value = subjectToValueMap.get(s);
- if (value == null)
- return;
-
- subjectToValueMap.remove(s);
- removeFromReverseMap(p, s, value);
- }
-
- private void removeFromReverseMap(final Node p, final Node s,
- final Node value) {
- final SetMultimap<Node, Node> valueTokeysMap = valueReverseIndex.get(p);
- valueTokeysMap.remove(s, value);
- }
-
- private Node getX(final Node s, final Node p) {
- final Map<Node, Node> subjectToValueMap = valueIndex.get(p);
- if (!columnIndex.containsKey(p) || subjectToValueMap == null)
- throw new IllegalArgumentException("column: '" + p
- + "' does not yet exist.");
- return subjectToValueMap.get(s);
- }
-
- private final class InternalRow implements Row {
- private final Node key;
-
- InternalRow(final Node key) {
- this.key = key;
- }
-
- @Override
- public void setValue(Column column, Node value) {
- if (value == null)
- unSetX(key, column.getColumnKey());
- else
- setX(key, column.getColumnKey(), value);
- }
-
- @Override
- public Node getValue(Column column) {
- return getX(key, column.getColumnKey());
- }
-
- @Override
- public Node getValue(Node columnKey) {
- return getX(key, columnKey);
- }
-
- @Override
- public PropertyTable getTable() {
- return PropertyTableHashMapImpl.this;
- }
-
- @Override
- public Node getRowKey() {
- return key;
- }
-
- @Override
- public Collection<Column> getColumns() {
- // TODO Auto-generated method stub
- return PropertyTableHashMapImpl.this.getColumns();
- }
-
- @Override
- public ExtendedIterator<Triple> getTripleIterator() {
- ArrayList<Triple> triples = new ArrayList<Triple>();
- for (Column column : getColumns()) {
- Node value = this.getValue(column);
- triples.add(Triple.create(key, column.getColumnKey(), value));
- }
- return WrappedIterator.create(triples.iterator());
- }
-
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/20cdd495/src/main/java/com/hp/hpl/jena/propertytable/impl/QueryIterPropertyTable.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/hp/hpl/jena/propertytable/impl/QueryIterPropertyTable.java b/src/main/java/com/hp/hpl/jena/propertytable/impl/QueryIterPropertyTable.java
deleted file mode 100644
index c096361..0000000
--- a/src/main/java/com/hp/hpl/jena/propertytable/impl/QueryIterPropertyTable.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package com.hp.hpl.jena.propertytable.impl;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-
-import org.apache.jena.atlas.io.IndentedWriter;
-
-import com.hp.hpl.jena.graph.Graph;
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.graph.Triple;
-import com.hp.hpl.jena.sparql.core.BasicPattern;
-import com.hp.hpl.jena.sparql.engine.ExecutionContext;
-import com.hp.hpl.jena.sparql.engine.QueryIterator;
-import com.hp.hpl.jena.sparql.engine.binding.Binding;
-import com.hp.hpl.jena.sparql.engine.iterator.QueryIter1;
-import com.hp.hpl.jena.sparql.serializer.SerializationContext;
-import com.hp.hpl.jena.sparql.util.FmtUtils;
-import com.hp.hpl.jena.sparql.util.Utils;
-
-public class QueryIterPropertyTable extends QueryIter1
- {
- private BasicPattern pattern ;
- private Graph graph ;
- private QueryIterator output ;
-
- public static QueryIterator create(QueryIterator input,
- BasicPattern pattern ,
- ExecutionContext execContext)
- {
- return new QueryIterPropertyTable(input, pattern, execContext) ;
- }
-
- private QueryIterPropertyTable(QueryIterator input,
- BasicPattern pattern ,
- ExecutionContext execContext)
- {
- super(input, execContext) ;
- this.pattern = pattern ;
- graph = execContext.getActiveGraph() ;
- // Create a chain of triple iterators.
- QueryIterator chain = getInput() ;
- Collection<BasicPattern> patterns = sort(pattern);
- for (BasicPattern p : patterns)
- chain = new QueryIterPropertyTableRow(chain, p, execContext) ;
- output = chain ;
- }
-
- private Collection<BasicPattern> sort(BasicPattern pattern){
- HashMap<Node, BasicPattern> map= new HashMap<Node, BasicPattern>();
- for(Triple triple: pattern.getList()){
- Node subject = triple.getSubject();
- if(! map.containsKey(subject)){
- List<Triple> triples = new ArrayList<Triple>();
- BasicPattern p = BasicPattern.wrap(triples);
- map.put(subject, p);
- p.add(triple);
- }else {
- map.get(subject).add(triple);
- }
- }
- return map.values();
- }
-
- @Override
- protected boolean hasNextBinding()
- {
- return output.hasNext() ;
- }
-
- @Override
- protected Binding moveToNextBinding()
- {
- return output.nextBinding() ;
- }
-
- @Override
- protected void closeSubIterator()
- {
- if ( output != null )
- output.close() ;
- output = null ;
- }
-
- @Override
- protected void requestSubCancel()
- {
- if ( output != null )
- output.cancel();
- }
-
- @Override
- protected void details(IndentedWriter out, SerializationContext sCxt)
- {
- out.print(Utils.className(this)) ;
- out.println() ;
- out.incIndent() ;
- FmtUtils.formatPattern(out, pattern, sCxt) ;
- out.decIndent() ;
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/20cdd495/src/main/java/com/hp/hpl/jena/propertytable/impl/QueryIterPropertyTableRow.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/hp/hpl/jena/propertytable/impl/QueryIterPropertyTableRow.java b/src/main/java/com/hp/hpl/jena/propertytable/impl/QueryIterPropertyTableRow.java
deleted file mode 100644
index 1aa4572..0000000
--- a/src/main/java/com/hp/hpl/jena/propertytable/impl/QueryIterPropertyTableRow.java
+++ /dev/null
@@ -1,217 +0,0 @@
-package com.hp.hpl.jena.propertytable.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.graph.Triple;
-import com.hp.hpl.jena.propertytable.PropertyTable;
-import com.hp.hpl.jena.propertytable.Row;
-import com.hp.hpl.jena.sparql.ARQInternalErrorException;
-import com.hp.hpl.jena.sparql.core.BasicPattern;
-import com.hp.hpl.jena.sparql.core.Var;
-import com.hp.hpl.jena.sparql.engine.ExecutionContext;
-import com.hp.hpl.jena.sparql.engine.QueryIterator;
-import com.hp.hpl.jena.sparql.engine.binding.Binding;
-import com.hp.hpl.jena.sparql.engine.binding.BindingFactory;
-import com.hp.hpl.jena.sparql.engine.binding.BindingMap;
-import com.hp.hpl.jena.sparql.engine.iterator.QueryIter;
-import com.hp.hpl.jena.sparql.engine.iterator.QueryIterRepeatApply;
-import com.hp.hpl.jena.util.iterator.ClosableIterator;
-import com.hp.hpl.jena.util.iterator.ExtendedIterator;
-import com.hp.hpl.jena.util.iterator.NiceIterator;
-import com.hp.hpl.jena.util.iterator.WrappedIterator;
-
-public class QueryIterPropertyTableRow extends QueryIterRepeatApply{
- private final BasicPattern pattern ;
-
- public QueryIterPropertyTableRow( QueryIterator input,
- BasicPattern pattern ,
- ExecutionContext cxt)
- {
- super(input, cxt) ;
- this.pattern = pattern ;
- }
-
- @Override
- protected QueryIterator nextStage(Binding binding)
- {
- return new RowMapper(binding, pattern, getExecContext()) ;
- }
-
- static int countMapper = 0 ;
- static class RowMapper extends QueryIter
- {
- private PropertyTable table;
-
- private BasicPattern pattern;
- private Binding binding ;
- private ClosableIterator<Row> graphIter ;
- private Binding slot = null ;
- private boolean finished = false ;
- private volatile boolean cancelled = false ;
-
- RowMapper(Binding binding, BasicPattern pattern, ExecutionContext cxt)
- {
- super(cxt) ;
- GraphPropertyTable graph = (GraphPropertyTable)cxt.getActiveGraph() ;
-
- this.pattern = substitute(pattern, binding);
- this.binding = binding ;
- BasicPattern pattern2 = tripleNode(pattern);
-
- ExtendedIterator<Row> iter = graph.propertyTableBaseFind( new RowMatch( pattern2) );
-
- if ( false )
- {
- // Materialize the results now. Debugging only.
- List<Row> x = iter.toList() ;
- this.graphIter = WrappedIterator.create(x.iterator()) ;
- iter.close();
- }
- else
- // Stream.
- this.graphIter = iter ;
- }
-
- private static Node tripleNode(Node node)
- {
- if ( node.isVariable() )
- return Node.ANY ;
- return node ;
- }
-
- private static BasicPattern tripleNode(BasicPattern pattern)
- {
- List<Triple> triples = new ArrayList<Triple>();
- for (Triple triple: pattern){
- triples.add( tripleNode(triple) );
- }
- return BasicPattern.wrap(triples);
- }
-
- private static Triple tripleNode(Triple triple){
- Node s = tripleNode(triple.getSubject()) ;
- Node p = tripleNode(triple.getPredicate()) ;
- Node o = tripleNode(triple.getObject()) ;
- return Triple.create(s, p, o);
- }
-
- private static Node substitute(Node node, Binding binding)
- {
- if ( Var.isVar(node) )
- {
- Node x = binding.get(Var.alloc(node)) ;
- if ( x != null )
- return x ;
- }
- return node ;
- }
-
- private static Triple substitute(Triple triple, Binding binding){
- Node s = substitute(triple.getSubject(), binding) ;
- Node p = substitute(triple.getPredicate(), binding) ;
- Node o = substitute(triple.getObject(), binding) ;
- return Triple.create(s, p, o);
- }
-
- private static BasicPattern substitute(BasicPattern pattern , Binding binding)
- {
- List<Triple> triples = new ArrayList<Triple>();
- for (Triple triple: pattern){
- triples.add( substitute(triple,binding) );
- }
- return BasicPattern.wrap(triples);
- }
-
- private Binding mapper(Row r)
- {
- BindingMap results = BindingFactory.create(binding) ;
-
- if ( ! insert(pattern, r, results) )
- return null ;
- return results ;
- }
-
- private static boolean insert(BasicPattern input, Row output, BindingMap results)
- {
- for (Triple triple: input){
- if (! insert(triple, output, results) ){
- return false;
- }
- }
- return true;
- }
-
- private static boolean insert(Triple input, Row output, BindingMap results){
- if ( ! insert(input.getSubject(), output.getRowKey(), results) )
- return false ;
-// if ( ! insert(input.getPredicate(), output.get, results) )
-// return false ;
- if ( ! insert(input.getObject(), output.getValue( input.getPredicate() ), results) )
- return false ;
- return true;
- }
-
- private static boolean insert(Node inputNode, Node outputNode, BindingMap results)
- {
- if ( ! Var.isVar(inputNode) )
- return true ;
-
- Var v = Var.alloc(inputNode) ;
- Node x = results.get(v) ;
- if ( x != null )
- return outputNode.equals(x) ;
-
- results.add(v, outputNode) ;
- return true ;
- }
-
- @Override
- protected boolean hasNextBinding()
- {
- if ( finished ) return false ;
- if ( slot != null ) return true ;
- if ( cancelled )
- {
- graphIter.close() ;
- finished = true ;
- return false ;
- }
-
- while(graphIter.hasNext() && slot == null )
- {
- Row r = graphIter.next() ;
- slot = mapper(r) ;
- }
- if ( slot == null )
- finished = true ;
- return slot != null ;
- }
-
- @Override
- protected Binding moveToNextBinding()
- {
- if ( ! hasNextBinding() )
- throw new ARQInternalErrorException() ;
- Binding r = slot ;
- slot = null ;
- return r ;
- }
-
- @Override
- protected void closeIterator()
- {
- if ( graphIter != null )
- NiceIterator.close(graphIter) ;
- graphIter = null ;
- }
-
- @Override
- protected void requestCancel()
- {
- // The QueryIteratorBase machinary will do the real work.
- cancelled = true ;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/20cdd495/src/main/java/com/hp/hpl/jena/propertytable/impl/RowMatch.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/hp/hpl/jena/propertytable/impl/RowMatch.java b/src/main/java/com/hp/hpl/jena/propertytable/impl/RowMatch.java
deleted file mode 100644
index ba221ef..0000000
--- a/src/main/java/com/hp/hpl/jena/propertytable/impl/RowMatch.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.hp.hpl.jena.propertytable.impl;
-
-import com.hp.hpl.jena.graph.Node;
-import com.hp.hpl.jena.sparql.core.BasicPattern;
-
-public class RowMatch {
-
- private BasicPattern pattern;
-
- public RowMatch( BasicPattern pattern ){
- this.pattern=pattern;
- }
-
- public Node getMatchSubject(){
- return pattern.get(0).getMatchSubject();
- }
-
- public Node getSubject(){
- return pattern.get(0).getSubject();
- }
-
- public BasicPattern getBasicPattern(){
- return pattern;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/20cdd495/src/main/java/com/hp/hpl/jena/propertytable/impl/StageGeneratorPropertyTable.java
----------------------------------------------------------------------
diff --git a/src/main/java/com/hp/hpl/jena/propertytable/impl/StageGeneratorPropertyTable.java b/src/main/java/com/hp/hpl/jena/propertytable/impl/StageGeneratorPropertyTable.java
deleted file mode 100644
index f7db0f9..0000000
--- a/src/main/java/com/hp/hpl/jena/propertytable/impl/StageGeneratorPropertyTable.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.hp.hpl.jena.propertytable.impl;
-
-import com.hp.hpl.jena.graph.Graph;
-import com.hp.hpl.jena.sparql.core.BasicPattern;
-import com.hp.hpl.jena.sparql.engine.ExecutionContext;
-import com.hp.hpl.jena.sparql.engine.QueryIterator;
-import com.hp.hpl.jena.sparql.engine.main.StageGenerator;
-
-public class StageGeneratorPropertyTable implements StageGenerator {
-
- // Using OpExecutor is preferred.
- StageGenerator above = null ;
-
- public StageGeneratorPropertyTable(StageGenerator original)
- {
- above = original ;
- }
-
- @Override
- public QueryIterator execute(BasicPattern pattern, QueryIterator input, ExecutionContext execCxt)
- {
- // --- In case this isn't for GraphPropertyTable
- Graph g = execCxt.getActiveGraph() ;
-
- if ( ! ( g instanceof GraphPropertyTable ) )
- // Not us - bounce up the StageGenerator chain
- return above.execute(pattern, input, execCxt) ;
- if (pattern.size() <= 1){
- System.out.println( "<=1 "+ pattern);
- return above.execute(pattern, input, execCxt) ;
- }
- System.out.println( ">1" + pattern);
- return QueryIterPropertyTable.create(input, pattern, execCxt);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/jena/blob/20cdd495/src/test/java/com/hp/hpl/jena/propertytable/impl/GraphCSVTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/com/hp/hpl/jena/propertytable/impl/GraphCSVTest.java b/src/test/java/com/hp/hpl/jena/propertytable/impl/GraphCSVTest.java
index 3145a19..01b0564 100644
--- a/src/test/java/com/hp/hpl/jena/propertytable/impl/GraphCSVTest.java
+++ b/src/test/java/com/hp/hpl/jena/propertytable/impl/GraphCSVTest.java
@@ -17,6 +17,8 @@ package com.hp.hpl.jena.propertytable.impl;
* limitations under the License.
*/
+import org.apache.jena.propertytable.impl.GraphCSV;
+import org.apache.jena.propertytable.impl.StageGeneratorPropertyTable;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;