Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am not able to reproduce your problem with the below test code. Can you try it on your system and let me know how it runs?</p> <p>(Uncomment line 38, <code>garages.addIndex(HashIndex.onAttribute(Garage.BRANDS_SERVICED))</code>, to make BOTH the Scala and Java iterators run blazingly fast...)</p> <p>The output first (time in milliseconds):</p> <pre><code>Done adding data Done adding index ============== Scala ============== Car{carId=4, name='BMW M3', description='2013 model', features=[radio, convertible]} Time : 3 seconds Car{carId=1, name='Ford Focus', description='great condition, low mileage', features=[spare tyre, sunroof]} Time : 1 seconds Car{carId=2, name='Ford Taurus', description='dirty and unreliable, flat tyre', features=[spare tyre, radio]} Time : 2 seconds ============== Java ============== Car{carId=4, name='BMW M3', description='2013 model', features=[radio, convertible]} Time : 3 seconds Car{carId=1, name='Ford Focus', description='great condition, low mileage', features=[spare tyre, sunroof]} Time : 1 seconds Car{carId=2, name='Ford Taurus', description='dirty and unreliable, flat tyre', features=[spare tyre, radio]} Time : 2 seconds </code></pre> <p>Code below:</p> <pre><code>import collection.JavaConversions._ import com.googlecode.cqengine.query.QueryFactory._ import com.googlecode.cqengine.CQEngine; import com.googlecode.cqengine.index.hash._; import com.googlecode.cqengine.IndexedCollection; import com.googlecode.cqengine.query.Query; import java.util.Arrays.asList; object CQTest { def main(args: Array[String]) { val cars: IndexedCollection[Car] = CQEngine.newInstance(); cars.add(new Car(1, "Ford Focus", "great condition, low mileage", asList("spare tyre", "sunroof"))); cars.add(new Car(2, "Ford Taurus", "dirty and unreliable, flat tyre", asList("spare tyre", "radio"))); cars.add(new Car(3, "Honda Civic", "has a flat tyre and high mileage", asList("radio"))); cars.add(new Car(4, "BMW M3", "2013 model", asList("radio", "convertible"))); // add cruft to try and slow down CQE for (i &lt;- 1 to 10000) { cars.add(new Car(i, "BMW2014_" + i, "2014 model", asList("radio", "convertible"))) } // Create an indexed collection of garages... val garages: IndexedCollection[Garage] = CQEngine.newInstance(); garages.add(new Garage(1, "Joe's garage", "London", asList("Ford Focus", "Honda Civic"))); garages.add(new Garage(2, "Jane's garage", "Dublin", asList("BMW M3"))); garages.add(new Garage(3, "John's garage", "Dublin", asList("Ford Focus", "Ford Taurus"))); garages.add(new Garage(4, "Jill's garage", "Dublin", asList("Ford Focus"))); // add cruft to try and slow down CQE for (i &lt;- 1 to 10000) { garages.add(new Garage(i, "Jill's garage", "Dublin", asList("DONT_MATCH_CARS_BMW2014_" + i))) } println("Done adding data") // cars.addIndex(HashIndex.onAttribute(Car.NAME)); // garages.addIndex(HashIndex.onAttribute(Garage.BRANDS_SERVICED)); println("Done adding index") val query = existsIn(garages, Car.NAME, Garage.BRANDS_SERVICED, equal(Garage.LOCATION, "Dublin")) val resultSet = cars.retrieve(query) var previous = System.currentTimeMillis() println("============== Scala ============== ") // Scala version resultSet.foreach(r =&gt; { println(r); val t = (System.currentTimeMillis() - previous) System.out.println("Time : " + t / 1000 + " seconds") previous = System.currentTimeMillis() }) println("============== Java ============== ") previous = System.currentTimeMillis() // Java version val i: java.util.Iterator[Car] = resultSet.iterator() while (i.hasNext) { val r = i.next() println(r); val t = (System.currentTimeMillis() - previous) System.out.println("Time : " + t / 1000 + " seconds") previous = System.currentTimeMillis() } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload