From: <wol...@us...> - 2013-05-02 20:15:18
|
Revision: 18393 http://sourceforge.net/p/exist/code/18393 Author: wolfgang_m Date: 2013-05-02 20:15:12 +0000 (Thu, 02 May 2013) Log Message: ----------- [feature] * Updating lucene index to version 4.2.1. Major architectural changes in lucene require some redesigns: nodeId and docId are now stored as docvalue fields, which are much faster than normal fields. * Enable extension indexes to hook into eXist's query optimizer and rewrite expressions by implementing interface QueryRewriter. Modified Paths: -------------- branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndex.java branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneMatchListener.java branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneUtil.java branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/PlainTextHighlighter.java branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/XMLToQuery.java branches/rangeindex/extensions/indexes/lucene/src/org/exist/xquery/modules/lucene/GetField.java branches/rangeindex/extensions/indexes/lucene/src/org/exist/xquery/modules/lucene/Query.java branches/rangeindex/extensions/indexes/lucene/src/org/exist/xquery/modules/lucene/QueryField.java branches/rangeindex/extensions/indexes/lucene/test/src/org/exist/indexing/lucene/LuceneIndexTest.java branches/rangeindex/extensions/indexes/ngram/src/org/exist/indexing/ngram/NGramIndexWorker.java branches/rangeindex/extensions/indexes/sort/src/org/exist/indexing/sort/SortIndexWorker.java branches/rangeindex/src/org/exist/collections/CollectionConfigurationManager.java branches/rangeindex/src/org/exist/fulltext/FTIndexWorker.java branches/rangeindex/src/org/exist/indexing/AbstractIndex.java branches/rangeindex/src/org/exist/indexing/IndexController.java branches/rangeindex/src/org/exist/indexing/IndexWorker.java branches/rangeindex/src/org/exist/storage/NodePath.java branches/rangeindex/src/org/exist/storage/statistics/IndexStatisticsWorker.java branches/rangeindex/src/org/exist/storage/structural/NativeStructuralIndex.java branches/rangeindex/src/org/exist/storage/structural/NativeStructuralIndexWorker.java branches/rangeindex/src/org/exist/xquery/Optimizer.java Added Paths: ----------- branches/rangeindex/extensions/indexes/lucene/lib/lucene-analyzers-common-4.2.1.jar branches/rangeindex/extensions/indexes/lucene/lib/lucene-core-4.2.1.jar branches/rangeindex/extensions/indexes/lucene/lib/lucene-queries-4.2.1.jar branches/rangeindex/extensions/indexes/lucene/lib/lucene-queryparser-4.2.1.jar branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/BinaryTokenStream.java branches/rangeindex/src/org/exist/xquery/QueryRewriter.java Removed Paths: ------------- branches/rangeindex/extensions/indexes/lucene/lib/lucene-analyzers-3.6.1.jar branches/rangeindex/extensions/indexes/lucene/lib/lucene-core-3.6.1.jar branches/rangeindex/extensions/indexes/lucene/lib/lucene-queries-3.6.1.jar Added: branches/rangeindex/extensions/indexes/lucene/lib/lucene-analyzers-common-4.2.1.jar =================================================================== (Binary files differ) Index: branches/rangeindex/extensions/indexes/lucene/lib/lucene-analyzers-common-4.2.1.jar =================================================================== --- branches/rangeindex/extensions/indexes/lucene/lib/lucene-analyzers-common-4.2.1.jar 2013-05-02 19:34:41 UTC (rev 18392) +++ branches/rangeindex/extensions/indexes/lucene/lib/lucene-analyzers-common-4.2.1.jar 2013-05-02 20:15:12 UTC (rev 18393) Property changes on: branches/rangeindex/extensions/indexes/lucene/lib/lucene-analyzers-common-4.2.1.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/rangeindex/extensions/indexes/lucene/lib/lucene-core-4.2.1.jar =================================================================== (Binary files differ) Index: branches/rangeindex/extensions/indexes/lucene/lib/lucene-core-4.2.1.jar =================================================================== --- branches/rangeindex/extensions/indexes/lucene/lib/lucene-core-4.2.1.jar 2013-05-02 19:34:41 UTC (rev 18392) +++ branches/rangeindex/extensions/indexes/lucene/lib/lucene-core-4.2.1.jar 2013-05-02 20:15:12 UTC (rev 18393) Property changes on: branches/rangeindex/extensions/indexes/lucene/lib/lucene-core-4.2.1.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/rangeindex/extensions/indexes/lucene/lib/lucene-queries-4.2.1.jar =================================================================== (Binary files differ) Index: branches/rangeindex/extensions/indexes/lucene/lib/lucene-queries-4.2.1.jar =================================================================== --- branches/rangeindex/extensions/indexes/lucene/lib/lucene-queries-4.2.1.jar 2013-05-02 19:34:41 UTC (rev 18392) +++ branches/rangeindex/extensions/indexes/lucene/lib/lucene-queries-4.2.1.jar 2013-05-02 20:15:12 UTC (rev 18393) Property changes on: branches/rangeindex/extensions/indexes/lucene/lib/lucene-queries-4.2.1.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/rangeindex/extensions/indexes/lucene/lib/lucene-queryparser-4.2.1.jar =================================================================== (Binary files differ) Index: branches/rangeindex/extensions/indexes/lucene/lib/lucene-queryparser-4.2.1.jar =================================================================== --- branches/rangeindex/extensions/indexes/lucene/lib/lucene-queryparser-4.2.1.jar 2013-05-02 19:34:41 UTC (rev 18392) +++ branches/rangeindex/extensions/indexes/lucene/lib/lucene-queryparser-4.2.1.jar 2013-05-02 20:15:12 UTC (rev 18393) Property changes on: branches/rangeindex/extensions/indexes/lucene/lib/lucene-queryparser-4.2.1.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/BinaryTokenStream.java =================================================================== --- branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/BinaryTokenStream.java (rev 0) +++ branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/BinaryTokenStream.java 2013-05-02 20:15:12 UTC (rev 18393) @@ -0,0 +1,67 @@ +package org.exist.indexing.lucene; + +import org.apache.lucene.analysis.TokenStream; +import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute; +import org.apache.lucene.util.AttributeImpl; +import org.apache.lucene.util.BytesRef; + +/** + * A binary tokenstream that lets you index a single + * binary token (BytesRef value). + * + */ +public final class BinaryTokenStream extends TokenStream { + private final ByteTermAttribute bytesAtt = addAttribute(ByteTermAttribute.class); + private boolean available = true; + + public BinaryTokenStream(BytesRef bytes) { + bytesAtt.setBytesRef(bytes); + } + + @Override + public boolean incrementToken() { + if (available) { + available = false; + return true; + } + return false; + } + + @Override + public void reset() { + available = true; + } + + public interface ByteTermAttribute extends TermToBytesRefAttribute { + public void setBytesRef(BytesRef bytes); + } + + public static class ByteTermAttributeImpl extends AttributeImpl implements ByteTermAttribute,TermToBytesRefAttribute { + private BytesRef bytes; + + @Override + public int fillBytesRef() { + return bytes.hashCode(); + } + + @Override + public BytesRef getBytesRef() { + return bytes; + } + + @Override + public void setBytesRef(BytesRef bytes) { + this.bytes = bytes; + } + + @Override + public void clear() {} + + @Override + public void copyTo(AttributeImpl target) { + ByteTermAttributeImpl other = (ByteTermAttributeImpl) target; + other.bytes = bytes; + } + } +} + Modified: branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndex.java =================================================================== --- branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndex.java 2013-05-02 19:34:41 UTC (rev 18392) +++ branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndex.java 2013-05-02 20:15:12 UTC (rev 18393) @@ -3,8 +3,7 @@ import org.apache.log4j.Logger; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.IndexReader; +import org.apache.lucene.index.*; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FSDirectory; @@ -25,13 +24,11 @@ import java.io.InputStream; import java.io.OutputStream; -import org.apache.lucene.index.CorruptIndexException; -import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.util.Version; public class LuceneIndex extends AbstractIndex implements RawBackupSupport { - public final static Version LUCENE_VERSION_IN_USE = Version.LUCENE_34; + public final static Version LUCENE_VERSION_IN_USE = Version.LUCENE_42; private static final Logger LOG = Logger.getLogger(LuceneIndexWorker.class); @@ -42,7 +39,7 @@ protected Directory directory; protected Analyzer defaultAnalyzer; - protected double bufferSize = IndexWriter.DEFAULT_RAM_BUFFER_SIZE_MB; + protected double bufferSize = IndexWriterConfig.DEFAULT_RAM_BUFFER_SIZE_MB; protected IndexWriter cachedWriter = null; protected int writerUseCount = 0; @@ -59,6 +56,10 @@ //Nothing special to do } + public String getDirName() { + return DIR_NAME; + } + @Override public void configure(BrokerPool pool, String dataDir, Element config) throws DatabaseConfigurationException { super.configure(pool, dataDir, config); @@ -90,7 +91,7 @@ @Override public void open() throws DatabaseConfigurationException { - File dir = new File(getDataDir(), DIR_NAME); + File dir = new File(getDataDir(), getDirName()); if (LOG.isDebugEnabled()) LOG.debug("Opening Lucene index directory: " + dir.getAbsolutePath()); if (dir.exists()) { @@ -161,11 +162,11 @@ protected boolean needsCommit = false; - protected IndexWriter getWriter() throws IOException { + public IndexWriter getWriter() throws IOException { return getWriter(false); } - protected synchronized IndexWriter getWriter(boolean exclusive) throws IOException { + public synchronized IndexWriter getWriter(boolean exclusive) throws IOException { while (writingReaderUseCount > 0) { try { wait(); @@ -200,7 +201,7 @@ return cachedWriter; } - protected synchronized void releaseWriter(IndexWriter writer) { + public synchronized void releaseWriter(IndexWriter writer) { if (writer == null) return; if (writer != cachedWriter) @@ -233,18 +234,18 @@ } } - protected synchronized IndexReader getReader() throws IOException { + public synchronized IndexReader getReader() throws IOException { commit(); if (cachedReader != null) { readerUseCount++; } else { - cachedReader = IndexReader.open(directory); + cachedReader = DirectoryReader.open(directory); readerUseCount = 1; } return cachedReader; } - protected synchronized void releaseReader(IndexReader reader) { + public synchronized void releaseReader(IndexReader reader) { if (reader == null) return; if (reader != cachedReader) @@ -273,7 +274,7 @@ if (cachedWritingReader != null) { writingReaderUseCount++; } else { - cachedWritingReader = IndexReader.open(directory, false); + cachedWritingReader = DirectoryReader.open(directory); writingReaderUseCount = 1; } notifyAll(); @@ -317,15 +318,15 @@ try { cachedReader.close(); cachedReader = null; - if (cachedSearcher != null) - cachedSearcher.close(); +// if (cachedSearcher != null) +// cachedSearcher.close(); cachedSearcher = null; } catch (IOException e) { LOG.warn("Exception while refreshing lucene index: " + e.getMessage(), e); } } - protected synchronized IndexSearcher getSearcher() throws IOException { + public synchronized IndexSearcher getSearcher() throws IOException { commit(); if (cachedSearcher != null) { searcherUseCount++; @@ -337,7 +338,7 @@ return cachedSearcher; } - protected synchronized void releaseSearcher(IndexSearcher searcher) { + public synchronized void releaseSearcher(IndexSearcher searcher) { if (searcher == null) return; if (searcher != cachedSearcher) @@ -349,7 +350,7 @@ @Override public void backupToArchive(RawDataBackup backup) throws IOException { for (String name : directory.listAll()) { - String path = DIR_NAME + "/" + name; + String path = getDirName() + "/" + name; OutputStream os = backup.newEntry(path); InputStream is = new FileInputStream(new File(getDataDir(), path)); byte[] buf = new byte[4096]; Modified: branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java =================================================================== --- branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java 2013-05-02 19:34:41 UTC (rev 18392) +++ branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java 2013-05-02 20:15:12 UTC (rev 18393) @@ -21,77 +21,18 @@ */ package org.exist.indexing.lucene; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.Stack; -import java.util.TreeMap; -import java.util.TreeSet; - import org.apache.log4j.Logger; - import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; -import org.apache.lucene.document.Document; -import org.apache.lucene.document.Field; -import org.apache.lucene.document.FieldSelector; -import org.apache.lucene.document.FieldSelectorResult; -import org.apache.lucene.document.NumericField; -import org.apache.lucene.index.FieldInfo; -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.IndexWriter; -import org.apache.lucene.index.Term; -import org.apache.lucene.index.TermDocs; -import org.apache.lucene.index.TermEnum; -import org.apache.lucene.index.TermFreqVector; -import org.apache.lucene.queryParser.ParseException; -import org.apache.lucene.queryParser.QueryParser; -import org.apache.lucene.search.BooleanQuery; -import org.apache.lucene.search.Collector; -import org.apache.lucene.search.DocIdSet; -import org.apache.lucene.search.DocIdSetIterator; -import org.apache.lucene.search.Filter; -import org.apache.lucene.search.FilteredQuery; -import org.apache.lucene.search.IndexSearcher; -import org.apache.lucene.search.MultiTermQuery; -import org.apache.lucene.search.Query; -import org.apache.lucene.search.ScoreDoc; -import org.apache.lucene.search.Scorer; -import org.apache.lucene.search.TermQuery; -import org.apache.lucene.search.TopScoreDocCollector; -import org.apache.lucene.util.BitVector; -import org.apache.lucene.util.NumericUtils; -import org.apache.lucene.util.OpenBitSet; -import org.apache.lucene.util.ReaderUtil; -import org.apache.lucene.util.Version; - +import org.apache.lucene.document.*; +import org.apache.lucene.index.*; +import org.apache.lucene.queryparser.classic.ParseException; +import org.apache.lucene.queryparser.classic.QueryParser; +import org.apache.lucene.search.*; +import org.apache.lucene.util.*; import org.exist.collections.Collection; -import org.exist.dom.AttrImpl; -import org.exist.dom.CharacterDataImpl; -import org.exist.dom.DocumentImpl; -import org.exist.dom.DocumentSet; -import org.exist.dom.ElementImpl; -import org.exist.dom.Match; -import org.exist.dom.NewArrayNodeSet; -import org.exist.dom.NodeProxy; -import org.exist.dom.NodeSet; -import org.exist.dom.QName; -import org.exist.dom.StoredNode; -import org.exist.dom.SymbolTable; -import org.exist.indexing.AbstractStreamListener; -import org.exist.indexing.IndexController; -import org.exist.indexing.IndexWorker; -import org.exist.indexing.MatchListener; -import org.exist.indexing.OrderedValuesIndex; -import org.exist.indexing.QNamedKeysIndex; -import org.exist.indexing.StreamListener; +import org.exist.dom.*; +import org.exist.indexing.*; import org.exist.indexing.lucene.PlainTextHighlighter.Offset; import org.exist.indexing.lucene.PlainTextIndexConfig.PlainTextDoc; import org.exist.indexing.lucene.PlainTextIndexConfig.PlainTextField; @@ -99,10 +40,7 @@ import org.exist.memtree.NodeImpl; import org.exist.numbering.NodeId; import org.exist.security.PermissionDeniedException; -import org.exist.storage.DBBroker; -import org.exist.storage.ElementValue; -import org.exist.storage.IndexSpec; -import org.exist.storage.NodePath; +import org.exist.storage.*; import org.exist.storage.txn.Txn; import org.exist.util.ByteConversion; import org.exist.util.DatabaseConfigurationException; @@ -110,12 +48,14 @@ import org.exist.xquery.*; import org.exist.xquery.value.IntegerValue; import org.exist.xquery.value.NodeValue; - import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.helpers.AttributesImpl; +import java.io.IOException; +import java.util.*; + /** * Class for handling all Lucene operations. * @@ -129,11 +69,18 @@ public static final String OPTION_LEADING_WILDCARD = "leading-wildcard"; public static final String OPTION_FILTER_REWRITE = "filter-rewrite"; public static final String DEFAULT_OPERATOR_OR = "or"; - + + public static final org.apache.lucene.document.FieldType TYPE_NODE_ID = new org.apache.lucene.document.FieldType(); + static { + TYPE_NODE_ID.setIndexed(true); + TYPE_NODE_ID.setStored(false); + TYPE_NODE_ID.setOmitNorms(true); + TYPE_NODE_ID.setStoreTermVectors(false); + TYPE_NODE_ID.setTokenized(true); + } + static final Logger LOG = Logger.getLogger(LuceneIndexWorker.class); - private static final FieldSelector NODE_FIELD_SELECTOR = new NodeFieldSelector(); - private LuceneIndex index; @SuppressWarnings("unused") @@ -160,10 +107,11 @@ private Analyzer analyzer; - public static final String FIELD_NODE_ID = "nodeId"; public static final String FIELD_DOC_ID = "docId"; public static final String FIELD_DOC_URI = "docUri"; + private final byte[] buf = new byte[1024]; + public LuceneIndexWorker(LuceneIndex parent, DBBroker broker) { this.index = parent; this.broker = broker; @@ -178,6 +126,11 @@ return index.getIndexName(); } + @Override + public QueryRewriter getQueryRewriter(XQueryContext context) { + return null; + } + public Object configure(IndexController controller, NodeList configNodes, Map<String, String> namespaces) throws DatabaseConfigurationException { this.controller = controller; LOG.debug("Configuring lucene index..."); @@ -308,7 +261,9 @@ IndexWriter writer = null; try { writer = index.getWriter(); - Term dt = new Term(FIELD_DOC_ID, NumericUtils.intToPrefixCoded(docId)); + BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_INT); + NumericUtils.intToPrefixCoded(docId, 0, bytes); + Term dt = new Term(FIELD_DOC_ID, bytes); writer.deleteDocuments(dt); } catch (IOException e) { LOG.warn("Error while removing lucene index: " + e.getMessage(), e); @@ -341,7 +296,9 @@ writer = index.getWriter(); for (Iterator<DocumentImpl> i = collection.iterator(broker); i.hasNext(); ) { DocumentImpl doc = i.next(); - Term dt = new Term(FIELD_DOC_ID, NumericUtils.intToPrefixCoded(doc.getDocId())); + BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_INT); + NumericUtils.intToPrefixCoded(doc.getDocId(), 0, bytes); + Term dt = new Term(FIELD_DOC_ID, bytes); writer.deleteDocuments(dt); } } catch (IOException e) { @@ -364,47 +321,42 @@ protected void removeNodes() { if (nodesToRemove == null) return; - IndexReader reader = null; + IndexWriter writer = null; try { - reader = index.getWritingReader(); - Term dt = new Term(FIELD_DOC_ID, NumericUtils.intToPrefixCoded(currentDoc.getDocId())); - TermDocs docsEnum = reader.termDocs(dt); - while (docsEnum.next()) { - Document doc = reader.document(docsEnum.doc()); - NodeId nodeId = readNodeId(doc); - if (nodesToRemove.contains(nodeId)) { - reader.deleteDocument(docsEnum.doc()); - } + writer = index.getWriter(); + + BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_INT); + NumericUtils.intToPrefixCoded(currentDoc.getDocId(), 0, bytes); + Term dt = new Term(FIELD_DOC_ID, bytes); + TermQuery tq = new TermQuery(dt); + for (NodeId nodeId : nodesToRemove) { + // store the node id + int nodeIdLen = nodeId.size(); + byte[] data = new byte[nodeIdLen + 2]; + ByteConversion.shortToByte((short) nodeId.units(), data, 0); + nodeId.serialize(data, 2); + + Term it = new Term(LuceneUtil.FIELD_NODE_ID, new BytesRef(data)); + TermQuery iq = new TermQuery(it); + BooleanQuery q = new BooleanQuery(); + q.add(tq, BooleanClause.Occur.MUST); + q.add(iq, BooleanClause.Occur.MUST); + writer.deleteDocuments(q); } - nodesToRemove = null; } catch (IOException e) { LOG.warn("Error while deleting lucene index entries: " + e.getMessage(), e); } finally { - index.releaseWritingReader(reader); + index.releaseWriter(writer); } } - private class NodeIdFilter extends Filter { - - @Override - public DocIdSet getDocIdSet(IndexReader reader) throws IOException { - LOG.debug("Reader: " + reader.getClass().getName()); - OpenBitSet bits = new OpenBitSet(reader.maxDoc()); - Term dt = new Term(FIELD_DOC_ID, NumericUtils.intToPrefixCoded(currentDoc.getDocId())); - TermDocs docsEnum = reader.termDocs(dt); - while (docsEnum.next()) { - LOG.debug("docsEnum: " + docsEnum.doc()); - Document doc = reader.document(docsEnum.doc()); - NodeId nodeId = readNodeId(doc); - if (nodesToRemove.contains(nodeId)) { - LOG.debug("Removing node " + nodeId); - bits.set(docsEnum.doc()); - } - } - return bits; - } + private NodeId readNodeId(int doc, BinaryDocValues nodeIdValues, BrokerPool pool) { + BytesRef ref = new BytesRef(buf); + nodeIdValues.get(doc, ref); + int units = ByteConversion.byteToShort(ref.bytes, ref.offset); + return pool.getNodeFactory().createFromData(units, ref.bytes, ref.offset + 2); } - + /** * Query the index. Returns a node set containing all matching nodes. Each node * in the node set has a {@link org.exist.indexing.lucene.LuceneIndexWorker.LuceneMatch} @@ -433,7 +385,7 @@ try { searcher = index.getSearcher(); for (QName qname : qnames) { - String field = encodeQName(qname); + String field = LuceneUtil.encodeQName(qname, index.getBrokerPool().getSymbols()); Analyzer analyzer = getAnalyzer(null, qname, context.getBroker(), docs); QueryParser parser = new QueryParser(LuceneIndex.LUCENE_VERSION_IN_USE, field, analyzer); setOptions(options, parser); @@ -506,7 +458,7 @@ try { searcher = index.getSearcher(); for (QName qname : qnames) { - String field = encodeQName(qname); + String field = LuceneUtil.encodeQName(qname, index.getBrokerPool().getSymbols()); analyzer = getAnalyzer(null, qname, context.getBroker(), docs); Query query = queryTranslator.parse(field, queryRoot, analyzer, options); if (query != null) { @@ -543,9 +495,8 @@ private void searchAndProcess(int contextId, QName qname, DocumentSet docs, NodeSet contextSet, NodeSet resultSet, boolean returnAncestor, IndexSearcher searcher, Query query, XQueryWatchDog watchDog) throws IOException, TerminatedException { - LuceneHitCollector collector = new LuceneHitCollector(); + LuceneHitCollector collector = new LuceneHitCollector(qname, query, docs, contextSet, resultSet, returnAncestor, contextId, watchDog); searcher.search(query, collector); - processHits(collector.getDocs(), searcher, contextId, qname, docs, contextSet, resultSet, returnAncestor, query, watchDog); } public NodeSet queryField(XQueryContext context, int contextId, DocumentSet docs, NodeSet contextSet, @@ -568,61 +519,6 @@ } return resultSet; } - - /** - * Process the query results collected from the Lucene index and - * map them to the corresponding XML nodes in eXist. - */ - private void processHits(List<ScoreDoc> hits, IndexSearcher searcher, int contextId, QName qname, DocumentSet docs, NodeSet contextSet, - NodeSet resultSet, boolean returnAncestor, Query query, XQueryWatchDog watchDog) throws TerminatedException { - for (ScoreDoc scoreDoc : hits) { - watchDog.proceed(null); - try { - Document doc = searcher.doc(scoreDoc.doc, NODE_FIELD_SELECTOR); - String fDocId = doc.get(FIELD_DOC_ID); - int docId = Integer.parseInt(fDocId); - DocumentImpl storedDocument = docs.getDoc(docId); - if (storedDocument == null) - continue; - NodeId nodeId = readNodeId(doc); - NodeProxy storedNode = new NodeProxy(storedDocument, nodeId); - if (qname != null) - storedNode.setNodeType(qname.getNameType() == ElementValue.ATTRIBUTE ? Node.ATTRIBUTE_NODE : Node.ELEMENT_NODE); - // if a context set is specified, we can directly check if the - // matching node is a descendant of one of the nodes - // in the context set. - if (contextSet != null) { - int sizeHint = contextSet.getSizeHint(storedDocument); - if (returnAncestor) { - NodeProxy parentNode = contextSet.get(storedNode); - // NodeProxy parentNode = contextSet.parentWithChild(storedNode, false, true, NodeProxy.UNKNOWN_NODE_LEVEL); - if (parentNode != null) { - LuceneMatch match = new LuceneMatch(contextId, nodeId, query); - match.setScore(scoreDoc.score); - parentNode.addMatch(match); - resultSet.add(parentNode, sizeHint); - if (Expression.NO_CONTEXT_ID != contextId) { - parentNode.deepCopyContext(storedNode, contextId); - } else - parentNode.copyContext(storedNode); - } - } else { - LuceneMatch match = new LuceneMatch(contextId, nodeId, query); - match.setScore(scoreDoc.score); - storedNode.addMatch(match); - resultSet.add(storedNode, sizeHint); - } - } else { - LuceneMatch match = new LuceneMatch(contextId, nodeId, query); - match.setScore(scoreDoc.score); - storedNode.addMatch(match); - resultSet.add(storedNode); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - } /** * Add SOLR formatted data to lucene index. @@ -658,12 +554,16 @@ pendingDoc = new Document(); // Set DocId - NumericField fDocId = new NumericField(FIELD_DOC_ID, Field.Store.YES, true); - fDocId.setIntValue(currentDoc.getDocId()); + IntDocValuesField fDocId = new IntDocValuesField(FIELD_DOC_ID, currentDoc.getDocId()); + pendingDoc.add(fDocId); - + + IntField fDocIdIdx = new IntField(FIELD_DOC_ID, currentDoc.getDocId(), Field.Store.NO); + pendingDoc.add(fDocIdIdx); + // For binary documents the doc path needs to be stored - String uri = currentDoc.getURI().toString(); + String uri = currentDoc.getURI().toString(); + Field fDocUri = new Field(FIELD_DOC_URI, uri, Field.Store.YES, Field.Index.NOT_ANALYZED); pendingDoc.add(fDocUri); } @@ -684,19 +584,16 @@ String contentFieldName = field.getName(); Analyzer fieldAnalyzer = (fieldType == null) ? null : fieldType.getAnalyzer(); - - // Extract (document) Boost factor - if (field.getBoost() > 0) { - pendingDoc.setBoost(field.getBoost()); - } // Actual field content ; Store flag can be set in solrField Field contentField = new Field(contentFieldName, field.getData().toString(), store, Field.Index.ANALYZED, Field.TermVector.YES); - - // Set boost value from SOLR config - contentField.setBoost(field.getBoost()); - + + // Extract (document) Boost factor + if (field.getBoost() > 0) { + contentField.setBoost(field.getBoost()); + } + pendingDoc.add(contentField); } } @@ -706,9 +603,6 @@ try { writer = index.getWriter(); - // by default, Lucene only indexes the first 10,000 terms in a field - writer.setMaxFieldLength(Integer.MAX_VALUE); - writer.addDocument(pendingDoc); } catch (IOException e) { LOG.warn("An exception was caught while indexing document: " + e.getMessage(), e); @@ -727,7 +621,7 @@ * @param queryText * @return search report */ - public NodeImpl search(XQueryContext context, List<String> toBeMatchedURIs, String queryText) throws XPathException { + public NodeImpl search(XQueryContext context, final List<String> toBeMatchedURIs, String queryText) throws XPathException { NodeImpl report = null; @@ -737,81 +631,85 @@ searcher = index.getSearcher(); // Get analyzer : to be retrieved from configuration - Analyzer searchAnalyzer = new StandardAnalyzer(Version.LUCENE_29); + final Analyzer searchAnalyzer = new StandardAnalyzer(Version.LUCENE_42); // Setup query Version, default field, analyzer - QueryParser parser = new QueryParser(Version.LUCENE_29, "", searchAnalyzer); - Query query = parser.parse(queryText); + final QueryParser parser = new QueryParser(Version.LUCENE_42, "", searchAnalyzer); + final Query query = parser.parse(queryText); // extract all used fields from query - String[] fields = LuceneUtil.extractFields(query, searcher.getIndexReader()); + final String[] fields = LuceneUtil.extractFields(query, searcher.getIndexReader()); - // Setup collector for results - LuceneHitCollector collector = new LuceneHitCollector(); - - // Perform actual search - searcher.search(query, collector); + final PlainTextHighlighter highlighter = new PlainTextHighlighter(query, searcher.getIndexReader()); - // Retrieve all documents that match the query - List<ScoreDoc> results = collector.getDocsByScore(); - - // reusable attributes - AttributesImpl attribs = null; - - PlainTextHighlighter highlighter = new PlainTextHighlighter(query, searcher.getIndexReader()); - - MemTreeBuilder builder = new MemTreeBuilder(); + final MemTreeBuilder builder = new MemTreeBuilder(); builder.startDocument(); - + // start root element - int nodeNr = builder.startElement("", "results", "results", null); - - BitVector processed = new BitVector(searcher.maxDoc()); - // Process result documents - for (ScoreDoc scoreDoc : results) { - if (processed.get(scoreDoc.doc)) - continue; - processed.set(scoreDoc.doc); - - Document doc = searcher.doc(scoreDoc.doc); - - // Get URI field of document - String fDocUri = doc.get(FIELD_DOC_URI); - - // Get score - float score = scoreDoc.score; - - // Check if document URI has a full match or if a - // document is in a collection - if(isDocumentMatch(fDocUri, toBeMatchedURIs)){ - - // setup attributes - attribs = new AttributesImpl(); - attribs.addAttribute("", "uri", "uri", "CDATA", fDocUri); - attribs.addAttribute("", "score", "score", "CDATA", ""+score); + final int nodeNr = builder.startElement("", "results", "results", null); - // write element and attributes - builder.startElement("", "search", "search", attribs); - for (String field : fields) { - String[] fieldContent = doc.getValues(field); - attribs.clear(); - attribs.addAttribute("", "name", "name", "CDATA", field); - for (String content : fieldContent) { - List<Offset> offsets = highlighter.getOffsets(content, searchAnalyzer); - if (offsets != null) { - builder.startElement("", "field", "field", attribs); - highlighter.highlight(content, offsets, builder); - builder.endElement(); - } - } + // Perform actual search + searcher.search(query, new Collector() { + private Scorer scorer; + private AtomicReader reader; + + @Override + public void setScorer(Scorer scorer) throws IOException { + this.scorer = scorer; + } + + @Override + public void collect(int docNum) throws IOException { + Document doc = reader.document(docNum); + + // Get URI field of document + String fDocUri = doc.get(FIELD_DOC_URI); + + // Get score + float score = scorer.score(); + + // Check if document URI has a full match or if a + // document is in a collection + if(isDocumentMatch(fDocUri, toBeMatchedURIs)){ + + // setup attributes + AttributesImpl attribs = new AttributesImpl(); + attribs.addAttribute("", "uri", "uri", "CDATA", fDocUri); + attribs.addAttribute("", "score", "score", "CDATA", ""+score); + + // write element and attributes + builder.startElement("", "search", "search", attribs); + for (String field : fields) { + String[] fieldContent = doc.getValues(field); + attribs.clear(); + attribs.addAttribute("", "name", "name", "CDATA", field); + for (String content : fieldContent) { + List<Offset> offsets = highlighter.getOffsets(content, searchAnalyzer); + if (offsets != null) { + builder.startElement("", "field", "field", attribs); + highlighter.highlight(content, offsets, builder); + builder.endElement(); + } + } + } + builder.endElement(); + + // clean attributes + attribs.clear(); } - builder.endElement(); + } - // clean attributes - attribs.clear(); - } - } - + @Override + public void setNextReader(AtomicReaderContext atomicReaderContext) throws IOException { + this.reader = atomicReaderContext.reader(); + } + + @Override + public boolean acceptsDocsOutOfOrder() { + return true; + } + }); + // finish root element builder.endElement(); @@ -834,34 +732,50 @@ return report; } - public String getFieldContent(XQueryContext context, int docId, String field) throws IOException { - Term dt = new Term(FIELD_DOC_ID, NumericUtils.intToPrefixCoded(docId)); + public String getFieldContent(int docId, String field) throws IOException { + BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_INT); + NumericUtils.intToPrefixCoded(docId, 0, bytes); + Term dt = new Term(FIELD_DOC_ID, bytes); + IndexReader reader = null; try { reader = index.getReader(); - TermDocs td = reader.termDocs(dt); - if (!td.next()) - return null; - Document doc = reader.document(td.doc()); - td.close(); - return doc.get(field); - + + List<AtomicReaderContext> leaves = reader.leaves(); + for (AtomicReaderContext context : leaves) { + DocsEnum docs = context.reader().termDocsEnum(dt); + if (docs.nextDoc() != DocsEnum.NO_MORE_DOCS) { + Document doc = reader.document(docs.docID()); + return doc.get(field); + } + } } finally { index.releaseReader(reader); } + return null; } public boolean hasIndex(int docId) throws IOException { - Term dt = new Term(FIELD_DOC_ID, NumericUtils.intToPrefixCoded(docId)); - IndexReader reader = null; + BytesRef bytes = new BytesRef(NumericUtils.BUF_SIZE_INT); + NumericUtils.intToPrefixCoded(docId, 0, bytes); + Term dt = new Term(FIELD_DOC_ID, bytes); + + IndexReader reader = null; try { reader = index.getReader(); - TermDocs td = reader.termDocs(dt); - boolean found = td.next(); - td.close(); + + boolean found = false; + List<AtomicReaderContext> leaves = reader.leaves(); + for (AtomicReaderContext context : leaves) { + DocsEnum docs = context.reader().termDocsEnum(dt); + if (docs.nextDoc() != DocsEnum.NO_MORE_DOCS) { + found = true; + break; + } + } return found; } finally { - index.releaseReader(reader); + index.releaseReader(reader); } } @@ -893,56 +807,45 @@ return false; } - private static class LuceneHitCollector extends Collector { + private class LuceneHitCollector extends Collector { - private List<ScoreDoc> docs = new ArrayList<ScoreDoc>(); - private int docBase; private Scorer scorer; - private LuceneHitCollector() { - //Nothing special to do - } + private AtomicReader reader; + private NumericDocValues docIdValues; + private BinaryDocValues nodeIdValues; + private final byte[] buf = new byte[1024]; + private final QName qname; + private final DocumentSet docs; + private final NodeSet contextSet; + private final NodeSet resultSet; + private final boolean returnAncestor; + private final int contextId; + private final Query query; + private final XQueryWatchDog watchdog; - public List<ScoreDoc> getDocs() { - Collections.sort(docs, new Comparator<ScoreDoc>() { - - public int compare(ScoreDoc scoreDoc, ScoreDoc scoreDoc1) { - if (scoreDoc.doc == scoreDoc1.doc) - return 0; - else if (scoreDoc.doc < scoreDoc1.doc) - return -1; - return 1; - } - }); - return docs; + private LuceneHitCollector(QName qname, Query query, DocumentSet docs, NodeSet contextSet, NodeSet resultSet, boolean returnAncestor, + int contextId, XQueryWatchDog watchDog) { + this.qname = qname; + this.docs = docs; + this.contextSet = contextSet; + this.resultSet = resultSet; + this.returnAncestor = returnAncestor; + this.contextId = contextId; + this.query = query; + this.watchdog = watchDog; } - - /** - * Get matching lucene documents by descending score - * @return - */ - public List<ScoreDoc> getDocsByScore() { - Collections.sort(docs, new Comparator<ScoreDoc>() { - public int compare(ScoreDoc scoreDoc, ScoreDoc scoreDoc1) { - if (scoreDoc.score == scoreDoc1.score) - return 0; - else if (scoreDoc.score < scoreDoc1.score) - return 1; - return -1; - } - }); - return docs; - } - @Override public void setScorer(Scorer scorer) throws IOException { this.scorer = scorer; } @Override - public void setNextReader(IndexReader indexReader, int docBase) throws IOException { - this.docBase = docBase; + public void setNextReader(AtomicReaderContext atomicReaderContext) throws IOException { + this.reader = atomicReaderContext.reader(); + this.docIdValues = this.reader.getNumericDocValues(FIELD_DOC_ID); + this.nodeIdValues = this.reader.getBinaryDocValues(LuceneUtil.FIELD_NODE_ID); } @Override @@ -954,20 +857,55 @@ public void collect(int doc) { try { float score = scorer.score(); - docs.add(new ScoreDoc(doc + docBase, score)); + int docId = (int) this.docIdValues.get(doc); + DocumentImpl storedDocument = docs.getDoc(docId); + if (storedDocument == null) + return; + BytesRef ref = new BytesRef(buf); + this.nodeIdValues.get(doc, ref); + int units = ByteConversion.byteToShort(ref.bytes, ref.offset); + NodeId nodeId = index.getBrokerPool().getNodeFactory().createFromData(units, ref.bytes, ref.offset + 2); + //LOG.info("doc: " + docId + "; node: " + nodeId.toString() + "; units: " + units); + + NodeProxy storedNode = new NodeProxy(storedDocument, nodeId); + if (qname != null) + storedNode.setNodeType(qname.getNameType() == ElementValue.ATTRIBUTE ? Node.ATTRIBUTE_NODE : Node.ELEMENT_NODE); + // if a context set is specified, we can directly check if the + // matching node is a descendant of one of the nodes + // in the context set. + if (contextSet != null) { + int sizeHint = contextSet.getSizeHint(storedDocument); + if (returnAncestor) { + NodeProxy parentNode = contextSet.get(storedNode); + // NodeProxy parentNode = contextSet.parentWithChild(storedNode, false, true, NodeProxy.UNKNOWN_NODE_LEVEL); + if (parentNode != null) { + LuceneMatch match = new LuceneMatch(contextId, nodeId, query); + match.setScore(score); + parentNode.addMatch(match); + resultSet.add(parentNode, sizeHint); + if (Expression.NO_CONTEXT_ID != contextId) { + parentNode.deepCopyContext(storedNode, contextId); + } else + parentNode.copyContext(storedNode); + } + } else { + LuceneMatch match = new LuceneMatch(contextId, nodeId, query); + match.setScore(score); + storedNode.addMatch(match); + resultSet.add(storedNode, sizeHint); + } + } else { + LuceneMatch match = new LuceneMatch(contextId, nodeId, query); + match.setScore(score); + storedNode.addMatch(match); + resultSet.add(storedNode); + } } catch (IOException e) { e.printStackTrace(); } } } - private NodeId readNodeId(Document doc) { - byte[] temp = doc.getBinaryValue(FIELD_NODE_ID); - int units = ByteConversion.byteToShort(temp, 0); - return index.getBrokerPool().getNodeFactory() - .createFromData(units, temp, 2); - } - /** * Check index configurations for all collection in the given DocumentSet and return * a list of QNames, which have indexes defined on them. @@ -992,9 +930,9 @@ IndexReader reader = null; try { reader = index.getReader(); - for (FieldInfo info: ReaderUtil.getMergedFieldInfos(reader)) { - if (!FIELD_DOC_ID.equals(info.name)) { - QName name = decodeQName(info.name); + for (FieldInfo info: MultiFields.getMergedFieldInfos(reader)) { + if (!FIELD_DOC_ID.equals(info.name)) { + QName name = LuceneUtil.decodeQName(info.name, index.getBrokerPool().getSymbols()); if (name != null && (qname == null || matchQName(qname, name))) indexes.add(name); } @@ -1058,9 +996,7 @@ IntegerValue vmax = (IntegerValue) hints.get(VALUE_COUNT); max = vmax == null ? Long.MAX_VALUE : vmax.getValue(); } - if (nodes == null || max < Long.MAX_VALUE) - return scanIndexByQName(qnames, docs, nodes, start, end, max); - return scanIndexByNodes(qnames, docs, nodes, start, end, max); + return scanIndexByQName(qnames, docs, nodes, start, end, max); } private Occurrences[] scanIndexByQName(List<QName> qnames, DocumentSet docs, NodeSet nodes, String start, String end, long max) { @@ -1069,59 +1005,61 @@ try { reader = index.getReader(); for (QName qname : qnames) { - String field = encodeQName(qname); - TermEnum terms; - if (start == null) - terms = reader.terms(new Term(field, "")); - else - terms = reader.terms(new Term(field, start)); - if (terms == null) - continue; - Term term; - TermDocs termDocs = reader.termDocs(); - do { - term = terms.term(); - if (term != null && term.field().equals(field)) { + String field = LuceneUtil.encodeQName(qname, index.getBrokerPool().getSymbols()); + List<AtomicReaderContext> leaves = reader.leaves(); + for (AtomicReaderContext context : leaves) { + NumericDocValues docIdValues = context.reader().getNumericDocValues(FIELD_DOC_ID); + BinaryDocValues nodeIdValues = context.reader().getBinaryDocValues(LuceneUtil.FIELD_NODE_ID); + Bits liveDocs = context.reader().getLiveDocs(); + Terms terms = context.reader().terms(field); + if (terms == null) + continue; + TermsEnum termsIter = terms.iterator(null); + if (termsIter.next() == null) { + continue; + } + do { + if (map.size() >= max) { + break; + } + BytesRef ref = termsIter.term(); + String term = ref.utf8ToString(); boolean include = true; if (end != null) { - if (term.text().compareTo(start) > 0) + if (term.compareTo(end) > 0) include = false; - } else if (start != null && !term.text().startsWith(start)) + } else if (start != null && !term.startsWith(start)) include = false; if (include) { - termDocs.seek(term); - while (termDocs.next()) { - if (reader.isDeleted(termDocs.doc())) + DocsEnum docsEnum = termsIter.docs(null, null); + while (docsEnum.nextDoc() != DocsEnum.NO_MORE_DOCS) { + if (liveDocs != null && !liveDocs.get(docsEnum.docID())) { continue; - Document doc = reader.document(termDocs.doc()); - String fDocId = doc.get(FIELD_DOC_ID); - int docId = Integer.parseInt(fDocId); + } + int docId = (int) docIdValues.get(docsEnum.docID()); DocumentImpl storedDocument = docs.getDoc(docId); if (storedDocument == null) continue; NodeId nodeId = null; if (nodes != null) { - // load document to check if the current node is in the passed context set, if any - nodeId = readNodeId(doc); + BytesRef nodeIdRef = new BytesRef(buf); + nodeIdValues.get(docsEnum.docID(), nodeIdRef); + int units = ByteConversion.byteToShort(nodeIdRef.bytes, nodeIdRef.offset); + nodeId = index.getBrokerPool().getNodeFactory().createFromData(units, nodeIdRef.bytes, nodeIdRef.offset + 2); } if (nodeId == null || nodes.get(storedDocument, nodeId) != null) { - Occurrences oc = map.get(term.text()); + Occurrences oc = map.get(term); if (oc == null) { - oc = new Occurrences(term.text()); - map.put(term.text(), oc); + oc = new Occurrences(term); + map.put(term, oc); } oc.addDocument(storedDocument); - oc.addOccurrences(termDocs.freq()); + oc.addOccurrences(docsEnum.freq()); } } - // termDocs.close(); } - } - if (map.size() >= max) - break; - } while (terms.next()); - termDocs.close(); - terms.close(); + } while(termsIter.next() != null); + } } } catch (IOException e) { LOG.warn("Error while scanning lucene index entries: " + e.getMessage(), e); @@ -1132,108 +1070,6 @@ return map.values().toArray(occur); } - private Occurrences[] scanIndexByNodes(List<QName> qnames, DocumentSet docs, NodeSet nodes, String start, String end, long max) { - TreeMap<String, Occurrences> map = new TreeMap<String, Occurrences>(); - - FieldSelector selector = new FieldSelector() { - private static final long serialVersionUID = 3270211696620175721L; - public FieldSelectorResult accept(String field) { - if (field.equals(FIELD_NODE_ID)) - return FieldSelectorResult.LOAD_AND_BREAK; - return FieldSelectorResult.NO_LOAD; - } - }; - IndexSearcher searcher = null; - try { - searcher = index.getSearcher(); - IndexReader reader = searcher.getIndexReader(); - for (Iterator<DocumentImpl> i = docs.getDocumentIterator(); i.hasNext(); ) { - DocumentImpl doc = i.next(); - Query query = new TermQuery(new Term(FIELD_DOC_ID, NumericUtils.intToPrefixCoded(doc.getDocId()))); - DocumentCollector collector = new DocumentCollector(searcher.maxDoc()); - searcher.search(query, collector); - - DocIdSetIterator iter = collector.docs.iterator(); - int next; - while ((next = iter.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) { - NodeId nodeId = null; - if (nodes != null) { - // load document to check if the current node is in the passed context set, if any - Document luceneDoc = searcher.doc(next, selector); - nodeId = readNodeId(luceneDoc); - } - if (nodeId == null || nodes.get(doc, nodeId) != null) { - for (QName qname : qnames) { - String field = encodeQName(qname); - TermFreqVector tfv = reader.getTermFreqVector(next, field); - if (tfv != null) { - String[] terms = tfv.getTerms(); - int[] freq = tfv.getTermFrequencies(); - for (int j = 0; j < terms.length; j++) { - boolean include = true; - if (end != null) { - if (terms[j].compareTo(start) > 0) - include = false; - } else if (start != null && !terms[j].startsWith(start)) - include = false; - if (include) { - Occurrences oc = map.get(terms[j]); - if (oc == null) { - oc = new Occurrences(terms[j]); - map.put(terms[j], oc); - } - oc.addDocument(doc); - oc.addOccurrences(freq[j]); - } - } - } - } - } - } - } - } catch (IOException e) { - LOG.warn("Error while scanning lucene index entries: " + e.getMessage(), e); - } finally { - index.releaseSearcher(searcher); - } - return occurrencesToArray(map); - } - - private Occurrences[] occurrencesToArray(TreeMap<String, Occurrences> map) { - Occurrences[] occur = new Occurrences[map.size()]; - return map.values().toArray(occur); - } - - private static class DocumentCollector extends Collector { - - OpenBitSet docs; - int base = 0; - - private DocumentCollector(int size) { - docs = new OpenBitSet(size); - } - - @Override - public void setScorer(Scorer scorer) throws IOException { - //What to do there ? - } - - @Override - public void collect(int doc) throws IOException { - docs.set(base + doc); - } - - @Override - public void setNextReader(IndexReader indexReader, int base) throws IOException { - this.base = base; - } - - @Override - public boolean acceptsDocsOutOfOrder() { - return true; - } - } - /** * Adds the passed character sequence to the lucene index. We * create one lucene document per XML node, using 2 fields to identify @@ -1280,23 +1116,30 @@ IndexWriter writer = null; try { writer = index.getWriter(); - // by default, Lucene only indexes the first 10,000 terms in a field - writer.setMaxFieldLength(Integer.MAX_VALUE); - NumericField fDocId = new NumericField(FIELD_DOC_ID, Field.Store.YES, true); - Field fNodeId = new Field(FIELD_NODE_ID, new byte [] { 0 }, Field.Store.YES); + // docId and nodeId are stored as doc value + IntDocValuesField fDocId = new IntDocValuesField(FIELD_DOC_ID, 0); + BinaryDocValuesField fNodeId = new BinaryDocValuesField(LuceneUtil.FIELD_NODE_ID, new BytesRef(8)); + ... [truncated message content] |
From: <wol...@us...> - 2013-05-07 20:52:01
|
Revision: 18406 http://sourceforge.net/p/exist/code/18406 Author: wolfgang_m Date: 2013-05-07 20:51:58 +0000 (Tue, 07 May 2013) Log Message: ----------- [ignore] Merge in trunk up to rev 18405. Revision Links: -------------- http://sourceforge.net/p/exist/code/18405 Modified Paths: -------------- branches/rangeindex/eXist.iml branches/rangeindex/eXist.ipr branches/rangeindex/extensions/replication/src/org/exist/replication/jms/publish/JMSMessageSender.java branches/rangeindex/extensions/replication/src/org/exist/replication/jms/publish/ReplicationTrigger.java branches/rangeindex/extensions/replication/src/org/exist/replication/jms/subscribe/MessageReceiverStartupTrigger.java branches/rangeindex/extensions/replication/src/org/exist/replication/shared/ClientParameters.java branches/rangeindex/src/org/exist/xquery/GeneralComparison.java Added Paths: ----------- branches/rangeindex/extensions/replication/src/org/exist/replication/shared/JmsConnectionHelper.java Property Changed: ---------------- branches/rangeindex/extensions/replication/ Modified: branches/rangeindex/eXist.iml =================================================================== --- branches/rangeindex/eXist.iml 2013-05-07 20:45:38 UTC (rev 18405) +++ branches/rangeindex/eXist.iml 2013-05-07 20:51:58 UTC (rev 18406) @@ -19,6 +19,7 @@ <sourceFolder url="file://$MODULE_DIR$/tools/izpack/src" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/tools/requestlog/src" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/tools/wrapper/src" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/extensions/indexes/range/src" isTestSource="false" /> <excludeFolder url="file://$MODULE_DIR$/extensions/modules/src/org/exist/xquery/modules/cqlparser" /> <excludeFolder url="file://$MODULE_DIR$/extensions/modules/src/org/exist/xquery/modules/jfreechart" /> <excludeFolder url="file://$MODULE_DIR$/extensions/modules/src/org/exist/xquery/modules/memcached" /> @@ -26,17 +27,13 @@ <excludeFolder url="file://$MODULE_DIR$/extensions/modules/src/org/exist/xquery/modules/xmlcalabash" /> <excludeFolder url="file://$MODULE_DIR$/extensions/modules/src/org/exist/xquery/modules/xmpp" /> <excludeFolder url="file://$MODULE_DIR$/extensions/modules/src/org/exist/xquery/modules/xslfo" /> - <excludeFolder url="file://$MODULE_DIR$/test/junit" /> - <excludeFolder url="file://$MODULE_DIR$/test/temp" /> <excludeFolder url="file://$MODULE_DIR$/tools/jetty/logs" /> <excludeFolder url="file://$MODULE_DIR$/tools/jetty/work" /> <excludeFolder url="file://$MODULE_DIR$/webapp/WEB-INF/data" /> <excludeFolder url="file://$MODULE_DIR$/webapp/WEB-INF/logs" /> </content> - <orderEntry type="jdk" jdkName="1.6" jdkType="JavaSDK" /> + <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> - <orderEntry type="library" exported="" name="optional libs" level="project" /> - <orderEntry type="library" exported="" name="core libs" level="project" /> <orderEntry type="library" exported="" name="tools" level="project" /> <orderEntry type="library" exported="" name="core" level="project" /> <orderEntry type="library" exported="" name="optional" level="project" /> Modified: branches/rangeindex/eXist.ipr =================================================================== --- branches/rangeindex/eXist.ipr 2013-05-07 20:45:38 UTC (rev 18405) +++ branches/rangeindex/eXist.ipr 2013-05-07 20:51:58 UTC (rev 18406) @@ -1,30 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> <component name="AntConfiguration"> - <defaultAnt bundledAnt="true" /> <buildFile url="file://$PROJECT_DIR$/build.xml"> - <additionalClassPath /> - <antReference projectDefault="true" /> <customJdkName value="1.6" /> - <maximumHeapSize value="128" /> <maximumStackSize value="32" /> - <properties /> </buildFile> <buildFile url="file://$PROJECT_DIR$/test/src/ant/build.xml"> - <additionalClassPath /> - <antReference projectDefault="true" /> <customJdkName value="1.5" /> - <maximumHeapSize value="128" /> <maximumStackSize value="32" /> - <properties /> </buildFile> <buildFile url="file://$PROJECT_DIR$/extensions/xprocxq/main/build.xml"> - <additionalClassPath /> - <antReference projectDefault="true" /> <customJdkName value="1.5" /> - <maximumHeapSize value="128" /> <maximumStackSize value="32" /> - <properties /> </buildFile> </component> <component name="BuildJarProjectSettings"> @@ -116,23 +103,8 @@ <option name="OPEN_IN_BROWSER" value="false" /> <option name="OUTPUT_DIRECTORY" /> </component> - <component name="FacetAutodetectingManager"> - <autodetection-disabled> - <facet-type id="android" /> - <facet-type id="JRailsFacetType" /> - <facet-type id="JRUBY" /> - <facet-type id="RailsFacetType" /> - <facet-type id="web"> - <modules> - <module name="eXist"> - <files> - <file url="file://$PROJECT_DIR$/tools/jetty/etc/standalone/WEB-INF/web.xml" /> - <file url="file://$PROJECT_DIR$/webapp/WEB-INF/web.xml" /> - </files> - </module> - </modules> - </facet-type> - </autodetection-disabled> + <component name="GradleSettings"> + <option name="gradleHome" value="$USER_HOME$/Apps/gradle" /> </component> <component name="IdProvider" IDEtalkID="EDCB317F9C51C9BBC9F54E158B17D480" /> <component name="JavacSettings"> @@ -354,14 +326,6 @@ <JAVADOC /> <SOURCES /> </library> - <library name="cocoon"> - <CLASSES> - <root url="file://$PROJECT_DIR$/lib/cocoon" /> - </CLASSES> - <JAVADOC /> - <SOURCES /> - <jarDirectory url="file://$PROJECT_DIR$/lib/cocoon" recursive="false" /> - </library> <library name="core"> <CLASSES> <root url="file://$PROJECT_DIR$/lib/core" /> @@ -375,9 +339,7 @@ <root url="file://$PROJECT_DIR$/lib/endorsed" /> </CLASSES> <JAVADOC /> - <SOURCES> - <root url="file://$USER_HOME$/Applications/xerces-2_9_1/src" /> - </SOURCES> + <SOURCES /> <jarDirectory url="file://$PROJECT_DIR$/lib/endorsed" recursive="false" /> </library> <library name="exquery-core"> @@ -404,12 +366,14 @@ <root url="file://$PROJECT_DIR$/extensions/indexes/lucene/lib" /> <root url="file://$PROJECT_DIR$/lib/extensions" /> <root url="file://$PROJECT_DIR$/extensions/xqdoc/lib" /> + <root url="file://$PROJECT_DIR$/extensions/webdav/lib" /> </CLASSES> <JAVADOC /> <SOURCES /> <jarDirectory url="file://$PROJECT_DIR$/extensions/fluent/lib" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/extensions/indexes/lucene/lib" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/extensions/indexes/spatial/lib" recursive="false" /> + <jarDirectory url="file://$PROJECT_DIR$/extensions/webdav/lib" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/extensions/xqdoc/lib" recursive="false" /> <jarDirectory url="file://$PROJECT_DIR$/lib/extensions" recursive="false" /> </library> Index: branches/rangeindex/extensions/replication =================================================================== --- branches/rangeindex/extensions/replication 2013-05-07 20:45:38 UTC (rev 18405) +++ branches/rangeindex/extensions/replication 2013-05-07 20:51:58 UTC (rev 18406) Property changes on: branches/rangeindex/extensions/replication ___________________________________________________________________ Modified: svn:mergeinfo ## -3,5 +3,5 ## /branches/adam/security-locking/extensions/replication:15302-15345 /branches/dizzzz/xquery3/extensions/replication:15611-15682 /branches/jmfg/res64-eXist/extensions/replication:12887-13224 -/trunk/eXist/extensions/replication:16258-16404,16406-16525,16527-16538,16540-16631,16633-16715 +/trunk/eXist/extensions/replication:16258-16404,16406-16525,16527-16538,16540-16631,16633-16715,18392-18405 /trunk/eXist/nbproject/extensions/replication:8007-14504 \ No newline at end of property Modified: branches/rangeindex/extensions/replication/src/org/exist/replication/jms/publish/JMSMessageSender.java =================================================================== --- branches/rangeindex/extensions/replication/src/org/exist/replication/jms/publish/JMSMessageSender.java 2013-05-07 20:45:38 UTC (rev 18405) +++ branches/rangeindex/extensions/replication/src/org/exist/replication/jms/publish/JMSMessageSender.java 2013-05-07 20:51:58 UTC (rev 18406) @@ -29,6 +29,7 @@ import javax.naming.InitialContext; import javax.naming.NamingException; import org.apache.log4j.Logger; +import org.exist.replication.shared.JmsConnectionHelper; import org.exist.replication.shared.MessageSender; import org.exist.replication.shared.TransportException; import org.exist.replication.shared.eXistMessage; @@ -123,11 +124,14 @@ context = new InitialContext(contextProps); // Lookup connection factory - ConnectionFactory cf = (ConnectionFactory) context.lookup(parameters.getConnectionFactory()); + ConnectionFactory cf = (ConnectionFactory) context.lookup(parameters.getConnectionFactory()); + + // Set specific properties on the connection factory + JmsConnectionHelper.configureConnectionFactory(cf, parameters); // Setup connection connection = cf.createConnection(); - + // Set clientId if present String clientId = parameters.getClientId(); if (clientId != null) { @@ -197,14 +201,9 @@ } } - // Send message producer.send(message); - // Close connection - // DW: connection could be re-used? - //connection.close(); - if(LOG.isDebugEnabled()){ LOG.debug("Message sent with id '" + message.getJMSMessageID() + "'"); } Modified: branches/rangeindex/extensions/replication/src/org/exist/replication/jms/publish/ReplicationTrigger.java =================================================================== --- branches/rangeindex/extensions/replication/src/org/exist/replication/jms/publish/ReplicationTrigger.java 2013-05-07 20:45:38 UTC (rev 18405) +++ branches/rangeindex/extensions/replication/src/org/exist/replication/jms/publish/ReplicationTrigger.java 2013-05-07 20:51:58 UTC (rev 18406) @@ -53,7 +53,7 @@ // Document Triggers // private void afterUpdateCreateDocument(DBBroker broker, Txn transaction, - DocumentImpl document, eXistMessage.ResourceOperation operation) throws TriggerException { + DocumentImpl document, eXistMessage.ResourceOperation operation) /* throws TriggerException */ { if (LOG.isDebugEnabled()) { LOG.debug(document.getURI().toString()); @@ -77,11 +77,12 @@ // Serialize document try { - msg.setPayload(MessageHelper.serialize(broker, document)); + msg.setPayload(MessageHelper.gzipSerialize(broker, document)); - } catch (IOException ex) { - LOG.error(ex); - throw new TriggerException("Unable to retrieve message payload: " + ex.getMessage()); + } catch (Throwable ex) { + LOG.error("Problem while serializing document (contentLength=" + + document.getContentLength() + ") to compressed message:" + ex.getMessage(), ex); + //throw new TriggerException("Unable to retrieve message payload: " + ex.getMessage()); } // Send Message @@ -172,6 +173,7 @@ @Override public void afterCreateCollection(DBBroker broker, Txn transaction, Collection collection) throws TriggerException { + if (LOG.isDebugEnabled()) { LOG.debug(collection.getURI().toString()); } @@ -283,7 +285,7 @@ * Send 'trigger' message with parameters set using * {@link #configure(org.exist.storage.DBBroker, org.exist.collections.Collection, java.util.Map)} */ - private void sendMessage(eXistMessage msg) throws TriggerException { + private void sendMessage(eXistMessage msg) /* throws TriggerException */ { // Send Message JMSMessageSender sender = new JMSMessageSender(parameters); try { @@ -291,7 +293,11 @@ } catch (TransportException ex) { LOG.error(ex.getMessage(), ex); - throw new TriggerException(ex.getMessage(), ex); + //throw new TriggerException(ex.getMessage(), ex); + + } catch (Throwable ex) { + LOG.error(ex.getMessage(), ex); + //throw new TriggerException(ex.getMessage(), ex); } } Modified: branches/rangeindex/extensions/replication/src/org/exist/replication/jms/subscribe/MessageReceiverStartupTrigger.java =================================================================== --- branches/rangeindex/extensions/replication/src/org/exist/replication/jms/subscribe/MessageReceiverStartupTrigger.java 2013-05-07 20:45:38 UTC (rev 18405) +++ branches/rangeindex/extensions/replication/src/org/exist/replication/jms/subscribe/MessageReceiverStartupTrigger.java 2013-05-07 20:51:58 UTC (rev 18406) @@ -30,6 +30,7 @@ import javax.naming.NamingException; import org.apache.log4j.Logger; import org.exist.replication.shared.JmsConnectionExceptionListener; +import org.exist.replication.shared.JmsConnectionHelper; import org.exist.storage.DBBroker; import org.exist.storage.StartupTrigger; @@ -121,11 +122,14 @@ if (!(destination instanceof Topic)) { String errorText = "'" + parameters.getTopic() + "' is not a Topic."; LOG.error(errorText); - throw new Exception(errorText); + throw new Exception(errorText); //TODO better exception? } // Lookup connection factory ConnectionFactory cf = (ConnectionFactory) context.lookup(parameters.getConnectionFactory()); + + // Set specific properties on the connection factory + JmsConnectionHelper.configureConnectionFactory(cf, parameters); // Setup connection connection = cf.createConnection(); Modified: branches/rangeindex/extensions/replication/src/org/exist/replication/shared/ClientParameters.java =================================================================== --- branches/rangeindex/extensions/replication/src/org/exist/replication/shared/ClientParameters.java 2013-05-07 20:45:38 UTC (rev 18405) +++ branches/rangeindex/extensions/replication/src/org/exist/replication/shared/ClientParameters.java 2013-05-07 20:51:58 UTC (rev 18406) @@ -38,6 +38,7 @@ public static final String CONNECTION_FACTORY = "connectionfactory"; public static final String TOPIC = "topic"; public static final String CLIENT_ID = "client-id"; + public static final String PARAMETER_GROUPING = ".."; protected String connectionFactory = null; protected String clientId = null; @@ -138,7 +139,8 @@ /** * Retrieve initial context properties, e.g. {@link Context.INITIAL_CONTEXT_FACTORY} - * and {@link Context.PROVIDER_URL} + * and {@link Context.PROVIDER_URL}. Only properties with key starting with + * ".java" are added to the result. */ public Properties getInitialContextProps(){ Properties contextProps = new Properties(); @@ -181,4 +183,12 @@ return providerUrl; } + public String getParameterValue(String key){ + return props.getProperty(key); + } + + public String getParameterValue(String group, String key){ + return props.getProperty(group + PARAMETER_GROUPING + key); + } + } Modified: branches/rangeindex/src/org/exist/xquery/GeneralComparison.java =================================================================== --- branches/rangeindex/src/org/exist/xquery/GeneralComparison.java 2013-05-07 20:45:38 UTC (rev 18405) +++ branches/rangeindex/src/org/exist/xquery/GeneralComparison.java 2013-05-07 20:51:58 UTC (rev 18406) @@ -284,13 +284,18 @@ */ public int getDependencies() { + final Expression left = getLeft(); + + // variable dependencies should be reported to caller, so remember them here + final int deps = left.getDependencies() & Dependency.VARS; + // left expression returns node set - if( Type.subTypeOf( getLeft().returnsType(), Type.NODE ) && + if( Type.subTypeOf( left.returnsType(), Type.NODE ) && // and does not depend on the context item - !Dependency.dependsOn( getLeft(), Dependency.CONTEXT_ITEM ) && ( !inWhereClause || !Dependency.dependsOn( getLeft(), Dependency.CONTEXT_VARS ) ) ) { - return( Dependency.CONTEXT_SET ); + !Dependency.dependsOn( left, Dependency.CONTEXT_ITEM ) && ( !inWhereClause || !Dependency.dependsOn( left, Dependency.CONTEXT_VARS ) ) ) { + return( deps + Dependency.CONTEXT_SET ); } else { - return( Dependency.CONTEXT_SET + Dependency.CONTEXT_ITEM ); + return ( deps + Dependency.CONTEXT_SET + Dependency.CONTEXT_ITEM ); } } |
From: <sha...@us...> - 2013-07-04 08:15:08
|
Revision: 18647 http://sourceforge.net/p/exist/code/18647 Author: shabanovd Date: 2013-07-04 08:15:00 +0000 (Thu, 04 Jul 2013) Log Message: ----------- [ignore] merge trunk up to rev 18646 Revision Links: -------------- http://sourceforge.net/p/exist/code/18646 Modified Paths: -------------- branches/rangeindex/.classpath branches/rangeindex/build/scripts/build-impl.xml branches/rangeindex/build/scripts/dist.xml branches/rangeindex/build/scripts/installer.xml branches/rangeindex/conf.xml.tmpl branches/rangeindex/extensions/betterform/build.xml branches/rangeindex/extensions/betterform/main/lib/betterform.jar branches/rangeindex/extensions/betterform/main/webapp/WEB-INF/betterform-config.xml branches/rangeindex/extensions/betterform/main/webapp/WEB-INF/betterform-version.info branches/rangeindex/extensions/build.properties branches/rangeindex/extensions/contentextraction/ivy.xml branches/rangeindex/extensions/expath/src/org/expath/exist/SendRequestFunction.java branches/rangeindex/extensions/exquery/lib/exquery-annotations-common-1.0-SNAPSHOT.jar branches/rangeindex/extensions/exquery/lib/exquery-annotations-common-api-1.0-SNAPSHOT.jar branches/rangeindex/extensions/exquery/lib/exquery-common-1.0-SNAPSHOT.jar branches/rangeindex/extensions/exquery/lib/exquery-serialization-annotations-1.0-SNAPSHOT.jar branches/rangeindex/extensions/exquery/lib/exquery-serialization-annotations-api-1.0-SNAPSHOT.jar branches/rangeindex/extensions/exquery/lib/exquery-xquery-1.0-SNAPSHOT.jar branches/rangeindex/extensions/exquery/lib/exquery-xquery3-1.0-SNAPSHOT.jar branches/rangeindex/extensions/exquery/restxq/lib/exquery-restxq-1.0-SNAPSHOT.jar branches/rangeindex/extensions/exquery/restxq/lib/exquery-restxq-api-1.0-SNAPSHOT.jar branches/rangeindex/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqServiceImpl.java branches/rangeindex/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqServiceSerializerImpl.java branches/rangeindex/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqTrigger.java branches/rangeindex/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/adapters/HttpServletRequestAdapter.java branches/rangeindex/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/xquery/RegistryFunctions.java branches/rangeindex/extensions/fluent/src/org/exist/fluent/Database.java branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/AnalyzerConfig.java branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneConfig.java branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java branches/rangeindex/extensions/indexes/lucene/src/org/exist/xquery/modules/lucene/Index.java branches/rangeindex/extensions/metadata/interface/extension.xml branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/MetaData.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/Metas.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/Check.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/DocumentByPair.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/DocumentByUUID.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/Keys.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/MetadataModule.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/PairDelete.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/PairGet.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/PairSet.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/UUID.java branches/rangeindex/extensions/metadata/interface/src/test/java/org/exist/storage/md/BackupRestoreMDTest.java branches/rangeindex/extensions/metadata/interface/src/test/java/org/exist/storage/md/MatchDocumentsTest.java branches/rangeindex/extensions/metadata/interface/src/test/java/org/exist/storage/md/SimpleMDTest.java branches/rangeindex/extensions/metadata/sleepycat/extension.xml branches/rangeindex/extensions/metadata/sleepycat/src/main/java/org/exist/storage/md/MetaDataImpl.java branches/rangeindex/extensions/metadata/sleepycat/src/main/java/org/exist/storage/md/MetaImpl.java branches/rangeindex/extensions/metadata/sleepycat/src/main/java/org/exist/storage/md/MetasImpl.java branches/rangeindex/extensions/modules/build.xml branches/rangeindex/extensions/modules/src/org/exist/xquery/modules/expathrepo/Deploy.java branches/rangeindex/extensions/modules/src/org/exist/xquery/modules/file/SerializeToFile.java branches/rangeindex/extensions/modules/src/org/exist/xquery/modules/httpclient/BaseHTTPClientFunction.java branches/rangeindex/extensions/modules/src/org/exist/xquery/modules/httpclient/ClearFunction.java branches/rangeindex/extensions/modules/src/org/exist/xquery/modules/jfreechart/JFreeChartFactory.java branches/rangeindex/extensions/modules/src/org/exist/xquery/modules/jfreechart/JFreeCharting.java branches/rangeindex/extensions/modules/src/org/exist/xquery/modules/xmlcalabash/readme.txt branches/rangeindex/extensions/replication/src/org/exist/replication/jms/publish/JMSMessageSender.java branches/rangeindex/extensions/replication/src/org/exist/replication/jms/publish/ReplicationTrigger.java branches/rangeindex/extensions/replication/src/org/exist/replication/shared/eXistMessage.java branches/rangeindex/installer/install.xml.tmpl branches/rangeindex/installer/install.xsl branches/rangeindex/installer/vm.properties branches/rangeindex/nbproject/build-impl.xml branches/rangeindex/nbproject/genfiles.properties branches/rangeindex/nbproject/project.properties branches/rangeindex/schema/collection.xconf.xsd branches/rangeindex/src/org/exist/atom/http/AtomServlet.java branches/rangeindex/src/org/exist/client/ClientFrame.java branches/rangeindex/src/org/exist/client/ConnectionDialog.java branches/rangeindex/src/org/exist/client/InteractiveClient.java branches/rangeindex/src/org/exist/client/QueryDialog.java branches/rangeindex/src/org/exist/client/security/AccessControlEntryDialog.form branches/rangeindex/src/org/exist/client/security/AccessControlEntryDialog.java branches/rangeindex/src/org/exist/client/security/EditPropertiesDialog.form branches/rangeindex/src/org/exist/client/security/EditPropertiesDialog.java branches/rangeindex/src/org/exist/client/security/EditUserDialog.java branches/rangeindex/src/org/exist/client/security/UserDialog.java branches/rangeindex/src/org/exist/client/security/UserManagerDialog.java branches/rangeindex/src/org/exist/collections/triggers/XQueryTrigger.java branches/rangeindex/src/org/exist/config/Configurator.java branches/rangeindex/src/org/exist/dom/NodeImpl.java branches/rangeindex/src/org/exist/dom/NodeProxy.java branches/rangeindex/src/org/exist/http/RESTServer.java branches/rangeindex/src/org/exist/http/servlets/XQueryServlet.java branches/rangeindex/src/org/exist/http/urlrewrite/Forward.java branches/rangeindex/src/org/exist/http/urlrewrite/XQueryURLRewrite.java branches/rangeindex/src/org/exist/interpreter/Context.java branches/rangeindex/src/org/exist/launcher/Launcher.java branches/rangeindex/src/org/exist/launcher/LauncherWrapper.java branches/rangeindex/src/org/exist/launcher/UtilityPanel.java branches/rangeindex/src/org/exist/launcher/browsing.png branches/rangeindex/src/org/exist/launcher/dashboard.png branches/rangeindex/src/org/exist/launcher/exide.png branches/rangeindex/src/org/exist/launcher/vm.properties branches/rangeindex/src/org/exist/repo/Deployment.java branches/rangeindex/src/org/exist/repo/PackageLoader.java branches/rangeindex/src/org/exist/scheduler/UserXQueryJob.java branches/rangeindex/src/org/exist/security/AbstractAccount.java branches/rangeindex/src/org/exist/security/AbstractPrincipal.java branches/rangeindex/src/org/exist/security/AbstractRealm.java branches/rangeindex/src/org/exist/security/internal/Password.java branches/rangeindex/src/org/exist/security/internal/SecurityManagerImpl.java branches/rangeindex/src/org/exist/soap/Session.java branches/rangeindex/src/org/exist/storage/BrokerFactory.java branches/rangeindex/src/org/exist/storage/BrokerPool.java branches/rangeindex/src/org/exist/storage/NativeBroker.java branches/rangeindex/src/org/exist/storage/btree/BTree.java branches/rangeindex/src/org/exist/storage/journal/FileSyncThread.java branches/rangeindex/src/org/exist/storage/journal/Journal.java branches/rangeindex/src/org/exist/storage/recovery/RecoveryManager.java branches/rangeindex/src/org/exist/util/io/Resource.java branches/rangeindex/src/org/exist/xmlrpc/RpcConnection.java branches/rangeindex/src/org/exist/xmlrpc/XmldbRequestProcessorFactory.java branches/rangeindex/src/org/exist/xquery/DebuggableExpression.java branches/rangeindex/src/org/exist/xquery/DynamicNameCheck.java branches/rangeindex/src/org/exist/xquery/LocationStep.java branches/rangeindex/src/org/exist/xquery/OpOr.java branches/rangeindex/src/org/exist/xquery/Optimizer.java branches/rangeindex/src/org/exist/xquery/Predicate.java branches/rangeindex/src/org/exist/xquery/TryCatchExpression.java branches/rangeindex/src/org/exist/xquery/XQueryContext.java branches/rangeindex/src/org/exist/xquery/functions/fn/FunBaseURI.java branches/rangeindex/src/org/exist/xquery/functions/securitymanager/SecurityManagerModule.java branches/rangeindex/src/org/exist/xquery/functions/system/GetExistHome.java branches/rangeindex/src/org/exist/xquery/functions/util/UUID.java branches/rangeindex/src/org/exist/xquery/lib/xqsuite/xqsuite.xql branches/rangeindex/src/org/exist/xquery/parser/XQuery.g branches/rangeindex/src/org/exist/xquery/parser/XQueryLexer.smap branches/rangeindex/src/org/exist/xquery/parser/XQueryParser.java branches/rangeindex/src/org/exist/xquery/parser/XQueryParser.smap branches/rangeindex/src/org/exist/xquery/parser/XQueryTree.g branches/rangeindex/src/org/exist/xquery/parser/XQueryTreeParser.java branches/rangeindex/src/org/exist/xquery/parser/XQueryTreeParser.smap branches/rangeindex/src/org/exist/xquery/util/DocUtils.java branches/rangeindex/src/org/exist/xquery/value/BinaryValueManager.java branches/rangeindex/test/src/org/exist/ant/AntUnitTestRunner.java branches/rangeindex/test/src/org/exist/storage/CollectionTest.java branches/rangeindex/test/src/org/exist/storage/MoveResourceTest.java branches/rangeindex/test/src/org/exist/storage/StoreBinaryTest.java branches/rangeindex/test/src/org/exist/storage/btree/BTreeTest.java branches/rangeindex/test/src/org/exist/xquery/AllXqueryTests.java branches/rangeindex/test/src/org/exist/xquery/OptimizerTest.java branches/rangeindex/test/src/org/exist/xquery/value/BinaryValueFromInputStreamTest.java branches/rangeindex/test/src/org/exist/xquery/value/MockBinaryValueManager.java branches/rangeindex/test/src/xquery/maps/maps.xql branches/rangeindex/tools/wrapper/bin/exist.sh.in branches/rangeindex/tools/wrapper/conf/wrapper.conf.in branches/rangeindex/tools/wrapper/src/org/exist/wrapper/Main.java branches/rangeindex/vm.properties Added Paths: ----------- branches/rangeindex/build/scripts/macosx.xml branches/rangeindex/eXist.iws branches/rangeindex/extensions/betterform/main/lib/dwr-3.0.RC2.jar branches/rangeindex/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/ExistXqueryRegistry.java branches/rangeindex/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/xquery/exist/ branches/rangeindex/extensions/exquery/restxq/src/test/java/org/exist/extensions/exquery/restxq/impl/ExistXqueryRegistryTest.java branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/analyzers/ branches/rangeindex/extensions/indexes/lucene/test/src/xquery/lucene/analyzers.xql branches/rangeindex/extensions/indexes/lucene/test/src/xquery/lucene/binary.xql branches/rangeindex/extensions/indexes/lucene/test/src/xquery/lucene/suite.xql branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/Reindex.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/Search.java branches/rangeindex/extensions/metadata/interface/src/test/java/org/exist/storage/md/SearchTest.java branches/rangeindex/extensions/metadata/sleepycat/src/main/java/org/exist/indexing/ branches/rangeindex/installer/App_DS_Store branches/rangeindex/installer/VolumeIcon.icns branches/rangeindex/installer/background.png branches/rangeindex/installer/scripts/eXist-db.mac/Contents/Info.plist.tmpl branches/rangeindex/lib/endorsed/saxonhe-9.4.0.7.jar branches/rangeindex/lib/endorsed/xml-resolver-1.2.jar branches/rangeindex/lib/endorsed/xml-resolver-LICENSE.txt branches/rangeindex/lib/endorsed/xml-resolver-NOTICE.txt branches/rangeindex/src/org/exist/launcher/ConfigurationDialog.form branches/rangeindex/src/org/exist/launcher/ConfigurationDialog.java branches/rangeindex/src/org/exist/launcher/ConfigurationUtility.java branches/rangeindex/src/org/exist/launcher/conf.xsl branches/rangeindex/test/src/org/exist/xquery/TestXPathOpOrSpecialCase.java branches/rangeindex/test/src/xquery/last.xql branches/rangeindex/test/src/xquery/suite.xql branches/rangeindex/tools/wrapper/bin/wrapper-windows-x86-64.exe branches/rangeindex/tools/wrapper/lib/wrapper-windows-x86-64.dll branches/rangeindex/tools/wrapper/platformsupport.txt Removed Paths: ------------- branches/rangeindex/eXist.iws branches/rangeindex/extensions/betterform/main/lib/dwr-2.0.5.jar branches/rangeindex/extensions/exquery/restxq/src/test/java/org/exist/extensions/exquery/restxq/impl/RestXqTriggerTest.java branches/rangeindex/installer/scripts/eXist-db.mac/Contents/Info.plist branches/rangeindex/lib/endorsed/resolver-1.2.jar branches/rangeindex/lib/endorsed/resolver-LICENSE.txt branches/rangeindex/lib/endorsed/resolver-NOTICE.txt branches/rangeindex/lib/endorsed/saxonhe-9.2.1.5.jar branches/rangeindex/tools/wrapper/bin/wrapper-aix-ppc-32 branches/rangeindex/tools/wrapper/bin/wrapper-aix-ppc-64 branches/rangeindex/tools/wrapper/bin/wrapper-freebsd-x86-32 branches/rangeindex/tools/wrapper/bin/wrapper-freebsd-x86-64 branches/rangeindex/tools/wrapper/bin/wrapper-hpux-ia-32 branches/rangeindex/tools/wrapper/bin/wrapper-hpux-ia-64 branches/rangeindex/tools/wrapper/bin/wrapper-hpux-parisc-32 branches/rangeindex/tools/wrapper/bin/wrapper-hpux-parisc-64 branches/rangeindex/tools/wrapper/bin/wrapper-linux-armel-32 branches/rangeindex/tools/wrapper/bin/wrapper-linux-armhf-32 branches/rangeindex/tools/wrapper/bin/wrapper-linux-ppc-32 branches/rangeindex/tools/wrapper/bin/wrapper-linux-ppc-64 branches/rangeindex/tools/wrapper/lib/libwrapper-aix-ppc-32.a branches/rangeindex/tools/wrapper/lib/libwrapper-aix-ppc-64.a branches/rangeindex/tools/wrapper/lib/libwrapper-freebsd-x86-32.so branches/rangeindex/tools/wrapper/lib/libwrapper-freebsd-x86-64.so branches/rangeindex/tools/wrapper/lib/libwrapper-hpux-ia-32.so branches/rangeindex/tools/wrapper/lib/libwrapper-hpux-ia-64.so branches/rangeindex/tools/wrapper/lib/libwrapper-hpux-parisc-32.sl branches/rangeindex/tools/wrapper/lib/libwrapper-hpux-parisc-64.sl branches/rangeindex/tools/wrapper/lib/libwrapper-linux-ppc-32.so branches/rangeindex/tools/wrapper/lib/libwrapper-linux-ppc-64.so Property Changed: ---------------- branches/rangeindex/ branches/rangeindex/extensions/indexes/lucene/src/org/exist/xquery/modules/lucene/Index.java branches/rangeindex/extensions/modules/src/org/exist/xquery/modules/httpclient/ClearFunction.java branches/rangeindex/extensions/modules/src/org/exist/xquery/modules/jfreechart/JFreeCharting.java branches/rangeindex/extensions/replication/ branches/rangeindex/src/org/exist/client/ConnectionDialog.java branches/rangeindex/src/org/exist/dom/ branches/rangeindex/src/org/exist/storage/ branches/rangeindex/src/org/exist/storage/NativeBroker.java branches/rangeindex/src/org/exist/storage/btree/ branches/rangeindex/src/org/exist/xquery/DebuggableExpression.java branches/rangeindex/src/org/exist/xquery/LocationStep.java branches/rangeindex/test/src/org/exist/xquery/OptimizerTest.java branches/rangeindex/tools/wrapper/bin/ Index: branches/rangeindex =================================================================== --- branches/rangeindex 2013-07-03 16:06:48 UTC (rev 18646) +++ branches/rangeindex 2013-07-04 08:15:00 UTC (rev 18647) Property changes on: branches/rangeindex ___________________________________________________________________ Modified: svn:mergeinfo ## -4,5 +4,7 ## /branches/adam/security-locking:15302-15345 /branches/dizzzz/xquery3:15611-15682 /branches/jmfg/res64-eXist:12887-13224 +/branches/pbosek/jorsek-official/eXist:18475-18477,18574-18589,18595-18616 /stable/eXist-2.0.x:17695-17697 +/trunk/eXist:18391-18646 /trunk/eXist/nbproject:8007-14504 \ No newline at end of property Modified: branches/rangeindex/.classpath =================================================================== --- branches/rangeindex/.classpath 2013-07-03 16:06:48 UTC (rev 18646) +++ branches/rangeindex/.classpath 2013-07-04 08:15:00 UTC (rev 18647) @@ -37,7 +37,7 @@ <classpathentry kind="lib" path="lib/endorsed/xml-apis-1.4.01.jar"/> <classpathentry kind="lib" path="lib/endorsed/serializer-2.7.1.jar"/> <classpathentry kind="lib" path="lib/endorsed/xercesImpl-2.11.0.jar"/> - <classpathentry kind="lib" path="lib/endorsed/resolver-1.2.jar"/> + <classpathentry kind="lib" path="lib/endorsed/xml-resolver-1.2.jar"/> <classpathentry kind="lib" path="lib/endorsed/xalan-2.7.1.jar"/> <classpathentry kind="lib" path="extensions/fluent/lib/hamcrest-core-1.1.jar"/> <classpathentry kind="lib" path="extensions/fluent/lib/hamcrest-library-1.1.jar"/> @@ -135,7 +135,6 @@ <classpathentry kind="lib" path="lib/optional/commons-lang3-3.1.jar"/> <classpathentry kind="lib" path="tools/aspectj/lib/aspectjrt-1.7.1.jar"/> <classpathentry kind="lib" path="lib/core/quartz-2.1.6.jar"/> - <classpathentry kind="lib" path="lib/endorsed/saxonhe-9.2.1.5.jar"/> <classpathentry kind="lib" path="lib/optional/fluent-hc-4.2.3.jar"/> <classpathentry kind="lib" path="lib/optional/httpclient-4.2.3.jar"/> <classpathentry kind="lib" path="lib/optional/httpclient-cache-4.2.3.jar"/> Modified: branches/rangeindex/build/scripts/build-impl.xml =================================================================== --- branches/rangeindex/build/scripts/build-impl.xml 2013-07-03 16:06:48 UTC (rev 18646) +++ branches/rangeindex/build/scripts/build-impl.xml 2013-07-04 08:15:00 UTC (rev 18647) @@ -143,7 +143,7 @@ <copy file="${basedir}/conf.xml.tmpl" tofile="${basedir}/conf.xml" filtering="true"> <filterset> <filter token="dataDir" value="webapp/WEB-INF/data"/> - <filter token="cacheSize" value="64"/> + <filter token="cacheSize" value="128"/> </filterset> </copy> <copy file="${basedir}/conf.xml.tmpl" tofile="${basedir}/installer/conf.xml" filtering="true"> @@ -329,6 +329,8 @@ <copy todir="${build.classes}/org/exist/launcher"> <fileset dir="${src}/org/exist/launcher"> <include name="**.png"/> + <include name="**.xsl"/> + <include name="**.properties"/> </fileset> </copy> <copy todir="${build.classes}/org/exist/webstart/resources"> Modified: branches/rangeindex/build/scripts/dist.xml =================================================================== --- branches/rangeindex/build/scripts/dist.xml 2013-07-03 16:06:48 UTC (rev 18646) +++ branches/rangeindex/build/scripts/dist.xml 2013-07-04 08:15:00 UTC (rev 18647) @@ -101,6 +101,10 @@ <lib dir="extensions/modules/lib"> <include name="*.jar"/> </lib> + <!-- Include content extraction jars if present --> + <lib dir="extensions/contentextraction/lib"> + <include name="*.jar"/> + </lib> <!-- Add configuration files to WEB-INF --> Modified: branches/rangeindex/build/scripts/installer.xml =================================================================== --- branches/rangeindex/build/scripts/installer.xml 2013-07-03 16:06:48 UTC (rev 18646) +++ branches/rangeindex/build/scripts/installer.xml 2013-07-04 08:15:00 UTC (rev 18647) @@ -3,7 +3,7 @@ <!-- eXist build file : Build installer --> <!-- ======================================================================= --> <!-- $Id$ --> -<project basedir="../.." default="snapshot-installer" name="Build installer"> +<project basedir="../.." default="installer" name="Build installer"> <description>Build installer</description> @@ -38,6 +38,14 @@ <delete dir="${jetty.dir}/work/Jetty__8080__exist"/> <touch file="webapp/WEB-INF/logs/exist.log"/> <touch file="webapp/WEB-INF/logs/xmldb.log"/> + + <copy file="installer/scripts/eXist-db.mac/Contents/Info.plist.tmpl" + tofile="installer/scripts/eXist-db.mac/Contents/Info.plist" filtering="true"> + <filterset> + <filter token="vmoptions" value=""/> + <filter token="classpath" value="$APP_PACKAGE/../start.jar"/> + </filterset> + </copy> </target> <target name="clean-installer-xars-dir" description="Remove installer apps.dir directory"> Modified: branches/rangeindex/conf.xml.tmpl =================================================================== --- branches/rangeindex/conf.xml.tmpl 2013-07-03 16:06:48 UTC (rev 18646) +++ branches/rangeindex/conf.xml.tmpl 2013-07-04 08:15:00 UTC (rev 18647) @@ -782,6 +782,7 @@ <!-- EXQuery Modules --> <!-- RESTXQ --> <module uri="http://exquery.org/ns/restxq" class="org.exist.extensions.exquery.restxq.impl.xquery.RestXqModule"/> + <module uri="http://exquery.org/ns/restxq/exist" class="org.exist.extensions.exquery.restxq.impl.xquery.exist.ExistRestXqModule"/> <!-- Request Module --> <module uri="http://exquery.org/ns/request" class="org.exist.extensions.exquery.modules.request.RequestModule"/> Modified: branches/rangeindex/extensions/betterform/build.xml =================================================================== --- branches/rangeindex/extensions/betterform/build.xml 2013-07-03 16:06:48 UTC (rev 18646) +++ branches/rangeindex/extensions/betterform/build.xml 2013-07-04 08:15:00 UTC (rev 18647) @@ -28,7 +28,7 @@ <sequential> <echo level="info">XSLT Generating @{out}</echo> <java classname="net.sf.saxon.Transform" - classpath="${exist.rootdir}/lib/endorsed/saxonhe-9.2.1.5.jar" + classpath="${exist.rootdir}/lib/endorsed/saxonhe-9.4.0.7.jar" logError="true" output="@{out}" fork="true"> Modified: branches/rangeindex/extensions/betterform/main/lib/betterform.jar =================================================================== (Binary files differ) Modified: branches/rangeindex/extensions/betterform/main/webapp/WEB-INF/betterform-config.xml =================================================================== --- branches/rangeindex/extensions/betterform/main/webapp/WEB-INF/betterform-config.xml 2013-07-03 16:06:48 UTC (rev 18646) +++ branches/rangeindex/extensions/betterform/main/webapp/WEB-INF/betterform-config.xml 2013-07-04 08:15:00 UTC (rev 18647) @@ -1,23 +1,16 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> <!-- ~ Copyright (c) 2012. betterFORM Project - http://www.betterform.de ~ Licensed under the terms of BSD License - --> + --><!-- $Id: betterform-config.xml 3274 2008-07-16 17:01:30Z lasse $ --><betterform-config> -<!-- $Id: betterform-config.xml 3274 2008-07-16 17:01:30Z lasse $ --> -<betterform-config> - <properties> - <property name="xforms.schema" value="XFormsDatatypes11.xsd" - description="XForms Schema holding Simple Type Declarations"/> + <property name="xforms.schema" value="XFormsDatatypes11.xsd" description="XForms Schema holding Simple Type Declarations"/> <property name="initLogging" value="false" description="'true' if logging should be initialized by betterform, false otherwise"/> - <property name="log4j.file" value="WEB-INF/log4j.xml" - description="the location of the log4j configuration file relative to context"/> + <property name="log4j.file" value="WEB-INF/log4j.xml" description="the location of the log4j configuration file relative to context"/> - <property name="defaultRequestEncoding" value="UTF-8" - description="The character encoding to use for the Request if none was set"/> + <property name="defaultRequestEncoding" value="UTF-8" description="The character encoding to use for the Request if none was set"/> <property name="uploadDir" value="upload" description="the name of the upload directory relative to context"/> @@ -31,11 +24,9 @@ description="optional parameter - 'local' or 'remote' operation of betterForm XForms Processor"/> --> - <property name="forms.uri.relative" value="false" - description="use relative pathes for resources in generated UI"/> + <property name="forms.uri.relative" value="false" description="use relative pathes for resources in generated UI"/> - <property name="filter.ignoreResponseBody" value="false" - description="if 'true' XFormsFilter will not check reponse body for XForms markup"/> + <property name="filter.ignoreResponseBody" value="false" description="if 'true' XFormsFilter will not check reponse body for XForms markup"/> <!-- Language selection rules at runtime: @@ -55,10 +46,7 @@ text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,* /*;q=0.5 image/png,* /*;q=0.5 --> - <property name="acceptContentTypePattern" value="application/xhtml\+html" - description="Based on this property, the XFormsFilter decide if should start XForms processing. Value - can be 'all_xml' (WebFactory.ALL_XML_TYPES) to accept all xml content types or a reg - expression to allow only certain ones."/> + <property name="acceptContentTypePattern" value="application/xhtml\+html" description="Based on this property, the XFormsFilter decide if should start XForms processing. Value can be 'all_xml' (WebFactory.ALL_XML_TYPES) to accept all xml content types or a reg expression to allow only certain ones."/> <!-- This property allows to switch the stylesheet compilation on. @@ -146,12 +134,9 @@ <error-messages> <!--todo: i18n structure for messages--> - <message id="default" - value="We're sorry. An unexpected Error occured." - description="Default message. Shouldn't be deleted"/> + <message id="default" value="We're sorry. An unexpected Error occured." description="Default message. Shouldn't be deleted"/> - <message id="session-invalid" - value="Sorry your session expired. Press Reload to start over."/> + <message id="session-invalid" value="Sorry your session expired. Press Reload to start over."/> </error-messages> <!-- @@ -160,13 +145,9 @@ entities and resolve these to the associated filenames. --> <useragents> - <useragent name="html" - processor="de.betterform.agent.web.servlet.PlainHtmlProcessor" - description="request/response-oriented XForms processor without any JavaScript"> + <useragent name="html" processor="de.betterform.agent.web.servlet.PlainHtmlProcessor" description="request/response-oriented XForms processor without any JavaScript"> </useragent> - <useragent name="dojo" - processor="de.betterform.agent.web.flux.FluxProcessor" - description="AJAX-enabled useragent with packed resources for production environments"> + <useragent name="dojo" processor="de.betterform.agent.web.flux.FluxProcessor" description="AJAX-enabled useragent with packed resources for production environments"> </useragent> </useragents> @@ -187,6 +168,7 @@ <uri-resolver scheme="https" class="de.betterform.connector.http.HTTPURIResolver" description="Handler for the https protocol"/> <uri-resolver scheme="xmlrpc" class="de.betterform.connector.xmlrpc.XMLRPCURIResolver" description="Handler for the xmlrpc protocol"/> <uri-resolver scheme="context" class="de.betterform.connector.context.ContextMapResolver" description="Handler for the context protocol"/> + <uri-resolver scheme="exist" class="de.betterform.connector.exist.ExistURIResolver" description="Handler for local eXist-db connections"/> <!-- <uri-resolver scheme="context" class="de.betterform.connector.context.ContextResolver"/> <uri-resolver scheme="contextobject" class="de.betterform.connector.context.ContextObjectResolver"/> @@ -195,9 +177,7 @@ <submission-handler scheme="file" class="de.betterform.connector.file.FileSubmissionHandler"/> <submission-handler scheme="http" class="de.betterform.connector.http.HTTPSubmissionHandler"/> <submission-handler scheme="https" class="de.betterform.connector.http.HTTPSubmissionHandler"/> -<!-- <submission-handler scheme="ant" class="de.betterform.connector.ant.AntSubmissionHandler"/> ---> <!-- HTTPSubmissionHandlerXI evaluates any bf:include within the data to load --> <!-- <submission-handler scheme="http" class="de.betterform.connector.http.HTTPSubmissionHandlerXI"/> @@ -213,6 +193,7 @@ <submission-handler scheme="xslt" class="de.betterform.connector.xslt.XSLTSubmissionHandler"/> <submission-handler scheme="model" class="de.betterform.connector.ModelSubmissionHandler"/> <submission-handler scheme="context" class="de.betterform.connector.context.ContextMapSubmissionHandler"/> + <submission-handler scheme="exist" class="de.betterform.connector.exist.ExistSubmissionHandler"/> <!-- <submission-handler scheme="jms" class="de.betterform.connector.jms.JMSSubmissionHandler"/>--> <!-- These connector types are deprecated. Their usage is strongly discouraged, Modified: branches/rangeindex/extensions/betterform/main/webapp/WEB-INF/betterform-version.info =================================================================== --- branches/rangeindex/extensions/betterform/main/webapp/WEB-INF/betterform-version.info 2013-07-03 16:06:48 UTC (rev 18646) +++ branches/rangeindex/extensions/betterform/main/webapp/WEB-INF/betterform-version.info 2013-07-04 08:15:00 UTC (rev 18647) @@ -1 +1,2 @@ -betterFORM 5.0rc1 - buildNumber:11537 - Timestamp:2012-11-06 15:52:22 +betterFORM 5.0rc3 - buildNumber:11832 - Timestamp:2013-06-06 17:35:40 + Modified: branches/rangeindex/extensions/build.properties =================================================================== --- branches/rangeindex/extensions/build.properties 2013-07-03 16:06:48 UTC (rev 18646) +++ branches/rangeindex/extensions/build.properties 2013-07-04 08:15:00 UTC (rev 18647) @@ -157,7 +157,7 @@ # XML Calabash include.module.xmlcalabash = true -include.module.xmlcalabash.url=http://xmlcalabash.com/download/calabash-0.9.29.zip +include.module.xmlcalabash.url=http://xmlcalabash.com/download/calabash-1.0.9-94.zip # Utility module to compare XML fragments; based on xmlunit include.module.xmldiff = true Modified: branches/rangeindex/extensions/contentextraction/ivy.xml =================================================================== --- branches/rangeindex/extensions/contentextraction/ivy.xml 2013-07-03 16:06:48 UTC (rev 18646) +++ branches/rangeindex/extensions/contentextraction/ivy.xml 2013-07-04 08:15:00 UTC (rev 18647) @@ -6,7 +6,7 @@ <ivy-module version="2.0"> <info organisation="org.exist" module="tika"/> <dependencies> - <dependency org="org.apache.tika" name="tika-parsers" rev="1.2" conf="*->*,!sources,!javadoc"> + <dependency org="org.apache.tika" name="tika-parsers" rev="1.3" conf="*->*,!sources,!javadoc"> <exclude module="jdom"/> <exclude module="slf4j-api"/> <exclude module="commons-codec"/> @@ -16,16 +16,24 @@ <exclude module="poi"/> <exclude module="poi-scratchpad"/> <exclude module="poi-ooxml"/> + <exclude module="xml-apis"/> + <exclude module="xercesImpl"/> + <exclude module="aspectjrt"/> </dependency> <dependency org="org.apache.poi" name="poi" rev="3.9" conf="*->*,!sources,!javadoc"> <exclude module="commons-io"/> <exclude module="commons-logging"/> <exclude module="servlet-api"/> + <exclude module="log4j"/> + <exclude module="commons-codec"/> </dependency> <dependency org="org.apache.poi" name="poi-scratchpad" rev="3.9" conf="*->*,!sources,!javadoc"/> <dependency org="org.apache.poi" name="poi-ooxml" rev="3.9" conf="*->*,!sources,!javadoc"> <exclude module="xml-apis"/> <exclude module="stax"/> + <exclude module="stax-api"/> + <exclude module="log4j"/> + <exclude module="jdom"/> </dependency> <dependency org="org.tukaani" name="xz" rev="1.1" conf="*->*,!sources,!javadoc"/> </dependencies> Modified: branches/rangeindex/extensions/expath/src/org/expath/exist/SendRequestFunction.java =================================================================== --- branches/rangeindex/extensions/expath/src/org/expath/exist/SendRequestFunction.java 2013-07-03 16:06:48 UTC (rev 18646) +++ branches/rangeindex/extensions/expath/src/org/expath/exist/SendRequestFunction.java 2013-07-04 08:15:00 UTC (rev 18647) @@ -39,6 +39,7 @@ import org.exist.xquery.value.Type; import org.expath.httpclient.HttpClientException; import org.expath.httpclient.HttpConnection; +import org.expath.httpclient.HttpCredentials; import org.expath.httpclient.HttpRequest; import org.expath.httpclient.HttpResponse; import org.expath.httpclient.impl.ApacheHttpConnection; @@ -100,12 +101,12 @@ * @param context The Context of the calling XQuery * @param signature The actual signature of the function */ - public SendRequestFunction(XQueryContext context, FunctionSignature signature) { + public SendRequestFunction(final XQueryContext context, final FunctionSignature signature) { super(context, signature); } @Override - public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException { + public Sequence eval(final Sequence[] args, final Sequence contextSequence) throws XPathException { Sequence bodies = Sequence.EMPTY_SEQUENCE; String href = null; @@ -131,13 +132,13 @@ return sendRequest(request, href, bodies); } - private Sequence sendRequest(NodeValue request, String href, Sequence bodies) throws XPathException { + private Sequence sendRequest(final NodeValue request, final String href, final Sequence bodies) throws XPathException { HttpRequest req = null; try { - org.expath.httpclient.model.Sequence b = new EXistSequence(bodies, getContext()); - Element r = new EXistElement(request, getContext()); - RequestParser parser = new RequestParser(); + final org.expath.httpclient.model.Sequence b = new EXistSequence(bodies, getContext()); + final Element r = new EXistElement(request, getContext()); + final RequestParser parser = new RequestParser(); req = parser.parse(r, b, href); // override anyway it href exists @@ -145,13 +146,13 @@ req.setHref(href); } - URI uri = new URI(req.getHref()); - EXistResult result = sendOnce(uri, req, parser); + final URI uri = new URI(req.getHref()); + final EXistResult result = sendOnce(uri, req, parser); return result.getResult(); - } catch(URISyntaxException ex ) { + } catch(final URISyntaxException ex ) { throw new XPathException("Href is not valid: " + req != null ? req.getHref() : "" + ". " + ex.getMessage(), ex); - } catch(HttpClientException hce) { + } catch(final HttpClientException hce) { throw new XPathException(hce.getMessage(), hce); } } @@ -162,29 +163,71 @@ * Authentication may require to reply to an authentication challenge, * by sending again the request, with credentials. */ - private EXistResult sendOnce(URI uri, HttpRequest request, RequestParser parser) throws HttpClientException + private EXistResult sendOnce(final URI uri, final HttpRequest request, final RequestParser parser) throws HttpClientException { - EXistResult result = new EXistResult(getContext()); - HttpConnection conn = new ApacheHttpConnection(uri); + final EXistResult result; - try { - if(parser.getSendAuth()) { - request.send(result, conn, parser.getCredentials()); - } - else { - HttpResponse response = request.send(result, conn, null); + if(parser.getSendAuth()) { + result = sendOnceWithAuth(uri, request, parser.getCredentials()); + } else { + HttpConnection conn = null; + try { + conn = new ApacheHttpConnection(uri); + final EXistResult firstResult = new EXistResult(context); + final HttpResponse response = request.send(firstResult, conn, null); if(response.getStatus() == 401) { conn.disconnect(); - conn = new ApacheHttpConnection(uri); - // create a new result, and throw the old one away - result = new EXistResult(getContext()); - request.send(result, conn, parser.getCredentials()); + result = sendOnceWithAuth(uri, request, parser.getCredentials()); + } else { + result = firstResult; + registerConnectionWithContext(conn); } + } catch(final HttpClientException hce) { + if(conn != null) { + try { + conn.disconnect(); + } catch(final HttpClientException hcee) { + logger.warn(hcee.getMessage(), hcee); + } + } + throw hce; } - } finally { - conn.disconnect(); } return result; } + + private EXistResult sendOnceWithAuth(final URI uri, final HttpRequest request, final HttpCredentials httpCredentials) throws HttpClientException { + final EXistResult result = new EXistResult(getContext()); + HttpConnection conn = null; + try { + conn = new ApacheHttpConnection(uri); + request.send(result, conn, httpCredentials); + registerConnectionWithContext(conn); + } catch(final HttpClientException hce) { + if(conn != null) { + try { + conn.disconnect(); + } catch(final HttpClientException hcee) { + logger.warn(hcee.getMessage(), hcee); + } + } + throw hce; + } + + return result; + } + + private void registerConnectionWithContext(final HttpConnection conn) { + context.registerCleanupTask(new XQueryContext.CleanupTask() { + @Override + public void cleanup(final XQueryContext context) { + try { + conn.disconnect(); + } catch(final HttpClientException hce) { + logger.warn(hce.getMessage(), hce); + } + } + }); + } } \ No newline at end of file Modified: branches/rangeindex/extensions/exquery/lib/exquery-annotations-common-1.0-SNAPSHOT.jar =================================================================== (Binary files differ) Modified: branches/rangeindex/extensions/exquery/lib/exquery-annotations-common-api-1.0-SNAPSHOT.jar =================================================================== (Binary files differ) Modified: branches/rangeindex/extensions/exquery/lib/exquery-common-1.0-SNAPSHOT.jar =================================================================== (Binary files differ) Modified: branches/rangeindex/extensions/exquery/lib/exquery-serialization-annotations-1.0-SNAPSHOT.jar =================================================================== (Binary files differ) Modified: branches/rangeindex/extensions/exquery/lib/exquery-serialization-annotations-api-1.0-SNAPSHOT.jar =================================================================== (Binary files differ) Modified: branches/rangeindex/extensions/exquery/lib/exquery-xquery-1.0-SNAPSHOT.jar =================================================================== (Binary files differ) Modified: branches/rangeindex/extensions/exquery/lib/exquery-xquery3-1.0-SNAPSHOT.jar =================================================================== (Binary files differ) Modified: branches/rangeindex/extensions/exquery/restxq/lib/exquery-restxq-1.0-SNAPSHOT.jar =================================================================== (Binary files differ) Modified: branches/rangeindex/extensions/exquery/restxq/lib/exquery-restxq-api-1.0-SNAPSHOT.jar =================================================================== (Binary files differ) Modified: branches/rangeindex/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqServiceImpl.java =================================================================== --- branches/rangeindex/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqServiceImpl.java 2013-07-03 16:06:48 UTC (rev 18646) +++ branches/rangeindex/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqServiceImpl.java 2013-07-04 08:15:00 UTC (rev 18647) @@ -91,7 +91,7 @@ } @Override - public void cleanupBinaryValueInstances() { + public void runCleanupTasks() { for(final BinaryValue binaryValue : binaryValues) { try { binaryValue.close(); @@ -116,7 +116,7 @@ @Override public void service(final HttpRequest request, final HttpResponse response, final ResourceFunctionExecuter resourceFunctionExecuter, final RestXqServiceSerializer restXqServiceSerializer) throws RestXqServiceException { super.service(request, response, resourceFunctionExecuter, restXqServiceSerializer); - binaryValueManager.cleanupBinaryValueInstances(); + binaryValueManager.runCleanupTasks(); } Modified: branches/rangeindex/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqServiceSerializerImpl.java =================================================================== --- branches/rangeindex/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqServiceSerializerImpl.java 2013-07-03 16:06:48 UTC (rev 18646) +++ branches/rangeindex/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqServiceSerializerImpl.java 2013-07-04 08:15:00 UTC (rev 18647) @@ -154,6 +154,10 @@ if(serializationProperty.getKey() == SerializationProperty.METHOD && serializationProperty.getValue().equals(SupportedMethod.html.name())) { //Map HTML -> HTML5 as eXist doesnt have a html serializer that isnt html5 props.setProperty(serializationProperty.getKey().name().toLowerCase(), SupportedMethod.html5.name()); + } else if(serializationProperty.getKey() == SerializationProperty.OMIT_XML_DECLARATION) { + + //TODO why are not all keys transformed from '_' to '-'? I have a feeling we did something special for MEDIA_TYPE??? + props.setProperty(serializationProperty.getKey().name().toLowerCase().replace('_', '-'), serializationProperty.getValue()); } else { props.setProperty(serializationProperty.getKey().name().toLowerCase(), serializationProperty.getValue()); } Modified: branches/rangeindex/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqTrigger.java =================================================================== --- branches/rangeindex/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqTrigger.java 2013-07-03 16:06:48 UTC (rev 18646) +++ branches/rangeindex/extensions/exquery/restxq/src/main/java/org/exist/extensions/exquery/restxq/impl/RestXqTrigger.java 2013-07-04 08:15:00 UTC (rev 18647) @@ -26,29 +26,16 @@ */ package org.exist.extensions.exquery.restxq.impl; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.*; -import java.util.Map.Entry; +import java.util.List; import org.apache.log4j.Logger; import org.exist.collections.triggers.FilteringTrigger; import org.exist.collections.triggers.TriggerException; -import org.exist.dom.BinaryDocument; import org.exist.dom.DocumentImpl; -import org.exist.security.Permission; -import org.exist.security.PermissionDeniedException; import org.exist.storage.DBBroker; import org.exist.storage.txn.Txn; import org.exist.xmldb.XmldbURI; -import org.exist.xquery.CompiledXQuery; -import org.exist.xquery.ErrorCodes; -import org.exist.xquery.XPathException; -import org.exist.xquery.value.Item; -import org.exist.xquery.value.Sequence; -import org.exist.xquery.value.StringValue; import org.exquery.ExQueryException; import org.exquery.restxq.RestXqService; -import org.exquery.restxq.RestXqServiceRegistry; /** * @@ -58,24 +45,6 @@ protected final static Logger LOG = Logger.getLogger(RestXqTrigger.class); - /** - * Key is XQuery Module URI - * Value is set of XQuery Module URIs on which the Module indicated by the Key depends on - */ - final static Map<String, Set<String>> dependenciesTree = new HashMap<String, Set<String>>(); - - /** - * Key is the missing Module URI - * Value is the Set of XQuery Module URIs that require the missing Module indicated by the Key - */ - final static Map<String, Set<String>> missingDependencies = new HashMap<String, Set<String>>(); - - /** - * The list of XQuerys that could not be compiled - * for reasons other than missing dependencies - */ - final static Set<String> invalidQueries = new HashSet<String>(); - @Override public void prepare(final int event, final DBBroker broker, final Txn transaction, final XmldbURI documentPath, final DocumentImpl existingDocument) throws TriggerException { @@ -144,336 +113,21 @@ } private void before(final DBBroker broker, final DocumentImpl document) { - if(isXquery(document)) { - deregisterServices(broker, document.getURI()); + final ExistXqueryRegistry xqueryRegistry = ExistXqueryRegistry.getInstance(); + if(xqueryRegistry.isXquery(document)) { + xqueryRegistry.deregisterServices(broker, document.getURI()); } } private void after(final DBBroker broker, final DocumentImpl document) throws TriggerException { - if(isXquery(document)) { + final ExistXqueryRegistry xqueryRegistry = ExistXqueryRegistry.getInstance(); + if(xqueryRegistry.isXquery(document)) { try { - final List<RestXqService> services = findServices(broker, document); - registerServices(broker, services); + final List<RestXqService> services = xqueryRegistry.findServices(broker, document); + xqueryRegistry.registerServices(broker, services); } catch(final ExQueryException eqe) { throw new TriggerException(eqe.getMessage(), eqe); } } } - - private boolean isXquery(final DocumentImpl document) { - return document instanceof BinaryDocument && document.getMetadata().getMimeType().equals(XQueryCompiler.XQUERY_MIME_TYPE); - } - - private void registerServices(final DBBroker broker, final List<RestXqService> services) { - getRegistry(broker).register(services); - } - - private void deregisterServices(final DBBroker broker, final XmldbURI xqueryLocation) { - - getRegistry(broker).deregister(xqueryLocation.getURI()); - - //find and remove services from modules that depend on this one - for(final String dependant : getDependants(xqueryLocation)) { - try { - - //TODO This null check is a temporary workaround - //as a NPE in the URI class was reported by Wolf - //where dependant was null. I can only imagine - //that another thread interrupted and removed it - //from the hashmap that it comes from. - //its quite possible the use of synchronized around - //the various maps in this class is not sufficient in scope - //and we should move to some locks and operating over closures - //on the maps. - if(dependant != null) { - getRegistry(broker).deregister(new URI(dependant)); - - //record the now missing dependency - recordMissingDependency(xqueryLocation.toString(), XmldbURI.create(dependant)); - } - } catch(final URISyntaxException urise) { - LOG.error(urise.getMessage(), urise); - } - } - - /* - * update the missingDependencies?? - * Probaly not needed as this will be done in find services - */ - } - - private Set<String> getDependants(final XmldbURI xqueryLocation) { - final Set<String> dependants = new HashSet<String>(); - - //make a copy of the dependenciesTree into depTree - final Map<String, Set<String>> depTree; - synchronized(dependenciesTree) { - depTree = new HashMap<String, Set<String>>(dependenciesTree); - } - - //find all modules that have a dependency on this one - for(final Entry<String, Set<String>> depTreeEntry : depTree.entrySet()) { - for(String dependency : depTreeEntry.getValue()) { - if(dependency.equals(xqueryLocation.toString())) { - dependants.add(depTreeEntry.getKey()); - continue; - } - } - } - return dependants; - } - - private List<RestXqService> findServices(final DBBroker broker, final DocumentImpl document) throws ExQueryException { - - try { - final CompiledXQuery compiled = XQueryCompiler.compile(broker, document); - - /* - * examine the compiled query, record all modules and modules of modules. - * Keep a dependencies list so that we can act on it if a module is deleted. - */ - final Map<String, Set<String>> queryDependenciesTree = XQueryInspector.getDependencies(compiled); - recordQueryDependenciesTree(queryDependenciesTree); - - /* - * A compiled query may be a missing dependency for another query - * so reexamine queries with missing dependencies - */ - reexamineModulesWithResolvedDependencies(broker, document.getURI().toString()); - - /* - * remove any potentially re-compiled query from the - * invalid queries list - */ - removeInvalidQuery(document.getURI()); - - return XQueryInspector.findServices(compiled); - } catch(final RestXqServiceCompilationException rxsce) { - - //if there was a missing dependency then record it - final MissingModuleHint missingModuleHint = extractMissingModuleHint(rxsce); - if(missingModuleHint != null) { - - if(missingModuleHint.dependantModule == null) { - recordMissingDependency(missingModuleHint.moduleHint, document.getURI()); - } else { - //avoids wrong missing dependency dependant being recorded for a complex module tree - try { - recordMissingDependency(missingModuleHint.moduleHint, XmldbURI.xmldbUriFor(missingModuleHint.dependantModule)); - } catch(final URISyntaxException use) { - recordInvalidQuery(document.getURI()); - LOG.error("XQuery '" + document.getURI() + "' could not be compiled! " + rxsce.getMessage()); - } - } - } else { - recordInvalidQuery(document.getURI()); - LOG.error("XQuery '" + document.getURI() + "' could not be compiled! " + rxsce.getMessage()); - } - - /* - * This may be the recompilation of a query - * so we should unregister any of its missing - * services. Luckily this is taken care of in - * the before{EVENT} trigger functions - */ - } - - return new ArrayList<RestXqService>(); - } - - - /** - * Gets the modules that have a missing dependency - * on the module indicated by compiledModuleURI - * and attempts to re-compile them and register their - * services - */ - private void reexamineModulesWithResolvedDependencies(final DBBroker broker, final String compiledModuleUri) { - - final Set<String> dependants; - synchronized(missingDependencies) { - final Set<String> deps = missingDependencies.get(compiledModuleUri); - if(deps != null) { - dependants = new HashSet(deps); - } else { - dependants = new HashSet(); - } - } - - for(final String dependant : dependants) { - - try { - - final DocumentImpl dependantModule = broker.getResource(XmldbURI.create(dependant), Permission.READ); - - /** - * This null check is needed, as a dependency module may have been renamed, - * and so is no longer accessible under its old URI. - * - * However if its dependant module (compiledModuleUri) compiles - * (which it must have for this function to be invoked) - * then we can assume that the dependant module references the new - * module dependency (in the case of a module move/rename) - * or the dependency has been removed - */ - if(dependantModule != null) { - LOG.info("Missing dependency '" + compiledModuleUri +"' has been added to the database, re-examining '" + dependant + "'..."); - - final List<RestXqService> services = findServices(broker, dependantModule); - registerServices(broker, services); - } else { - LOG.info("Dependant '" + compiledModuleUri + "' has been resolved. Dependency on: " + dependant + "was removed"); - - //we need to remove dependant from the dependenciesTree of dependant - removeDependency(dependant, compiledModuleUri); - } - } catch(final PermissionDeniedException pde) { - LOG.error(pde.getMessage(), pde); - } catch(final ExQueryException eqe) { - LOG.error(eqe.getMessage(), eqe); - } - - //remove the resolve dependecies from the missing dependencies - removeMissingDependency(compiledModuleUri, dependant); - } - } - - private void removeMissingDependency(final String dependency, final String dependant) { - synchronized(missingDependencies) { - final Set<String> missingDependants = missingDependencies.get(dependency); - missingDependants.remove(dependant); - if(missingDependants.isEmpty()) { - missingDependencies.remove(dependency); - } - } - } - - private void recordQueryDependenciesTree(final Map<String, Set<String>> queryDependenciesTree) { - synchronized(dependenciesTree) { - //Its not a merge its an ovewrite! - dependenciesTree.putAll(queryDependenciesTree); - } - } - - private void removeInvalidQuery(final XmldbURI xqueryUri) { - synchronized(invalidQueries) { - invalidQueries.remove(xqueryUri.toString()); - } - } - - private void recordInvalidQuery(final XmldbURI xqueryUri) { - synchronized(invalidQueries) { - invalidQueries.add(xqueryUri.toString()); - } - } - - private class MissingModuleHint { - public String moduleHint = null; - public String dependantModule = null; - } - - private MissingModuleHint extractMissingModuleHint(final RestXqServiceCompilationException rxsce) { - - MissingModuleHint missingModuleHint = null; - - if(rxsce.getCause() instanceof XPathException) { - final XPathException xpe = (XPathException)rxsce.getCause(); - if(xpe.getErrorCode() == ErrorCodes.XQST0059) { - final Sequence errorVals = xpe.getErrorVal(); - - if(errorVals != null && errorVals.getItemCount() > 0){ - - final Item errorVal1 = errorVals.itemAt(0); - if(errorVal1 instanceof StringValue) { - if(missingModuleHint == null) { - missingModuleHint = new MissingModuleHint(); - } - missingModuleHint.moduleHint = ((StringValue)errorVal1).getStringValue(); - } - - if(errorVals.getItemCount() == 2) { - final Item errorVal2 = errorVals.itemAt(1); - if(errorVal2 instanceof StringValue) { - if(missingModuleHint == null) { - missingModul... [truncated message content] |
From: <sha...@us...> - 2013-07-07 10:06:36
|
Revision: 18660 http://sourceforge.net/p/exist/code/18660 Author: shabanovd Date: 2013-07-07 10:06:34 +0000 (Sun, 07 Jul 2013) Log Message: ----------- [ignore] update lucene from 4.2.1 to 4.3.1 & add facet jar Modified Paths: -------------- branches/rangeindex/.classpath branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/analyzers/NoDiacriticsStandardAnalyzer.java Added Paths: ----------- branches/rangeindex/extensions/indexes/lucene/lib/lucene-analyzers-common-4.3.1.jar branches/rangeindex/extensions/indexes/lucene/lib/lucene-core-4.3.1.jar branches/rangeindex/extensions/indexes/lucene/lib/lucene-facet-4.3.1.jar branches/rangeindex/extensions/indexes/lucene/lib/lucene-queries-4.3.1.jar branches/rangeindex/extensions/indexes/lucene/lib/lucene-queryparser-4.3.1.jar Removed Paths: ------------- branches/rangeindex/extensions/indexes/lucene/lib/lucene-analyzers-common-4.2.1.jar branches/rangeindex/extensions/indexes/lucene/lib/lucene-core-4.2.1.jar branches/rangeindex/extensions/indexes/lucene/lib/lucene-queries-4.2.1.jar branches/rangeindex/extensions/indexes/lucene/lib/lucene-queryparser-4.2.1.jar Property Changed: ---------------- branches/rangeindex/ Index: branches/rangeindex =================================================================== --- branches/rangeindex 2013-07-07 09:37:39 UTC (rev 18659) +++ branches/rangeindex 2013-07-07 10:06:34 UTC (rev 18660) Property changes on: branches/rangeindex ___________________________________________________________________ Modified: svn:ignore ## -15,3 +15,4 ## .log4j.xml.swp autodeploy backup +.settings Modified: branches/rangeindex/.classpath =================================================================== --- branches/rangeindex/.classpath 2013-07-07 09:37:39 UTC (rev 18659) +++ branches/rangeindex/.classpath 2013-07-07 10:06:34 UTC (rev 18660) @@ -48,8 +48,6 @@ <classpathentry kind="lib" path="lib/core/xmlrpc-client-3.1.3.jar"/> <classpathentry kind="lib" path="lib/core/xmlrpc-common-3.1.3.jar"/> <classpathentry kind="lib" path="lib/core/xmlrpc-server-3.1.3.jar"/> - <classpathentry kind="lib" path="extensions/modules/lib/cssparser-0.9.5.jar"/> - <classpathentry kind="lib" path="extensions/modules/lib/sac-1.3.jar"/> <classpathentry kind="lib" path="extensions/expath/lib/http-client-java-0.3.0.jar"/> <classpathentry kind="lib" path="extensions/exquery/lib/exquery-common-1.0-SNAPSHOT.jar"/> <classpathentry kind="lib" path="extensions/exquery/lib/exquery-annotations-common-api-1.0-SNAPSHOT.jar"/> @@ -107,9 +105,6 @@ <classpathentry kind="lib" path="lib/core/commons-codec-1.7.jar"/> <classpathentry kind="lib" path="lib/core/gnu-crypto-2.0.1-min.jar"/> <classpathentry kind="lib" path="lib/optional/commons-net-2.2.jar"/> - <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-analyzers-3.6.1.jar"/> - <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-core-3.6.1.jar"/> - <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-queries-3.6.1.jar"/> <classpathentry kind="lib" path="tools/jetty/lib/existdb-favicon.jar"/> <classpathentry kind="lib" path="tools/jetty/lib/jetty-continuation-8.1.9.v20130131.jar"/> <classpathentry kind="lib" path="tools/jetty/lib/jetty-http-8.1.9.v20130131.jar"/> @@ -140,5 +135,10 @@ <classpathentry kind="lib" path="lib/optional/httpclient-cache-4.2.3.jar"/> <classpathentry kind="lib" path="lib/optional/httpcore-4.2.2.jar"/> <classpathentry kind="lib" path="lib/optional/httpmime-4.2.3.jar"/> + <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-analyzers-common-4.3.1.jar"/> + <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-core-4.3.1.jar"/> + <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-facet-4.3.1.jar"/> + <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-queries-4.3.1.jar"/> + <classpathentry kind="lib" path="extensions/indexes/lucene/lib/lucene-queryparser-4.3.1.jar"/> <classpathentry kind="output" path="test/classes"/> </classpath> Added: branches/rangeindex/extensions/indexes/lucene/lib/lucene-analyzers-common-4.3.1.jar =================================================================== (Binary files differ) Index: branches/rangeindex/extensions/indexes/lucene/lib/lucene-analyzers-common-4.3.1.jar =================================================================== --- branches/rangeindex/extensions/indexes/lucene/lib/lucene-analyzers-common-4.3.1.jar 2013-07-07 09:37:39 UTC (rev 18659) +++ branches/rangeindex/extensions/indexes/lucene/lib/lucene-analyzers-common-4.3.1.jar 2013-07-07 10:06:34 UTC (rev 18660) Property changes on: branches/rangeindex/extensions/indexes/lucene/lib/lucene-analyzers-common-4.3.1.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/rangeindex/extensions/indexes/lucene/lib/lucene-core-4.3.1.jar =================================================================== (Binary files differ) Index: branches/rangeindex/extensions/indexes/lucene/lib/lucene-core-4.3.1.jar =================================================================== --- branches/rangeindex/extensions/indexes/lucene/lib/lucene-core-4.3.1.jar 2013-07-07 09:37:39 UTC (rev 18659) +++ branches/rangeindex/extensions/indexes/lucene/lib/lucene-core-4.3.1.jar 2013-07-07 10:06:34 UTC (rev 18660) Property changes on: branches/rangeindex/extensions/indexes/lucene/lib/lucene-core-4.3.1.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/rangeindex/extensions/indexes/lucene/lib/lucene-facet-4.3.1.jar =================================================================== (Binary files differ) Index: branches/rangeindex/extensions/indexes/lucene/lib/lucene-facet-4.3.1.jar =================================================================== --- branches/rangeindex/extensions/indexes/lucene/lib/lucene-facet-4.3.1.jar 2013-07-07 09:37:39 UTC (rev 18659) +++ branches/rangeindex/extensions/indexes/lucene/lib/lucene-facet-4.3.1.jar 2013-07-07 10:06:34 UTC (rev 18660) Property changes on: branches/rangeindex/extensions/indexes/lucene/lib/lucene-facet-4.3.1.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/rangeindex/extensions/indexes/lucene/lib/lucene-queries-4.3.1.jar =================================================================== (Binary files differ) Index: branches/rangeindex/extensions/indexes/lucene/lib/lucene-queries-4.3.1.jar =================================================================== --- branches/rangeindex/extensions/indexes/lucene/lib/lucene-queries-4.3.1.jar 2013-07-07 09:37:39 UTC (rev 18659) +++ branches/rangeindex/extensions/indexes/lucene/lib/lucene-queries-4.3.1.jar 2013-07-07 10:06:34 UTC (rev 18660) Property changes on: branches/rangeindex/extensions/indexes/lucene/lib/lucene-queries-4.3.1.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: branches/rangeindex/extensions/indexes/lucene/lib/lucene-queryparser-4.3.1.jar =================================================================== (Binary files differ) Index: branches/rangeindex/extensions/indexes/lucene/lib/lucene-queryparser-4.3.1.jar =================================================================== --- branches/rangeindex/extensions/indexes/lucene/lib/lucene-queryparser-4.3.1.jar 2013-07-07 09:37:39 UTC (rev 18659) +++ branches/rangeindex/extensions/indexes/lucene/lib/lucene-queryparser-4.3.1.jar 2013-07-07 10:06:34 UTC (rev 18660) Property changes on: branches/rangeindex/extensions/indexes/lucene/lib/lucene-queryparser-4.3.1.jar ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Modified: branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java =================================================================== --- branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java 2013-07-07 09:37:39 UTC (rev 18659) +++ branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java 2013-07-07 10:06:34 UTC (rev 18660) @@ -128,7 +128,6 @@ return index.getIndexName(); } - @Override public QueryRewriter getQueryRewriter(XQueryContext context) { return null; } @@ -623,7 +622,7 @@ * @param queryText * @return search report */ - public NodeImpl search(XQueryContext context, final List<String> toBeMatchedURIs, String queryText) throws XPathException { + public NodeImpl search(final XQueryContext context, final List<String> toBeMatchedURIs, String queryText) throws XPathException { NodeImpl report = null; @@ -633,10 +632,10 @@ searcher = index.getSearcher(); // Get analyzer : to be retrieved from configuration - final Analyzer searchAnalyzer = new StandardAnalyzer(Version.LUCENE_42); + final Analyzer searchAnalyzer = new StandardAnalyzer(Version.LUCENE_43); // Setup query Version, default field, analyzer - final QueryParser parser = new QueryParser(Version.LUCENE_42, "", searchAnalyzer); + final QueryParser parser = new QueryParser(Version.LUCENE_43, "", searchAnalyzer); final Query query = parser.parse(queryText); // extract all used fields from query @@ -648,32 +647,8 @@ builder.startDocument(); // start root element -<<<<<<< .working final int nodeNr = builder.startElement("", "results", "results", null); -======= - int nodeNr = builder.startElement("", "results", "results", null); - - BitVector processed = new BitVector(searcher.maxDoc()); - // Process result documents - for (ScoreDoc scoreDoc : results) { - if (processed.get(scoreDoc.doc)) - continue; - processed.set(scoreDoc.doc); - - Document doc = searcher.doc(scoreDoc.doc); - - // Get URI field of document - String fDocUri = doc.get(FIELD_DOC_URI); - - // Get score - float score = scoreDoc.score; - - // Check if document URI has a full match or if a - // document is in a collection - if(isDocumentMatch(fDocUri, toBeMatchedURIs)){ ->>>>>>> .merge-right.r18646 -<<<<<<< .working // Perform actual search searcher.search(query, new Collector() { private Scorer scorer; @@ -697,72 +672,47 @@ // Check if document URI has a full match or if a // document is in a collection if(isDocumentMatch(fDocUri, toBeMatchedURIs)){ + + DocumentImpl storedDoc = null; + try { + // try to read document to check if user is allowed to access it + storedDoc = context.getBroker().getXMLResource(XmldbURI.createInternal(fDocUri), Lock.READ_LOCK); + if (storedDoc == null) { + return; + } - // setup attributes - AttributesImpl attribs = new AttributesImpl(); - attribs.addAttribute("", "uri", "uri", "CDATA", fDocUri); - attribs.addAttribute("", "score", "score", "CDATA", ""+score); - - // write element and attributes - builder.startElement("", "search", "search", attribs); - for (String field : fields) { - String[] fieldContent = doc.getValues(field); - attribs.clear(); - attribs.addAttribute("", "name", "name", "CDATA", field); - for (String content : fieldContent) { - List<Offset> offsets = highlighter.getOffsets(content, searchAnalyzer); - if (offsets != null) { - builder.startElement("", "field", "field", attribs); - highlighter.highlight(content, offsets, builder); - builder.endElement(); + // setup attributes + AttributesImpl attribs = new AttributesImpl(); + attribs.addAttribute("", "uri", "uri", "CDATA", fDocUri); + attribs.addAttribute("", "score", "score", "CDATA", ""+score); + + // write element and attributes + builder.startElement("", "search", "search", attribs); + for (String field : fields) { + String[] fieldContent = doc.getValues(field); + attribs.clear(); + attribs.addAttribute("", "name", "name", "CDATA", field); + for (String content : fieldContent) { + List<Offset> offsets = highlighter.getOffsets(content, searchAnalyzer); + if (offsets != null) { + builder.startElement("", "field", "field", attribs); + highlighter.highlight(content, offsets, builder); + builder.endElement(); + } } } - } - builder.endElement(); - - // clean attributes - attribs.clear(); -======= - DocumentImpl storedDoc = null; - try { - // try to read document to check if user is allowed to access it - storedDoc = context.getBroker().getXMLResource(XmldbURI.createInternal(fDocUri), Lock.READ_LOCK); - if (storedDoc == null) { - continue; - } - // setup attributes - attribs = new AttributesImpl(); - attribs.addAttribute("", "uri", "uri", "CDATA", fDocUri); - attribs.addAttribute("", "score", "score", "CDATA", ""+score); - - // write element and attributes - builder.startElement("", "search", "search", attribs); - for (String field : fields) { - String[] fieldContent = doc.getValues(field); + builder.endElement(); + + // clean attributes attribs.clear(); - attribs.addAttribute("", "name", "name", "CDATA", field); - for (String content : fieldContent) { - List<Offset> offsets = highlighter.getOffsets(content, searchAnalyzer); - if (offsets != null) { - builder.startElement("", "field", "field", attribs); - highlighter.highlight(content, offsets, builder); - builder.endElement(); - } + } catch (PermissionDeniedException e) { + // not allowed to read the document: ignore the match. + } finally { + if (storedDoc != null) { + storedDoc.getUpdateLock().release(Lock.READ_LOCK); } } - builder.endElement(); - - // clean attributes - attribs.clear(); - } catch (PermissionDeniedException e) { - // not allowed to read the document: ignore the match. - } finally { - if (storedDoc != null) { - storedDoc.getUpdateLock().release(Lock.READ_LOCK); - } ->>>>>>> .merge-right.r18646 } -<<<<<<< .working } @Override @@ -776,11 +726,6 @@ } }); -======= - } - } - ->>>>>>> .merge-right.r18646 // finish root element builder.endElement(); Modified: branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/analyzers/NoDiacriticsStandardAnalyzer.java =================================================================== --- branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/analyzers/NoDiacriticsStandardAnalyzer.java 2013-07-07 09:37:39 UTC (rev 18659) +++ branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/analyzers/NoDiacriticsStandardAnalyzer.java 2013-07-07 10:06:34 UTC (rev 18660) @@ -1,13 +1,19 @@ package org.exist.indexing.lucene.analyzers; import org.apache.lucene.analysis.*; +import org.apache.lucene.analysis.core.LowerCaseFilter; +import org.apache.lucene.analysis.core.StopAnalyzer; +import org.apache.lucene.analysis.core.StopFilter; +import org.apache.lucene.analysis.miscellaneous.ASCIIFoldingFilter; import org.apache.lucene.analysis.standard.StandardFilter; import org.apache.lucene.analysis.standard.StandardTokenizer; +import org.apache.lucene.analysis.util.CharArraySet; +import org.apache.lucene.analysis.util.StopwordAnalyzerBase; +import org.apache.lucene.analysis.util.WordlistLoader; import org.apache.lucene.util.Version; import java.io.IOException; import java.io.Reader; -import java.util.Set; /** * A copy of StandardAnalyzer using an additional ASCIIFoldingFilter to @@ -28,15 +34,15 @@ /** An unmodifiable set containing some common English words that are usually not useful for searching. */ - public static final Set<?> STOP_WORDS_SET = StopAnalyzer.ENGLISH_STOP_WORDS_SET; + public static final CharArraySet STOP_WORDS_SET = StopAnalyzer.ENGLISH_STOP_WORDS_SET; /** Builds an analyzer with the given stop words. * @param matchVersion Lucene version to match See {@link * <a href="#version">above</a>} * @param stopWords stop words */ - public NoDiacriticsStandardAnalyzer(Version matchVersion, Set<?> stopWords) { + public NoDiacriticsStandardAnalyzer(Version matchVersion, CharArraySet stopWords) { super(matchVersion, stopWords); - replaceInvalidAcronym = matchVersion.onOrAfter(Version.LUCENE_24); + replaceInvalidAcronym = matchVersion.onOrAfter(Version.LUCENE_43); } /** Builds an analyzer with the default stop words ({@link @@ -78,17 +84,18 @@ protected TokenStreamComponents createComponents(final String fieldName, final Reader reader) { final StandardTokenizer src = new StandardTokenizer(matchVersion, reader); src.setMaxTokenLength(maxTokenLength); - src.setReplaceInvalidAcronym(replaceInvalidAcronym); +// src.setReplaceInvalidAcronym(replaceInvalidAcronym); TokenStream tok = new StandardFilter(matchVersion, src); tok = new ASCIIFoldingFilter(tok); tok = new LowerCaseFilter(matchVersion, tok); tok = new StopFilter(matchVersion, tok, stopwords); - return new TokenStreamComponents(src, tok) { - @Override - protected boolean reset(final Reader reader) throws IOException { - src.setMaxTokenLength(NoDiacriticsStandardAnalyzer.this.maxTokenLength); - return super.reset(reader); - } - }; + return new TokenStreamComponents(src, tok); +// { +// @Override +// protected boolean reset(final Reader reader) throws IOException { +// src.setMaxTokenLength(NoDiacriticsStandardAnalyzer.this.maxTokenLength); +// return super.reset(reader); +// } +// }; } } |
From: <sha...@us...> - 2013-07-07 10:16:22
|
Revision: 18661 http://sourceforge.net/p/exist/code/18661 Author: shabanovd Date: 2013-07-07 10:16:17 +0000 (Sun, 07 Jul 2013) Log Message: ----------- [ignore] merge trunk Modified Paths: -------------- branches/rangeindex/extensions/replication/src/org/exist/replication/jms/subscribe/JMSMessageListener.java branches/rangeindex/extensions/webdav/src/org/exist/webdav/ExistCollection.java branches/rangeindex/extensions/webdav/src/org/exist/webdav/ExistDocument.java branches/rangeindex/nbproject/project.properties branches/rangeindex/schema/collection.xconf.xsd branches/rangeindex/src/org/exist/atom/modules/AtomProtocol.java branches/rangeindex/src/org/exist/backup/restore/SystemImportHandler.java branches/rangeindex/src/org/exist/collections/CollectionConfigurationManager.java branches/rangeindex/src/org/exist/config/Configurator.java branches/rangeindex/src/org/exist/dom/ElementImpl.java branches/rangeindex/src/org/exist/http/RESTServer.java branches/rangeindex/src/org/exist/plugin/PluginsManagerImpl.java branches/rangeindex/src/org/exist/protocolhandler/embedded/EmbeddedUpload.java branches/rangeindex/src/org/exist/repo/Deployment.java branches/rangeindex/src/org/exist/security/AbstractRealm.java branches/rangeindex/src/org/exist/security/PermissionFactory.java branches/rangeindex/src/org/exist/security/internal/RealmImpl.java branches/rangeindex/src/org/exist/security/internal/SecurityManagerImpl.java branches/rangeindex/src/org/exist/security/xacml/XACMLUtil.java branches/rangeindex/src/org/exist/soap/AdminSoapBindingImpl.java branches/rangeindex/src/org/exist/storage/BrokerPool.java branches/rangeindex/src/org/exist/storage/NativeBroker.java branches/rangeindex/src/org/exist/storage/btree/BTree.java branches/rangeindex/src/org/exist/storage/index/BFile.java branches/rangeindex/src/org/exist/storage/txn/TransactionManager.java branches/rangeindex/src/org/exist/storage/txn/Txn.java branches/rangeindex/src/org/exist/util/Configuration.java branches/rangeindex/src/org/exist/util/io/Resource.java branches/rangeindex/src/org/exist/xmldb/LocalCollection.java branches/rangeindex/src/org/exist/xmldb/LocalCollectionManagementService.java branches/rangeindex/src/org/exist/xmldb/LocalIndexQueryService.java branches/rangeindex/src/org/exist/xmldb/LocalUserManagementService.java branches/rangeindex/src/org/exist/xmldb/LocalXMLResource.java branches/rangeindex/src/org/exist/xmldb/LocalXUpdateQueryService.java branches/rangeindex/src/org/exist/xmlrpc/RpcConnection.java branches/rangeindex/src/org/exist/xquery/BasicExpressionVisitor.java branches/rangeindex/src/org/exist/xquery/DefaultExpressionVisitor.java branches/rangeindex/src/org/exist/xquery/ExpressionVisitor.java branches/rangeindex/src/org/exist/xquery/FunctionCall.java branches/rangeindex/src/org/exist/xquery/functions/inspect/InspectFunction.java branches/rangeindex/src/org/exist/xquery/functions/inspect/InspectModule.java branches/rangeindex/src/org/exist/xquery/functions/xmldb/XMLDBSetMimeType.java branches/rangeindex/src/org/exist/xquery/update/Delete.java branches/rangeindex/src/org/exist/xquery/update/Insert.java branches/rangeindex/src/org/exist/xquery/update/Modification.java branches/rangeindex/src/org/exist/xquery/update/Rename.java branches/rangeindex/src/org/exist/xquery/update/Replace.java branches/rangeindex/src/org/exist/xquery/update/Update.java branches/rangeindex/src/org/exist/xquery/value/HexBinaryValueType.java branches/rangeindex/test/src/org/exist/xquery/xqts/QT3TS_To_junit.java branches/rangeindex/test/src/org/exist/xquery/xqts/XQTS_To_junit.java branches/rangeindex/tools/jetty/etc/jetty.xml Added Paths: ----------- branches/rangeindex/src/org/exist/xquery/functions/inspect/FunctionCallVisitor.java branches/rangeindex/tools/jetty/lib/javax.annotation-1.1.0.v201108011116.jar branches/rangeindex/tools/jetty/lib/jetty-annotations-8.1.11.v20130520.jar Property Changed: ---------------- branches/rangeindex/ branches/rangeindex/extensions/replication/ branches/rangeindex/src/org/exist/dom/ branches/rangeindex/src/org/exist/storage/ branches/rangeindex/src/org/exist/storage/NativeBroker.java branches/rangeindex/src/org/exist/storage/btree/ branches/rangeindex/src/org/exist/storage/index/ branches/rangeindex/src/org/exist/storage/txn/ Index: branches/rangeindex =================================================================== --- branches/rangeindex 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex 2013-07-07 10:16:17 UTC (rev 18661) Property changes on: branches/rangeindex ___________________________________________________________________ Modified: svn:mergeinfo ## -6,5 +6,5 ## /branches/jmfg/res64-eXist:12887-13224 /branches/pbosek/jorsek-official/eXist:18475-18477,18574-18589,18595-18616 /stable/eXist-2.0.x:17695-17697 -/trunk/eXist:18391-18646 +/trunk/eXist:18391-18660 /trunk/eXist/nbproject:8007-14504 \ No newline at end of property Index: branches/rangeindex/extensions/replication =================================================================== --- branches/rangeindex/extensions/replication 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/extensions/replication 2013-07-07 10:16:17 UTC (rev 18661) Property changes on: branches/rangeindex/extensions/replication ___________________________________________________________________ Modified: svn:mergeinfo ## -3,5 +3,5 ## /branches/adam/security-locking/extensions/replication:15302-15345 /branches/dizzzz/xquery3/extensions/replication:15611-15682 /branches/jmfg/res64-eXist/extensions/replication:12887-13224 -/trunk/eXist/extensions/replication:16258-16404,16406-16525,16527-16538,16540-16631,16633-16715,18391-18646 +/trunk/eXist/extensions/replication:16258-16404,16406-16525,16527-16538,16540-16631,16633-16715,18391-18660 /trunk/eXist/nbproject/extensions/replication:8007-14504 \ No newline at end of property Modified: branches/rangeindex/extensions/replication/src/org/exist/replication/jms/subscribe/JMSMessageListener.java =================================================================== --- branches/rangeindex/extensions/replication/src/org/exist/replication/jms/subscribe/JMSMessageListener.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/extensions/replication/src/org/exist/replication/jms/subscribe/JMSMessageListener.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -418,7 +418,7 @@ collection.release(Lock.WRITE_LOCK); //collection.setTriggersEnabled(true); } - + txnManager.close(txn); brokerPool.release(broker); } @@ -484,7 +484,7 @@ if (collection != null) { collection.release(Lock.WRITE_LOCK); } - + txnManager.close(txn); brokerPool.release(broker); } @@ -558,6 +558,7 @@ collection.release(Lock.WRITE_LOCK); } + txnManager.close(txn); brokerPool.release(broker); } @@ -617,6 +618,7 @@ collection.release(Lock.WRITE_LOCK); } + txnManager.close(txn); brokerPool.release(broker); } @@ -721,7 +723,7 @@ if (collection != null) { collection.release(Lock.WRITE_LOCK); } - + txnManager.close(txn); brokerPool.release(broker); } } @@ -809,7 +811,7 @@ srcCollection.release(Lock.WRITE_LOCK); } - + txnManager.close(txn); brokerPool.release(broker); @@ -886,7 +888,7 @@ srcCollection.release(Lock.WRITE_LOCK); } - + txnManager.close(txn); brokerPool.release(broker); Modified: branches/rangeindex/extensions/webdav/src/org/exist/webdav/ExistCollection.java =================================================================== --- branches/rangeindex/extensions/webdav/src/org/exist/webdav/ExistCollection.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/extensions/webdav/src/org/exist/webdav/ExistCollection.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -276,6 +276,7 @@ collection.release(Lock.WRITE_LOCK); } + txnManager.close(txn); brokerPool.release(broker); if(LOG.isDebugEnabled()) @@ -349,6 +350,7 @@ if (collection != null) { collection.release(Lock.WRITE_LOCK); } + txnManager.close(txn); brokerPool.release(broker); @@ -490,7 +492,7 @@ if (collection != null) { collection.release(Lock.WRITE_LOCK); } - + txnManager.close(txn); brokerPool.release(broker); if(LOG.isDebugEnabled()) @@ -597,7 +599,7 @@ srcCollection.release(Lock.WRITE_LOCK); } - + txnManager.close(txn); brokerPool.release(broker); if(LOG.isDebugEnabled()) Modified: branches/rangeindex/extensions/webdav/src/org/exist/webdav/ExistDocument.java =================================================================== --- branches/rangeindex/extensions/webdav/src/org/exist/webdav/ExistDocument.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/extensions/webdav/src/org/exist/webdav/ExistDocument.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -309,7 +309,7 @@ if (collection != null) { collection.release(Lock.WRITE_LOCK); } - + txnManager.close(txn); brokerPool.release(broker); if (LOG.isDebugEnabled()) { @@ -503,6 +503,7 @@ document.getUpdateLock().release(Lock.WRITE_LOCK); } + txnManager.close(txn); brokerPool.release(broker); if (LOG.isDebugEnabled()) { @@ -581,7 +582,7 @@ if (document != null) { document.getUpdateLock().release(Lock.WRITE_LOCK); } - + txnManager.close(txn); brokerPool.release(broker); if (LOG.isDebugEnabled()) { @@ -700,7 +701,7 @@ srcCollection.release(Lock.WRITE_LOCK); } - + txnManager.close(txn); brokerPool.release(broker); if (LOG.isDebugEnabled()) { @@ -809,7 +810,7 @@ if (document != null) { document.getUpdateLock().release(Lock.WRITE_LOCK); } - + txnManager.close(txn); if(broker != null) { brokerPool.release(broker); } Modified: branches/rangeindex/nbproject/project.properties =================================================================== --- branches/rangeindex/nbproject/project.properties 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/nbproject/project.properties 2013-07-07 10:16:17 UTC (rev 18661) @@ -51,6 +51,7 @@ file.reference.saxonhe-9.4.0.7.jar=lib/endorsed/saxonhe-9.4.0.7.jar file.reference.servlet-api-3.0.jar=lib/optional/servlet-api-3.0.jar file.reference.tagsoup-1.2.jar=extensions/expath/lib/tagsoup-1.2.jar +file.reference.xml-resolver-1.2.jar=lib/endorsed/xml-resolver-1.2.jar jar.archive.disabled=${jnlp.enabled} jar.index=${jnlp.enabled} jnlp.mixed.code=default @@ -133,7 +134,6 @@ javadoc.nonavbar=false src.src13.dir=extensions/debuggee/src build.generated.dir=${build.dir}/generated -file.reference.resolver-1.2.jar=lib/endorsed/resolver-1.2.jar run.test.classpath=\ ${javac.test.classpath}:\ ${build.test.classes.dir}:\ @@ -221,7 +221,7 @@ javadoc.additionalparam=-J-Xmx320m javac.classpath=\ ${file.reference.xml-apis-1.4.01.jar}:\ - ${file.reference.resolver-1.2.jar}:\ + ${file.reference.xml-resolver-1.2.jar}:\ ${file.reference.serializer-2.7.1.jar}:\ ${file.reference.xercesImpl-2.11.0.jar}:\ ${file.reference.saxonhe-9.4.0.7.jar}:\ Modified: branches/rangeindex/schema/collection.xconf.xsd =================================================================== --- branches/rangeindex/schema/collection.xconf.xsd 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/schema/collection.xconf.xsd 2013-07-07 10:16:17 UTC (rev 18661) @@ -197,6 +197,7 @@ <xs:attribute name="match" use="optional" type="xs:string"/> <xs:attribute name="analyzer" use="optional" type="xs:IDREF"/> <xs:attribute name="boost" use="optional" type="xs:double"/> + <xs:attribute name="field" use="optional" type="xs:string"/> </xs:complexType> <xs:complexType name="singleQnameAttrType"> @@ -300,4 +301,4 @@ <xs:attribute name="path" type="xs:string" use="optional" form="unqualified"/> </xs:attributeGroup> -</xs:schema> \ No newline at end of file +</xs:schema> Modified: branches/rangeindex/src/org/exist/atom/modules/AtomProtocol.java =================================================================== --- branches/rangeindex/src/org/exist/atom/modules/AtomProtocol.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/atom/modules/AtomProtocol.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -249,7 +249,9 @@ } catch (final LockException ex) { transact.abort(transaction); throw new EXistException("Cannot acquire write lock.", ex); - } + } finally { + transact.close(transaction); + } } else if ("entry".equals(root.getLocalName())) { if (collection == null) { @@ -361,6 +363,7 @@ * EXistException("Serialization error.",ex); */ } finally { + transact.close(transaction); if (feedDoc != null) {feedDoc.getUpdateLock().release(Lock.WRITE_LOCK);} } @@ -483,6 +486,7 @@ transact.abort(transaction); throw new EXistException("Cannot acquire write lock.", ex); } finally { + transact.close(transaction); if (feedDoc != null) {feedDoc.getUpdateLock().release(Lock.WRITE_LOCK);} } @@ -509,7 +513,9 @@ } catch (final LockException e) { transact.abort(transaction); throw new PermissionDeniedException(e.getMessage()); - } + } finally { + transact.close(transaction); + } } } @@ -620,6 +626,7 @@ transact.abort(transaction); throw ex; } finally { + transact.close(transaction); if (feedDoc != null) {feedDoc.getUpdateLock().release(Lock.WRITE_LOCK);} } @@ -701,6 +708,7 @@ * EXistException("Serialization error.",ex); */ } finally { + transact.close(transaction); if (feedDoc != null) {feedDoc.getUpdateLock().release(Lock.WRITE_LOCK);} @@ -794,7 +802,9 @@ } catch (final LockException e) { transact.abort(transaction); throw new PermissionDeniedException(e.getMessage()); - } + } finally { + transact.close(transaction); + } } } @@ -820,7 +830,7 @@ transact.commit(transaction); response.setStatusCode(204); } finally { - transact.abort(transaction); + transact.close(transaction); } return; } @@ -892,6 +902,7 @@ transact.abort(transaction); throw new EXistException("Cannot acquire write lock.", ex); } finally { + transact.close(transaction); if (feedDoc != null) { feedDoc.getUpdateLock().release(Lock.WRITE_LOCK); } Modified: branches/rangeindex/src/org/exist/backup/restore/SystemImportHandler.java =================================================================== --- branches/rangeindex/src/org/exist/backup/restore/SystemImportHandler.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/backup/restore/SystemImportHandler.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -212,7 +212,9 @@ } catch (final Exception e) { txnManager.abort(txn); throw new SAXException(e); - } + } finally { + txnManager.close(txn); + } currentCollection = mkcol(collUri, getDateFromXSDateTimeStringForItem(created, name)); @@ -423,6 +425,7 @@ txnManager.abort(txn); throw new IOException(e); } finally { + txnManager.close(txn); // if (resource != null) // resource.getUpdateLock().release(Lock.READ_LOCK); } @@ -455,7 +458,9 @@ txnManager.abort(txn); listener.warn("Failed to remove deleted collection: " + name + ": " + e.getMessage()); - } + } finally { + txnManager.close(txn); + } } } catch (final Exception e) { listener.warn("Failed to remove deleted collection: " + name + ": " + e.getMessage()); @@ -483,8 +488,10 @@ txnManager.abort(txn); listener.warn("Failed to remove deleted resource: " + name + ": " + e.getMessage()); - } - } + } finally { + txnManager.close(txn); + } + } } catch (final Exception e) { listener.warn("Failed to remove deleted resource: " + name + ": " + e.getMessage()); } @@ -541,7 +548,9 @@ } catch (final Exception e) { txnManager.abort(txn); throw new SAXException(e); - } + } finally { + txnManager.close(txn); + } } class CollectionDeferredPermission extends AbstractDeferredPermission<Collection> { @@ -579,6 +588,7 @@ throw xe; } finally { + txnManager.close(txn); getTarget().release(Lock.WRITE_LOCK); } @@ -626,6 +636,7 @@ throw xe; } finally { + txnManager.close(txn); getTarget().getUpdateLock().release(Lock.WRITE_LOCK); } Modified: branches/rangeindex/src/org/exist/collections/CollectionConfigurationManager.java =================================================================== --- branches/rangeindex/src/org/exist/collections/CollectionConfigurationManager.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/collections/CollectionConfigurationManager.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -342,7 +342,9 @@ } catch (final Exception e) { transact.abort(txn); throw new EXistException("Failed to initialize '" + uri + "' : " + e.getMessage()); - } + } finally { + transact.close(txn); + } } /** Create a stored default configuration document for the root collection @@ -392,7 +394,9 @@ } catch (final CollectionConfigurationException e) { transact.abort(transaction); throw new EXistException(e.getMessage()); - } + } finally { + transact.close(transaction); + } } /* Modified: branches/rangeindex/src/org/exist/config/Configurator.java =================================================================== --- branches/rangeindex/src/org/exist/config/Configurator.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/config/Configurator.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -1220,6 +1220,7 @@ throw new IOException(e); } finally { + transact.close(txn); broker.setSubject(currentUser); } } Index: branches/rangeindex/src/org/exist/dom =================================================================== --- branches/rangeindex/src/org/exist/dom 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/dom 2013-07-07 10:16:17 UTC (rev 18661) Property changes on: branches/rangeindex/src/org/exist/dom ___________________________________________________________________ Modified: svn:mergeinfo ## -6,4 +6,4 ## /branches/wolfgang/src/org/exist/dom:10658-11213 /stable/eXist-1.4.x/src/org/exist/dom:11626 /trunk/eXist/nbproject/src/org/exist/dom:8007-14504 -/trunk/eXist/src/org/exist/dom:18391-18646 +/trunk/eXist/src/org/exist/dom:18391-18660 \ No newline at end of property Modified: branches/rangeindex/src/org/exist/dom/ElementImpl.java =================================================================== --- branches/rangeindex/src/org/exist/dom/ElementImpl.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/dom/ElementImpl.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -425,6 +425,7 @@ transact.abort(transaction); throw new DOMException(DOMException.INVALID_STATE_ERR, e.getMessage()); } finally { + transact.close(transaction); ownerDocument.getBrokerPool().release(broker); } } @@ -1179,6 +1180,7 @@ transact.abort(transaction); LOG.warn("Exception while inserting node: " + e.getMessage(), e); } finally { + transact.close(transaction); ownerDocument.getBrokerPool().release(broker); } return null; Modified: branches/rangeindex/src/org/exist/http/RESTServer.java =================================================================== --- branches/rangeindex/src/org/exist/http/RESTServer.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/http/RESTServer.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -924,6 +924,8 @@ } catch (final LockException e) { transact.abort(transaction); throw new PermissionDeniedException(e.getMessage()); + } finally { + transact.close(transaction); } // content type = application/x-www-form-urlencoded @@ -1126,6 +1128,7 @@ transact.abort(transaction); throw new PermissionDeniedException(e.getMessage()); } finally { + transact.close(transaction); if (vtempFile != null) { vtempFile.delete(); } @@ -1186,6 +1189,8 @@ } catch (final TransactionException e) { transact.abort(txn); LOG.warn("Transaction aborted: " + e.getMessage(), e); + } finally { + transact.close(txn); } } Modified: branches/rangeindex/src/org/exist/plugin/PluginsManagerImpl.java =================================================================== --- branches/rangeindex/src/org/exist/plugin/PluginsManagerImpl.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/plugin/PluginsManagerImpl.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -112,7 +112,9 @@ transaction.abort(txn); e.printStackTrace(); LOG.debug("loading configuration failed: " + e.getMessage()); - } + } finally { + transaction.close(txn); + } final Configuration _config_ = Configurator.parse(this, broker, collection, CONFIG_FILE_URI); configuration = Configurator.configure(this, _config_); Modified: branches/rangeindex/src/org/exist/protocolhandler/embedded/EmbeddedUpload.java =================================================================== --- branches/rangeindex/src/org/exist/protocolhandler/embedded/EmbeddedUpload.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/protocolhandler/embedded/EmbeddedUpload.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -228,6 +228,7 @@ throw new IOException(ex.getMessage(), ex); } finally { + transact.close(txn); LOG.debug("Done."); if(collectionLocked && collection != null){ collection.release(Lock.READ_LOCK); Modified: branches/rangeindex/src/org/exist/repo/Deployment.java =================================================================== --- branches/rangeindex/src/org/exist/repo/Deployment.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/repo/Deployment.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -466,6 +466,8 @@ } catch (final Exception e) { LOG.error("Exception occurred while removing package.", e); mgr.abort(txn); + } finally { + mgr.close(txn); } } @@ -505,6 +507,8 @@ mgr.commit(txn); } catch (final Exception e) { mgr.abort(txn); + } finally { + mgr.close(txn); } } @@ -581,6 +585,8 @@ mgr.commit(txn); } catch (final Exception e) { mgr.abort(txn); + } finally { + mgr.close(txn); } try { @@ -648,6 +654,8 @@ } catch (final Exception e) { mgr.abort(txn); e.printStackTrace(); + } finally { + mgr.close(txn); } } } Modified: branches/rangeindex/src/org/exist/security/AbstractRealm.java =================================================================== --- branches/rangeindex/src/org/exist/security/AbstractRealm.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/security/AbstractRealm.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -116,6 +116,8 @@ } catch(final TriggerException te) { transact.abort(txn); throw new EXistException(te); + } finally { + transact.close(txn); } } Modified: branches/rangeindex/src/org/exist/security/PermissionFactory.java =================================================================== --- branches/rangeindex/src/org/exist/security/PermissionFactory.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/security/PermissionFactory.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -159,6 +159,7 @@ transact.abort(transaction); throw new PermissionDeniedException("Permission to modify permissions is denied for user '" + broker.getSubject().getName() + "' on '" + pathUri.toString() + "': " + te.getMessage(), te); } finally { + transact.close(transaction); if(doc != null) { doc.getUpdateLock().release(Lock.WRITE_LOCK); } Modified: branches/rangeindex/src/org/exist/security/internal/RealmImpl.java =================================================================== --- branches/rangeindex/src/org/exist/security/internal/RealmImpl.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/security/internal/RealmImpl.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -213,6 +213,8 @@ transaction.abort(txn); e.printStackTrace(); LOG.debug("loading configuration failed: " + e.getMessage()); + } finally { + transaction.close(txn); } getSecurityManager().addUser(remove_account.getId(), remove_account); @@ -258,8 +260,10 @@ } catch (final Exception e) { transaction.abort(txn); LOG.debug(e); + } finally { + transaction.close(txn); } - + getSecurityManager().addGroup(remove_group.getId(), (Group)remove_group); principalDb.remove(remove_group.getName()); } Modified: branches/rangeindex/src/org/exist/security/internal/SecurityManagerImpl.java =================================================================== --- branches/rangeindex/src/org/exist/security/internal/SecurityManagerImpl.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/security/internal/SecurityManagerImpl.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -182,6 +182,8 @@ transaction.abort(txn); e.printStackTrace(); LOG.debug("loading acl failed: " + e.getMessage()); + } finally { + transaction.close(txn); } try { @@ -204,6 +206,8 @@ transaction.abort(txn); e.printStackTrace(); LOG.debug("loading configuration failed: " + e.getMessage()); + } finally { + transaction.close(txn); } final Configuration _config_ = Configurator.parse(this, broker, collection, CONFIG_FILE_URI); Modified: branches/rangeindex/src/org/exist/security/xacml/XACMLUtil.java =================================================================== --- branches/rangeindex/src/org/exist/security/xacml/XACMLUtil.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/security/xacml/XACMLUtil.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -264,8 +264,10 @@ transact.abort(txn); LOG.error("Error creating policy collection", e); return null; - } - } + } finally { + transact.close(txn); + } + } return policyCollection; } catch (final PermissionDeniedException e) { @@ -615,8 +617,10 @@ if(e instanceof EXistException) {throw (EXistException)e;} throw new EXistException("Error storing policy '" + docPath + "'", e); - } - } + } finally { + transact.close(txn); + } + } /** Reads an <code>InputStream</code> into a string. * @param in The stream to read into a string. Modified: branches/rangeindex/src/org/exist/soap/AdminSoapBindingImpl.java =================================================================== --- branches/rangeindex/src/org/exist/soap/AdminSoapBindingImpl.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/soap/AdminSoapBindingImpl.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -123,6 +123,7 @@ LOG.debug(e.getMessage(), e); throw new RemoteException(e.getMessage()); } finally { + transact.close(txn); pool.release(broker); } } @@ -155,6 +156,7 @@ LOG.debug(e.getMessage(), e); throw new RemoteException(e.getMessage(), e); } finally { + transact.close(txn); pool.release(broker); } } @@ -202,6 +204,7 @@ LOG.debug(e.getMessage(), e); throw new RemoteException(e.getMessage(), e); } finally { + transact.close(txn); pool.release(broker); } } @@ -257,6 +260,7 @@ LOG.debug(e.getMessage(), e); throw new RemoteException(e.getMessage(), e); } finally { + transact.close(txn); pool.release(broker); } } @@ -325,6 +329,7 @@ transact.abort(transaction); throw new RemoteException(e.getMessage(), e); } finally { + transact.close(transaction); pool.release(broker); } } @@ -387,6 +392,7 @@ transact.abort(transaction); throw new RemoteException(e.getMessage(), e); } finally { + transact.close(transaction); pool.release(broker); } @@ -437,6 +443,7 @@ transact.abort(txn); throw new RemoteException(e.getMessage(), e); } finally { + transact.close(txn); if(collection != null) {collection.release(Lock.WRITE_LOCK);} pool.release(broker); @@ -625,6 +632,7 @@ transact.abort(transaction); throw new RemoteException(e.getMessage()); } finally { + transact.close(transaction); if(doc != null) {doc.getUpdateLock().release(Lock.WRITE_LOCK);} pool.release(broker); @@ -704,6 +712,7 @@ transact.abort(transaction); throw new RemoteException(e.getMessage()); } finally { + transact.close(transaction); if(destination != null) {destination.release(Lock.WRITE_LOCK);} if(doc != null) @@ -765,6 +774,7 @@ transact.abort(transaction); throw new RemoteException(e.getMessage()); } finally { + transact.close(transaction); if(collection != null) {collection.release(move ? Lock.WRITE_LOCK : Lock.READ_LOCK);} if(destination != null) @@ -994,6 +1004,7 @@ transact.abort(transaction); throw new RemoteException(e.getMessage()); } finally { + transact.close(transaction); if(doc != null) {doc.getUpdateLock().release(Lock.WRITE_LOCK);} pool.release(broker); @@ -1013,6 +1024,8 @@ final Session session = getSession(sessionId); final Subject user = session.getUser(); DocumentImpl doc = null; + final TransactionManager transact = pool.getTransactionManager(); + Txn transaction = null; try { broker = pool.get(user); // TODO check XML/Binary resource @@ -1027,8 +1040,7 @@ if(lockOwner != null && (!lockOwner.equals(user)) && (!manager.hasAdminPrivileges(user))) {throw new PermissionDeniedException("Resource is already locked by user " + lockOwner.getName());} - final TransactionManager transact = pool.getTransactionManager(); - final Txn transaction = transact.beginTransaction(); + transaction = transact.beginTransaction(); doc.setUserLock(null); // TODO check XML/Binary resource // broker.storeDocument(transaction, doc); @@ -1036,8 +1048,10 @@ transact.commit(transaction); return; } catch (final Exception ex){ + transact.abort(transaction); throw new RemoteException(ex.getMessage()); } finally { + transact.close(transaction); if(doc != null) {doc.getUpdateLock().release(Lock.WRITE_LOCK);} pool.release(broker); Index: branches/rangeindex/src/org/exist/storage =================================================================== --- branches/rangeindex/src/org/exist/storage 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/storage 2013-07-07 10:16:17 UTC (rev 18661) Property changes on: branches/rangeindex/src/org/exist/storage ___________________________________________________________________ Modified: svn:mergeinfo ## -5,5 +5,5 ## /branches/jmfg/res64-eXist/src/org/exist/storage:12887-13224 /branches/wolfgang/src/org/exist/storage/structural:10694-11213 /trunk/eXist/nbproject/src/org/exist/storage:8007-14504 -/trunk/eXist/src/org/exist/storage:18391-18646 +/trunk/eXist/src/org/exist/storage:18391-18660 /trunk/eXist/src/org/exist/storage/structural:10658-10832*,10875-11212 \ No newline at end of property Modified: branches/rangeindex/src/org/exist/storage/BrokerPool.java =================================================================== --- branches/rangeindex/src/org/exist/storage/BrokerPool.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/storage/BrokerPool.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -903,8 +903,10 @@ transactionManager.abort(txn); } catch (final TriggerException e) { transactionManager.abort(txn); - } - } + } finally { + transactionManager.close(txn); + } + } } catch(final PermissionDeniedException pde) { LOG.fatal(pde.getMessage(), pde); } @@ -1140,6 +1142,8 @@ final String msg = "Initialisation of system collections failed: " + e.getMessage(); LOG.error(msg, e); throw new EXistException(msg, e); + } finally { + transact.close(txn); } } } Modified: branches/rangeindex/src/org/exist/storage/NativeBroker.java =================================================================== --- branches/rangeindex/src/org/exist/storage/NativeBroker.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/storage/NativeBroker.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -1788,6 +1788,7 @@ LOG.warn("An error occurred during reindex: " + e.getMessage(), e); } finally { + transact.close(transaction); pool.getProcessMonitor().endJob(); LOG.info(String.format("Finished indexing collection %s in %s msec.", collection.getURI().toString(), System.currentTimeMillis() - start)); @@ -1922,6 +1923,7 @@ transact.abort(transaction); } finally { + transact.close(transaction); //restore the user setUser(currentUser); } @@ -1945,7 +1947,9 @@ } catch(final Exception e) { transact.abort(transaction); LOG.warn("Failed to remove temp collection: " + e.getMessage(), e); - } + } finally { + transact.close(transaction); + } } @Override Property changes on: branches/rangeindex/src/org/exist/storage/NativeBroker.java ___________________________________________________________________ Modified: svn:mergeinfo ## -6,4 +6,4 ## /branches/wolfgang/src/org/exist/storage/NativeBroker.java:10658-11213 /stable/eXist-1.4.x/src/org/exist/storage/NativeBroker.java:11893 /trunk/eXist/nbproject/src/org/exist/storage/NativeBroker.java:8007-14504 -/trunk/eXist/src/org/exist/storage/NativeBroker.java:18391-18646 +/trunk/eXist/src/org/exist/storage/NativeBroker.java:18391-18660 \ No newline at end of property Index: branches/rangeindex/src/org/exist/storage/btree =================================================================== --- branches/rangeindex/src/org/exist/storage/btree 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/storage/btree 2013-07-07 10:16:17 UTC (rev 18661) Property changes on: branches/rangeindex/src/org/exist/storage/btree ___________________________________________________________________ Modified: svn:mergeinfo ## -5,4 +5,4 ## /branches/wolfgang/src/org/exist/storage/btree:10658-11213 /stable/eXist-1.4.x/src/org/exist/storage/btree:13335 /trunk/eXist/nbproject/src/org/exist/storage/btree:8007-14504 -/trunk/eXist/src/org/exist/storage/btree:18391-18646 +/trunk/eXist/src/org/exist/storage/btree:18391-18660 \ No newline at end of property Modified: branches/rangeindex/src/org/exist/storage/btree/BTree.java =================================================================== --- branches/rangeindex/src/org/exist/storage/btree/BTree.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/storage/btree/BTree.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -2257,7 +2257,11 @@ * @param idx */ private void removeKey(int idx) { - System.arraycopy(keys, idx + 1, keys, idx, nKeys - idx - 1); + try { + System.arraycopy(keys, idx + 1, keys, idx, nKeys - idx - 1); + } catch (ArrayIndexOutOfBoundsException e) { + System.err.println("keys: " + nKeys + " idx: " + idx); + } pageHeader.setValueCount((short) --nKeys); saved = false; } Index: branches/rangeindex/src/org/exist/storage/index =================================================================== --- branches/rangeindex/src/org/exist/storage/index 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/storage/index 2013-07-07 10:16:17 UTC (rev 18661) Property changes on: branches/rangeindex/src/org/exist/storage/index ___________________________________________________________________ Modified: svn:mergeinfo ## -5,4 +5,5 ## /branches/wolfgang/src/org/exist/storage/index:10658-11213 /branches/wolfgang/src/org/exist/storage/structural/index:10694-11213 /trunk/eXist/nbproject/src/org/exist/storage/index:8007-14504 +/trunk/eXist/src/org/exist/storage/index:18391-18660 /trunk/eXist/src/org/exist/storage/structural/index:10875-11212 \ No newline at end of property Modified: branches/rangeindex/src/org/exist/storage/index/BFile.java =================================================================== --- branches/rangeindex/src/org/exist/storage/index/BFile.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/storage/index/BFile.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -1119,7 +1119,7 @@ } protected void undoRemovePage(RemoveEmptyPageLoggable loggable) { - createPageHelper(null, loggable.page); + createPageHelper(loggable, loggable.page); } protected void redoCreateOverflow(OverflowCreateLoggable loggable) { @@ -1314,7 +1314,7 @@ } protected void undoRemoveOverflow(OverflowRemoveLoggable loggable) { - final DataPage page = createPageHelper(null, loggable.pageNum); + final DataPage page = createPageHelper(loggable, loggable.pageNum); final BFilePageHeader ph = page.getPageHeader(); ph.setStatus(loggable.status); ph.setDataLength(loggable.length); @@ -1398,7 +1398,7 @@ if (dp == null) { final Page page = getPage(newPage); byte[] data = page.read(); - if (page.getPageHeader().getLsn() == Lsn.LSN_INVALID || requiresRedo(loggable, page)) { + if (page.getPageHeader().getLsn() == Lsn.LSN_INVALID || (loggable != null && requiresRedo(loggable, page)) ) { reuseDeleted(page); final BFilePageHeader ph = (BFilePageHeader) page.getPageHeader(); ph.setStatus(RECORD); @@ -1411,7 +1411,7 @@ dp = new SinglePage(page, data, true); } } - if (loggable.getLsn() > dp.getPageHeader().getLsn()) + if (loggable != null && loggable.getLsn() > dp.getPageHeader().getLsn()) {dp.getPageHeader().setLsn(loggable.getLsn());} dp.setDirty(true); dataCache.add(dp); Index: branches/rangeindex/src/org/exist/storage/txn =================================================================== --- branches/rangeindex/src/org/exist/storage/txn 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/storage/txn 2013-07-07 10:16:17 UTC (rev 18661) Property changes on: branches/rangeindex/src/org/exist/storage/txn ___________________________________________________________________ Modified: svn:mergeinfo ## -6,3 +6,4 ## /branches/wolfgang/src/org/exist/storage/txn:10658-11213 /trunk/eXist/nbproject/src/org/exist/storage/txn:8007-14504 /trunk/eXist/src/org/exist/storage/structural/txn:10875-11212 +/trunk/eXist/src/org/exist/storage/txn:18391-18660 \ No newline at end of property Modified: branches/rangeindex/src/org/exist/storage/txn/TransactionManager.java =================================================================== --- branches/rangeindex/src/org/exist/storage/txn/TransactionManager.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/storage/txn/TransactionManager.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -62,9 +62,15 @@ public final static String PROPERTY_RECOVERY_FORCE_RESTART = "db-connection.recovery.force-restart"; /** + * Timeout for inactive transactions. A transaction which has not processed + * any operations for this time may be considered dead. + */ + public final static long TXN_INACTIVE_TIMEOUT = 60 * 1000; + + /** * Logger for this class */ - private static final Logger LOG = Logger .getLogger(TransactionManager.class); + private static final Logger LOG = Logger.getLogger(TransactionManager.class); private long nextTxnId = 0; @@ -171,8 +177,9 @@ * @throws TransactionException */ public void commit(final Txn txn) throws TransactionException { - if (!enabled) - {return;} + if (!enabled || txn.getState() != Txn.State.STARTED) { + return; + } new RunWithLock<Object>() { public Object execute() { @@ -196,11 +203,13 @@ } public void abort(final Txn txn) { - if (!enabled || txn == null) - {return;} + if (!enabled || txn == null || txn.getState() != Txn.State.STARTED) { + return; + } new RunWithLock<Object>() { public Object execute() { + transactions.remove(txn.getId()); try { journal.writeToLog(new TxnAbort(txn.getId())); } catch (final TransactionException e) { @@ -210,7 +219,6 @@ {journal.flushToLog(true);} txn.signalAbort(); txn.releaseAll(); - transactions.remove(txn.getId()); processSystemTasks(); return null; } @@ -218,6 +226,21 @@ } /** + * Make sure the transaction has either been committed or aborted. + * + * @param txn + */ + public void close(final Txn txn) { + if (!enabled || txn == null) { + return; + } + if (txn.getState() == Txn.State.STARTED) { + LOG.warn("Transaction was not committed or aborted!", new Throwable()); + abort(txn); + } + } + + /** * Keep track of a new operation within the given transaction. * * @param txnId Modified: branches/rangeindex/src/org/exist/storage/txn/Txn.java =================================================================== --- branches/rangeindex/src/org/exist/storage/txn/Txn.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/storage/txn/Txn.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -33,16 +33,29 @@ */ public class Txn { + public enum State { STARTED, ABORTED, COMMITTED }; + private long id; - + + private State state; + private List<LockInfo> locksHeld = new ArrayList<LockInfo>(); private List<TxnListener> listeners = new ArrayList<TxnListener>(); public Txn(long transactionId) { this.id = transactionId; + this.state = State.STARTED; } - + + public State getState() { + return state; + } + + public void setState(State state) { + this.state = state; + } + public long getId() { return id; } @@ -69,12 +82,14 @@ } public void signalAbort() { + state = State.ABORTED; for (int i = 0; i < listeners.size(); i++) { listeners.get(i).abort(); } } public void signalCommit() { + state = State.COMMITTED; for (int i = 0; i < listeners.size(); i++) { listeners.get(i).commit(); } Modified: branches/rangeindex/src/org/exist/util/Configuration.java =================================================================== --- branches/rangeindex/src/org/exist/util/Configuration.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/util/Configuration.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -24,7 +24,6 @@ import org.apache.log4j.Logger; import org.exist.repo.Deployment; -import org.quartz.SimpleTrigger; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -43,7 +42,6 @@ import org.exist.protocolhandler.eXistURLStreamHandlerFactory; import org.exist.scheduler.JobConfig; import org.exist.scheduler.JobException; -import org.exist.scheduler.Scheduler; import org.exist.security.internal.RealmImpl; import org.exist.security.xacml.XACMLConstants; import org.exist.storage.BrokerFactory; @@ -80,6 +78,7 @@ import java.util.HashMap; import java.util.Hashtable; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Map.Entry; import java.util.Properties; @@ -666,7 +665,7 @@ if(strJobType == null) { jobType = JobType.USER; //default to user if unspecified } else { - jobType = JobType.valueOf(strJobType.toUpperCase()); + jobType = JobType.valueOf(strJobType.toUpperCase(Locale.ENGLISH)); } final String jobName = getConfigAttributeValue(job, JobConfig.JOB_NAME_ATTRIBUTE); Modified: branches/rangeindex/src/org/exist/util/io/Resource.java =================================================================== --- branches/rangeindex/src/org/exist/util/io/Resource.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/util/io/Resource.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -207,8 +207,10 @@ } catch (final Exception e) { tm.abort(transaction); return false; - } - } catch (final Exception e) { + } finally { + tm.close(transaction); + } + } catch (final Exception e) { return false; } finally { @@ -245,7 +247,9 @@ } catch (final Exception e) { tm.abort(transaction); return false; - } + } finally { + tm.close(transaction); + } } catch (final Exception e) { return false; @@ -336,6 +340,7 @@ if (transaction != null) {tm.abort(transaction);} return false; } finally { + tm.close(transaction); if(source != null) {source.release(Lock.WRITE_LOCK);} if(destination != null) {destination.release(Lock.WRITE_LOCK);} } @@ -401,6 +406,7 @@ if (transaction != null) {tm.abort(transaction);} return false; } finally { + tm.close(transaction); if(source != null) {source.release(Lock.WRITE_LOCK);} if(destination != null) {destination.release(Lock.WRITE_LOCK);} } @@ -484,6 +490,7 @@ e.printStackTrace(); if (txn != null) {tm.abort(txn);} } finally { + tm.close(txn); if (db != null) {db.release( broker );} } @@ -615,7 +622,9 @@ } catch (final Exception e) { if (txn != null) {tm.abort(txn);} return false; - } + } finally { + tm.close(txn); + } } finally { if (db != null) {db.release(broker);} @@ -718,6 +727,7 @@ tm.abort(transaction); throw new IOException(e); } finally { + tm.close(transaction); closeFile(is); if (resource != null) @@ -1314,6 +1324,7 @@ } throw new IOException(e); } finally { + tm.close(txn); if (resource != null) {resource.getUpdateLock().release(Lock.READ_LOCK);} } Modified: branches/rangeindex/src/org/exist/xmldb/LocalCollection.java =================================================================== --- branches/rangeindex/src/org/exist/xmldb/LocalCollection.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/xmldb/LocalCollection.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -198,6 +198,7 @@ transact.abort(transaction); throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e.getMessage(), e); } finally { + transact.close(transaction); if(collection != null) { collection.release(Lock.WRITE_LOCK); } @@ -733,6 +734,7 @@ transact.abort(transaction); throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); } finally { + transact.close(transaction); if(collection != null) { collection.getLock().release(Lock.WRITE_LOCK); } @@ -811,6 +813,7 @@ transact.abort(txn); throw new XMLDBException(ErrorCodes.VENDOR_ERROR, "Exception while storing binary resource: " + e.getMessage(), e); } finally { + transact.close(txn); if(collection != null) { collection.getLock().release(Lock.WRITE_LOCK); } @@ -889,6 +892,7 @@ LOG.error(e); throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); } finally { + transact.close(txn); brokerPool.release(broker); brokerPool.setSubject(subject); } Modified: branches/rangeindex/src/org/exist/xmldb/LocalCollectionManagementService.java =================================================================== --- branches/rangeindex/src/org/exist/xmldb/LocalCollectionManagementService.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/xmldb/LocalCollectionManagementService.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -126,6 +126,7 @@ throw new XMLDBException( ErrorCodes.PERMISSION_DENIED, "not allowed to create collection", e ); } finally { + transact.close(transaction); brokerPool.release( broker ); brokerPool.setSubject(preserveSubject); } @@ -212,6 +213,7 @@ } finally { if(collection != null) {collection.release(Lock.WRITE_LOCK);} + transact.close(transaction); brokerPool.release( broker ); brokerPool.setSubject(preserveSubject); } @@ -286,6 +288,7 @@ {destination.release(Lock.WRITE_LOCK);} if(collection != null) {collection.release(Lock.WRITE_LOCK);} + transact.close(transaction); brokerPool.release( broker ); brokerPool.setSubject(preserveSubject); } @@ -365,6 +368,7 @@ {source.release(Lock.WRITE_LOCK);} if(destination != null) {destination.release(Lock.WRITE_LOCK);} + transact.close(transaction); brokerPool.release( broker ); brokerPool.setSubject(preserveSubject); } @@ -439,6 +443,7 @@ } finally { if(collection != null) {collection.release(Lock.READ_LOCK);} if(destination != null) {destination.release(Lock.WRITE_LOCK);} + transact.close(transaction); brokerPool.release( broker ); brokerPool.setSubject(preserveSubject); } @@ -509,6 +514,7 @@ } finally { if(source != null) {source.release(Lock.WRITE_LOCK);} if(destination != null) {destination.release(Lock.WRITE_LOCK);} + transact.close(transaction); brokerPool.release( broker ); brokerPool.setSubject(preserveSubject); } Modified: branches/rangeindex/src/org/exist/xmldb/LocalIndexQueryService.java =================================================================== --- branches/rangeindex/src/org/exist/xmldb/LocalIndexQueryService.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/xmldb/LocalIndexQueryService.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -132,8 +132,10 @@ transact.abort(txn); throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); } catch (final EXistException e) { + transact.abort(txn); throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); } finally { + transact.close(txn); pool.release(broker); pool.setSubject(preserveSubject); } Modified: branches/rangeindex/src/org/exist/xmldb/LocalUserManagementService.java =================================================================== --- branches/rangeindex/src/org/exist/xmldb/LocalUserManagementService.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/xmldb/LocalUserManagementService.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -1030,6 +1030,7 @@ transact.abort(transaction); throw se; } finally { + transact.close(transaction); if(document != null) { ((AbstractEXistResource)resource).closeDocument(document, Lock.WRITE_LOCK); } @@ -1078,6 +1079,7 @@ transact.abort(transaction); throw se; } finally { + transact.close(transaction); if(coll != null) { coll.release(Lock.WRITE_LOCK); } Modified: branches/rangeindex/src/org/exist/xmldb/LocalXMLResource.java =================================================================== --- branches/rangeindex/src/org/exist/xmldb/LocalXMLResource.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/xmldb/LocalXMLResource.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -603,6 +603,7 @@ throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e.getMessage(), e); } finally { + transact.close(transaction); closeDocument(document, Lock.WRITE_LOCK); pool.release(broker); pool.setSubject(preserveSubject); Modified: branches/rangeindex/src/org/exist/xmldb/LocalXUpdateQueryService.java =================================================================== --- branches/rangeindex/src/org/exist/xmldb/LocalXUpdateQueryService.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/xmldb/LocalXUpdateQueryService.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -124,6 +124,7 @@ e.printStackTrace(); throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(),e); } finally { + transact.close(transaction); if(processor != null) {processor.reset();} pool.release(broker); Modified: branches/rangeindex/src/org/exist/xmlrpc/RpcConnection.java =================================================================== --- branches/rangeindex/src/org/exist/xmlrpc/RpcConnection.java 2013-07-07 10:06:34 UTC (rev 18660) +++ branches/rangeindex/src/org/exist/xmlrpc/RpcConnection.java 2013-07-07 10:16:17 UTC (rev 18661) @@ -202,6 +202,7 @@ handleException(e); } finally { + transact.close(transaction); factory.getBrokerPool().release(broker); } return false; @@ -259,6 +260,7 @@ transact.abort(transaction); throw new EXistException(e.getMessage()); } finally { + transact.close(transaction); factory.getBrokerPool().release(broker); } return false; @@ -1234,6 +1236,7 @@ transact.abort(transaction); throw new EXistException(e.getMessage()); } finally { + transact.close(transaction); factory.getBrokerPool().release(broker); } } @@ -1306,6 +1309,7 @@ transact.abort(transaction); throw new EXistException(e.getMessage()); } finally { + transact.close(transaction); factory.getBrokerPool().release(broker); } } @@ -2267,6 +2271,7 @@ return false; } finally { + transact.close(transaction); factory.getBrokerPool().release(broker); } } @@ -2472,6 +2477,7 @@ handleException(e); } finally { + transact.close(transaction); factory.getBrokerPool().release(broker); // DWES there are situations the file is not cleaned up if(source!=null) @@ -2575,6 +2581,7 @@ return false; } finally { + transact.close(transaction); factory.getBrokerPool().release(broker); } return doc != null; @@ -3082,10 +3089,12 @@ return true; } catch (final Throwable e) { + transact.abort(transaction); handleException(e); return false; } finally { + transact.close(transaction); factory.getBrokerPool().release(broker); } } @@ -3135,6 +3144,7 @@ return false; } finally { + transact.close(transaction); factory.getBrokerPool().release(broker); } } @@ -4360,6 +4370,7 @@ return false; } finally { + transact.close(trans... [truncated message content] |
From: <sha...@us...> - 2013-07-14 13:45:35
|
Revision: 18681 http://sourceforge.net/p/exist/code/18681 Author: shabanovd Date: 2013-07-14 13:45:30 +0000 (Sun, 14 Jul 2013) Log Message: ----------- [feature] metadata integration into full text search Modified Paths: -------------- branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndex.java branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneUtil.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/MDStorageManager.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/MetaData.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/Reindex.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/Search.java branches/rangeindex/extensions/metadata/interface/src/test/java/org/exist/storage/md/SearchTest.java branches/rangeindex/extensions/metadata/sleepycat/src/main/java/org/exist/indexing/lucene/PlugToLucene.java branches/rangeindex/extensions/metadata/sleepycat/src/main/java/org/exist/storage/md/MetaDataImpl.java branches/rangeindex/src/org/exist/Database.java branches/rangeindex/src/org/exist/indexing/AbstractStreamListener.java branches/rangeindex/src/org/exist/indexing/IndexController.java branches/rangeindex/src/org/exist/indexing/IndexWorker.java branches/rangeindex/src/org/exist/indexing/StreamListener.java branches/rangeindex/src/org/exist/storage/BrokerPool.java Added Paths: ----------- branches/rangeindex/extensions/metadata/interface/src/test/java/org/exist/storage/md/LuceneSearchTest.java branches/rangeindex/src/org/exist/storage/MetaStorage.java branches/rangeindex/src/org/exist/storage/MetaStreamListener.java Modified: branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndex.java =================================================================== --- branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndex.java 2013-07-14 09:36:52 UTC (rev 18680) +++ branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndex.java 2013-07-14 13:45:30 UTC (rev 18681) @@ -28,7 +28,7 @@ public class LuceneIndex extends AbstractIndex implements RawBackupSupport { - public final static Version LUCENE_VERSION_IN_USE = Version.LUCENE_42; + public final static Version LUCENE_VERSION_IN_USE = Version.LUCENE_43; private static final Logger LOG = Logger.getLogger(LuceneIndexWorker.class); Modified: branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java =================================================================== --- branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java 2013-07-14 09:36:52 UTC (rev 18680) +++ branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java 2013-07-14 13:45:30 UTC (rev 18681) @@ -59,7 +59,7 @@ import java.util.*; /** - * Class for handling all Lucene operations. + * Class for handling all Lucene operations. * * @author Wolfgang Meier (wol...@ex...) * @author Dannes Wessels (da...@ex...) @@ -85,7 +85,6 @@ private LuceneIndex index; - @SuppressWarnings("unused") private IndexController controller; private LuceneMatchListener matchListener = null; @@ -587,8 +586,7 @@ Analyzer fieldAnalyzer = (fieldType == null) ? null : fieldType.getAnalyzer(); // Actual field content ; Store flag can be set in solrField - Field contentField = new Field(contentFieldName, field.getData().toString(), - store, Field.Index.ANALYZED, Field.TermVector.YES); + Field contentField = new Field(contentFieldName, field.getData().toString(), store, Field.Index.ANALYZED, Field.TermVector.YES); // Extract (document) Boost factor if (field.getBoost() > 0) { @@ -998,7 +996,7 @@ return false; //To change body of implemented methods use File | Settings | File Templates. } - public Occurrences[] scanIndex(XQueryContext context, DocumentSet docs, NodeSet nodes, Map hints) { + public Occurrences[] scanIndex(XQueryContext context, DocumentSet docs, NodeSet nodes, Map<?,?> hints) { List<QName> qnames = hints == null ? null : (List<QName>)hints.get(QNAMES_KEY); qnames = getDefinedIndexes(qnames); //Expects a StringValue @@ -1133,14 +1131,28 @@ try { writer = index.getWriter(); // docId and nodeId are stored as doc value - IntDocValuesField fDocId = new IntDocValuesField(FIELD_DOC_ID, 0); + NumericDocValuesField fDocId = new NumericDocValuesField(FIELD_DOC_ID, 0); BinaryDocValuesField fNodeId = new BinaryDocValuesField(LuceneUtil.FIELD_NODE_ID, new BytesRef(8)); // docId also needs to be indexed IntField fDocIdIdx = new IntField(FIELD_DOC_ID, 0, IntField.TYPE_NOT_STORED); + final List<Field> metas = new ArrayList<Field>(); + //XXX: optimize - put outside 'for' + controller.streamMetas(new MetaStreamListener() { + @Override + public void metadata(QName key, Object value) { + if (value instanceof String) { + String name = key.getLocalName();//LuceneUtil.encodeQName(key, index.getBrokerPool().getSymbols()); + Field fld = new Field(name, value.toString(), Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES); + metas.add(fld); + //System.out.println(" "+name+" = "+value.toString()); + } + } + }); + for (PendingDoc pending : nodesToWrite) { - Document doc = new Document(); - fDocId.setIntValue(currentDoc.getDocId()); + final Document doc = new Document(); + fDocId.setLongValue(currentDoc.getDocId()); doc.add(fDocId); // store the node id @@ -1165,8 +1177,7 @@ else contentField = LuceneUtil.encodeQName(pending.qname, index.getBrokerPool().getSymbols()); - Field fld = new Field(contentField, pending.text.toString(), Field.Store.NO, Field.Index.ANALYZED, - Field.TermVector.YES); + Field fld = new Field(contentField, pending.text.toString(), Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES); if (pending.idxConf.getBoost() > 0) fld.setBoost(pending.idxConf.getBoost()); @@ -1177,7 +1188,11 @@ fDocIdIdx.setIntValue(currentDoc.getDocId()); doc.add(fDocIdIdx); - + + for (Field meta : metas) { + doc.add(meta); + } + if (pending.idxConf.getAnalyzer() == null) writer.addDocument(doc); else { Modified: branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneUtil.java =================================================================== --- branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneUtil.java 2013-07-14 09:36:52 UTC (rev 18680) +++ branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneUtil.java 2013-07-14 13:45:30 UTC (rev 18681) @@ -22,6 +22,7 @@ public class LuceneUtil { public static final String FIELD_NODE_ID = "nodeId"; + public static final String FIELD_NODE_IDS = "nodeIds"; public static byte[] createId(int docId, NodeId nodeId) { // build id from nodeId and docId Modified: branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/MDStorageManager.java =================================================================== --- branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/MDStorageManager.java 2013-07-14 09:36:52 UTC (rev 18680) +++ branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/MDStorageManager.java 2013-07-14 13:45:30 UTC (rev 18681) @@ -22,6 +22,7 @@ package org.exist.storage.md; import java.lang.reflect.Constructor; +import java.lang.reflect.Field; import java.util.List; import java.util.Map; @@ -38,6 +39,7 @@ import org.exist.plugin.PluginsManager; import org.exist.security.PermissionDeniedException; import org.exist.storage.DBBroker; +import org.exist.storage.MetaStorage; import org.exist.storage.md.xquery.MetadataModule; import org.exist.util.serializer.SAXSerializer; import org.exist.xquery.XQueryContext; @@ -87,16 +89,31 @@ } _ = this; + + Database db = manager.getDatabase(); + + inject(db, md); - manager.getDatabase().getDocumentTriggers().add(new DocumentEvents()); - manager.getDatabase().getCollectionTriggers().add(new CollectionEvents()); + db.getDocumentTriggers().add(new DocumentEvents()); + db.getCollectionTriggers().add(new CollectionEvents()); - Map<String, Class<?>> map = (Map) manager.getDatabase().getConfiguration().getProperty(XQueryContext.PROPERTY_BUILT_IN_MODULES); + Map<String, Class<?>> map = (Map<String, Class<?>>) db.getConfiguration().getProperty(XQueryContext.PROPERTY_BUILT_IN_MODULES); map.put( NAMESPACE_URI, MetadataModule.class); } + private void inject(Database db, MetaStorage md) { + try { + Field field = db.getClass().getDeclaredField("metaStorage"); + field.setAccessible(true); + field.set(db, md); + } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { + e.printStackTrace(); + } + + } + @Override public void start(DBBroker broker) throws EXistException { Modified: branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/MetaData.java =================================================================== --- branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/MetaData.java 2013-07-14 09:36:52 UTC (rev 18680) +++ branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/MetaData.java 2013-07-14 13:45:30 UTC (rev 18681) @@ -28,16 +28,15 @@ import org.exist.collections.Collection; import org.exist.dom.DocumentAtExist; import org.exist.dom.DocumentImpl; -import org.exist.memtree.NodeImpl; import org.exist.security.PermissionDeniedException; +import org.exist.storage.MetaStorage; import org.exist.xmldb.XmldbURI; -import org.exist.xquery.XPathException; /** * @author <a href="mailto:sha...@gm...">Dmitriy Shabanov</a> * */ -public abstract class MetaData { +public abstract class MetaData implements MetaStorage { protected static MetaData _ = null; @@ -80,8 +79,8 @@ public abstract XmldbURI UUIDtoURI(String uuid); public abstract String URItoUUID(XmldbURI uri); - public abstract void indexMetas(Metas metas); +// public abstract void indexMetas(Metas metas); - public abstract NodeImpl search(String queryText, List<String> toBeMatchedURIs) throws XPathException; - public abstract List<String> searchDocuments(String queryText, List<String> toBeMatchedURIs) throws XPathException; +// public abstract NodeImpl search(String queryText, List<String> toBeMatchedURIs) throws XPathException; +// public abstract List<String> searchDocuments(String queryText, List<String> toBeMatchedURIs) throws XPathException; } Modified: branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/Reindex.java =================================================================== --- branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/Reindex.java 2013-07-14 09:36:52 UTC (rev 18680) +++ branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/Reindex.java 2013-07-14 13:45:30 UTC (rev 18681) @@ -124,8 +124,10 @@ Metas metas = md.addMetas(childDoc); - if (metas != null) - md.indexMetas(metas); + if (metas != null) { + //XXX: md.indexMetas(metas); + ; + } } } } Modified: branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/Search.java =================================================================== --- branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/Search.java 2013-07-14 09:36:52 UTC (rev 18680) +++ branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/xquery/Search.java 2013-07-14 13:45:30 UTC (rev 18681) @@ -110,7 +110,7 @@ else query = args[1].itemAt(0).getStringValue(); - report = MetaData.get().search(query, toBeMatchedURIs); + //XXX: report = MetaData.get().search(query, toBeMatchedURIs); } catch (XPathException ex) { // Log and rethrow Added: branches/rangeindex/extensions/metadata/interface/src/test/java/org/exist/storage/md/LuceneSearchTest.java =================================================================== --- branches/rangeindex/extensions/metadata/interface/src/test/java/org/exist/storage/md/LuceneSearchTest.java (rev 0) +++ branches/rangeindex/extensions/metadata/interface/src/test/java/org/exist/storage/md/LuceneSearchTest.java 2013-07-14 13:45:30 UTC (rev 18681) @@ -0,0 +1,1525 @@ +package org.exist.storage.md; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import java.io.File; +import java.io.StringReader; +import java.util.*; +import java.util.Map.Entry; + +import org.exist.Indexer; +import org.exist.TestUtils; +import org.exist.collections.Collection; +import org.exist.collections.CollectionConfigurationManager; +import org.exist.collections.IndexInfo; +import org.exist.dom.DefaultDocumentSet; +import org.exist.dom.DocumentImpl; +import org.exist.dom.DocumentSet; +import org.exist.dom.MutableDocumentSet; +import org.exist.dom.QName; +import org.exist.indexing.OrderedValuesIndex; +import org.exist.indexing.QNamedKeysIndex; +import org.exist.indexing.lucene.LuceneIndex; +import org.exist.indexing.lucene.LuceneIndexWorker; +import org.exist.security.xacml.AccessContext; +import org.exist.storage.BrokerPool; +import org.exist.storage.DBBroker; +import org.exist.storage.ElementValue; +import org.exist.storage.txn.TransactionManager; +import org.exist.storage.txn.Txn; +import org.exist.test.TestConstants; +import org.exist.util.Configuration; +import org.exist.util.ConfigurationHelper; +import org.exist.util.MimeTable; +import org.exist.util.MimeType; +import org.exist.util.Occurrences; +import org.exist.xmldb.XmldbURI; +import org.exist.xquery.XQuery; +import org.exist.xquery.XQueryContext; +import org.exist.xquery.CompiledXQuery; +import org.exist.xquery.value.Sequence; +import org.exist.xupdate.Modification; +import org.exist.xupdate.XUpdateProcessor; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.xml.sax.InputSource; + +import static org.exist.storage.md.MDStorageManager.NAMESPACE_URI; +import static org.exist.storage.md.MDStorageManager.PREFIX; + +public class LuceneSearchTest { + + protected static String XUPDATE_START = + "<xu:modifications version=\"1.0\" xmlns:xu=\"http://www.xmldb.org/xupdate\">"; + + protected static String XUPDATE_END = + "</xu:modifications>"; + + private static String XML1 = + "<section>" + + " <head>The title in big letters</head>" + + " <p rend=\"center\">A simple paragraph with <hi>just</hi> text in it.</p>" + + " <p rend=\"right\">paragraphs with <span>mix</span><span>ed</span> content are <span>danger</span>ous.</p>" + + "</section>"; + + private static String XML2 = + "<test>" + + " <item id='1' attr='attribute'><description>Chair</description></item>" + + " <item id='2'><description>Table</description>\n<condition>good</condition></item>" + + " <item id='3'><description>Cabinet</description>\n<condition>bad</condition></item>" + + "</test>"; + + private static String XML3 = + "<section>" + + " <head>TITLE IN UPPERCASE LETTERS</head>" + + " <p>UPPERCASE PARAGRAPH</p>" + + "</section>"; + + private static String XML4 = + "<test><a>A X</a><b><c>B X</c> C</b></test>"; + + private static String XML5 = + "<article>" + + " <head>The <b>title</b>of it</head>" + + " <p>A simple paragraph with <hi>highlighted</hi> text <note>and a note</note> " + + " in it.</p>" + + " <p>Paragraphs with <s>mix</s><s>ed</s> content are <s>danger</s>ous.</p>" + + " <p><note1>ignore</note1> <s2>warn</s2>ings</p>" + + "</article>"; + + private static String XML6 = + "<a>" + + " <b>AAA</b>" + + " <c>AAA</c>" + + " <b>AAA</b>" + + "</a>"; + + private static String XML7 = + "<section>" + + " <head>Query Test</head>" + + " <p>Eine wunderbare Heiterkeit hat meine ganze Seele eingenommen, gleich den " + + " süßen Frühlingsmorgen, die ich mit ganzem Herzen genieße. Ich bin allein und " + + " freue mich meines Lebens in dieser Gegend, die für solche Seelen geschaffen " + + " ist wie die meine. Ich bin so glücklich, mein Bester, so ganz in dem Gefühle " + + " von ruhigem Dasein versunken, daß meine Kunst darunter leidet.</p>" + + "</section>"; + + private static String COLLECTION_CONFIG1 = + "<collection xmlns=\"http://exist-db.org/collection-config/1.0\">" + + " <index>" + + " <fulltext default=\"none\">" + + " </fulltext>" + + " <lucene>" + + " <analyzer class=\"org.apache.lucene.analysis.core.SimpleAnalyzer\"/>" + + " <text match=\"/section/p\"/>" + + " <text qname=\"head\"/>" + + " <text qname=\"@rend\"/>" + + " <text qname=\"hi\"/>" + + " <text qname=\"LINE\"/>" + + " </lucene>" + + " </index>" + + "</collection>"; + + private static String COLLECTION_CONFIG2 = + "<collection xmlns=\"http://exist-db.org/collection-config/1.0\">" + + " <index>" + + " <fulltext default=\"none\">" + + " <create qname=\"item\"/>" + + " <create qname=\"description\"/>" + + " <create qname=\"condition\"/>" + + " <create qname=\"@attr\"/>" + + " </fulltext>" + + " <lucene>" + + " <text qname=\"item\"/>" + + " <text match=\"//description\"/>" + + " <text qname=\"condition\"/>" + + " <text qname=\"@attr\"/>" + + " </lucene>" + + " </index>" + + "</collection>"; + + private static String COLLECTION_CONFIG3 = + "<collection xmlns=\"http://exist-db.org/collection-config/1.0\">" + + " <index>" + + " <fulltext default=\"none\">" + + " </fulltext>" + + " <lucene>" + + " <analyzer id=\"whitespace\" class=\"org.apache.lucene.analysis.core.WhitespaceAnalyzer\"/>" + + " <text match=\"/section/head\" analyzer=\"whitespace\"/>" + + " <text match=\"//p\"/>" + + " </lucene>" + + " </index>" + + "</collection>"; + + private static String COLLECTION_CONFIG4 = + "<collection xmlns=\"http://exist-db.org/collection-config/1.0\">" + + " <index>" + + " <fulltext default=\"none\">" + + " </fulltext>" + + " <lucene>" + + " <text match=\"/test/a\"/>" + + " <text match=\"/test/b/*\"/>" + + " </lucene>" + + " </index>" + + "</collection>"; + + private static String COLLECTION_CONFIG5 = + "<collection xmlns=\"http://exist-db.org/collection-config/1.0\">" + + " <index xmlns:tei=\"http://www.tei-c.org/ns/1.0\">" + + " <fulltext default=\"none\" attributes=\"no\">" + + " </fulltext>" + + " <lucene>" + + " <text qname=\"article\">" + + " <ignore qname=\"note\"/>" + + " <inline qname=\"s\"/>" + + " </text>" + + " <text qname=\"p\">" + + " <ignore qname=\"note\"/>" + + " <inline qname=\"s\"/>" + + " </text>" + + " <text qname=\"head\"/>" + + " <ignore qname=\"note1\"/>" + + " <inline qname=\"s2\"/>" + + " </lucene>" + + " </index>" + + "</collection>"; + + private static String COLLECTION_CONFIG6 = + "<collection xmlns=\"http://exist-db.org/collection-config/1.0\">" + + " <index xmlns:tei=\"http://www.tei-c.org/ns/1.0\">" + + " <fulltext default=\"none\" attributes=\"no\">" + + " </fulltext>" + + " <lucene>" + + " <text qname=\"b\"/>" + + " <text qname=\"c\" boost=\"2.0\"/>" + + " </lucene>" + + " </index>" + + "</collection>"; + + private static Map<String, String> metas1 = new HashMap<String, String>(); + static { + metas1.put("status", "draft"); + } + + private static Map<String, String> metas2 = new HashMap<String, String>(); + static { + metas2.put("status", "final"); + } + + private static BrokerPool pool; + private static Collection root; + private Boolean savedConfig; + + @Test + public void simpleQueries() { + System.out.println("Test simple queries ..."); + DocumentSet docs = configureAndStore(COLLECTION_CONFIG1, XML1, "test.xml", metas1); + DBBroker broker = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + assertNotNull(broker); + + MetaData md = MetaData.get(); + assertNotNull(md); + + for(final Iterator<DocumentImpl> i = docs.getDocumentIterator(); i.hasNext(); ) { + final DocumentImpl doc = i.next(); + + Metas docMD = md.getMetas(doc); + Meta meta = docMD.get("status"); + assertNotNull(meta); + + assertEquals("draft", meta.getValue()); + } + + checkIndex(docs, broker, new QName[] { new QName("status", NAMESPACE_URI, PREFIX) }, "draft", 1); + + checkIndex(docs, broker, new QName[] { new QName("head", "") }, "title", 1); + + checkIndex(docs, broker, new QName[] { new QName("head", "") }, "title", 1); + Occurrences[] o = checkIndex(docs, broker, new QName[]{new QName("p", "")}, "with", 1); + assertEquals(2, o[0].getOccurrences()); + checkIndex(docs, broker, new QName[] { new QName("hi", "") }, "just", 1); + checkIndex(docs, broker, null, "in", 1); + + QName attrQN = new QName("rend", ""); + attrQN.setNameType(ElementValue.ATTRIBUTE); + checkIndex(docs, broker, new QName[] { attrQN }, null, 2); + checkIndex(docs, broker, new QName[] { attrQN }, "center", 1); + checkIndex(docs, broker, new QName[] { attrQN }, "right", 1); + + XQuery xquery = broker.getXQueryService(); + assertNotNull(xquery); + Sequence seq = xquery.execute("/section[ft:query(p, 'content')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + seq = xquery.execute("/section[ft:query(p/@rend, 'center')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + seq = xquery.execute("/section[ft:query(hi, 'just')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(0, seq.getItemCount()); + + seq = xquery.execute("/section[ft:query(p/*, 'just')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + seq = xquery.execute("/section[ft:query(head/*, 'just')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(0, seq.getItemCount()); + System.out.println("Test PASSED."); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + + @Test + public void configuration() { + DocumentSet docs = configureAndStore(COLLECTION_CONFIG4, XML4, "test.xml", metas1); + DBBroker broker = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + assertNotNull(broker); + + checkIndex(docs, broker, new QName[] { new QName("a", "") }, "x", 1); + checkIndex(docs, broker, new QName[] { new QName("c", "") }, "x", 1); + + XQuery xquery = broker.getXQueryService(); + assertNotNull(xquery); + Sequence seq = xquery.execute("/test[ft:query(a, 'x')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + seq = xquery.execute("/test[ft:query(.//c, 'x')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + seq = xquery.execute("/test[ft:query(b, 'x')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(0, seq.getItemCount()); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + + @Test + public void inlineAndIgnore() { + System.out.println("Test simple queries ..."); + DocumentSet docs = configureAndStore(COLLECTION_CONFIG5, + new Resource[] { + new Resource("test1.xml", XML5, metas1), + new Resource("test2.xml", XML5, metas2), + }); + DBBroker broker = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + assertNotNull(broker); + +// checkIndex(docs, broker, new QName[] { new QName("head", "") }, "title", 1); +// checkIndex(docs, broker, new QName[] { new QName("p", "") }, "simple", 1); +// checkIndex(docs, broker, new QName[] { new QName("p", "") }, "mixed", 1); +// checkIndex(docs, broker, new QName[] { new QName("p", "") }, "dangerous", 1); +// checkIndex(docs, broker, new QName[] { new QName("p", "") }, "note", 0); +// checkIndex(docs, broker, new QName[] { new QName("p", "") }, "ignore", 0); +// checkIndex(docs, broker, new QName[] { new QName("p", "") }, "warnings", 1); + + XQuery xquery = broker.getXQueryService(); + assertNotNull(xquery); + Sequence seq = xquery.execute("/article[ft:query(head, 'title')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(2, seq.getItemCount()); + + assertNotNull(xquery); + seq = xquery.execute("/article[ft:query(head, 'title AND status:draft')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + assertNotNull(xquery); + seq = xquery.execute("/article[ft:query(head, 'title AND status:final')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + assertNotNull(xquery); + seq = xquery.execute("/article[ft:query(head, 'title AND status:(final OR draft)')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(2, seq.getItemCount()); + + assertNotNull(xquery); + seq = xquery.execute("/article[ft:query(head, 'title AND status:another')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(0, seq.getItemCount()); + + seq = xquery.execute("/article[ft:query(p, 'highlighted')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(2, seq.getItemCount()); + + seq = xquery.execute("/article[ft:query(p, 'mixed')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(2, seq.getItemCount()); + + seq = xquery.execute("/article[ft:query(p, 'mix')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(0, seq.getItemCount()); + + seq = xquery.execute("/article[ft:query(p, 'dangerous')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(2, seq.getItemCount()); + + seq = xquery.execute("/article[ft:query(p, 'ous')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(0, seq.getItemCount()); + + seq = xquery.execute("/article[ft:query(p, 'danger')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(0, seq.getItemCount()); + + seq = xquery.execute("/article[ft:query(p, 'note')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(0, seq.getItemCount()); + + seq = xquery.execute("/article[ft:query(., 'highlighted')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(2, seq.getItemCount()); + + seq = xquery.execute("/article[ft:query(., 'mixed')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(2, seq.getItemCount()); + + seq = xquery.execute("/article[ft:query(., 'dangerous')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(2, seq.getItemCount()); + + seq = xquery.execute("/article[ft:query(., 'warnings')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(2, seq.getItemCount()); + + seq = xquery.execute("/article[ft:query(., 'danger')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(0, seq.getItemCount()); + + seq = xquery.execute("/article[ft:query(., 'note')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(0, seq.getItemCount()); + + seq = xquery.execute("/article[ft:query(., 'ignore')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(0, seq.getItemCount()); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + + @Test + public void boosts() { + configureAndStore(COLLECTION_CONFIG6, XML6, "test.xml", metas1); + DBBroker broker = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + assertNotNull(broker); + + XQuery xquery = broker.getXQueryService(); + assertNotNull(xquery); + Sequence seq = xquery.execute("for $a in ft:query((//b|//c), 'AAA') " + + "order by ft:score($a) descending return $a/local-name(.)", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(3, seq.getItemCount()); + assertEquals("c", seq.getStringValue()); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + + @Test + public void queryTranslation() { + configureAndStore(COLLECTION_CONFIG1, XML7, "test.xml", metas1); + DBBroker broker = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + assertNotNull(broker); + + XQuery xquery = broker.getXQueryService(); + assertNotNull(xquery); + + XQueryContext context = new XQueryContext(broker.getBrokerPool(), AccessContext.TEST); + CompiledXQuery compiled = xquery.compile(context, "declare variable $q external; " + + "ft:query(//p, util:parse($q)/query)"); + + context.declareVariable("q", "<query><term>heiterkeit</term></query>"); + Sequence seq = xquery.execute(compiled, null); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + context.declareVariable("q", + "<query>" + + " <bool>" + + " <term>heiterkeit</term><term>blablabla</term>" + + " </bool>" + + "</query>"); + seq = xquery.execute(compiled, null); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + context.declareVariable("q", + "<query>" + + " <bool>" + + " <term occur='should'>heiterkeit</term><term occur='should'>blablabla</term>" + + " </bool>" + + "</query>"); + seq = xquery.execute(compiled, null); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + context.declareVariable("q", + "<query>" + + " <bool>" + + " <term occur='must'>heiterkeit</term><term occur='must'>blablabla</term>" + + " </bool>" + + "</query>"); + seq = xquery.execute(compiled, null); + assertNotNull(seq); + assertEquals(0, seq.getItemCount()); + + context.declareVariable("q", + "<query>" + + " <bool>" + + " <term occur='must'>heiterkeit</term><term occur='not'>herzen</term>" + + " </bool>" + + "</query>"); + seq = xquery.execute(compiled, null); + assertNotNull(seq); + assertEquals(0, seq.getItemCount()); + + context.declareVariable("q", + "<query>" + + " <bool>" + + " <phrase occur='must'>wunderbare heiterkeit</phrase><term occur='must'>herzen</term>" + + " </bool>" + + "</query>"); + seq = xquery.execute(compiled, null); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + context.declareVariable("q", + "<query>" + + " <phrase slop='5'>heiterkeit seele eingenommen</phrase>" + + "</query>"); + seq = xquery.execute(compiled, null); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + // phrase with wildcards + context.declareVariable("q", + "<query>" + + " <phrase slop='5'><term>heiter*</term><term>se?nnnle*</term></phrase>" + + "</query>"); + seq = xquery.execute(compiled, null); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + context.declareVariable("q", + "<query>" + + " <wildcard>?eiter*</wildcard>" + + "</query>"); + seq = xquery.execute(compiled, null); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + context.declareVariable("q", + "<query>" + + " <fuzzy max-edits='2'>selee</fuzzy>" + + "</query>"); + seq = xquery.execute(compiled, null); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + context.declareVariable("q", + "<query>" + + " <bool>" + + " <fuzzy occur='must' max-edits='2'>selee</fuzzy>" + + " <wildcard occur='should'>bla*</wildcard>" + + " </bool>" + + "</query>"); + seq = xquery.execute(compiled, null); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + context.declareVariable("q", + "<query>" + + " <regex>heit.*keit</regex>" + + "</query>"); + seq = xquery.execute(compiled, null); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + context.declareVariable("q", + "<query>" + + " <phrase><term>wunderbare</term><regex>heit.*keit</regex></phrase>" + + "</query>"); + seq = xquery.execute(compiled, null); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + + @Test + public void analyzers() { + DocumentSet docs = configureAndStore(COLLECTION_CONFIG3, XML3, "test.xml", metas1); + DBBroker broker = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + assertNotNull(broker); + + checkIndex(docs, broker, new QName[] { new QName("head", "") }, "TITLE", 1); + checkIndex(docs, broker, new QName[] { new QName("p", "") }, "uppercase", 1); + + XQuery xquery = broker.getXQueryService(); + assertNotNull(xquery); + Sequence seq = xquery.execute("/section[ft:query(p, 'UPPERCASE')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + seq = xquery.execute("/section[ft:query(head, 'TITLE')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + seq = xquery.execute("/section[ft:query(head, 'title')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(0, seq.getItemCount()); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + + @Test + public void dropSingleDoc() { + System.out.println("Test removal of single document ..."); + DocumentSet docs = configureAndStore(COLLECTION_CONFIG1, XML1, "dropDocument.xml", metas1); + DBBroker broker = null; + TransactionManager transact = null; + Txn transaction = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + assertNotNull(broker); + transact = pool.getTransactionManager(); + assertNotNull(transact); + transaction = transact.beginTransaction(); + assertNotNull(transaction); + + System.out.println("Removing document dropDocument.xml"); + root.removeXMLResource(transaction, broker, XmldbURI.create("dropDocument.xml")); + transact.commit(transaction); + + checkIndex(docs, broker, null, null, 0); + + System.out.println("Test PASSED."); + } catch (Exception e) { + if (transact != null) + transact.abort(transaction); + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + + @Test + public void dropDocuments() { + System.out.println("Test removal of multiple documents ..."); + configureAndStore(COLLECTION_CONFIG1, "samples/shakespeare"); + DBBroker broker = null; + TransactionManager transact = null; + Txn transaction = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + assertNotNull(broker); + transact = pool.getTransactionManager(); + assertNotNull(transact); + transaction = transact.beginTransaction(); + assertNotNull(transaction); + + XQuery xquery = broker.getXQueryService(); + assertNotNull(xquery); + Sequence seq = xquery.execute("//LINE[ft:query(., 'bark')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(6, seq.getItemCount()); + + System.out.println("Removing document r_and_j.xml"); + root.removeXMLResource(transaction, broker, XmldbURI.create("r_and_j.xml")); + transact.commit(transaction); + + seq = xquery.execute("//LINE[ft:query(., 'bark')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(3, seq.getItemCount()); + + transaction = transact.beginTransaction(); + assertNotNull(transaction); + System.out.println("Removing document hamlet.xml"); + root.removeXMLResource(transaction, broker, XmldbURI.create("hamlet.xml")); + transact.commit(transaction); + + seq = xquery.execute("//LINE[ft:query(., 'bark')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + System.out.println("Test PASSED."); + } catch (Exception e) { + if (transact != null) + transact.abort(transaction); + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + + @Test + public void removeCollection() { + System.out.println("Test removal of collection ..."); + DocumentSet docs = configureAndStore(COLLECTION_CONFIG1, "samples/shakespeare"); + DBBroker broker = null; + TransactionManager transact = null; + Txn transaction = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + assertNotNull(broker); + transact = pool.getTransactionManager(); + assertNotNull(transact); + transaction = transact.beginTransaction(); + assertNotNull(transaction); + + XQuery xquery = broker.getXQueryService(); + assertNotNull(xquery); + Sequence seq = xquery.execute("//SPEECH[ft:query(LINE, 'love')]", null, AccessContext.TEST); + assertNotNull(seq); + System.out.println("Found: " + seq.getItemCount()); + assertEquals(166, seq.getItemCount()); + + System.out.println("Removing collection"); + broker.removeCollection(transaction, root); + + root = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI); + assertNotNull(root); + broker.saveCollection(transaction, root); + + transact.commit(transaction); + + root = null; + + checkIndex(docs, broker, null, null, 0); + + System.out.println("Test PASSED."); + } catch (Exception e) { + if (transact != null) + transact.abort(transaction); + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + + @Test + public void reindex() { + DocumentSet docs = configureAndStore(COLLECTION_CONFIG1, XML1, "dropDocument.xml", metas1); + DBBroker broker = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + assertNotNull(broker); + + broker.reindexCollection(TestConstants.TEST_COLLECTION_URI); + + checkIndex(docs, broker, new QName[] { new QName("head", "") }, "title", 1); + Occurrences[] o = checkIndex(docs, broker, new QName[]{new QName("p", "")}, "with", 1); + assertEquals(2, o[0].getOccurrences()); + checkIndex(docs, broker, new QName[] { new QName("hi", "") }, "just", 1); + checkIndex(docs, broker, null, "in", 1); + + QName attrQN = new QName("rend", ""); + attrQN.setNameType(ElementValue.ATTRIBUTE); + checkIndex(docs, broker, new QName[] { attrQN }, null, 2); + checkIndex(docs, broker, new QName[] { attrQN }, "center", 1); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } finally { + pool.release(broker); + } + } + + /** + * Remove nodes from different levels of the tree and check if the index is + * correctly updated. + */ + @Test + public void xupdateRemove() { + DocumentSet docs = configureAndStore(COLLECTION_CONFIG2, XML2, "xupdate.xml", metas1); + DBBroker broker = null; + TransactionManager transact = null; + Txn transaction = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + transact = pool.getTransactionManager(); + transaction = transact.beginTransaction(); + + checkIndex(docs, broker, new QName[] { new QName("description", "") }, "chair", 1); + checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 5); + checkIndex(docs, broker, new QName[] { new QName("condition", "") }, null, 2); + + XQuery xquery = broker.getXQueryService(); + assertNotNull(xquery); + Sequence seq = xquery.execute("//item[ft:query(description, 'chair')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + XUpdateProcessor proc = new XUpdateProcessor(broker, docs, AccessContext.TEST); + assertNotNull(proc); + proc.setBroker(broker); + proc.setDocumentSet(docs); + String xupdate = + XUPDATE_START + + " <xu:remove select=\"//item[@id='2']/condition\"/>" + + XUPDATE_END; + Modification[] modifications = proc.parse(new InputSource(new StringReader(xupdate))); + assertNotNull(modifications); + modifications[0].process(transaction); + proc.reset(); + + checkIndex(docs, broker, new QName[] { new QName("condition", "") }, null, 1); + checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 4); + checkIndex(docs, broker, new QName[] { new QName("condition", "") }, "good", 0); + checkIndex(docs, broker, new QName[] { new QName("item", "") }, "good", 0); + Occurrences o[] = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "table", 1); + assertEquals("table", o[0].getTerm()); + o = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "cabinet", 1); + assertEquals("cabinet", o[0].getTerm()); + o = checkIndex(docs, broker, new QName[] { new QName("item", "") }, "table", 1); + assertEquals("table", o[0].getTerm()); + o = checkIndex(docs, broker, new QName[] { new QName("item", "") }, "cabinet", 1); + assertEquals("cabinet", o[0].getTerm()); + + proc.setBroker(broker); + proc.setDocumentSet(docs); + xupdate = + XUPDATE_START + + " <xu:remove select=\"//item[@id='3']/description/text()\"/>" + + XUPDATE_END; + modifications = proc.parse(new InputSource(new StringReader(xupdate))); + assertNotNull(modifications); + modifications[0].process(transaction); + proc.reset(); + + proc.setBroker(broker); + proc.setDocumentSet(docs); + xupdate = + XUPDATE_START + + " <xu:remove select=\"//item[@id='1']\"/>" + + XUPDATE_END; + modifications = proc.parse(new InputSource(new StringReader(xupdate))); + assertNotNull(modifications); + modifications[0].process(transaction); + proc.reset(); + + o = checkIndex(docs, broker, new QName[] { new QName("description", "") }, null, 1); + assertEquals("table", o[0].getTerm()); + checkIndex(docs, broker, new QName[] { new QName("description", "") }, "chair", 0); + checkIndex(docs, broker, new QName[] { new QName("item", "") }, "chair", 0); + + transact.commit(transaction); + } catch (Exception e) { + if (transact != null) + transact.abort(transaction); + e.printStackTrace(); + fail(e.getMessage()); + } finally { + if (pool != null) { + pool.release(broker); + } + } + } + + /** + * Remove nodes from different levels of the tree and check if the index is + * correctly updated. + */ + @Test + public void xupdateInsert() { + DocumentSet docs = configureAndStore(COLLECTION_CONFIG2, XML2, "xupdate.xml", metas1); + DBBroker broker = null; + TransactionManager transact = null; + Txn transaction = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + transact = pool.getTransactionManager(); + transaction = transact.beginTransaction(); + + Occurrences occur[] = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "chair", 1); + assertEquals("chair", occur[0].getTerm()); + checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 5); + + XQuery xquery = broker.getXQueryService(); + assertNotNull(xquery); + Sequence seq = xquery.execute("//item[ft:query(description, 'chair')]", null, AccessContext.TEST); + assertNotNull(seq); + assertEquals(1, seq.getItemCount()); + + // Append to root node + XUpdateProcessor proc = new XUpdateProcessor(broker, docs, AccessContext.TEST); + assertNotNull(proc); + proc.setBroker(broker); + proc.setDocumentSet(docs); + String xupdate = + XUPDATE_START + + " <xu:append select=\"/test\">" + + " <item id='4'><description>Armchair</description> <condition>bad</condition></item>" + + " </xu:append>" + + XUPDATE_END; + Modification[] modifications = proc.parse(new InputSource(new StringReader(xupdate))); + assertNotNull(modifications); + modifications[0].process(transaction); + proc.reset(); + + Occurrences o[] = checkIndex(docs, broker, new QName[] { new QName("condition", "") }, null, 2); + System.out.println("prices: " + o.length); + for (int i = 0; i < o.length; i++) { + System.out.println("occurance: " + o[i].getTerm() + ": " + o[i].getOccurrences()); + } + checkIndex(docs, broker, new QName[] { new QName("description", "") }, null, 4); + checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 6); + + o = checkIndex(docs, broker, new QName[] { new QName("condition", "") }, "bad", 1); + assertEquals("bad", o[0].getTerm()); + o = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "armchair", 1); + assertEquals("armchair", o[0].getTerm()); + o = checkIndex(docs, broker, new QName[] { new QName("item", "") }, "bad", 1); + assertEquals("bad", o[0].getTerm()); + o = checkIndex(docs, broker, new QName[] { new QName("item", "") }, "armchair", 1); + assertEquals("armchair", o[0].getTerm()); + + // Insert before top element + proc.setBroker(broker); + proc.setDocumentSet(docs); + xupdate = + XUPDATE_START + + " <xu:insert-before select=\"//item[@id = '1']\">" + + " <item id='0'><description>Wheelchair</description> <condition>poor</condition></item>" + + " </xu:insert-before>" + + XUPDATE_END; + modifications = proc.parse(new InputSource(new StringReader(xupdate))); + assertNotNull(modifications); + modifications[0].process(transaction); + proc.reset(); + + checkIndex(docs, broker, new QName[] { new QName("condition", "") }, null, 3); + checkIndex(docs, broker, new QName[] { new QName("description", "") }, null, 5); + checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 8); + + o = checkIndex(docs, broker, new QName[] { new QName("condition", "") }, "poor", 1); + assertEquals("poor", o[0].getTerm()); + o = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "wheelchair", 1); + assertEquals("wheelchair", o[0].getTerm()); + o = checkIndex(docs, broker, new QName[] { new QName("item", "") }, "poor", 1); + assertEquals("poor", o[0].getTerm()); + o = checkIndex(docs, broker, new QName[] { new QName("item", "") }, "wheelchair", 1); + assertEquals("wheelchair", o[0].getTerm()); + + // Insert after element + proc.setBroker(broker); + proc.setDocumentSet(docs); + xupdate = + XUPDATE_START + + " <xu:insert-after select=\"//item[@id = '1']\">" + + " <item id='1.1'><description>refrigerator</description> <condition>perfect</condition></item>" + + " </xu:insert-after>" + + XUPDATE_END; + modifications = proc.parse(new InputSource(new StringReader(xupdate))); + assertNotNull(modifications); + modifications[0].process(transaction); + proc.reset(); + + checkIndex(docs, broker, new QName[] { new QName("condition", "") }, null, 4); + checkIndex(docs, broker, new QName[] { new QName("description", "") }, null, 6); + checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 10); + + o = checkIndex(docs, broker, new QName[] { new QName("condition", "") }, "perfect", 1); + assertEquals("perfect", o[0].getTerm()); + o = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "refrigerator", 1); + assertEquals("refrigerator", o[0].getTerm()); + o = checkIndex(docs, broker, new QName[] { new QName("item", "") }, "perfect", 1); + assertEquals("perfect", o[0].getTerm()); + o = checkIndex(docs, broker, new QName[] { new QName("item", "") }, "refrigerator", 1); + assertEquals("refrigerator", o[0].getTerm()); + + proc.setBroker(broker); + proc.setDocumentSet(docs); + xupdate = + XUPDATE_START + + " <xu:insert-after select=\"//item[@id = '1']/description\">" + + " <condition>average</condition>" + + " </xu:insert-after>" + + XUPDATE_END; + modifications = proc.parse(new InputSource(new StringReader(xupdate))); + assertNotNull(modifications); + modifications[0].process(transaction); + proc.reset(); + + checkIndex(docs, broker, new QName[] { new QName("condition", "") }, null, 5); + checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 11); + o = checkIndex(docs, broker, new QName[] { new QName("condition", "") }, "average", 1); + assertEquals("average", o[0].getTerm()); + o = checkIndex(docs, broker, new QName[] { new QName("item", "") }, "average", 1); + assertEquals("average", o[0].getTerm()); + + // Insert before nested element + proc.setBroker(broker); + proc.setDocumentSet(docs); + xupdate = + XUPDATE_START + + " <xu:insert-before select=\"//item[@id = '1']/description\">" + + " <condition>awesome</condition>" + + " </xu:insert-before>" + + XUPDATE_END; + modifications = proc.parse(new InputSource(new StringReader(xupdate))); + assertNotNull(modifications); + modifications[0].process(transaction); + proc.reset(); + + checkIndex(docs, broker, new QName[] { new QName("condition", "") }, null, 6); + checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 12); + o = checkIndex(docs, broker, new QName[] { new QName("condition", "") }, "awesome", 1); + assertEquals("awesome", o[0].getTerm()); + o = checkIndex(docs, broker, new QName[] { new QName("item", "") }, "awesome", 1); + assertEquals("awesome", o[0].getTerm()); + + // Overwrite attribute + proc.setBroker(broker); + proc.setDocumentSet(docs); + xupdate = + XUPDATE_START + + " <xu:append select=\"//item[@id = '1']\">" + + " <xu:attribute name=\"attr\">abc</xu:attribute>" + + " </xu:append>" + + XUPDATE_END; + modifications = proc.parse(new InputSource(new StringReader(xupdate))); + assertNotNull(modifications); + modifications[0].process(transaction); + proc.reset(); + + QName qnattr[] = { new QName("attr", "", "") }; + qnattr[0].setNameType(ElementValue.ATTRIBUTE); + o = checkIndex(docs, broker, qnattr, null, 1); + assertEquals("abc", o[0].getTerm()); + checkIndex(docs, broker, qnattr, "attribute", 0); + + transact.commit(transaction); + } catch (Exception e) { + if (transact != null) + transact.abort(transaction); + e.printStackTrace(); + fail(e.getMessage()); + } finally { + if (pool != null) { + pool.release(broker); + } + } + } + + @Test + public void xupdateUpdate() { + DocumentSet docs = configureAndStore(COLLECTION_CONFIG2, XML2, "xupdate.xml", metas1); + DBBroker broker = null; + TransactionManager transact = null; + Txn transaction = null; + try { + broker = pool.get(pool.getSecurityManager().getSystemSubject()); + transact = pool.getTransactionManager(); + transaction = transact.beginTransaction(); + + Occurrences occur[] = checkIndex(docs, broker, new QName[] { new QName("description", "") }, "chair", 1); + assertEquals("chair", occur[0].getTerm()); + checkIndex(docs, broker, new QName[] { new QName("item", "") }, null, 5); + + XQuery xquery = broker.getXQueryService(); + assertNotNull(xquery); + Sequence seq = xquery.execute("//item[ft:query(description, '... [truncated message content] |
From: <sha...@us...> - 2013-07-24 19:39:48
|
Revision: 18765 http://sourceforge.net/p/exist/code/18765 Author: shabanovd Date: 2013-07-24 19:39:46 +0000 (Wed, 24 Jul 2013) Log Message: ----------- [ignore] avoid NPE Modified Paths: -------------- branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java branches/rangeindex/src/org/exist/storage/NativeBroker.java Modified: branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java =================================================================== --- branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java 2013-07-23 22:27:36 UTC (rev 18764) +++ branches/rangeindex/extensions/indexes/lucene/src/org/exist/indexing/lucene/LuceneIndexWorker.java 2013-07-24 19:39:46 UTC (rev 18765) @@ -88,8 +88,6 @@ protected LuceneIndex index; - private IndexController controller; - private LuceneMatchListener matchListener = null; private XMLToQuery queryTranslator; @@ -135,7 +133,6 @@ } public Object configure(IndexController controller, NodeList configNodes, Map<String, String> namespaces) throws DatabaseConfigurationException { - this.controller = controller; LOG.debug("Configuring lucene index..."); config = new LuceneConfig(configNodes, namespaces); return config; @@ -1142,7 +1139,7 @@ final List<Field> metas = new ArrayList<Field>(); final List<CategoryPath> paths = new ArrayList<CategoryPath>(); - controller.streamMetas(new MetaStreamListener() { + broker.getIndexController().streamMetas(new MetaStreamListener() { @Override public void metadata(QName key, Object value) { if (value instanceof String) { Modified: branches/rangeindex/src/org/exist/storage/NativeBroker.java =================================================================== --- branches/rangeindex/src/org/exist/storage/NativeBroker.java 2013-07-23 22:27:36 UTC (rev 18764) +++ branches/rangeindex/src/org/exist/storage/NativeBroker.java 2013-07-24 19:39:46 UTC (rev 18765) @@ -1783,7 +1783,7 @@ reindexCollection(transaction, collection, mode); transact.commit(transaction); - } catch (final TransactionException e) { + } catch (final Exception e) { transact.abort(transaction); LOG.warn("An error occurred during reindex: " + e.getMessage(), e); |
From: <sha...@us...> - 2013-07-26 15:28:23
|
Revision: 18778 http://sourceforge.net/p/exist/code/18778 Author: shabanovd Date: 2013-07-26 15:28:17 +0000 (Fri, 26 Jul 2013) Log Message: ----------- [ignore] move metadata interfaces to core because of dependencies at lucene index Added Paths: ----------- branches/rangeindex/src/org/exist/storage/md/ branches/rangeindex/src/org/exist/storage/md/Meta.java branches/rangeindex/src/org/exist/storage/md/MetaData.java branches/rangeindex/src/org/exist/storage/md/Metas.java Removed Paths: ------------- branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/Meta.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/MetaData.java branches/rangeindex/extensions/metadata/interface/src/main/java/org/exist/storage/md/Metas.java Added: branches/rangeindex/src/org/exist/storage/md/Meta.java =================================================================== --- branches/rangeindex/src/org/exist/storage/md/Meta.java (rev 0) +++ branches/rangeindex/src/org/exist/storage/md/Meta.java 2013-07-26 15:28:17 UTC (rev 18778) @@ -0,0 +1,39 @@ +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.storage.md; + +/** + * @author <a href="mailto:sha...@gm...">Dmitriy Shabanov</a> + * + */ +public interface Meta { + + public String getUUID(); + + public String getKey(); + + public Object getValue(); + + public String getObject(); + + public void delete(); +} \ No newline at end of file Added: branches/rangeindex/src/org/exist/storage/md/MetaData.java =================================================================== --- branches/rangeindex/src/org/exist/storage/md/MetaData.java (rev 0) +++ branches/rangeindex/src/org/exist/storage/md/MetaData.java 2013-07-26 15:28:17 UTC (rev 18778) @@ -0,0 +1,86 @@ +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.storage.md; + +import java.util.List; + +import org.apache.log4j.Logger; +import org.exist.EXistException; +import org.exist.collections.Collection; +import org.exist.dom.DocumentAtExist; +import org.exist.dom.DocumentImpl; +import org.exist.security.PermissionDeniedException; +import org.exist.storage.MetaStorage; +import org.exist.xmldb.XmldbURI; + +/** + * @author <a href="mailto:sha...@gm...">Dmitriy Shabanov</a> + * + */ +public abstract class MetaData implements MetaStorage { + + protected static MetaData _ = null; + + public static MetaData get() { + return _; + } + + protected final static Logger LOG = Logger.getLogger(MetaData.class); + + public abstract DocumentImpl getDocument(String uuid) throws EXistException, PermissionDeniedException; + public abstract Collection getCollection(String uuid) throws EXistException, PermissionDeniedException; + + public abstract List<DocumentImpl> matchDocuments(String key, String value) throws EXistException, PermissionDeniedException; + public abstract List<DocumentImpl> matchDocumentsByKey(String key) throws EXistException, PermissionDeniedException; + public abstract List<DocumentImpl> matchDocumentsByValue(String value) throws EXistException, PermissionDeniedException; + + public abstract Metas addMetas(DocumentAtExist doc); + public abstract Metas addMetas(Collection col); + + public abstract Meta getMeta(String uuid); + + //low level + protected abstract Meta _addMeta(Metas metas, String uuid, String key, String value); + protected abstract Metas _addMetas(String uri, String uuid); + protected abstract Metas replaceMetas(XmldbURI uri, String uuid); + + public abstract Metas getMetas(DocumentAtExist doc); + public abstract Metas getMetas(XmldbURI uri); + + public abstract void copyMetas(XmldbURI oldDoc, DocumentImpl newDoc); + public abstract void copyMetas(XmldbURI oldDoc, Collection newCol); + + public abstract void moveMetas(XmldbURI oldUri, XmldbURI newUri); + + public abstract void delMetas(XmldbURI uri); + + public abstract void sync(); + public abstract void close(); + + public abstract XmldbURI UUIDtoURI(String uuid); + public abstract String URItoUUID(XmldbURI uri); + +// public abstract void indexMetas(Metas metas); + +// public abstract NodeImpl search(String queryText, List<String> toBeMatchedURIs) throws XPathException; +// public abstract List<String> searchDocuments(String queryText, List<String> toBeMatchedURIs) throws XPathException; +} Added: branches/rangeindex/src/org/exist/storage/md/Metas.java =================================================================== --- branches/rangeindex/src/org/exist/storage/md/Metas.java (rev 0) +++ branches/rangeindex/src/org/exist/storage/md/Metas.java 2013-07-26 15:28:17 UTC (rev 18778) @@ -0,0 +1,45 @@ +/* + * eXist Open Source Native XML Database + * Copyright (C) 2012 The eXist Project + * http://exist-db.org + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * 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 Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + * $Id$ + */ +package org.exist.storage.md; + +import java.util.List; + +/** + * @author <a href="mailto:sha...@gm...">Dmitriy Shabanov</a> + * + */ +public interface Metas { + + public String getUUID(); + + public String getURI(); + + public Meta get(String key); + + public Meta put(String key, Object value); + + public void delete(String key); + + public List<Meta> metas(); + + public void delete(); +} |