Skip to content

Commit

Permalink
Merge branch 'solandra' of git://github.com/tjake/Solandra into solandra
Browse files Browse the repository at this point in the history
Conflicts:
	test/lucandra/cluster/IndexManagerTests.java
  • Loading branch information
ceocoder committed May 19, 2011
2 parents 97dd32c + ec35913 commit 6b791b4
Show file tree
Hide file tree
Showing 7 changed files with 493 additions and 257 deletions.
25 changes: 25 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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}" />
Expand Down
4 changes: 2 additions & 2 deletions reuters-demo/schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
38 changes: 31 additions & 7 deletions src/lucandra/IndexWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 6b791b4

Please sign in to comment.