Permalink
Browse files

include uuid and digest in index info (closes #132)

  • Loading branch information...
1 parent 1ed435a commit 25ab23b271e91591867bcad3432ba2dbba4dc007 Robert Newson committed Aug 1, 2011
Showing with 14 additions and 2 deletions.
  1. +14 −2 src/main/java/com/github/rnewson/couchdb/lucene/DatabaseIndexer.java
@@ -85,14 +85,16 @@
private IndexReader reader;
private final IndexWriter writer;
private final Database database;
+ private final View view;
public IndexState(final DocumentConverter converter,
final IndexWriter writer, final Analyzer analyzer,
- final Database database) {
+ final Database database, final View view) {
this.converter = converter;
this.writer = writer;
this.analyzer = analyzer;
this.database = database;
+ this.view = view;
}
public synchronized IndexReader borrowReader(final boolean staleOk)
@@ -151,6 +153,14 @@ private synchronized String getEtag() {
return etag;
}
+ public UUID getUuid() throws JSONException, IOException {
+ return database.getUuid();
+ }
+
+ public String getDigest() {
+ return view.getDigest();
+ }
+
private String newEtag() {
return Long.toHexString(now());
}
@@ -398,6 +408,8 @@ public void info(final HttpServletRequest req,
result.put("disk_size", Utils.directorySize(reader.directory()));
result.put("doc_count", reader.numDocs());
result.put("doc_del_count", reader.numDeletedDocs());
+ result.put("uuid", state.getUuid());
+ result.put("digest", state.getDigest());
final JSONArray fields = new JSONArray();
for (final Object field : reader.getFieldNames(FieldOption.INDEXED)) {
if (((String) field).startsWith("_")) {
@@ -760,7 +772,7 @@ private void init() throws IOException, JSONException {
final IndexWriter writer = newWriter(dir);
final IndexState state = new IndexState(converter, writer,
- view.getAnalyzer(), database);
+ view.getAnalyzer(), database, view);
state.setPendingSequence(seq);
states.put(view, state);
}

0 comments on commit 25ab23b

Please sign in to comment.