Skip to content

Instantly share code, notes, and snippets.

@rjurney
Created June 17, 2014 23:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjurney/9ba5ef7228b345ad4026 to your computer and use it in GitHub Desktop.
Save rjurney/9ba5ef7228b345ad4026 to your computer and use it in GitHub Desktop.
Trying to build a Map inside a map operation
import javax.ws.rs.{QueryParam, GET, Produces, Path}
import scala.Array
import javax.ws.rs.core.{Response, MediaType}
import org.slf4j.{LoggerFactory, Logger}
import org.joda.time.format.{ISODateTimeFormat, DateTimeFormatter}
import org.joda.time.DateTimeZone
import com.securityx.modelfeature.dao.BeaconsDao
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import com.securityx.modelfeature.FeatureServiceConfiguration
import com.sun.corba.se.spi.activation._ActivatorImplBase
import org.joda.time.MutableDateTime
import collection.mutable.ListBuffer
import collection.parallel.mutable
val conf = new FeatureServiceConfiguration
conf.setZkQuorum("hiveapp1,hiveapp2,hiveapp3")
conf.setEnvironment("DEV")
val beaconsDao = new BeaconsDao(conf)
val tableName = "DEV_BEACONS"
val buf = beaconsDao.getBeaconingSeries("2014-06-14T00:00:00.000Z", "2014-06-15T00:00:00.000Z", 3600)
// Need to group by source and dest
val groups = buf.groupBy(x => Map[String, Any]
("sourceNameOrIp" -> x.get("sourceNameOrIp"),
"destinationNameOrIp" -> x.get("destinationNameOrIp")
))
groups.map {case(key, value) => (value.map{case(key2, value2) => (value)})}
groups.map {case(key, value) => (value.map{_.get("risk")})}
// Help me, I am trying to return a Map with fields "risk" and "eventTime"
groups.map {case(key, value) => (value.map{val x = Map()})}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment