store.deleteByQuery(query);//don't you love that HBase sometimes does not delete arbitrarily
assertNumResults(store.newQuery(), URLS.length);
//assert that data is deleted
for (int i = 0; i < SORTED_URLS.length; i++) {
WebPage page = store.get(SORTED_URLS[i]);
Assert.assertNotNull(page);
Assert.assertNotNull(page.getUrl());
Assert.assertEquals(page.getUrl().toString(), SORTED_URLS[i]);
Assert.assertEquals(0, page.getOutlinks().size());
Assert.assertEquals(0, page.getParsedContent().size());
if(page.getContent() != null) {
System.out.println("url:" + page.getUrl().toString());
System.out.println( "limit:" + page.getContent().limit());
} else {
Assert.assertNull(page.getContent());
}
}
//test 6 - delete some with some fields
WebPageDataCreator.createWebPageData(store);
query = store.newQuery();
query.setFields(WebPage.Field.URL.getName());
String startKey = SORTED_URLS[NUM_KEYS];
String endKey = SORTED_URLS[SORTED_URLS.length - NUM_KEYS];
query.setStartKey(startKey);
query.setEndKey(endKey);
assertNumResults(store.newQuery(), URLS.length);
store.deleteByQuery(query);
store.deleteByQuery(query);
store.deleteByQuery(query);//don't you love that HBase sometimes does not delete arbitrarily
assertNumResults(store.newQuery(), URLS.length);
//assert that data is deleted
for (int i = 0; i < URLS.length; i++) {
WebPage page = store.get(URLS[i]);
Assert.assertNotNull(page);
if( URLS[i].compareTo(startKey) < 0 || URLS[i].compareTo(endKey) >= 0) {
//not deleted
assertWebPage(page, i);
} else {
//deleted
Assert.assertNull(page.getUrl());
Assert.assertNotNull(page.getOutlinks());
Assert.assertNotNull(page.getParsedContent());
Assert.assertNotNull(page.getContent());
Assert.assertTrue(page.getOutlinks().size() > 0);
Assert.assertTrue(page.getParsedContent().size() > 0);
}
}
}