instruction stringclasses 1
value | output stringlengths 5 1M |
|---|---|
Explain and rewrite the following Scala code: | /*
* Copyright 2022 Typelevel
*
* 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... |
Explain and rewrite the following Scala code: | package com.foo.datainsights
/**
* Created by ssahoo on 6/4/15.
*/
object Consts {
final val REPORTS_TopicName = "expense.reports"
final val REPORTEntries_TopicName = "expense.reportentries"
final val BrokerNames ="node1:9092"
final val Zookeeper="node1:2181/expensekafka"
final val TopicName_Count = "expen... |
Explain and rewrite the following Scala code: | /*
* Licensed to Intel Corporation under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* Intel Corporation licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use t... |
Explain and rewrite the following Scala code: | package mesosphere.marathon.core.task.tracker.impl
import akka.actor.{ ActorRef, ActorSystem, PoisonPill, Terminated }
import akka.testkit.TestProbe
import mesosphere.marathon.Protos.MarathonTask
import mesosphere.marathon.core.base.ConstantClock
import mesosphere.marathon.tasks.TaskTracker
import mesosphere.marathon.... |
Explain and rewrite the following Scala code: | package breeze.optimize
/*
Copyright 2009 David Hall, Daniel Ramage
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 la... |
Explain and rewrite the following Scala code: |
package org.openapitools.client.model
case class Link (
_class: Option[String],
_href: Option[String]
)
object Link {
def toStringBody(var_class: Object, var_href: Object) =
s"""
| {
| "class":$var_class,"href":$var_href
| }
""".stripMargin
}
|
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala.lang.psi.uast.declarations
import java.util
import com.intellij.psi.{PsiAnnotation, PsiClass}
import org.jetbrains.annotations.Nullable
import org.jetbrains.plugins.scala.lang.psi.api.base.{ScAnnotation, ScConstructorInvocation, ScReference}
import org.jetbrains.plugins.scala.lang.... |
Explain and rewrite the following Scala code: | package metamorphic.dsl.application
case class Application(
name: String,
services: List[Service]) {
def service(serviceName: String): Option[Service] = {
services.find(service => service.name.equals(serviceName))
}
} |
Explain and rewrite the following Scala code: | /*
* Copyright 2017 PayPal
*
* 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 writin... |
Explain and rewrite the following Scala code: | /*
* Copyright 2013 http4s.org
*
* 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: | package edu.gemini.sp.vcs.log
import edu.gemini.spModel.core.SPProgramID
import edu.gemini.util.security.principal.GeminiPrincipal
import javax.security.auth.Subject
import collection.JavaConverters._
import java.io.File
trait VcsLog {
/** Log an event to the database.
* @param op the kind of operation
* @... |
Explain and rewrite the following Scala code: | package routers
import akka.http.scaladsl.server.{Directives, Route}
import utils.JsonSupport
trait Router extends Directives {
def route: Route
}
trait JsonRouter extends Router with JsonSupport
|
Explain and rewrite the following Scala code: | package controllers
import play.api.mvc._
import org.reactivecouchbase.play.PlayCouchbase
import play.api.Play
import java.util.UUID
import scala.concurrent.Future
import play.api.libs.json.{JsObject, Json}
import org.reactivecouchbase.CouchbaseRWImplicits.jsObjectToDocumentWriter
import java.util.concurrent.atomic.At... |
Explain and rewrite the following Scala code: | package booli
import org.osgeo.proj4j.{CRSFactory, CoordinateTransformFactory}
object Configuration {
val user = sys.env("PRICEMAP_BOOLI_USER")
val token = sys.env("PRICEMAP_BOOLI_TOKEN")
val url = "https://api.booli.se/sold"
val pageSize = 500
val outputPath = sys.env("PRICEMAP_OUTPUT_PATH")
val tileCach... |
Explain and rewrite the following Scala code: | /*
* UnrollQuadTree.scala
* (Grenzwerte)
*
* Copyright (c) 2015 Hanns Holger Rutz. All rights reserved.
*
* This software is published under the GNU General Public License v3+
*
*
* For further information, please contact Hanns Holger Rutz at
* contact@sciss.de
*/
package de.sciss.grenzwerte
import d... |
Explain and rewrite the following Scala code: | /*
* Copyright 2013 http4s.org
*
* 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: | package dao
import dao.helper.TableFilter
import database._
import javax.inject.Inject
import models._
import slick.jdbc.PostgresProfile.api._
import slick.lifted.TableQuery
import utils.date.DateTimeOps.SqlTimestampConverter
import scala.concurrent.{ExecutionContext, Future}
trait ReportCardEvaluationDao extends Ab... |
Explain and rewrite the following Scala code: | //
// Processor.scala -- Scala benchmark component Processor
// Project OrcTests
//
// Copyright (c) 2018 The University of Texas at Austin. All rights reserved.
//
// Use and redistribution of this file is governed by the license terms in
// the LICENSE file found in the project's top-level directory and also found at... |
Explain and rewrite the following Scala code: | package com.moon.pattern
import org.junit.Test
/**
* Created by Paul on 2017/3/1.
*/
class Pattern14 {
// @Test
// def test(){
// val vs = Vector(20.0, 4.5, 50.0, 15.75, 30.0, 3.5)
// println(vs filter (price => price >= 20))
// println(vs map (price => price * 0.10))
// println(vs reduce ((total, p... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2012 Orderly 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/licenses/L... |
Explain and rewrite the following Scala code: | package org.deepdive.inference
case class WeightInferenceResult(weightId: Long, value: Double) |
Explain and rewrite the following Scala code: | // Scala for the Impatient / Chapter 5 / Exercise 3:
// Write a class Time with read-only properties hours and minutes and a method before(other: Time): Boolean that checks
// whether this time comes before the other. A Time object should be constructed as new Time(hrs, min), where hrs is in
// military time format (be... |
Explain and rewrite the following Scala code: | /*
* Copyright 2001-2008 Artima, 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 la... |
Explain and rewrite the following Scala code: | //package ch.descabato
//
//import org.scalatest._
//import org.scalatest.Matchers._
//
//class BackupSpec extends FlatSpec {
// import org.scalacheck.Gen._
//
// val toTest = new BackupIndexHandler() {
// val config = new BackupFolderConfiguration()
// }
//
// "detect roots" should "work" in {
// testWit... |
Explain and rewrite the following Scala code: | /*
* This file is part of the "silex" library of helpers for Apache Spark.
*
* Copyright (c) 2015 Red Hat, 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.... |
Explain and rewrite the following Scala code: | package scato
package io
import IOCore.Thunk
case class Concurrently[A](thunk: Thunk) extends AnyVal {
def *>[B](par: Concurrently[B]): Concurrently[B] =
Concurrent.concurrently(IO[A](thunk), IO[B](par.thunk)).map(_._2).concurrently
def map[B](f: A => B): Concurrently[B] = Concurrently[B](Thunk.map(thunk)(f))... |
Explain and rewrite the following Scala code: | package com.airbnb.scheduler.jobs
import com.fasterxml.jackson.annotation.JsonProperty
object VolumeMode extends Enumeration {
type VolumeMode = Value
// read-write and read-only.
val RW, RO = Value
}
object NetworkMode extends Enumeration {
type NetworkMode = Value
// Bridged and Host
val BRIDGE, HOST... |
Explain and rewrite the following Scala code: | import fr.njin.playoauth.common.domain._
import scala.concurrent.Future
class InMemoryOauthRORep[T <: OauthResourceOwner](val users: Map[String, T] = Map.empty[String, T]) extends OauthResourceOwnerRepository[T] {
def find(id: String): Future[Option[T]] = Future.successful(users.get(id))
}
class InMemoryOauthClient... |
Explain and rewrite the following Scala code: | /**
* Copyright 2017 Interel
*
* 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 t... |
Explain and rewrite the following Scala code: | package io.daewon.util
trait Monad[+M, Cont[_]] {
def unit[A](a: A): Cont[A]
def flatMap[A](f: M => Cont[A]): Cont[A]
}
|
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 2021 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 mesosphere.marathon.upgrade
import akka.actor.{ ActorRef, ActorSystem, Props }
import akka.event.EventStream
import akka.testkit.TestActor.{ AutoPilot, NoAutoPilot }
import akka.testkit.{ ImplicitSender, TestActorRef, TestKit, TestProbe }
import akka.util.Timeout
import com.codahale.metrics.MetricRegistry
impo... |
Explain and rewrite the following Scala code: | package lila.search
import lila.common.paginator._
import makeTimeout.large
import play.api.libs.json.Writes
final class PaginatorBuilder[A, Q : Writes](
searchApi: SearchReadApi[A, Q],
maxPerPage: Int) {
def apply(query: Q, page: Int): Fu[Paginator[A]] = Paginator(
adapter = new ESAdapter(query),
... |
Explain and rewrite the following Scala code: | /*
* Copyright 2022 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: | /*
* 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: | import scala.reflect.runtime.universe._
import scala.tools.reflect.Eval
object B { override def toString = "object" }
class C { override def toString = "class" }
package foo1 {
object B { override def toString = "package > object" }
class C { override def toString = "package > class" }
}
object Foo2 {
object B... |
Explain and rewrite the following Scala code: | package info.glennengstrand.news
import java.util.Date
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.glennengstrand.io._
/** helper functions for outbound object creation */
object Outbound extends ElasticSearchSearcher {
val log = LoggerFactory.getLogger("info.glennengstrand.news.Outbound")... |
Explain and rewrite the following Scala code: | package core
import akka.actor.Actor
import domain.Tweet
import com.datastax.driver.core.{BoundStatement, Cluster}
import scala.util.Success
class TweetWriterActor(cluster: Cluster) extends Actor {
val session = cluster.connect(Keyspaces.akkaCassandra)
val preparedStatement = session.prepare("INSERT INTO tweets(key... |
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: | package com.twitter.finagle.stream
import com.twitter.concurrent.Offer
import com.twitter.io.Buf
trait StreamResponse { self =>
/**
* This represents the actual HTTP reply (response headers) for this
* response.
*/
def info: StreamResponse.Info
/**
* An Offer for the next message in the stream.
... |
Explain and rewrite the following Scala code: | /* Copyright (C) 2008-2014 University of Massachusetts Amherst.
This file is part of "FACTORIE" (Factor graphs, Imperative, Extensible)
http://factorie.cs.umass.edu, http://github.com/factorie
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with... |
Explain and rewrite the following Scala code: | package dotty.tools.dotc
package transform
import core._
import MegaPhase._
import Contexts._
import Flags._
import SymUtils._
import Symbols._
import Decorators._
import DenotTransformers._
import Names._
import NameOps._
import NameKinds._
import NullOpsDecorator._
import ResolveSuper._
import reporting.IllegalSuper... |
Explain and rewrite the following Scala code: | package com.wavesplatform.database.jna
import java.io.File
import com.protonail.leveldb.jna.{LevelDB, LevelDBCompressionType, LevelDBOptions}
import org.iq80.leveldb.{CompressionType, DB, DBFactory, Options}
class LevelDBJNADBFactory extends DBFactory {
private[this] def openJnaDatabase(path: File, options: Option... |
Explain and rewrite the following Scala code: | // Copyright: 2010 - 2017 https://github.com/ensime/ensime-server/graphs
// License: http://www.gnu.org/licenses/gpl-3.0.en.html
package org.ensime.vfs
import java.io.File
import java.util.zip.ZipFile
import org.apache.commons.vfs2._
import org.apache.commons.vfs2.impl._
import org.apache.commons.vfs2.provider.zip.Zi... |
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: | /* __ *\\
** ________ ___ / / ___ Scala API **
** / __/ __// _ | / / / _ | (c) 2003-2013, LAMP/EPFL **
** __\\ \\/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
** /____/\\___/_/... |
Explain and rewrite the following Scala code: |
trait Functor[F[_]] {
def fmap[A,B](fun: A=>B, arg:F[A]): F[B]
}
object Functor{
implicit val ListFunctor: Functor[List] = new Functor[List] {
def fmap[A, B](f: A => B, arg: List[A]):List[B] = arg map f
}
final class OOFunctor[F[_],A](arg:F[A])(implicit ftr: Functor[F]) {
def fmap[B](fun: A=>B):F[B] =... |
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 Netflix, 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 i... |
Explain and rewrite the following Scala code: | package io.petersen.oauth.consumer
import com.massrelevance.dropwizard.ScalaApplication
import com.massrelevance.dropwizard.bundles.ScalaBundle
import io.dropwizard.db.DataSourceFactory
import io.dropwizard.hibernate.HibernateBundle
import io.dropwizard.migrations.MigrationsBundle
import io.dropwizard.setup.{Enviro... |
Explain and rewrite the following Scala code: | /*
* Copyright 2007-2010 WorldWide Conferencing, LLC
*
* 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: | /*
* 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 io.youi.server.util
import java.io.File
import java.nio.file.Files
import java.security.KeyStore
import javax.net.ssl.{KeyManagerFactory, SSLContext, TrustManagerFactory}
object SSLUtil {
def createSSLContext(keyStoreFile: File, password: String): SSLContext = {
val passwordChars = password.toCharArray... |
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.foreach.analytics.spark
import org.apache.spark.{SparkConf, SparkContext}
/**
* Created by aitor on 12/2/17.
*/
object WordCount {
def main(args: Array[String]): Unit = {
val conf = new SparkConf().setAppName(this.getClass.getName).setMaster("local")
val sc = new SparkContext(conf)
va... |
Explain and rewrite the following Scala code: | /*
* Copyright 2015 data Artisans GmbH
*
* 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... |
Explain and rewrite the following Scala code: | package org.sample.helloworld
import org.apache.predictionio.controller._
import scala.io.Source
import scala.collection.immutable.HashMap
// all data need to be serializable
class MyTrainingData(
// list of (day, temperature) tuples
val temperatures: List[(String, Double)]
) extends Serializable
class MyQuery(... |
Explain and rewrite the following Scala code: | /*
* Copyright (c) 2014-2020 by The Monix Project Developers.
* See the project homepage at: https://monix.io
*
* 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... |
Explain and rewrite the following Scala code: | package edu.rice.habanero.benchmarks.barber
import java.util.concurrent.atomic.AtomicLong
import edu.rice.habanero.actors.{GparsActor, GparsActorState, GparsPool}
import edu.rice.habanero.benchmarks.barber.SleepingBarberConfig._
import edu.rice.habanero.benchmarks.{Benchmark, BenchmarkRunner, PseudoRandom}
import sc... |
Explain and rewrite the following Scala code: | /*
* Copyright 2009-2010 WorldWide Conferencing, LLC
*
* 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: | package controllers.billing
import scalaz._
import Scalaz._
import scalaz.Validation
import scalaz.Validation.FlatMap._
import scalaz.NonEmptyList._
import net.liftweb.json._
import net.liftweb.json.JsonParser._
import io.megam.auth.funnel.{ FunnelResponse, FunnelResponses }
import io.megam.auth.funnel.FunnelErrors._... |
Explain and rewrite the following Scala code: | package com.lynbrookrobotics.potassium.model.examples
import com.lynbrookrobotics.potassium.ClockMocking._
import com.lynbrookrobotics.potassium.Signal
import com.lynbrookrobotics.potassium.commons.drivetrain.twoSided.TwoSidedDriveProperties
import com.lynbrookrobotics.potassium.control.PIDConfig
import com.lynbrookro... |
Explain and rewrite the following Scala code: | package apus.util
import java.io.InputStream
import scala.xml.{Elem, SAXParser}
import scala.xml.factory.XMLLoader
/**
* Use this class for XML parsing instead of scala.xml.XML,
* in case that it finds SAXParserFactory from Aalto. <br/>
*
* Created by Hao Chen on 2014/11/24.
*/
object Xml extends XMLLoader[Elem... |
Explain and rewrite the following Scala code: | package algebra
/**
* Priority is a type class for prioritized implicit search.
*
* This type class will attempt to provide an implicit instance of `P`
* (the preferred type). If that type is not available it will
* fallback to `F` (the fallback type). If neither type is available
* then a `Priority[P, F]` insta... |
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 fpinscala.errorhandling
import scala.{Option => _, Some => _, Either => _, _} // hide std library `Option`, `Some` and `Either`, since we are writing our own in this chapter
sealed trait Option[+A] {
def map[B](f: A => B): Option[B] = this match {
case None => None
case Some(a) => Some(f(a))
}... |
Explain and rewrite the following Scala code: | package com.datawizards.splot.model
import com.datawizards.splot.calculations.PlotSeriesCalculator
import com.datawizards.splot.model.PlotType.PlotType
import com.datawizards.splot.theme.PlotTheme
object Plot {
def apply[T] (
plotType: PlotType,
width: Int,
height:... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala
package annotator
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.lang.annotation.AnnotationHolder
import org.jetbrains.plugins.scala.annotator.quickfix.ReportHighlightingErrorQuickFix
import org.jetbrains.plugins.scala.lang.psi.api.ScalaFile
import org.j... |
Explain and rewrite the following Scala code: | package org.littlewings.tweetbot.application.lilymyu.lyrics.producer
import javax.enterprise.context.{ApplicationScoped, Dependent}
import javax.enterprise.inject.Produces
import javax.inject.Inject
import org.littlewings.tweetbot.application.lilymyu.lyrics.config.LilymyuLyricsConfig
import org.littlewings.tweetbot.a... |
Explain and rewrite the following Scala code: | /**
* Copyright (C) 2009-2011 the original author or authors.
* See the notice.md file distributed with this work for additional
* information regarding copyright ownership.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Yo... |
Explain and rewrite the following Scala code: | package com.sksamuel.elastic4s.requests.searches.queries
import com.sksamuel.elastic4s.json.{XContentBuilder, XContentFactory}
object RankFeatureQueryBuilderFn {
def apply(q: RankFeatureQuery): XContentBuilder = {
val builder = XContentFactory.jsonBuilder()
builder.startObject("rank_feature")
builder.fi... |
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: | {
println(/* offset: 37 */f)
def f = {}
}
def f = {} |
Explain and rewrite the following Scala code: | /**
* Angles
* Copyright (C) 2015 Jakob Hendeß, Niklas Wolber
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
... |
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 lila.video
import org.joda.time.DateTime
case class TagNb(_id: Tag, nb: Int) {
def tag = _id
def empty = nb == 0
def isNumeric = tag forall (_.isDigit)
}
case class Filter(tags: List[String]) {
def toggle(tag: String) = copy(
tags = if (tags contains tag) tags filter (tag!=) else tags :+ tag
... |
Explain and rewrite the following Scala code: | package ru.pavkin.todoist.api.core.model
import org.scalacheck.Arbitrary._
import org.scalacheck.Gen
import org.scalatest.prop.GeneratorDrivenPropertyChecks
import org.scalatest.{FunSuite, Matchers}
class DayOfWeekSpec extends FunSuite with Matchers with GeneratorDrivenPropertyChecks {
test("DayOfWeek.unsafeBy ret... |
Explain and rewrite the following Scala code: | // Copyright (C) 2017 Calin Cruceru <calin.cruceru@stud.acs.upb.ro>.
//
// See the LICENCE file distributed with this work for additional
// information regarding copyright ownership.
package org.symnet
package models.iptables
package extensions.nat
// scala
import org.junit.runner.RunWith
import org.scalatest.{FunSu... |
Explain and rewrite the following Scala code: | package lila.message
object Event {
case class NewMessage(t: Thread, p: Post)
}
|
Explain and rewrite the following Scala code: | package org.scalatest.examples.spec.composingbeforeandaftereach
import org.scalatest._
import org.scalatest.BeforeAndAfterEach
import collection.mutable.ListBuffer
trait Builder extends BeforeAndAfterEach { this: Suite =>
val builder = new StringBuilder
override def beforeEach() {
builder.append("ScalaTe... |
Explain and rewrite the following Scala code: | package com.twitter.inject.thrift.filtered_integration.http_server
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.filters.CommonFilters
import com.twitter.finatra.http.routing.HttpRouter
import com.twitter.inject.thrift.modules.ThriftClientIdModule
class GreeterHttpServer extends HttpServe... |
Explain and rewrite the following Scala code: | package java.lang.ref
class PhantomReference[T >: Null <: AnyRef](referent: T, queue: ReferenceQueue[_]) extends Reference[T](referent) {
def this(referent: T) = this(referent, null)
override def get: T = null
}
|
Explain and rewrite the following Scala code: | package debop4s.core.jodatime
import java.sql.Timestamp
import org.joda.time.DateTime
class JodaRichTimestamp(val self: Timestamp) extends AnyVal with Ordered[Timestamp] {
def toDateTime: DateTime = new DateTime(self)
def compare(that: Timestamp): Int = {
self.getNanos - that.getNanos
}
}
|
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: | // This is supposed to be compiled by Scala 2.11
trait T {
def d = 42
val v = ""
object O
final val w = 33
}
trait S2T {
var x: Int = 0
lazy val y: Int = 1
val z: Int = 2
val a: Int
var b: Int
def f(x: Int): Int = x + y
}
trait S2Tprivate {
private var x: Int = 0
private lazy val y: Int = 1
... |
Explain and rewrite the following Scala code: | /*
* Copyright (C) 2016 Vincibean <Andre Bessi>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This... |
Explain and rewrite the following Scala code: | package com.blackboxsociety.app.controllers.login
import com.blackboxsociety.mvc._
import com.blackboxsociety.http._
import scalaz.concurrent._
import com.blackboxsociety.app.services._
import com.blackboxsociety.mvc.form._
import com.blackboxsociety.http.routes._
case class Post(services: ServiceManifest) extends Co... |
Explain and rewrite the following Scala code: | package breeze.linalg.operators
import breeze.linalg._
import breeze.linalg.support.{CanZipMapKeyValues, CanZipMapValues, CanCopy}
import breeze.generic.{UFunc}
import breeze.generic.UFunc.{UImpl, UImpl2}
import breeze.macros.expand
import breeze.math.{Field, Ring, Semiring}
import breeze.storage.Zero
import scala.{s... |
Explain and rewrite the following Scala code: | package viewmodels
import models._
import org.joda.time.DateTime
case class BlogEntryWithMeta(
blogEntry: BlogEntry,
category: Category,
tags: Seq[Tag])
object BlogEntryWithMeta {
implicit def dateTimeOrdering: Ordering[DateTime] = Ordering.fromLessThan(_ isBefore _)
implicit def orderBlogEntryWithMeta: ... |
Explain and rewrite the following Scala code: | package fpinscala.errorhandling
import java.util.regex.Pattern
import fpinscala.errorhandling
import org.scalatest.FunSuite
import org.scalatest.Matchers._
/**
* Created by ejdy on 14.12.15.
*/
class OptionTest extends org.scalatest.FlatSpec {
"Option map" should "return the same for my and library implementation... |
Explain and rewrite the following Scala code: | package org.clulab.processors
import org.clulab.struct.DirectedGraphEdgeIterator
import org.scalatest._
import org.clulab.processors.corenlp.CoreNLPProcessor
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.io.Source
import java.util.concurrent.{TimeUnit, Executors}
import java.lang.Long
import o... |
Explain and rewrite the following Scala code: | package com.lookout.borderpatrol.test.sessionx
import java.net.URL
import javax.xml.bind.DatatypeConverter
import com.lookout.borderpatrol.Endpoint
import com.lookout.borderpatrol.sessionx._
import com.lookout.borderpatrol.sessionx.SecretStores._
import com.lookout.borderpatrol.sessionx.ConsulResponse._
import com.lo... |
Explain and rewrite the following Scala code: | package org.jetbrains.plugins.scala
package lang.psi.api
import com.intellij.openapi.diagnostic.Logger
import com.intellij.psi.PsiElement
import org.jetbrains.plugins.scala.caches.ScalaRecursionManager
import org.jetbrains.plugins.scala.extensions._
import org.jetbrains.plugins.scala.lang.psi.ScalaPsiUtil.SafeCheckExc... |
Explain and rewrite the following Scala code: | package io.github.interestinglab.waterdrop.output.batch
import io.github.interestinglab.waterdrop.apis.BaseOutput
import io.github.interestinglab.waterdrop.config.{Config, ConfigFactory}
import org.apache.spark.sql.{DataFrameWriter, Dataset, Row, SparkSession}
import java.util
import scala.collection.JavaConversions.... |
Explain and rewrite the following Scala code: | package wakfutcp.protocol.messages.server
import wakfutcp.protocol.{Codec, ServerMessage}
final case class GroupResultMessage(
groupType: Byte,
result: Int
) extends ServerMessage {
override val id = 504
}
object GroupResultMessage {
import Codec._
import cats.syntax.apply._
implicit val codec: Codec[Gr... |
Explain and rewrite the following Scala code: | package scorex.network
import java.net.{InetAddress, InetSocketAddress}
import com.google.common.primitives.{Ints, Longs}
import scorex.app.ApplicationVersion
import scorex.serialization.{BytesSerializable, Deser}
import scorex.utils.ScorexLogging
import scala.util.Try
case class Handshake(applicationName: String,... |
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: | // Copyright 2010 Foursquare Labs Inc. All Rights Reserved.
package net.liftweb {
package mongodb {
package record {
package field {
import net.liftweb.record._
import net.liftweb.record.RecordHelpers.jvalueToJsExp
import net.liftweb.record.field._
import net.liftweb.http.js.JE.{JsObj, Num, Str, JsNull}
import xml.{T... |
Explain and rewrite the following Scala code: | package org.bitcoins.core.util
import org.slf4j.Logger
import scodec.bits.ByteVector
/**
* Created by chris on 2/26/16.
* Trait to implement ubiquitous factory functions across our codebase
*/
abstract class Factory[+T] {
/** Creates a T out of a hex string. */
def fromHex(hex: String): T = fromBytes(Bitco... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.