Permalink
Browse files

Merge branch 'solandra' of git://github.com/tjake/Solandra into solandra

Conflicts:
	test/lucandra/cluster/IndexManagerTests.java
  • Loading branch information...
ceocoder committed May 19, 2011
2 parents 97dd32c + ec35913 commit 6b791b4d1397d1ccc01fbe0a5d72cd2f68c1974a
View
@@ -170,6 +170,31 @@
<fail if="testfailed" message="Some test(s) failed." />
</target>
+ <target name="test-long" depends="compile.tests">
+ <echo message="running tests" />
+ <mkdir dir="${build}/output" />
+ <junit fork="on" failureproperty="testfailed">
+
+ <classpath>
+ <path refid="solandra.classpath"/>
+ <pathelement location="${basedir}/solandra-app/"/>
+ </classpath>
+
+ <formatter type="xml" usefile="true" />
+ <formatter type="brief" usefile="false" />
+
+ <batchtest todir="${build}/output">
+ <fileset dir="${build.test.classes}" includes="**/IndexManagerTests.class" />
+ </batchtest>
+
+ <jvmarg value="-Xmx1G" />
+ <jvmarg value="-Dlog4j.configuration=file:///${basedir}/resources/log4j.properties"/>
+ <jvmarg value="-Dlog4j.defaultInitOverride=true" />
+
+ </junit>
+ <fail if="testfailed" message="Some test(s) failed." />
+ </target>
+
<target name="solandra.jar" depends="compile,compile.tests">
<jar jarfile="solandra.jar" basedir="${build.classes}" />
<jar jarfile="solandra-tests.jar" basedir="${build.test.classes}" />
View
@@ -221,8 +221,8 @@
<fields>
<field name="id" type="string" indexed="true" stored="true" required="true" />
- <field name="title" type="text" indexed="true" stored="true"/>
- <field name="text" type="text" indexed="true" stored="true"/>
+ <field name="title" type="text" indexed="true" stored="true" termPositions="true"/>
+ <field name="text" type="text" indexed="true" stored="true" termPositions="true"/>
<field name="date" type="date" indexed="true" stored="true"/>
<field name="dateline" type="text" indexed="true" stored="true"/>
<field name="places" type="string" indexed="true" stored="true" multiValued="true" omitNorms="true" termVectors="true" />
@@ -36,7 +36,9 @@
import com.google.common.collect.MapMaker;
import org.apache.cassandra.db.*;
+import org.apache.cassandra.db.filter.QueryPath;
import org.apache.cassandra.thrift.ColumnParent;
+import org.apache.cassandra.thrift.ConsistencyLevel;
import org.apache.cassandra.utils.ByteBufferUtil;
import org.apache.cassandra.utils.Pair;
import org.apache.log4j.Logger;
@@ -355,23 +357,45 @@ public void addDocument(String indexName, Document doc, Analyzer analyzer, int d
commit(indexName, false);
}
- public TopDocs deleteDocuments(String indexName, Query query, boolean autoCommit) throws CorruptIndexException,
+ public long deleteDocuments(String indexName, Query query, boolean autoCommit) throws CorruptIndexException,
IOException
{
IndexReader reader = new IndexReader(indexName);
IndexSearcher searcher = new IndexSearcher(reader);
- TopDocs results = searcher.search(query, 1000);
+
+ // Also delete the id lookup
+ ByteBuffer idKey = CassandraUtils.hashKeyBytes(indexName.getBytes("UTF-8"),
+ CassandraUtils.delimeterBytes, "ids".getBytes("UTF-8"));
+
+ RowMutation rm = new RowMutation(CassandraUtils.keySpace, idKey);
- for (int i = 0; i < results.totalHits; i++)
+
+ TopDocs results = null;
+ long total = 0;
+ do
{
- ScoreDoc doc = results.scoreDocs[i];
+ results = searcher.search(query, 1024);
- deleteLucandraDocument(indexName, doc.doc, autoCommit);
- }
+ for (int i = 0; i < results.totalHits; i++)
+ {
+ ScoreDoc doc = results.scoreDocs[i];
- return results;
+ deleteLucandraDocument(indexName, doc.doc, true);
+
+ //Scale the doc ID to the sharded id.
+ ByteBuffer buf = ByteBufferUtil.bytes(String.valueOf(doc.doc));
+ rm.delete(new QueryPath(CassandraUtils.schemaInfoColumnFamily, buf), System.currentTimeMillis());
+ }
+
+
+ CassandraUtils.robustInsert(ConsistencyLevel.QUORUM, rm);
+
+ total += results.totalHits;
+ }while(results.totalHits > 0);
+
+ return total;
}
public void deleteDocuments(String indexName, Term term, boolean autoCommit) throws CorruptIndexException,
Oops, something went wrong.

0 comments on commit 6b791b4

Please sign in to comment.