From 8b01c301c3ba2004f9f724becabc80ce0edff047 Mon Sep 17 00:00:00 2001 From: eaceaser Date: Tue, 9 Aug 2011 13:25:56 -0700 Subject: [PATCH] get rid of "optimization" that was breaking 2nd order intersections --- .../flockdb/queries/IntersectionQuery.scala | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/main/scala/com/twitter/flockdb/queries/IntersectionQuery.scala b/src/main/scala/com/twitter/flockdb/queries/IntersectionQuery.scala index d91dede7..e516ec0f 100644 --- a/src/main/scala/com/twitter/flockdb/queries/IntersectionQuery.scala +++ b/src/main/scala/com/twitter/flockdb/queries/IntersectionQuery.scala @@ -37,23 +37,19 @@ class IntersectionQuery(query1: QueryTree, query2: QueryTree, averageIntersectio def selectPage(count: Int, cursor: Cursor) = selectPageByDestinationId(count, cursor) def selectPageByDestinationId(count: Int, cursor: Cursor) = time({ - 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 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) - } - resultWindow + 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 }) def selectWhereIn(page: Seq[Long]) = time({