private DocIdSet createDocSetOld(ArrayList<Integer> nums) throws Exception { DocSet p4d = DocSetFactory.getP4DDocSetInstance(); for (int num : nums) { p4d.addDoc(num); } return p4d; }
private DocIdSet createDocSet(int[] nums) throws Exception { DocSet p4d = DocSetFactory.getPForDeltaDocSetInstance(); for (int num : nums) { p4d.addDoc(num); } return p4d; }
@Test public void _testFind() throws Exception { // test the accuracy of PForDeltaDocIdSet.find() System.out.println("Running test case: PForDeltaDocIdSet.find() ..."); ArrayList<OpenBitSet> obs = new ArrayList<OpenBitSet>(); ArrayList<DocIdSet> docs = new ArrayList<DocIdSet>(); int maxDoc = 35000; int listNum = 1; getRandomDataSets(obs, docs, maxDoc, listNum); ArrayList<Integer> input = bitSetToArrayList(obs.get(0)); DocSet docSet = new PForDeltaDocIdSet(); boolean saw403 = false; for (Integer integer : input) { if (integer == 403) { saw403 = true; System.out.println("find the guy"); } docSet.addDoc(integer); } boolean got = docSet.find(403); assertEquals(saw403, got); System.out.println("---------------completed----------------------------"); }
private DocIdSet createDocSetOldBatch(ArrayList<Integer> nums) throws Exception { DocSet p4d = DocSetFactory.getP4DDocSetInstance(); int[] numsArray = new int[nums.size()]; int i = 0; for (Integer num : nums) { numsArray[i++] = num; } p4d.addDocs(numsArray, 0, numsArray.length); return p4d; }
@Test public void _testPartialEmptyAnd() throws IOException { // test the accuracy of PForDeltaOrDocIdSet try { ArrayList<Integer> output = new ArrayList<Integer>(); System.out.println( "Running OrDocIdSet of PForDeltaDocIdSet test case: partial empty and ..."); DocSet ds1 = new PForDeltaDocIdSet(); DocSet ds2 = new PForDeltaDocIdSet(); ds2.addDoc(42); ds2.addDoc(57); ds2.addDoc(99); ArrayList<DocIdSet> docs = new ArrayList<DocIdSet>(); docs.add(ds1); // ds1 is empty docs.add(ds2); DocSet ds3 = new PForDeltaDocIdSet(); DocSet ds4 = new PForDeltaDocIdSet(); ds4.addDoc(57); ds4.addDoc(80); ds4.addDoc(99); ArrayList<DocIdSet> docs2 = new ArrayList<DocIdSet>(); docs2.add(ds3); // ds3 is empty docs2.add(ds4); // PForDeltaOrDocIdSet orlist1 = new PForDeltaOrDocIdSet(docs); // PForDeltaOrDocIdSet orlist2 = new PForDeltaOrDocIdSet(docs2); OrDocIdSet orlist1 = new OrDocIdSet(docs); OrDocIdSet orlist2 = new OrDocIdSet(docs2); ArrayList<DocIdSet> docs3 = new ArrayList<DocIdSet>(); docs3.add(orlist1); docs3.add(orlist2); AndDocIdSet andlist = new AndDocIdSet(docs3); DocIdSetIterator iter = andlist.iterator(); int docId = iter.nextDoc(); while (docId != DocIdSetIterator.NO_MORE_DOCS) { output.add(docId); docId = iter.nextDoc(); } assertEquals(57, output.get(0).intValue()); assertEquals(99, output.get(1).intValue()); } catch (Exception e) { e.printStackTrace(); } System.out.println("-----------------completed--------------------------"); }
private DocIdSet createDocSetOldBatch(int[] nums) throws Exception { DocSet p4d = DocSetFactory.getP4DDocSetInstance(); p4d.addDocs(nums, 0, nums.length); return p4d; }