Permalink
Browse files

Bug fixes related to deleting documents, benchmark work

  • Loading branch information...
1 parent 89797a1 commit b119c887b8bf419e7f7b6482a0fa265d1ecd0f25 @tjake committed Dec 21, 2010
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+SCHEMA_URL=http://localhost:8983/solandra/schema/bench
+SCHEMA=schema.xml
+
+curl $SCHEMA_URL --data-binary @$SCHEMA -H 'Content-type:text/xml; charset=utf-8'
+
+echo "Posted $SCHEMA to $SCHEMA_URL"
@@ -0,0 +1,4 @@
+
+#!/bin/bash
+
+java -ea -Xmx1G -Xms256M -cp $( echo ../*.jar ../lib/*.jar ../resources | sed 's/ /:/g') lucandra.benchmarks.BenchmarkTest $*
@@ -1,4 +0,0 @@
-
-#!/bin/bash
-
-java -ea -Xmx1G -Xms256M -cp $( echo *.jar lib/*.jar config config| sed 's/ /:/g') lucandra.benchmarks.BenchmarkTest $*
File renamed without changes.
@@ -277,9 +277,7 @@ public static void addMutations(Map<ByteBuffer, RowMutation> mutationList, Strin
RowMutation rm = mutationList.get(key);
if (rm == null)
{
-
rm = new RowMutation(CassandraUtils.keySpace, key);
-
mutationList.put(key, rm);
}
@@ -300,7 +298,7 @@ public static void addMutations(Map<ByteBuffer, RowMutation> mutationList, Strin
{ // insert
rm.add(new QueryPath(columnFamily, null, column), value, System.currentTimeMillis());
-
+
}
}
@@ -91,16 +91,15 @@
private final static ThreadLocal<Map<String, byte[]>> fieldNorms = new ThreadLocal<Map<String, byte[]>>();
private final static ThreadLocal<OpenBitSet> docsHit = new ThreadLocal<OpenBitSet>();
private final static ThreadLocal<Object> fieldCacheRefs = new ThreadLocal<Object>();
-
-
+
private static final Logger logger = Logger.getLogger(IndexReader.class);
public IndexReader(String name) {
super();
setIndexName(name);
}
- public synchronized IndexReader reopen() throws CorruptIndexException, IOException {
+ public synchronized IndexReader reopen() throws CorruptIndexException, IOException {
clearCache();
return this;
@@ -132,8 +131,6 @@ public synchronized void clearCache() {
if (fieldCacheRefs.get() != null)
fieldCacheRefs.set(UUID.randomUUID());
-
-
}
protected void doClose() throws IOException {
@@ -484,6 +481,12 @@ public String getIndexName() {
public void setIndexName(String name) {
+
+ String currentName = indexName.get();
+
+ if(currentName == null || !currentName.equals(name))
+ clearCache();
+
indexName.set(name);
}
@@ -497,8 +500,6 @@ public void addTermEnumCache(Term term, LucandraTermEnum termEnum) {
@Override
public Directory directory() {
- clearCache();
-
return mockDirectory;
}
@@ -305,10 +305,7 @@ public void deleteDocuments(Query query) throws CorruptIndexException, IOExcepti
for (int i = 0; i < results.totalHits; i++) {
ScoreDoc doc = results.scoreDocs[i];
- byte[] docId = Integer.toHexString(doc.doc).getBytes();
-
- deleteLucandraDocument(docId);
-
+ deleteLucandraDocument(doc.doc);
}
}
@@ -331,7 +328,7 @@ public void deleteDocuments(Term term) throws CorruptIndexException, IOException
Collection<IColumn> columns = row.cf.getSortedColumns();
for (IColumn col : columns) {
- deleteLucandraDocument(Integer.toHexString(CassandraUtils.readVInt(col.name())).getBytes());
+ deleteLucandraDocument(CassandraUtils.readVInt(col.name()));
}
}
}
@@ -345,8 +342,10 @@ public void deleteDocuments(Term term) throws CorruptIndexException, IOException
}
}
- private void deleteLucandraDocument(byte[] docId) {
+ private void deleteLucandraDocument(int docNumber) {
+ byte[] docId = Integer.toHexString(docNumber).getBytes();
+
ByteBuffer key = CassandraUtils.hashKeyBytes(getIndexName().getBytes(), CassandraUtils.delimeterBytes, docId);
List<Row> rows = CassandraUtils.robustRead(key, CassandraUtils.metaColumnPath, Arrays.asList(CassandraUtils.documentMetaFieldBytes), ConsistencyLevel.ONE);
@@ -377,7 +376,7 @@ private void deleteLucandraDocument(byte[] docId) {
throw new RuntimeException("JVM doesn't support UTF-8", e);
}
- CassandraUtils.addMutations(getMutationList(), CassandraUtils.termVecColumnFamily, docId, key, (ByteBuffer)null);
+ CassandraUtils.addMutations(getMutationList(), CassandraUtils.termVecColumnFamily, CassandraUtils.writeVInt(docNumber), key, (ByteBuffer)null);
}
// finally delete ourselves
@@ -147,6 +147,9 @@ private void fillDocBuffer()
Row row = rows.get(0);
+ if(row == null || row.cf == null)
+ return;
+
for(IColumn sc : row.cf.getSortedColumns()){
Integer id = Integer.valueOf(ByteBufferUtil.string(sc.name()));
Oops, something went wrong.

0 comments on commit b119c88

Please sign in to comment.