Permalink
Browse files

get rid of "optimization" that was breaking 2nd order intersections

  • Loading branch information...
eaceaser
eaceaser committed Aug 9, 2011
1 parent 5dbba45 commit 8b01c301c3ba2004f9f724becabc80ce0edff047
Showing with 11 additions and 15 deletions.
  1. +11 −15 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({

0 comments on commit 8b01c30

Please sign in to comment.