Skip to content

Commit

Permalink
more minor fixes to CassandraStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
jerryli9876 committed Aug 6, 2012
1 parent 7748126 commit 5cef68b
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ trait CassandraStorage extends Storage with Cassandra {
// read the trace
private val CASSANDRA_GET_TRACE = Stats.getCounter("cassandra_gettrace")

// trace exist call
private val CASSANDRA_TRACE_EXISTS = Stats.getCounter("cassandra_traceexists")

// trace is too big!
private val CASSANDRA_GET_TRACE_TOO_BIG = Stats.getCounter("cassandra_gettrace_too_big")

Expand Down Expand Up @@ -98,20 +101,16 @@ trait CassandraStorage extends Storage with Cassandra {
*/

def tracesExist(traceIds: Seq[Long]): Future[Set[Long]] = {
// CASSANDRA_GET_TRACE.incr
CASSANDRA_TRACE_EXISTS.incr
Future.collect {
traceIds.grouped(storageConfig.traceFetchBatchSize).toSeq.map { ids =>
traces.multigetRows(ids.toSet.asJava, None, None, Order.Normal, 1).map { rowSet =>
var traceSet = new HashSet[Long]()
ids.foreach { id =>
ids.flatMap { id =>
val spans = rowSet.asScala(id).asScala.map {
case (colName, col) => ThriftAdapter(col.value)
}
if (!spans.isEmpty) {
traceSet += spans.head.traceId
}
}
traceSet
if (spans.isEmpty) None else Some(spans.head.traceId)
}.toSet
}
}
}.map {
Expand Down

0 comments on commit 5cef68b

Please sign in to comment.