-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
searchCollector (use in limited conf)
- Loading branch information
Showing
14 changed files
with
288 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package net.ion.nsearcher.search; | ||
|
||
import java.io.IOException; | ||
import java.util.Set; | ||
|
||
import org.apache.lucene.index.DirectoryReader; | ||
|
||
import net.ion.nsearcher.common.ReadDocument; | ||
|
||
public abstract class AbstractDocCollector implements DocCollector { | ||
public abstract ColResult accept(ReadDocument doc) ; | ||
|
||
public ColResult accept(DirectoryReader dreader, SearchRequest sreq, int docId) throws IOException{ | ||
return accept(toDoc(dreader, sreq, docId)) ; | ||
} | ||
|
||
private ReadDocument toDoc(DirectoryReader dreader, SearchRequest sreq, int docId) throws IOException { | ||
Set<String> fields = sreq.selectorField(); | ||
if (fields == null || fields.size() == 0) { | ||
return ReadDocument.loadDocument(dreader.document(docId)); | ||
} | ||
return ReadDocument.loadDocument(dreader.document(docId, sreq.selectorField())); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package net.ion.nsearcher.search; | ||
|
||
import java.io.IOException; | ||
|
||
import org.apache.lucene.index.DirectoryReader; | ||
|
||
public interface DocCollector { | ||
|
||
public enum ColResult { | ||
ACCEPT, REVOKE, BREAK | ||
} | ||
|
||
public final static DocCollector BLANK = new DocCollector() { | ||
public ColResult accept(DirectoryReader dreader, SearchRequest sreq, int docId) { | ||
return ColResult.ACCEPT; | ||
} | ||
}; | ||
|
||
public ColResult accept(DirectoryReader dreader, SearchRequest sreq, int docId) throws IOException ; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package net.ion.nsearcher.search; | ||
|
||
import java.io.IOException; | ||
|
||
import net.ion.framework.db.Page; | ||
|
||
import org.apache.lucene.index.DirectoryReader; | ||
|
||
public class PageCollector implements DocCollector{ | ||
|
||
private Page page ; | ||
private DocCollector pre; | ||
private int count = -1 ; | ||
|
||
public PageCollector(Page page, DocCollector pre){ | ||
this.page = page ; | ||
this.pre = pre ; | ||
} | ||
|
||
@Override | ||
public ColResult accept(DirectoryReader dreader, SearchRequest sreq, int docId) throws IOException { | ||
if (pre.accept(dreader, sreq, docId) == ColResult.ACCEPT){ | ||
count++ ; | ||
if (count >= page.getStartLoc() && count < page.getEndLoc()){ | ||
return ColResult.ACCEPT ; | ||
} else if (count == page.getEndLoc()){ | ||
return ColResult.BREAK ; | ||
} | ||
} | ||
return ColResult.REVOKE ; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.