Permalink
Browse files

Revert "get rid of "optimization" that was breaking 2nd order interse…

…ctions"

This reverts commit 8b01c30.
  • Loading branch information...
1 parent ef762a0 commit 6c62d62285f55011751b2eb61e55d741ffd16c32 eaceaser committed Aug 10, 2011
Showing with 15 additions and 11 deletions.
  1. +15 −11 src/main/scala/com/twitter/flockdb/queries/IntersectionQuery.scala
@@ -37,19 +37,23 @@ class IntersectionQuery(query1: QueryTree, query2: QueryTree, averageIntersectio
def selectPage(count: Int, cursor: Cursor) = selectPageByDestinationId(count, cursor)
def selectPageByDestinationId(count: Int, cursor: Cursor) = time({
- val guessedPageSize = (count / averageIntersectionProportion).toInt
- val internalPageSize = guessedPageSize min intersectionPageSizeMax.toInt
- val timeout = intersectionTimeout.inMillis
+ if (count1 == 0 || count2 == 0) {
+ new ResultWindow(List[(Long,Cursor)](), count, cursor)
+ } else {
+ val guessedPageSize = (count / averageIntersectionProportion).toInt
+ val internalPageSize = guessedPageSize min intersectionPageSizeMax.toInt
+ val timeout = intersectionTimeout.inMillis
- val now = System.currentTimeMillis
- var resultWindow = pageIntersection(smallerQuery, largerQuery, internalPageSize, count, cursor)
- while (resultWindow.page.size < count &&
- resultWindow.continueCursor != Cursor.End &&
- System.currentTimeMillis - now < timeout
- ) {
- resultWindow = resultWindow ++ pageIntersection(smallerQuery, largerQuery, internalPageSize, count, resultWindow.continueCursor)
+ val now = System.currentTimeMillis
+ var resultWindow = pageIntersection(smallerQuery, largerQuery, internalPageSize, count, cursor)
+ while (resultWindow.page.size < count &&
+ resultWindow.continueCursor != Cursor.End &&
+ System.currentTimeMillis - now < timeout
+ ) {
+ resultWindow = resultWindow ++ pageIntersection(smallerQuery, largerQuery, internalPageSize, count, resultWindow.continueCursor)
+ }
+ resultWindow
}
- resultWindow
})
def selectWhereIn(page: Seq[Long]) = time({

0 comments on commit 6c62d62

Please sign in to comment.