scala.collection.mutable.LinkedHashMap Scala Examples
The following examples show how to use scala.collection.mutable.LinkedHashMap.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
Example 1
Source File: AllStagesResourceSuite.scala From drizzle-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import java.util.Date import scala.collection.mutable.LinkedHashMap import org.apache.spark.SparkFunSuite import org.apache.spark.scheduler.{StageInfo, TaskInfo, TaskLocality} import org.apache.spark.ui.jobs.UIData.{StageUIData, TaskUIData} class AllStagesResourceSuite extends SparkFunSuite { def getFirstTaskLaunchTime(taskLaunchTimes: Seq[Long]): Option[Date] = { val tasks = new LinkedHashMap[Long, TaskUIData] taskLaunchTimes.zipWithIndex.foreach { case (time, idx) => tasks(idx.toLong) = TaskUIData( new TaskInfo(idx, idx, 1, time, "", "", TaskLocality.ANY, false), None) } val stageUiData = new StageUIData() stageUiData.taskData = tasks val status = StageStatus.ACTIVE val stageInfo = new StageInfo( 1, 1, "stage 1", 10, Seq.empty, Seq.empty, "details abc") val stageData = AllStagesResource.stageUiToStageData(status, stageInfo, stageUiData, false) stageData.firstTaskLaunchedTime } test("firstTaskLaunchedTime when there are no tasks") { val result = getFirstTaskLaunchTime(Seq()) assert(result == None) } test("firstTaskLaunchedTime when there are tasks but none launched") { val result = getFirstTaskLaunchTime(Seq(-100L, -200L, -300L)) assert(result == None) } test("firstTaskLaunchedTime when there are tasks and some launched") { val result = getFirstTaskLaunchTime(Seq(-100L, 1449255596000L, 1449255597000L)) assert(result == Some(new Date(1449255596000L))) } }
Example 2
Source File: AllStagesResourceSuite.scala From sparkoscope with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import java.util.Date import scala.collection.mutable.LinkedHashMap import org.apache.spark.SparkFunSuite import org.apache.spark.scheduler.{StageInfo, TaskInfo, TaskLocality} import org.apache.spark.ui.jobs.UIData.{StageUIData, TaskUIData} class AllStagesResourceSuite extends SparkFunSuite { def getFirstTaskLaunchTime(taskLaunchTimes: Seq[Long]): Option[Date] = { val tasks = new LinkedHashMap[Long, TaskUIData] taskLaunchTimes.zipWithIndex.foreach { case (time, idx) => tasks(idx.toLong) = TaskUIData( new TaskInfo(idx, idx, 1, time, "", "", TaskLocality.ANY, false), None) } val stageUiData = new StageUIData() stageUiData.taskData = tasks val status = StageStatus.ACTIVE val stageInfo = new StageInfo( 1, 1, "stage 1", 10, Seq.empty, Seq.empty, "details abc") val stageData = AllStagesResource.stageUiToStageData(status, stageInfo, stageUiData, false) stageData.firstTaskLaunchedTime } test("firstTaskLaunchedTime when there are no tasks") { val result = getFirstTaskLaunchTime(Seq()) assert(result == None) } test("firstTaskLaunchedTime when there are tasks but none launched") { val result = getFirstTaskLaunchTime(Seq(-100L, -200L, -300L)) assert(result == None) } test("firstTaskLaunchedTime when there are tasks and some launched") { val result = getFirstTaskLaunchTime(Seq(-100L, 1449255596000L, 1449255597000L)) assert(result == Some(new Date(1449255596000L))) } }
Example 3
Source File: AllStagesResourceSuite.scala From multi-tenancy-spark with Apache License 2.0 | 5 votes |
package org.apache.spark.status.api.v1 import java.util.Date import scala.collection.mutable.LinkedHashMap import org.apache.spark.SparkFunSuite import org.apache.spark.scheduler.{StageInfo, TaskInfo, TaskLocality} import org.apache.spark.ui.jobs.UIData.{StageUIData, TaskUIData} class AllStagesResourceSuite extends SparkFunSuite { def getFirstTaskLaunchTime(taskLaunchTimes: Seq[Long]): Option[Date] = { val tasks = new LinkedHashMap[Long, TaskUIData] taskLaunchTimes.zipWithIndex.foreach { case (time, idx) => tasks(idx.toLong) = TaskUIData( new TaskInfo(idx, idx, 1, time, "", "", TaskLocality.ANY, false), None) } val stageUiData = new StageUIData() stageUiData.taskData = tasks val status = StageStatus.ACTIVE val stageInfo = new StageInfo( 1, 1, "stage 1", 10, Seq.empty, Seq.empty, "details abc") val stageData = AllStagesResource.stageUiToStageData(status, stageInfo, stageUiData, false) stageData.firstTaskLaunchedTime } test("firstTaskLaunchedTime when there are no tasks") { val result = getFirstTaskLaunchTime(Seq()) assert(result == None) } test("firstTaskLaunchedTime when there are tasks but none launched") { val result = getFirstTaskLaunchTime(Seq(-100L, -200L, -300L)) assert(result == None) } test("firstTaskLaunchedTime when there are tasks and some launched") { val result = getFirstTaskLaunchTime(Seq(-100L, 1449255596000L, 1449255597000L)) assert(result == Some(new Date(1449255596000L))) } }
Example 4
Source File: fileUtils.scala From RISCV-FiveStage with Apache License 2.0 | 5 votes |
package FiveStage import chisel3.iotesters._ import java.io.File import java.nio.file.Path import scala.collection.mutable.LinkedHashMap // import cats.effect.ContextShift import cats.implicits._ import cats._ import cats.syntax._ import cats.Applicative._ import atto._, Atto._ object fileUtils { def say(word: Any)(implicit filename: sourcecode.File, line: sourcecode.Line): Unit = { val fname = filename.value.split("/").last println(Console.YELLOW + s"[${fname}: ${sourcecode.Line()}]" + Console.RESET + s" - $word") } def sayRed(word: Any)(implicit filename: sourcecode.File, line: sourcecode.Line): Unit = { val fname = filename.value.split("/").last println(Console.YELLOW + s"[${fname}: ${sourcecode.Line()}]" + Console.RED + s" - $word") } def sayGreen(word: Any)(implicit filename: sourcecode.File, line: sourcecode.Line): Unit = { val fname = filename.value.split("/").last println(Console.YELLOW + s"[${fname}: ${sourcecode.Line()}]" + Console.GREEN + s" - $word") } def getListOfFiles(dir: String): List[File] = (new File(dir)).listFiles.filter(_.isFile).toList def getListOfFiles(dir: Path): List[File] = dir.toFile().listFiles.filter(_.isFile).toList def getListOfFolders(dir: String): List[File] = (new File(dir)).listFiles.filter(_.isDirectory).toList def getListOfFolders(dir: Path): List[File] = dir.toFile().listFiles.filter(_.isDirectory).toList def getListOfFilesRecursive(dir: String): List[File] = { getListOfFiles(dir) ::: getListOfFolders(dir).flatMap(f => getListOfFilesRecursive(f.getPath) ) } import cats.implicits._ import java.nio.file.Paths import java.util.concurrent.Executors import scala.concurrent.ExecutionContext def relativeFile(name: String) = { new File(getClass.getClassLoader.getResource(name).getPath) } def getTestDir: File = new File(getClass.getClassLoader.getResource("tests").getPath) def getAllTests: List[File] = getListOfFilesRecursive(getTestDir.getPath) .filter( f => f.getPath.endsWith(".s") ) def getAllTestNames: List[String] = getAllTests.map(_.toString.split("/").takeRight(1).mkString) // Not tested. def getAllWindowsTestNames: List[String] = getAllTests.map(_.toString.split("\\\\").takeRight(1).mkString) def clearTestResults = { try { val testResults = relativeFile("/testResults") testResults.delete() } catch { case _:Throwable => () } } def readTest(testOptions: TestOptions): Either[String, List[String]] = { // Ahh, the GNU toolchain and its tabs val annoyingTabCharacter = ' ' getAllTests.filter(_.getName.contains(testOptions.testName)).headOption.toRight(s"File not found: ${testOptions.testName}").flatMap{ filename => import scala.io.Source scala.util.Try( Source.fromFile(filename) .getLines.toList .map(_.replace(annoyingTabCharacter, ' '))) .toOption .toRight(s"Error reading $filename") } } }