instruction stringclasses 1
value | output stringlengths 5 1M |
|---|---|
Explain and rewrite the following Scala code: | package almhirt.streaming
import akka.actor._
import akka.stream.actor._
/** This thing is unbound. Handle with care! */
trait UnboundedSink[T] {
def publish(element: T)
}
object UnboundedSink {
def apply[T](unboundedSink: ActorRef): UnboundedSink[T] with almhirt.common.Stoppable = {
new UnboundedSink[T] wit... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... |
Explain and rewrite the following Scala code: | package lila.tournament
import chess.variant.Variant
import chess.{ Speed, Mode, StartingPosition }
import lila.db.BSON
import lila.rating.PerfType
import reactivemongo.bson._
object BSONHandlers {
private implicit val startingPositionBSONHandler = new BSONHandler[BSONString, StartingPosition] {
def read(bsonS... |
Explain and rewrite the following Scala code: | package ch.epfl.perfNetwork.jsfacade
import scala.scalajs.js
@js.native
/**
* @author Thibault Urien
*
*/
trait JSBenchData extends js.Object {
def date: Number
def testName: String
def representativeTime: Number
def confidenceIntervalLo: Number
def confidenceIntervalHi: Number
def allMesures: js.Array... |
Explain and rewrite the following Scala code: | /*
* Copyright 2015 IBM Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to ... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | /*
* Copyright 2015 Renaud Bruneliere
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agree... |
Explain and rewrite the following Scala code: | /*
*************************************************************************************
* Copyright 2011 Normation SAS
*************************************************************************************
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero Ge... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... |
Explain and rewrite the following Scala code: | /*
* Copyright 2016 Frugal Mechanic (http://frugalmechanic.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala.lang.psi.types.api
import com.intellij.openapi.project.Project
import com.intellij.psi._
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.plugins.scala.decompiler.DecompilerUtil
import org.jetbrains.plugins.scala.lang.psi.api.statements.ScTypeAlias
import org.je... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... |
Explain and rewrite the following Scala code: | // Copyright 2014 Commonwealth Bank of Australia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by ap... |
Explain and rewrite the following Scala code: | /*******************************************************************************/
/* */
/* Copyright (C) 2017 by Max Lv <max.c.lv@gmail.com> */
/* Copyright (C) 2017 by Mygod Studio <contact-shadowsocks-android@mygod.... |
Explain and rewrite the following Scala code: | package com.dominikgruber.scalatorrent
import org.scalatest._
import scala.io.{Codec, Source}
abstract class UnitSpec extends FlatSpec with Matchers {
def loadTorrentFile(file: String): String = {
val source = Source.fromURL(getClass.getResource(file))(Codec.ISO8859)
val sourceString = source.mkString
... |
Explain and rewrite the following Scala code: | package org.receiver2d.engine.ecs.components
import org.receiver2d.engine.ecs.Entity
/**
* Anything that is able to be attached to an Entity, such as a Collider,
* Rigidbody, CharacterController, et cetera, that provides additional
* functionality in-game. This class must be extended by all components.
*/
trait C... |
Explain and rewrite the following Scala code: | /*
* GNU GENERAL PUBLIC LICENSE
* Version 2, June 1991
*
* Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, ... |
Explain and rewrite the following Scala code: | package pl.pholda.pda
import pl.pholda.pda.model.{StationId, TrainId}
/**
* Created by piotr on 28.02.16.
*/
package object feed {
protected val trainIdRegex = "p=train&id=(\\\\d+)$".r
protected val stationIdRegex = "p=station&id=(\\\\d+)'?$".r
def extractTrainId(url: String): TrainId = {
trainIdRege... |
Explain and rewrite the following Scala code: | package org.jetbrains.jps.incremental.scala.remote
import java.io._
import java.net.{InetAddress, Socket}
import com.intellij.util.Base64Converter
import com.martiansoftware.nailgun.NGConstants
import org.jetbrains.jps.incremental.messages.BuildMessage.Kind
import org.jetbrains.jps.incremental.scala._
/**
* @author... |
Explain and rewrite the following Scala code: | package com.snapswap.layer.unmarshaller
import java.util.UUID
import scala.util.{Try, Success, Failure}
import org.joda.time.format.DateTimeFormat
import org.joda.time.DateTime
import spray.json._
import com.snapswap.layer._
trait BaseLayerUnmarshaller extends DefaultJsonProtocol {
protected def enumNameFormat(enu... |
Explain and rewrite the following Scala code: | package com.thetestpeople.trt.utils
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest._
import com.thetestpeople.trt.utils.UriUtils._
@RunWith(classOf[JUnitRunner])
class UriUtilsTest extends FlatSpec with Matchers {
"It" should "let you construct sub-URLs with a slash" i... |
Explain and rewrite the following Scala code: | package metal
import metal.mutable.{HashMap => MHashMap}
class MapPtrOpsSuite extends MetalSuite {
test("remove") {
val mII = MHashMap(1 -> 2)
mII.ptr match {
case IsVPtr(vp) =>
vp.remove
assert(mII.isEmpty)
}
}
test("key") {
val mII = MHashMap(1 -> 2)
mII.ptrFind(1) ... |
Explain and rewrite the following Scala code: | import scala.tools.nsc.Settings
import scala.tools.partest.ReplTest
object Test extends ReplTest {
override def transformSettings(s: Settings) = {
s.Yreplclassbased.value = false // test object-based encoding
s
}
def code = """
|case class Name(value: String)
|val x = Name("foo")
|val y = Na... |
Explain and rewrite the following Scala code: | package com.celexus.tipsy.model
import com.ning.http.client.{Response, ListenableFuture}
import org.slf4j.{LoggerFactory, Logger}
import play.api.libs.json.{Json, JsObject}
/**
* A class representing all information about a stock, by its ticker
*/
class StockDetails(response: ListenableFuture[Response]) {
priva... |
Explain and rewrite the following Scala code: | /**
* Copyright 2013 Israel Freitas (israel.araujo.freitas@gmail.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless... |
Explain and rewrite the following Scala code: |
/**
* Copyright 2015 Thomson Reuters
*
* Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or a... |
Explain and rewrite the following Scala code: | /***********************************************************************
* Copyright (c) 2013-2016 Commonwealth Computer Research, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution and is ... |
Explain and rewrite the following Scala code: | package scorex.network
import org.scalamock.scalatest.MockFactory
import org.scalatest.{FreeSpec, Matchers, OneInstancePerTest}
import scorex.account.PublicKeyAccount
import scorex.block.{Block, SignerData}
import scorex.block.Block._
import scorex.consensus.ConsensusModule
import scorex.network.BlockchainSynchronizer... |
Explain and rewrite the following Scala code: | package spark
import org.scalatest.BeforeAndAfter
import org.scalatest.FunSuite
import org.scalatest.matchers.ShouldMatchers
import collection.mutable
import java.util.Random
import scala.math.exp
import scala.math.signum
import spark.SparkContext._
class AccumulatorSuite extends FunSuite with ShouldMatchers with Bef... |
Explain and rewrite the following Scala code: | // Copyright 2014 Commonwealth Bank of Australia
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by ap... |
Explain and rewrite the following Scala code: | /** Copyright 2014 TappingStone, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law ... |
Explain and rewrite the following Scala code: | package org.sofi.deadman.model
final case class EntityWarning(
entity: String,
key: String,
ttw: Long,
aggregate: String,
ttl: Long,
creation: Long,
warning: Long,
tags: String
)
object EntityWarning {
import scala.concurrent.{ ExecutionContext, Future }
import org.sofi.deadman.messages.event.Task... |
Explain and rewrite the following Scala code: | /*
* Copyright 2013 Twitter Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to... |
Explain and rewrite the following Scala code: | package io.github.mandar2812.dynaml.evaluation
import breeze.linalg.DenseVector
import org.apache.spark.rdd.RDD
/**
* Abstract trait for metrics
*/
trait Metrics[P] {
protected val scoresAndLabels: List[(P, P)]
def print(): Unit
def generatePlots(): Unit = {}
def kpi(): DenseVector[P]
}
object Metrics{
d... |
Explain and rewrite the following Scala code: | /*
* Code Pulse: A real-time code coverage testing tool. For more information
* see http://code-pulse.com
*
* Copyright (C) 2014 Applied Visions - http://securedecisions.avi.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2014 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0,
* and you may not use this file except in compliance with the Apache License Version 2.0.
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org... |
Explain and rewrite the following Scala code: | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may... |
Explain and rewrite the following Scala code: | /* ************************************************************** *
* *
* Copyright (c) 2016-, Kota Mizushima, All rights reserved. *
* *
* ... |
Explain and rewrite the following Scala code: | package papermm.engine
import com.jme3.app.Application
import com.jme3.app.state.AppStateManager
import com.jme3.math.FastMath
import com.jme3.scene.Node
import com.jme3.ui.Picture
import papermm.main._
class TitleEngine(heroNode: Node, sinkingEngine: SinkingEngine, sunMoonSsao: SunMoonSsao) extends MiniAppState {
... |
Explain and rewrite the following Scala code: | package mimir.util
import java.util.concurrent.BlockingQueue
import java.util.concurrent.LinkedBlockingQueue
import java.util.concurrent.TimeUnit
import org.apache.log4j.AppenderSkeleton
import org.apache.log4j.helpers.LogLog
import org.apache.log4j.spi.LoggingEvent
import scala.beans.{BeanProperty, BooleanBeanPropert... |
Explain and rewrite the following Scala code: | package org.rebeam.boxes.persistence
/**
* A link, either empty, or giving an identifier for an object
*/
sealed trait Link
/**
* Link associating an identifier with this object
* @param id The id of this object
*/
case class LinkId(id: Long) extends Link
/**
* No link for this object - it isn't identified
*... |
Explain and rewrite the following Scala code: | package fr.ramiro.sfuzzy.dsl
/**
* Created by Ramiro on 12/05/2017.
*/
class Conclusion {
def WITH(n: BigDecimal): Conclusion = ???
}
|
Explain and rewrite the following Scala code: | /*
* Copyright 2013 Commonwealth Computer Research, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applica... |
Explain and rewrite the following Scala code: | //
// Copyright 2013 Mirko Nasato
//
// Licensed under the Apache License, Version 2.0
// http://www.apache.org/licenses/LICENSE-2.0
//
package io.encoded.seriala.jackson
import io.encoded.seriala.schema._
import io.encoded.seriala.SerialWriter
import scala.reflect.runtime.universe._
import com.fasterxml.jackson.core.... |
Explain and rewrite the following Scala code: | package io.chymyst.jc
import java.util
import java.util.concurrent.ConcurrentLinkedQueue
import javolution.util.FastMap
import com.google.common.collect.ConcurrentHashMultiset
import scala.collection.JavaConverters.{asScalaIteratorConverter, asScalaSetConverter}
import scala.collection.mutable
import scala.util.Try
... |
Explain and rewrite the following Scala code: | /**
* This file is part of the TA Buddy project.
* Copyright (c) 2013-2014 Alexey Aksenov ezh@ezh.msk.ru
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Affero General Global License version 3
* as published by the Free Software Foundation with the addition... |
Explain and rewrite the following Scala code: | package yuima.algovis.maze.ui
import yuima.algovis.maze.core.FieldType._
import yuima.algovis.maze.core._
import scala.annotation.tailrec
import scala.collection.mutable
import scalafx.animation.AnimationTimer
import scalafx.beans.binding.NumberBinding
import scalafx.scene.Scene
import scalafx.scene.layout.Pane
impor... |
Explain and rewrite the following Scala code: | package org.scalaide.refactoring.internal.method.ui
import org.eclipse.swt.widgets.Button
import org.scalaide.refactoring.internal.ScalaIdeRefactoring
/**
* Generates the wizard page for a MergeParameterLists refactoring.
*/
trait MergeParameterListsConfigurationPageGenerator extends MethodSignatureRefactoringConfi... |
Explain and rewrite the following Scala code: | import scala.quoted._
object scalatest {
inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition) }
def assertImpl(cond: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] = {
import qctx.tasty._
import util._
cond.unseal.underlyingArgument match {
case t @ Apply(Select(lh... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | package com.twitter.scrooge.thrift_validation
import scala.collection.JavaConverters._
object ThriftValidationException {
/**
* A java compatible exception which is used to communicate when a thrift_validation
* has failed with the respective [[ThriftValidationViolation]]
*
* @param endpoint thrift... |
Explain and rewrite the following Scala code: | /*
* The MIT License
*
* Copyright (c) 2019 Fulcrum Genomics LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to us... |
Explain and rewrite the following Scala code: | package clusterconsole.client
import scala.scalajs.js
package object style extends js.GlobalScope {
val jQuery: JQueryStatic = js.native
}
|
Explain and rewrite the following Scala code: | /***********************************************************************
* Copyright (c) 2013-2018 Commonwealth Computer Research, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution and... |
Explain and rewrite the following Scala code: | package mesosphere.marathon
package api
import java.net.URI
import javax.ws.rs.core.Response.Status
import javax.ws.rs.core.{NewCookie, Response}
import mesosphere.marathon.plugin.http.HttpResponse
/**
* Implementation of plugin-interface HttpResponse; a response builder with some extra helper methods.
*/
class ... |
Explain and rewrite the following Scala code: | package com.sunshine.streaming
import org.apache.spark.SparkConf
import org.apache.spark.streaming.StreamingContext
import org.apache.spark.streaming.StreamingContext._
import org.apache.spark.streaming.Seconds
import org.apache.spark.storage.StorageLevel
/**
* Chen Chao
*/
object NetworkWordCount {
def main(arg... |
Explain and rewrite the following Scala code: | package sorm.test.types
import org.scalatest.FunSuite
import org.scalatest.matchers.ShouldMatchers
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import sext._, embrace._
import sorm._
import sorm.test.MultiInstanceSuite
@RunWith(classOf[JUnitRunner])
class BooleanSupportSuite extends FunSuit... |
Explain and rewrite the following Scala code: | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may... |
Explain and rewrite the following Scala code: | /*
* Copyright 2017 HM Revenue & Customs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or a... |
Explain and rewrite the following Scala code: | package org.bitcoins.rpc.bitcoincore.networking
import akka.http.scaladsl.model.Uri
/**
* Created by chris on 5/7/17.
*/
sealed trait AddedNodeInfo {
def addedNode: Uri
def connected: Boolean
def addresses: Seq[NodeAddress]
}
object AddedNodeInfo {
private case class AddedNodeInfoImpl(addedNode: Uri, co... |
Explain and rewrite the following Scala code: | /**
* Created by wuyiran on 11/18/16.
*/
package com.iwantfind
import org.apache.hadoop.conf._
import org.apache.spark.{SparkConf, SparkContext}
object CollectAnalyser {
// check
def isValidate(line: String): Boolean = {
line.split(' ').size >= 4
}
// return ip
def parseIP (line :String):String = {... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | package net.fyrie.redis
import org.specs2._
import net.fyrie.redis.types._
import net.fyrie.redis.serialization._
class ScriptsSpec extends mutable.Specification with UnstableClient {
"eval" >> {
"should eval simple script returning a number" ! client { r ⇒
r.sync.eval("return ARGV[1] + ARGV[2]", args =... |
Explain and rewrite the following Scala code: | /*
* Copyright 2014–2018 SlamData Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agr... |
Explain and rewrite the following Scala code: | package io.github.yzernik.bitcoinscodec.structures
import scodec.Codec
import scodec.codecs._
case class InvVect(
inv_type: InvVect.InvType,
hash: Hash)
object InvVect {
sealed trait InvType
case object ERROR extends InvType
case object MSG_TX extends InvType
case object MSG_BLOCK extends InvType
imp... |
Explain and rewrite the following Scala code: | package org.bitcoins.core.crypto
import org.bitcoins.testkit.core.gen.CryptoGenerators
import org.bitcoins.core.number.UInt32
import org.bitcoins.core.util.BitcoinSLogger
import org.scalacheck.{Gen, Prop, Properties}
import scala.util.Success
class ExtKeySpec extends Properties("ExtKeySpec") {
private val logger =... |
Explain and rewrite the following Scala code: | package sigmastate.interpreter
import sigmastate.{FixedCost, JitCost, PerItemCost, SMethod, SType, TypeBasedCost}
import sigmastate.Values.{FixedCostValueCompanion, PerItemCostValueCompanion, ValueCompanion}
import sigmastate.lang.Terms.MethodCall
/** An item in the cost accumulation trace of a [[sigmastate.Values.Er... |
Explain and rewrite the following Scala code: | /*
* Copyright 2017-2018 47 Degrees, LLC. <http://www.47deg.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless require... |
Explain and rewrite the following Scala code: | package org.modelfun.conf
/**
*
*/
case class ChainedConf(first: Conf, second: Conf) extends Conf {
override def has(name: Symbol): Boolean = first.has(name) || second.has(name)
override def apply(name: Any, default: Double, context: Conf) = if (first has name) first(name, default, context) else second(name... |
Explain and rewrite the following Scala code: | package dsentric.schema
import com.github.ghik.silencer.silent
import dsentric._
import dsentric.codecs.DStringCodec
import dsentric.contracts._
import dsentric.operators.Internal
@silent
object Definition {
type Definitions = Vector[ObjectDefinition]
type Infos = Vector[ContractInfo]
def contractName[D... |
Explain and rewrite the following Scala code: | package io.reactors
package protocol
import io.reactors.common.Conc
import org.scalatest._
import org.scalatest.concurrent.AsyncTimeLimitedTests
import scala.collection._
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
import scala.concurrent.Promise
import scala.concurrent.duration._
clas... |
Explain and rewrite the following Scala code: | package com.github.wartman4404.gldraw
import android.content.Context
import java.io.{InputStream, BufferedInputStream, FileInputStream, File, Closeable}
import java.util.zip.ZipFile
import android.graphics.{Bitmap, BitmapFactory}
import android.os.Build
import android.util.Log
import unibrush.{UniBrush, UniBrushSour... |
Explain and rewrite the following Scala code: | package week12
import akka.actor.Actor
/**
* Created by Varsha on 12/4/2014.
*/
class Counter extends Actor {
var count = 0
/* def counter(n: Int): Receive = {
case "incr" => context.become(counter(n + 1))
case "get" => sender ! n
}*/
def receive = {
case "incr" => count += 1
case "get" => p... |
Explain and rewrite the following Scala code: | package net.sansa_stack.rdf.common.partition.core
import net.sansa_stack.rdf.common.partition.layout.TripleLayout
import org.apache.jena.graph.Triple
/*
trait RdfPartition {
/** The layout comprises the schema of the table that can hold matching triples
* and the mapping of triples to instance tuples */
def l... |
Explain and rewrite the following Scala code: | package io.getquill.codegen.codegen
import io.getquill.codegen.util.StringUtil._
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers
import scala.reflect.runtime.universe._
import scala.tools.reflect.ToolBox
class SimpleCodegenSpec extends AnyFreeSpec with Matchers {
case class... |
Explain and rewrite the following Scala code: | /*
* Scala (https://www.scala-lang.org)
*
* Copyright EPFL and Lightbend, Inc.
*
* Licensed under Apache License 2.0
* (http://www.apache.org/licenses/LICENSE-2.0).
*
* See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*/
package scala.async.internal
... |
Explain and rewrite the following Scala code: | /**
* Copyright 2015 Thomson Reuters
*
* Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or ag... |
Explain and rewrite the following Scala code: | package org.openmole.web.mole
import _root_.akka.actor.ActorSystem
import org.openmole.core.eventdispatcher.Event
import org.openmole.core.tools.io.FromString
import org.openmole.core.workflow.validation.DataflowProblem
import org.scalatra._
import scalate.ScalateSupport
import servlet.{ FileItem, FileUploadSupport }
... |
Explain and rewrite the following Scala code: | /*
Copyright 2015 Twitter, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software... |
Explain and rewrite the following Scala code: | /*
* Copyright 2016 The BigDL Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agr... |
Explain and rewrite the following Scala code: | package latis.ops
import latis.dm._
import scala.collection.mutable.{Seq => mSeq}
import scala.collection.mutable.ListBuffer
/**
* Reduce nested Functions of Index to a single Function of index.
*/
class Flatten extends Operation {
/*
* try using Operation2
* don't rely on domain,range types from Function
... |
Explain and rewrite the following Scala code: | package pl.project13.scala.akka.raft
import pl.project13.scala.akka.raft.protocol._
import akka.testkit.{ImplicitSender, TestKit, TestProbe, TestFSMRef}
import org.scalatest._
import akka.actor.ActorSystem
import pl.project13.scala.akka.raft.model.{Term, LogIndexMap}
import pl.project13.scala.akka.raft.example.protoco... |
Explain and rewrite the following Scala code: | // Copyright (C) 2019 MapRoulette contributors (see CONTRIBUTORS.md).
// Licensed under the Apache License, Version 2.0 (see LICENSE).
package org.maproulette.session
import javax.inject.{Inject, Singleton}
import org.apache.commons.lang3.StringUtils
import org.joda.time.DateTime
import org.maproulette.Config
import o... |
Explain and rewrite the following Scala code: | package sparkConfig
import org.apache.spark.SparkConf
/**
* Created by cenk on 22/02/15.
*/
trait BaseSparkConf {
def sparkConf(map: scala.collection.immutable.HashMap[String, String]): SparkConf
}
|
Explain and rewrite the following Scala code: | package mesosphere.marathon
package raml
import org.apache.mesos.{ Protos => Mesos }
import scala.collection.immutable.Map
trait EnvVarConversion {
implicit val envVarRamlWrites: Writes[Map[String, state.EnvVarValue], Map[String, EnvVarValueOrSecret]] =
Writes {
_.map {
case (name, state.EnvVarSt... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | /**
* Copyright: Copyright (C) 2016, ATS Advanced Telematic Systems GmbH
* License: MPL-2.0
*/
package org.genivi.sota.core
import akka.actor.ActorSystem
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.{Directive1, Route}
import cats.data... |
Explain and rewrite the following Scala code: | package eventstore
package akka
package tcp
import java.net.InetSocketAddress
import scala.concurrent.duration._
import scala.util.{Failure, Success, Try}
import _root_.akka.actor.{ActorRef, Status, Terminated}
import _root_.akka.io.{IO, Tcp}
import _root_.akka.testkit.{TestActorRef, TestProbe}
import _root_.akka.stre... |
Explain and rewrite the following Scala code: | package scalaoauth2.provider
import org.scalatest._
import org.scalatest.Matchers._
import scala.concurrent.Future
import play.api.libs.json._
class OAuth2ProviderSpec extends FlatSpec {
object TestOAuthProvider extends OAuth2Provider {
override def responseAccessToken(r: GrantHandlerResult) = super.responseAc... |
Explain and rewrite the following Scala code: | package com.gildedrose.items
import com.gildedrose.Item
/**
* Created by jlafuente on 26/09/2015.
*/
object ExtendedItem {
implicit def Item2ExtendedItem(item : Item) : ExtendedItem = item.name match {
case "Aged Brie" => new AgedBrie(item)
case "Sulfuras, Hand of Ragnaros" => new Sulfuras(item)
case... |
Explain and rewrite the following Scala code: | /*
* Copyright 2016 The BigDL Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agr... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you ... |
Explain and rewrite the following Scala code: | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may ... |
Explain and rewrite the following Scala code: | /*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2015-2021 Andre White.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE... |
Explain and rewrite the following Scala code: | /*
* Copyright 2013 - 2020 Outworkers Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or... |
Explain and rewrite the following Scala code: | /*
* Copyright 2015 Matt Massie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to i... |
Explain and rewrite the following Scala code: | object Test extends App {
val f = () => 5
def test(g: => Int): Unit = {
val gFunc = g _
val isSameClosureClass = gFunc.getClass == f.getClass
val isSame = gFunc eq f
println("Is same closure class: "+isSameClosureClass+" is same closure: "+isSame)
}
test(f())
}
|
Explain and rewrite the following Scala code: | import concurrent.Await
import org.specs2.mutable.Specification
import concurrent.duration._
import reactivemongo.bson.{ BSONString, BSONDocument }
class DatabaseCollectionNameReadSpec extends Specification {
sequential
import Common._
"ReactiveMongo db" should {
val db2 = db.sister("specs2-test-reactivemo... |
Explain and rewrite the following Scala code: | package org.sisioh.aws4s.s3.model
import java.util.Date
import com.amazonaws.services.s3.model.PartSummary
import org.sisioh.aws4s.PimpedType
object PartSummaryFactory {
def create(): PartSummary = new PartSummary()
}
class RichPartSummary(val underlying: PartSummary)
extends AnyVal with PimpedType[PartSumm... |
Explain and rewrite the following Scala code: | /*
* Copyright 2016 The BigDL Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.