Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Commit

Permalink
get rid of "optimization" that was breaking 2nd order intersections
Browse files Browse the repository at this point in the history
  • Loading branch information
eaceaser committed Aug 9, 2011
1 parent 5dbba45 commit 8b01c30
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions src/main/scala/com/twitter/flockdb/queries/IntersectionQuery.scala
Expand Up @@ -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({
Expand Down

0 comments on commit 8b01c30

Please sign in to comment.