This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

don't repeat last term

  • Loading branch information...
tjake committed Jul 19, 2011
1 parent 6035498 commit d0df20a9dafd91389287ac7bed3e85be21497556
Showing with 8 additions and 152 deletions.
  1. +2 −8 src/lucandra/LucandraTermEnum.java
  2. +6 −144 test/solandra/SolandraTests.java
@@ -84,7 +84,7 @@ public int docFreq()
@Override
public boolean next() throws IOException
{
- if(currentTermEntry == null)
+ if(termView.size() == 0)
return false;
// current term is in tree
@@ -94,14 +94,8 @@ public boolean next() throws IOException
// rebuffer from last key
if (termView.size() == 0)
{
- //logger.info("Rebuffering terms");
-
+ //logger.info("Rebuffering terms");
termView = termCache.skipTo(currentTermEntry.getKey());
-
- if (termView.size() == 0)
- {
-
- }
if (termView.size() == 0 ||
(termView.size() == 1 && termView.firstEntry().getKey().equals(currentTermEntry.getKey())))
@@ -46,12 +46,8 @@
import org.apache.solr.common.SolrDocumentList;
import org.apache.solr.common.SolrInputDocument;
-public class SolandraTests
-{
- static Logger logger = Logger.getLogger(SolandraTests.class);
- static ExecutorService eservice;
- static Map<String, CommonsHttpSolrServer> solrClients = new HashMap<String, CommonsHttpSolrServer>();
- static int port = 8983;
+public class SolandraTests extends SolandraTestRunner
+{
static String indexName1 = String.valueOf(System.nanoTime());
static String indexName2 = String.valueOf(System.nanoTime());
static String[] subIndexes = new String[] { "", "one", "two", "three" };
@@ -81,74 +77,7 @@
+ "<defaultSearchField>title</defaultSearchField>\n"
+ "</schema>\n";
- @BeforeClass
- public static void setUpBeforeClass()
- {
-
- //CassandraUtils.cacheInvalidationInterval = 0; // real-time
-
- try
- {
- // start cassandra
- CassandraUtils.startupServer();
-
- // Start Jetty Solandra Instance
- eservice = Executors.newSingleThreadExecutor();
- eservice.execute(new Runnable() {
-
- @Override
- public void run()
- {
- try
- {
- JettySolandraRunner jetty = new JettySolandraRunner("/solandra", port);
- jetty.start();
- }
- catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
- });
-
- // Wait for ping
- // A raw term query type doesn't check the schema
- URL url = new URL("http://localhost:" + port + "/solandra/select?q={!raw+f=junit_test_query}ping");
-
- Exception ex = null;
- // Wait for a total of 20 seconds: 100 tries, 200 milliseconds each
- for (int i = 0; i < 20; i++)
- {
- try
- {
- InputStream stream = url.openStream();
- stream.close();
- }
- catch (IOException e)
- {
- // e.printStackTrace();
- ex = e;
- Thread.sleep(1000);
-
- continue;
- }
-
- }
- }
- catch (Throwable t)
- {
- t.printStackTrace();
- System.exit(0);
- }
- }
-
- @AfterClass
- public static void tearDownAfterClass() throws Exception
- {
- eservice.shutdownNow();
- }
-
+
@Test
public void allTestsManyIndexes() throws Exception
{
@@ -159,7 +88,7 @@ public void allTestsManyIndexes() throws Exception
{
logger.info("Running tests for core: " + core);
- addSchema(core);
+ addSchema(core, schemaXml);
logger.info("added schema");
for (String vcore : subIndexes)
@@ -211,75 +140,8 @@ public void allTestsManyIndexes() throws Exception
}
}
- private CommonsHttpSolrServer getSolrClient(String indexName) throws MalformedURLException
- {
- CommonsHttpSolrServer client = solrClients.get(indexName);
-
- if (client == null)
- {
- client = new CommonsHttpSolrServer("http://localhost:" + port + "/solandra/" + indexName);
- solrClients.put(indexName, client);
- }
-
- return client;
- }
-
- public void addSchema(final String indexName) throws Exception
- {
-
- URL url = new URL("http://localhost:" + port + "/solandra/schema/" + indexName + "/schema.xml");
-
- // write
- try
- {
-
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setDoOutput(true);
- OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
- wr.write(schemaXml);
- wr.flush();
- wr.close();
-
- assertEquals(200, conn.getResponseCode());
-
- }
- catch (IOException e)
- {
- e.printStackTrace();
- fail();
- }
-
- // verify
- try
- {
- InputStream stream = url.openStream();
-
- BufferedReader rd = new BufferedReader(new InputStreamReader(stream));
- String line;
- String xml = "";
- while ((line = rd.readLine()) != null)
- {
- xml += line + "\n";
- }
-
- stream.close();
-
- assertTrue(!xml.isEmpty());
-
- SolrQuery q = new SolrQuery().setQuery("*:*").addField("*").addField("score");
-
- QueryResponse r = getSolrClient(indexName).query(q);
- assertEquals(0, r.getResults().getNumFound());
-
- }
- catch (IOException e)
- {
- e.printStackTrace();
- fail();
- }
-
- }
-
+
+
public void testOneDocument(CommonsHttpSolrServer solrClient) throws Exception
{

0 comments on commit d0df20a

Please sign in to comment.