Skip to content
Browse files

fix term reader bug

  • Loading branch information...
1 parent 3af3b0b commit 944a399db6a2a464e624929c82e03707c4c29d0e @tjake committed Jul 18, 2011
View
46 resources/tests/solandra.properties
@@ -0,0 +1,46 @@
+
+#Set to true if you want solandra to compress fields + meta data
+#This will size on disk at the cost of indexing speed
+#Compression is google snappy
+solandra.compression = true
+
+#The consistency level of solandra reads and writes
+solandra.consistency = QUORUM
+
+#The number of milliseconds solandra will wait before
+#checking to see if it's cache needs to be invalidated
+#for a given index
+solandra.cache.invalidation.check.interval = 1000
+
+#The largest number of documents to store in one sub-index
+#
+#Solandra splits a index into sub-indexes in order to search them in parallel
+#across nodes.
+#
+#*NOTE* This value should not be changed once documents are indexed
+#*NOTE* This value must be a power of 2
+solandra.maximum.docs.per.shard = 1048576
+
+#The number of index ids to reserve at a time
+#*NOTE* this value must be a power of 2
+solandra.index.id.reserve.size = 16384
+
+#The number of shards to write to at once
+#This should roughly equal the number of
+#nodes in your cluster
+solandra.shards.at.once = 4
+
+#The number of documents to buffer per index
+#before forcing a commit.
+solandra.write.buffer.queue.size = 16
+
+#keyspace name for solandra
+solandra.keyspace = L
+
+#The number of retries solandra will attempt before
+#failing a write or read (TimeoutException)
+cassandra.retries = 1024
+
+#The number of milliseconds solandra will wait before
+#retrying a read or write
+cassandra.retries.sleep = 100
View
9 src/lucandra/IndexReader.java
@@ -44,6 +44,8 @@
import org.apache.lucene.index.IndexWriter.MaxFieldLength;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.TermFreqVector;
+import org.apache.lucene.search.FieldCache;
+import org.apache.lucene.search.LucandraFieldCache;
import org.apache.lucene.search.Similarity;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.LockObtainFailedException;
@@ -113,11 +115,15 @@ public synchronized IndexReader reopen(IndexCommit commit) throws CorruptIndexEx
public void clearCache()
{
-
String activeIndex = getIndexName();
if (activeIndex != null)
{
+ if(FieldCache.DEFAULT instanceof LucandraFieldCache)
+ {
+ LucandraFieldCache.purgeReader.finished(this);
+ }
+
globalCache.remove(activeIndex);
}
@@ -367,7 +373,6 @@ else if(term.isSetIs_binary())
@Override
public Object getCoreCacheKey()
{
-
try
{
return getCache().fieldCacheKey;
View
16 src/lucandra/LucandraTermEnum.java
@@ -84,25 +84,21 @@ public int docFreq()
@Override
public boolean next() throws IOException
{
- // current term is in tree
- if (termView.size() < 2)
- {
- //logger.info("Reached end of term list");
- currentTermEntry = null;
+ if(currentTermEntry == null)
return false;
- }
-
+
+ // current term is in tree
termView = termView.tailMap(currentTermEntry.getKey(), false);
- currentTermEntry = termView.firstEntry();
+ currentTermEntry = termView.firstEntry() == null ? currentTermEntry : termView.firstEntry();
// rebuffer from last key
- if (termView.size() == 1)
+ if (termView.size() == 0)
{
//logger.info("Rebuffering terms");
termView = termCache.skipTo(currentTermEntry.getKey());
- if (termView.size() < 2 && termView.firstEntry().getKey().equals(currentTermEntry))
+ if (termView.size() < 2 && termView.firstEntry().getKey().equals(currentTermEntry.getKey()))
{
currentTermEntry = null;
return false;
View
5 src/lucandra/ReaderCache.java
@@ -26,12 +26,15 @@
import com.google.common.collect.MapMaker;
+import org.apache.log4j.Logger;
import org.apache.lucene.document.Document;
import org.apache.lucene.index.IndexReader.ReaderFinishedListener;
import org.apache.lucene.util.OpenBitSet;
public class ReaderCache
{
+ private static final Logger logger = Logger.getLogger(ReaderCache.class);
+
public final String indexName;
public final Map<Integer, Document> documents;
public final TermCache termCache;
@@ -50,7 +53,7 @@ public ReaderCache(String indexName) throws IOException
docHits = new OpenBitSet(CassandraIndexManager.maxDocsPerShard);
readerFinishedListeners = new ArrayList<ReaderFinishedListener>();
- fieldCacheKey = UUID.randomUUID();
+ fieldCacheKey = UUID.randomUUID();
}
View
4 src/lucandra/TermCache.java
@@ -74,7 +74,7 @@ public TermCache(String indexName) throws IOException
range = bufferTerms(skip, bufferSize);
}
- //logger.info(range);
+ //logger.info(Thread.currentThread().getName()+" rebuffered "+needsBuffering+" "+range);
if (skip.compareTo(range.left) >= 0 && (!range.right.equals(emptyTerm)) && skip.compareTo(range.right) <= 0)
{
@@ -203,7 +203,7 @@ public TermCache(String indexName) throws IOException
if (row.cf == null)
{
- logger.info("Encountered deleted row");
+ //logger.info("Encountered deleted row");
continue;
}
String key = ByteBufferUtil.string(row.key.key, CassandraUtils.UTF_8);
View
2 src/org/apache/lucene/search/LucandraFieldCache.java
@@ -160,7 +160,7 @@ public Object getValue()
{
}
- final static IndexReader.ReaderFinishedListener purgeReader = new IndexReader.ReaderFinishedListener() {
+ public final static IndexReader.ReaderFinishedListener purgeReader = new IndexReader.ReaderFinishedListener() {
public void finished(IndexReader reader)
{
View
4 src/solandra/SolandraIndexWriter.java
@@ -233,8 +233,8 @@ public int addDoc(AddUpdateCommand cmd) throws IOException
if (docId != null)
{
isUpdate = true;
- // if(logger.isDebugEnabled())
- logger.info("update for document " + docId);
+ if(logger.isDebugEnabled())
+ logger.debug("update for document " + docId);
}
else
{
View
8 test/solandra/SolandraTests.java
@@ -85,7 +85,7 @@
public static void setUpBeforeClass()
{
- CassandraUtils.cacheInvalidationInterval = 0; // real-time
+ //CassandraUtils.cacheInvalidationInterval = 0; // real-time
try
{
@@ -700,6 +700,7 @@ public void testAllUUIDSearchAgain() throws Exception
SolrQuery q = new SolrQuery().setQuery("uuid:[* TO *]");
QueryResponse r = otherClient.query(q);
+
assertEquals(27, r.getResults().getNumFound());
}
@@ -889,10 +890,14 @@ public void testAddMoreDocuments() throws Exception
docs
.add("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><add><doc><field name=\"messageType\">InstructionDef</field><field name=\"ownerUUID\">29c9d1e1-86d0-499f-801a-bd03618deb35</field><field name=\"generatorUUID\">29c9d1e1-86d0-499f-801a-bd03618deb35</field><field name=\"key\">stop</field><field name=\"name\">Stop this transport.</field><field name=\"desc\">Stop this transport.</field><field name=\"uuid\">867441f2-ff91-4bc4-aa28-a7c1c4900d02</field><field name=\"json\">{\"InstructionDef\":{\"uuid\":\"867441f2-ff91-4bc4-aa28-a7c1c4900d02\",\"ownerUUID\":\"29c9d1e1-86d0-499f-801a-bd03618deb35\",\"generatorUUID\":\"29c9d1e1-86d0-499f-801a-bd03618deb35\",\"key\":\"stop\",\"name\":\"Stop this transport.\",\"desc\":\"Stop this transport.\"}}</field></doc></add>");
+
+
URL url = new URL("http://localhost:" + port + "/solandra/~" + otherIndexName + "/update?commit=true");
writeDocs(docs, url);
+ otherClient.commit(true, true);
+
SolrQuery q = new SolrQuery().setQuery("*:*");
try
@@ -943,7 +948,6 @@ public void testSingleSearchQuery() throws Exception
assertEquals(7, r.getResults().getNumFound());
q = new SolrQuery().setQuery("messageType:[* TO *]");
-
r = otherClient.query(q);
assertEquals(42, r.getResults().getNumFound());

0 comments on commit 944a399

Please sign in to comment.
Something went wrong with that request. Please try again.