You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by vg...@apache.org on 2007/05/25 04:46:52 UTC
svn commit: r541516 - in /xml/xindice/trunk/java/src/org/apache/xindice:
client/xmldb/embed/ core/ core/data/ core/filer/ core/indexer/ core/query/
Author: vgritsenko
Date: Thu May 24 19:46:51 2007
New Revision: 541516
URL: http://svn.apache.org/viewvc?view=rev&rev=541516
Log:
bit of cleanup
restore readRecord(key) method with trivial implementation
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java
xml/xindice/trunk/java/src/org/apache/xindice/core/Collection.java
xml/xindice/trunk/java/src/org/apache/xindice/core/DocumentCache.java
xml/xindice/trunk/java/src/org/apache/xindice/core/data/Entry.java
xml/xindice/trunk/java/src/org/apache/xindice/core/filer/BTreeFiler.java
xml/xindice/trunk/java/src/org/apache/xindice/core/filer/FSFiler.java
xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Filer.java
xml/xindice/trunk/java/src/org/apache/xindice/core/filer/HashFiler.java
xml/xindice/trunk/java/src/org/apache/xindice/core/filer/MemFiler.java
xml/xindice/trunk/java/src/org/apache/xindice/core/filer/SizeableMemFiler.java
xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/IndexManager.java
xml/xindice/trunk/java/src/org/apache/xindice/core/query/XPathQueryResolver.java
Modified: xml/xindice/trunk/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java?view=diff&rev=541516&r1=541515&r2=541516
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/client/xmldb/embed/CollectionImpl.java Thu May 24 19:46:51 2007
@@ -26,8 +26,8 @@
import org.apache.xindice.core.Collection;
import org.apache.xindice.core.Database;
import org.apache.xindice.core.FaultCodes;
-import org.apache.xindice.core.data.NodeSet;
import org.apache.xindice.core.data.Entry;
+import org.apache.xindice.core.data.NodeSet;
import org.apache.xindice.core.meta.MetaData;
import org.apache.xindice.core.query.QueryUtil;
import org.apache.xindice.util.Configuration;
@@ -117,22 +117,27 @@
Entry entry = col.getEntry(id);
if (entry == null) {
return null;
- } else if (entry.getEntryType() == Entry.DOCUMENT) {
- DocumentImpl doc = (DocumentImpl) entry.getValue();
+ }
- // This should probably just pass the document.
- if (doc.getDataBytes() == null) {
- return new XMLResourceImpl(id, id, this, TextWriter.toString(doc));
- } else {
- return new XMLResourceImpl(id, id, this, doc.getSymbols(), doc.getDataBytes());
- }
+ switch (entry.getEntryType()) {
+ case Entry.DOCUMENT:
+ DocumentImpl doc = (DocumentImpl) entry.getValue();
+
+ // This should probably just pass the document.
+ if (doc.getDataBytes() == null) {
+ return new XMLResourceImpl(id, id, this, TextWriter.toString(doc));
+ } else {
+ return new XMLResourceImpl(id, id, this, doc.getSymbols(), doc.getDataBytes());
+ }
- } else if (entry.getEntryType() == Entry.BINARY) {
- return new BinaryResourceImpl(id, this, (byte[]) entry.getValue());
- } else {
- throw new XMLDBException(ErrorCodes.UNKNOWN_RESOURCE_TYPE,
- "Internal error: Unexpected resource type " + entry.getClass().getName());
+ case Entry.BINARY:
+ return new BinaryResourceImpl(id, this, (byte[]) entry.getValue());
+
+ default:
+ throw new XMLDBException(ErrorCodes.UNKNOWN_RESOURCE_TYPE,
+ "Internal error: Unexpected resource type " + entry.getEntryType());
}
+
} catch (Exception e) {
throw FaultCodes.createXMLDBException("Resource not available: " + id, e);
}
@@ -282,7 +287,7 @@
* method has been called on the <code>Collection</code><br />
*/
public String createId() throws XMLDBException {
-
+
checkOpen();
return col.createNewOID().toString();
}
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/Collection.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/Collection.java?view=diff&rev=541516&r1=541515&r2=541516
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/Collection.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/Collection.java Thu May 24 19:46:51 2007
@@ -24,12 +24,12 @@
import org.apache.xindice.core.data.DocumentSet;
import org.apache.xindice.core.data.EmptyDocumentSet;
import org.apache.xindice.core.data.EmptyNodeSet;
+import org.apache.xindice.core.data.Entry;
import org.apache.xindice.core.data.Key;
import org.apache.xindice.core.data.NodeSet;
import org.apache.xindice.core.data.Record;
import org.apache.xindice.core.data.RecordSet;
import org.apache.xindice.core.data.Value;
-import org.apache.xindice.core.data.Entry;
import org.apache.xindice.core.filer.Filer;
import org.apache.xindice.core.indexer.IndexManager;
import org.apache.xindice.core.indexer.Indexer;
@@ -336,12 +336,12 @@
private String debugHeader() {
return "["
- + Thread.currentThread().getName()
- + "] '"
- + (parent != null ? parent.getCanonicalName() : "")
- + "/"
- + name
- + "' ";
+ + Thread.currentThread().getName()
+ + "] '"
+ + (parent != null ? parent.getCanonicalName() : "")
+ + "/"
+ + name
+ + "' ";
}
/**
@@ -715,7 +715,7 @@
}
}
- Record record = filer.readRecord(key, false);
+ Record record = filer.readRecord(key);
if (record == null) {
return null;
}
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/DocumentCache.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/DocumentCache.java?view=diff&rev=541516&r1=541515&r2=541516
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/DocumentCache.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/DocumentCache.java Thu May 24 19:46:51 2007
@@ -21,8 +21,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.xindice.core.data.Key;
import org.apache.xindice.core.data.Entry;
+import org.apache.xindice.core.data.Key;
import org.apache.xindice.xml.NodeSource;
import org.apache.xindice.xml.SymbolTable;
import org.apache.xindice.xml.dom.DBDocument;
@@ -65,8 +65,10 @@
if (v == null) {
return null;
+
} else if (v.getValue() instanceof Document) {
return new Entry(key, (Document) v.getValue(), v.getMeta());
+
} else if (v.getValue() instanceof String) {
try {
Document doc = DOMParser.toDocument((String) v.getValue());
@@ -77,6 +79,7 @@
log.warn("ignored exception", e);
}
}
+
} else if (v.getValue() instanceof byte[]) {
try {
SymbolTable s = col.getSymbols();
@@ -109,6 +112,7 @@
return null;
}
+
/**
* Stores compressed document's bytes in the cache
*
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/data/Entry.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/data/Entry.java?view=diff&rev=541516&r1=541515&r2=541516
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/data/Entry.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/data/Entry.java Thu May 24 19:46:51 2007
@@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
+ * $Id$
*/
package org.apache.xindice.core.data;
@@ -27,6 +28,8 @@
/**
* Entry is a high-level representation of a database record, that includes
* its internal meta information
+ *
+ * @version $Revision$, $Date$
*/
public class Entry {
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/filer/BTreeFiler.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/filer/BTreeFiler.java?view=diff&rev=541516&r1=541515&r2=541516
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/filer/BTreeFiler.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/filer/BTreeFiler.java Thu May 24 19:46:51 2007
@@ -89,6 +89,10 @@
return "BTreeFiler";
}
+ public Record readRecord(Key key) throws DBException {
+ return readRecord(key, false);
+ }
+
public Record readRecord(Key key, boolean metaOnly) throws DBException {
if (key == null || key.getLength() == 0) {
return null;
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/filer/FSFiler.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/filer/FSFiler.java?view=diff&rev=541516&r1=541515&r2=541516
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/filer/FSFiler.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/filer/FSFiler.java Thu May 24 19:46:51 2007
@@ -19,8 +19,6 @@
package org.apache.xindice.core.filer;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.xindice.core.DBException;
import org.apache.xindice.core.FaultCodes;
import org.apache.xindice.core.data.Key;
@@ -49,20 +47,21 @@
*/
public final class FSFiler extends SimpleConfigurable implements Filer {
- private static final Log log = LogFactory.getLog(FSFiler.class);
+ // private static final Log log = LogFactory.getLog(FSFiler.class);
private static final String LOCATION = "location";
private static final String EXT = "ext";
private static final String READONLY = "readonly";
+
private FileCache cache = new FileCache();
private LockManager locks = new LockManager(16);
- private Set extensions = null;
+ private Set extensions;
private String location;
private File dir;
- private boolean opened = false;
- private boolean readOnly = false;
+ private boolean opened;
+ private boolean readOnly;
public FSFiler() {
@@ -137,6 +136,10 @@
}
public void flush() {
+ }
+
+ public Record readRecord(Key key) throws DBException {
+ return readRecord(key, false);
}
public Record readRecord(Key key, boolean metaOnly) throws DBException {
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Filer.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Filer.java?view=diff&rev=541516&r1=541515&r2=541516
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Filer.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/filer/Filer.java Thu May 24 19:46:51 2007
@@ -53,7 +53,16 @@
* Key.
*
* @param key The Record's Key
- * @param metaOnly
+ * @return The returned Record
+ */
+ Record readRecord(Key key) throws DBException;
+
+ /**
+ * readRecord returns a Record from the Filer based on the specified
+ * Key containing filer meta information and value.
+ *
+ * @param key The Record's Key
+ * @param metaOnly if true, resulting record contains only meta information
* @return The returned Record
*/
Record readRecord(Key key, boolean metaOnly) throws DBException;
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/filer/HashFiler.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/filer/HashFiler.java?view=diff&rev=541516&r1=541515&r2=541516
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/filer/HashFiler.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/filer/HashFiler.java Thu May 24 19:46:51 2007
@@ -123,6 +123,10 @@
}
}
+ public Record readRecord(Key key) throws DBException {
+ return readRecord(key, false);
+ }
+
public Record readRecord(Key key, boolean metaOnly) throws DBException {
if (key == null || key.getLength() == 0) {
return null;
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/filer/MemFiler.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/filer/MemFiler.java?view=diff&rev=541516&r1=541515&r2=541516
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/filer/MemFiler.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/filer/MemFiler.java Thu May 24 19:46:51 2007
@@ -109,12 +109,16 @@
public void flush() {
}
+ public Record readRecord(Key key) throws DBException {
+ return readRecord(key, false);
+ }
+
public Record readRecord(Key key, boolean metaOnly) throws DBException {
if (key == null || key.getLength() == 0) {
return null;
}
checkOpened();
- return metaOnly ? new Record(key, null) : (Record) hashTable.get(key);
+ return (Record) hashTable.get(key);
}
public Record writeRecord(Key key, Value value) throws DBException {
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/filer/SizeableMemFiler.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/filer/SizeableMemFiler.java?view=diff&rev=541516&r1=541515&r2=541516
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/filer/SizeableMemFiler.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/filer/SizeableMemFiler.java Thu May 24 19:46:51 2007
@@ -124,12 +124,16 @@
public void flush() {
}
+ public Record readRecord(Key key) throws DBException {
+ return readRecord(key, false);
+ }
+
public Record readRecord(Key key, boolean metaOnly) throws DBException {
if (key == null || key.getLength() == 0) {
return null;
}
checkOpened();
- return metaOnly ? new Record(key, null) : (Record) hashTable.get(key);
+ return (Record) hashTable.get(key);
}
public Record writeRecord(Key key, Value value) throws DBException {
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/IndexManager.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/IndexManager.java?view=diff&rev=541516&r1=541515&r2=541516
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/IndexManager.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/indexer/IndexManager.java Thu May 24 19:46:51 2007
@@ -24,9 +24,9 @@
import org.apache.xindice.Stopwatch;
import org.apache.xindice.core.Collection;
import org.apache.xindice.core.DBException;
+import org.apache.xindice.core.data.Entry;
import org.apache.xindice.core.data.Key;
import org.apache.xindice.core.data.RecordSet;
-import org.apache.xindice.core.data.Entry;
import org.apache.xindice.util.Configuration;
import org.apache.xindice.util.ConfigurationCallback;
import org.apache.xindice.util.ObjectStack;
@@ -46,9 +46,9 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Timer;
import java.util.TimerTask;
import java.util.WeakHashMap;
-import java.util.Timer;
/**
* IndexManager is a class that manages Indexes. Good description, eh?
Modified: xml/xindice/trunk/java/src/org/apache/xindice/core/query/XPathQueryResolver.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/core/query/XPathQueryResolver.java?view=diff&rev=541516&r1=541515&r2=541516
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/core/query/XPathQueryResolver.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/core/query/XPathQueryResolver.java Thu May 24 19:46:51 2007
@@ -23,11 +23,11 @@
import org.apache.commons.logging.LogFactory;
import org.apache.xindice.core.Collection;
import org.apache.xindice.core.DBException;
+import org.apache.xindice.core.data.Entry;
import org.apache.xindice.core.data.Key;
import org.apache.xindice.core.data.NodeSet;
import org.apache.xindice.core.data.RecordSet;
import org.apache.xindice.core.data.Value;
-import org.apache.xindice.core.data.Entry;
import org.apache.xindice.core.indexer.IndexManager;
import org.apache.xindice.core.indexer.IndexMatch;
import org.apache.xindice.core.indexer.IndexPattern;