vgritsenko 2004/03/20 06:02:39
Modified: . status.xml java/src/org/apache/xindice/core/filer BTree.java BTreeFiler.java HashFiler.java Paged.java Streamable.java java/src/org/apache/xindice/core/indexer IndexPattern.java ValueIndexer.java Log: Change Streamable interface from DataInput/OutputStream to DataInput/Output interfaces. Revision Changes Path 1.40 +3 -0 xml-xindice/status.xml Index: status.xml =================================================================== RCS file: /home/cvs/xml-xindice/status.xml,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- status.xml 4 Mar 2004 13:18:49 -0000 1.39 +++ status.xml 20 Mar 2004 14:02:38 -0000 1.40 @@ -74,6 +74,9 @@ <changes> <release version="1.1b4-dev" date="March 4 2004"> + <action dev="VG" type="update"> + Implemented support for MetaData for Binary resources. + </action> <action dev="VG" type="fix" fixes-bug="22155"> Support boolean, string, and number XPath query results. </action> 1.26 +11 -8 xml-xindice/java/src/org/apache/xindice/core/filer/BTree.java Index: BTree.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/BTree.java,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- BTree.java 8 Feb 2004 02:49:45 -0000 1.25 +++ BTree.java 20 Mar 2004 14:02:38 -0000 1.26 @@ -26,11 +26,13 @@ import org.apache.xindice.core.indexer.IndexQuery; import java.io.ByteArrayOutputStream; +import java.io.DataInput; import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; +import java.io.DataOutput; import java.lang.ref.WeakReference; import java.util.Arrays; import java.util.Map; @@ -89,8 +91,6 @@ public BTree() { super(); fileHeader = (BTreeFileHeader) getFileHeader(); - fileHeader.setPageCount(1); - fileHeader.setTotalCount(1); } public BTree(File file) { @@ -954,7 +954,10 @@ //////////////////////////////////////////////////////////////////// public FileHeader createFileHeader() { - return new BTreeFileHeader(); + BTreeFileHeader header = new BTreeFileHeader(); + header.setPageCount(1); + header.setTotalCount(1); + return header; } public FileHeader createFileHeader(boolean read) throws IOException { @@ -1027,11 +1030,11 @@ public BTreePageHeader() { } - public BTreePageHeader(DataInputStream dis) throws IOException { + public BTreePageHeader(DataInput dis) throws IOException { super(dis); } - public synchronized void read(DataInputStream dis) throws IOException { + public synchronized void read(DataInput dis) throws IOException { super.read(dis); if (getStatus() == UNUSED) { return; @@ -1040,7 +1043,7 @@ valueCount = dis.readShort(); } - public synchronized void write(DataOutputStream dos) throws IOException { + public synchronized void write(DataOutput dos) throws IOException { super.write(dos); dos.writeShort(valueCount); } 1.23 +7 -7 xml-xindice/java/src/org/apache/xindice/core/filer/BTreeFiler.java Index: BTreeFiler.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/BTreeFiler.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- BTreeFiler.java 8 Feb 2004 02:49:45 -0000 1.22 +++ BTreeFiler.java 20 Mar 2004 14:02:38 -0000 1.23 @@ -27,8 +27,8 @@ import org.apache.xindice.core.data.RecordSet; import org.apache.xindice.core.data.Value; -import java.io.DataInputStream; -import java.io.DataOutputStream; +import java.io.DataInput; +import java.io.DataOutput; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; @@ -295,11 +295,11 @@ public BTreeFilerPageHeader() { } - public BTreeFilerPageHeader(DataInputStream dis) throws IOException { + public BTreeFilerPageHeader(DataInput dis) throws IOException { super(dis); } - public synchronized void read(DataInputStream dis) throws IOException { + public synchronized void read(DataInput dis) throws IOException { super.read(dis); if (getStatus() == UNUSED) { @@ -310,7 +310,7 @@ modified = dis.readLong(); } - public synchronized void write(DataOutputStream dos) throws IOException { + public synchronized void write(DataOutput dos) throws IOException { super.write(dos); dos.writeLong(created); dos.writeLong(modified); 1.23 +7 -7 xml-xindice/java/src/org/apache/xindice/core/filer/HashFiler.java Index: HashFiler.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/HashFiler.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- HashFiler.java 8 Feb 2004 02:49:45 -0000 1.22 +++ HashFiler.java 20 Mar 2004 14:02:38 -0000 1.23 @@ -27,8 +27,8 @@ import org.apache.xindice.core.data.RecordSet; import org.apache.xindice.core.data.Value; -import java.io.DataInputStream; -import java.io.DataOutputStream; +import java.io.DataInput; +import java.io.DataOutput; import java.io.File; import java.io.IOException; import java.io.RandomAccessFile; @@ -403,11 +403,11 @@ public HashPageHeader() { } - public HashPageHeader(DataInputStream dis) throws IOException { + public HashPageHeader(DataInput dis) throws IOException { super(dis); } - public synchronized void read(DataInputStream dis) throws IOException { + public synchronized void read(DataInput dis) throws IOException { super.read(dis); if (getStatus() == UNUSED) { @@ -419,7 +419,7 @@ nextCollision = dis.readLong(); } - public synchronized void write(DataOutputStream dos) throws IOException { + public synchronized void write(DataOutput dos) throws IOException { super.write(dos); dos.writeLong(created); dos.writeLong(modified); 1.29 +17 -19 xml-xindice/java/src/org/apache/xindice/core/filer/Paged.java Index: Paged.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/Paged.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- Paged.java 8 Feb 2004 02:49:45 -0000 1.28 +++ Paged.java 20 Mar 2004 14:02:38 -0000 1.29 @@ -21,8 +21,8 @@ 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.DBObject; +import org.apache.xindice.core.FaultCodes; import org.apache.xindice.core.data.Key; import org.apache.xindice.core.data.Value; import org.apache.xindice.util.Configurable; @@ -30,21 +30,23 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; +import java.io.DataInput; import java.io.DataInputStream; +import java.io.DataOutput; import java.io.DataOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.RandomAccessFile; +import java.lang.ref.WeakReference; +import java.util.Collection; +import java.util.EmptyStackException; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Stack; import java.util.WeakHashMap; -import java.util.Collection; -import java.util.EmptyStackException; -import java.lang.ref.WeakReference; /** * Paged is a paged file implementation that is foundation for both the @@ -554,7 +556,7 @@ * * @return The FileHeader */ - public FileHeader getFileHeader() { + protected FileHeader getFileHeader() { return fileHeader; } @@ -571,17 +573,13 @@ fileHeader.setMaxKeySize(config.getShortAttribute(CONFIG_KEYSIZE_MAX, fileHeader.getMaxKeySize())); - RandomAccessFile raf = null; try { - raf = getDescriptor(); fileHeader.write(); flush(); return true; } catch (Exception e) { throw new FilerException(FaultCodes.GEN_CRITICAL_ERROR, "Error creating " + file.getName(), e); - } finally { - closeDescriptor(raf); } } @@ -1119,22 +1117,22 @@ * Paged file page's header */ public abstract static class PageHeader implements Streamable { - private boolean dirty = false; + private boolean dirty; private byte status = UNUSED; - private short keyLen = 0; - private int keyHash = 0; - private int dataLen = 0; - private int recordLen = 0; + private short keyLen; + private int keyHash; + private int dataLen; + private int recordLen; private long nextPage = -1; public PageHeader() { } - public PageHeader(DataInputStream dis) throws IOException { + public PageHeader(DataInput dis) throws IOException { read(dis); } - public synchronized void read(DataInputStream dis) throws IOException { + public synchronized void read(DataInput dis) throws IOException { status = dis.readByte(); dirty = false; if (status == UNUSED) { @@ -1148,7 +1146,7 @@ nextPage = dis.readLong(); } - public synchronized void write(DataOutputStream dos) throws IOException { + public synchronized void write(DataOutput dos) throws IOException { dirty = false; dos.writeByte(status); dos.writeShort(keyLen); 1.6 +6 -6 xml-xindice/java/src/org/apache/xindice/core/filer/Streamable.java Index: Streamable.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/filer/Streamable.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- Streamable.java 8 Feb 2004 02:49:45 -0000 1.5 +++ Streamable.java 20 Mar 2004 14:02:38 -0000 1.6 @@ -18,8 +18,8 @@ package org.apache.xindice.core.filer; -import java.io.DataInputStream; -import java.io.DataOutputStream; +import java.io.DataInput; +import java.io.DataOutput; import java.io.IOException; /** @@ -36,7 +36,7 @@ * @param is The DataInputStream * @throws IOException if an IOException occurs */ - public void read(DataInputStream is) throws IOException; + public void read(DataInput is) throws IOException; /** * write writes the object state to the stream. @@ -44,5 +44,5 @@ * @param os The DataOutputStream * @throws IOException if an IOException occurs */ - public void write(DataOutputStream os) throws IOException; + public void write(DataOutput os) throws IOException; } 1.14 +16 -17 xml-xindice/java/src/org/apache/xindice/core/indexer/IndexPattern.java Index: IndexPattern.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/indexer/IndexPattern.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- IndexPattern.java 21 Feb 2004 04:11:14 -0000 1.13 +++ IndexPattern.java 20 Mar 2004 14:02:38 -0000 1.14 @@ -22,8 +22,8 @@ import org.apache.xindice.xml.NamespaceMap; import org.apache.xindice.xml.SymbolTable; -import java.io.DataInputStream; -import java.io.DataOutputStream; +import java.io.DataInput; +import java.io.DataOutput; import java.io.IOException; import java.util.StringTokenizer; @@ -35,20 +35,20 @@ */ public final class IndexPattern implements Streamable { - public static final int PATTERN_NONE = -1; + public static final int PATTERN_NONE = -1; public static final int PATTERN_WILDCARD = -2; - public static final int PATTERN_NAME = -3; + public static final int PATTERN_NAME = -3; - public static final int SCORE_NONE = 0; + public static final int SCORE_NONE = 0; public static final int SCORE_WILDCARD = 1; - public static final int SCORE_NAME = 2; - public static final int SCORE_NATURAL = 3; + public static final int SCORE_NAME = 2; + public static final int SCORE_NATURAL = 3; - private SymbolTable symbols = null; - private String elemName = null; + private SymbolTable symbols; + private String elemName; private short elemID = PATTERN_NONE; - private String attrName = null; + private String attrName; private short attrID = PATTERN_NONE; @@ -182,24 +182,24 @@ return attrName; } - public void read(DataInputStream dis) throws IOException { + public void read(DataInput dis) throws IOException { elemID = dis.readShort(); if (elemID == PATTERN_NAME) { short len = dis.readShort(); byte[] name = new byte[len]; - dis.read(name); + dis.readFully(name); elemName = new String(name, "utf-8"); } attrID = dis.readShort(); if (attrID == PATTERN_NAME) { short len = dis.readShort(); byte[] name = new byte[len]; - dis.read(name); + dis.readFully(name); attrName = new String(name, "utf-8"); } } - public void write(DataOutputStream dos) throws IOException { + public void write(DataOutput dos) throws IOException { dos.writeShort(elemID); if (elemID == PATTERN_NAME) { byte[] name = elemName.getBytes("utf-8"); @@ -234,4 +234,3 @@ } } } - 1.19 +12 -4 xml-xindice/java/src/org/apache/xindice/core/indexer/ValueIndexer.java Index: ValueIndexer.java =================================================================== RCS file: /home/cvs/xml-xindice/java/src/org/apache/xindice/core/indexer/ValueIndexer.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- ValueIndexer.java 8 Feb 2004 02:50:21 -0000 1.18 +++ ValueIndexer.java 20 Mar 2004 14:02:38 -0000 1.19 @@ -28,6 +28,7 @@ import org.apache.xindice.core.filer.BTreeCallback; import org.apache.xindice.core.filer.BTreeCorruptException; import org.apache.xindice.core.filer.BTreeNotFoundException; +import org.apache.xindice.core.filer.Paged; import org.apache.xindice.core.query.QueryEngine; import org.apache.xindice.util.Configuration; import org.apache.xindice.xml.SymbolTable; @@ -90,8 +91,15 @@ public ValueIndexer() { super(); - // Set default - getFileHeader().setPageSize(1024); + } + + /** + * Override createFileHeader - set page size to 1024 + */ + public Paged.FileHeader createFileHeader() { + Paged.FileHeader header = super.createFileHeader(); + header.setPageSize(1024); + return header; } public void setConfig(Configuration config) {