• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala PrintStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中java.io.PrintStream的典型用法代码示例。如果您正苦于以下问题:Scala PrintStream类的具体用法?Scala PrintStream怎么用?Scala PrintStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了PrintStream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: OutputStreamLoggerAdapter

//设置package包名称以及导入依赖的类
package logoon.adapters.console

import java.io.{ OutputStream, PrintStream }

import logoon._

class OutputStreamLoggerAdapter(output: OutputStream) extends LoggerAdapter {
  override def log(name: String, level: LogLevel, message: => String, context: Map[String, String]): Unit = {
    output.write("[%-5s] %s\n".format(level, message).getBytes())
    context.foreach { case (key, value) => output.write("%25s = %s\n".format(key, value).getBytes) }
  }
  override def log(name: String, level: LogLevel, message: => String, throwable: => Throwable, context: Map[String, String]): Unit = {
    log(name, level, message, context)
    throwable.printStackTrace(new PrintStream(output))
  }
}

object ConsoleLoggerAdapter extends OutputStreamLoggerAdapter(System.out)

class InMemoryLogLevelConfig extends LogLevelConfig {
  var levels: Map[String, LogLevel] = Map("" -> LogLevel.OFF)
  override def logLevel(name: String): LogLevel =
    levels.get(name) match {
      case Some(level) => level
      case None        => logLevel(name.substring(0, name.length - 1))
    }
  override def setLogLevel(name: String, level: LogLevel): Unit = levels += (name -> level)
} 
开发者ID:btlines,项目名称:logoon,代码行数:29,代码来源:ConsoleLoggerAdapter.scala


示例2: ByteCodeExecutor

//设置package包名称以及导入依赖的类
package org.arnoldc

import java.io.{PrintStream, ByteArrayOutputStream}

class ByteCodeExecutor extends ClassLoader {
  val originalOutputStream = System.out

  def getOutput(bytecode: Array[Byte], className: String): String = {

    val outputRedirectionStream = new ByteArrayOutputStream()

   System.setOut(new PrintStream(outputRedirectionStream))

    invokeMainMethod(bytecode, className)
    System.setOut(originalOutputStream)
    outputRedirectionStream.toString
  }

  def invokeMainMethod(bytecode: Array[Byte], className: String) = {
    val template = new ByteCodeExecutor()
    val testClass = template.defineClass(className, bytecode, 0, bytecode.length)
    val testInstance = testClass.newInstance().asInstanceOf[ {def main(test: Array[String])}]
    testInstance.main(null)
  }
} 
开发者ID:derlorenz,项目名称:VongSprech,代码行数:26,代码来源:ByteCodeExecutor.scala


示例3: ConsoleProgressBarTest

//设置package包名称以及导入依赖的类
package hu.ssh.progressbar.console

import java.io.{ByteArrayOutputStream, PrintStream}

import com.google.common.base.{Splitter, Strings}
import com.google.common.collect.Iterables
import org.scalatest.{FlatSpec, Matchers}


class ConsoleProgressBarTest extends FlatSpec with Matchers {
  "ProgressBar" should "output as expected" in {
    val outputstream = new ByteArrayOutputStream
    try {
      val progressBar = ConsoleProgressBar.on(new PrintStream(outputstream)).withFormat(":percent")
      progressBar.tick(0)
      assert(getLastOutput(outputstream.toString) == "  0.00")
      progressBar.tick(25)
      assert(getLastOutput(outputstream.toString) == " 25.00")
      progressBar.tick(30)
      assert(getLastOutput(outputstream.toString) == " 55.00")
      progressBar.tick(44)
      assert(getLastOutput(outputstream.toString) == " 99.00")
      progressBar.tickOne()
      assert(getLastOutput(outputstream.toString) == "100.00")
    } finally outputstream.close()
  }

  private def getLastOutput(string: String): String = {
    if (Strings.isNullOrEmpty(string)) return string
    val outputs = Splitter.on(ConsoleProgressBar.CARRIAGE_RETURN).omitEmptyStrings.split(string)
    Iterables.getLast(outputs)
  }
} 
开发者ID:arguslab,项目名称:Argus-SAF,代码行数:34,代码来源:ConsoleProgressBarTest.scala


示例4: capture

//设置package包名称以及导入依赖的类
package xyz.hyperreal

import java.io.{PrintStream, ByteArrayOutputStream}

package object gerbil {
	def capture( code: String ) = {
		val buf = new ByteArrayOutputStream
		
		Console.withOut( new PrintStream(buf) )( Gerbil.run(code) )
		buf.toString.trim
	}
	
	def captureReturn( code: String ) = {
		val buf = new ByteArrayOutputStream
		val ret = Console.withOut( new PrintStream(buf) )( Gerbil.run(code) )
		
		(ret, buf.toString.trim)
	}
} 
开发者ID:edadma,项目名称:gerbil,代码行数:20,代码来源:gerbil.scala


示例5: Test

//设置package包名称以及导入依赖的类
package xyz.hyperreal.energize

import java.io.{PrintStream, ByteArrayOutputStream}


object Test {

  def dbconnect = Energize.dbconnect( "H2", "org.h2.Driver", "jdbc:h2:mem:", "sa", "" )

	def capture( code: String ) = {
		val buf = new ByteArrayOutputStream
		val (c, s, d) = dbconnect
		val key = AUTHORIZATION.getString( "key" )

		Console.withOut( new PrintStream(buf) )( Energize.configure(io.Source.fromString(code), c, s, d, key) )
		c.close
		buf.toString.trim
	}
	
	def captureReturn( code: String ) = {
		val buf = new ByteArrayOutputStream
		val (c, s, d) = dbconnect
		val key = AUTHORIZATION.getString( "key" )
		val ret = Console.withOut( new PrintStream(buf) )( Energize.configure(io.Source.fromString(code), c, s, d, key) )

		c.close
		(ret, buf.toString.trim)
	}
} 
开发者ID:vinctustech,项目名称:energize,代码行数:30,代码来源:Test.scala


示例6: ByteCodeExecutor

//设置package包名称以及导入依赖的类
package merkelonrails

import java.io.{ByteArrayOutputStream, PrintStream}

class ByteCodeExecutor extends ClassLoader {
  val originalOutputStream = System.out

  def getOutput(bytecode: Array[Byte], className: String): String = {

    val outputRedirectionStream = new ByteArrayOutputStream()

   System.setOut(new PrintStream(outputRedirectionStream))

    invokeMainMethod(bytecode, className)
    System.setOut(originalOutputStream)
    outputRedirectionStream.toString
  }

  def invokeMainMethod(bytecode: Array[Byte], className: String) = {
    val template = new ByteCodeExecutor()
    val testClass = template.defineClass(className, bytecode, 0, bytecode.length)
    val testInstance = testClass.newInstance().asInstanceOf[ {def main(test: Array[String])}]
    testInstance.main(null)
  }
} 
开发者ID:lehoffma,项目名称:MerkelOnRails,代码行数:26,代码来源:ByteCodeExecutor.scala


示例7: ConfigTest

//设置package包名称以及导入依赖的类
package delorean.commands

import java.io.{ByteArrayOutputStream, PrintStream}
import java.nio.file._

import delorean._
import org.junit.Assert._
import org.junit._

import scala.util.Try

class ConfigTest {

    val outContent = new ByteArrayOutputStream()

    /**
      * This will redirect the output stream into outContent and we can access the print output from it.
      */
    @Before
    def setUpStreams(): Unit = System.setOut(new PrintStream(outContent))

    /**
      * Resetting the stream to null.
      */
    @After
    def cleanUpStreams(): Unit = System.setOut(null)

    @Test
    def configTest(): Unit = {
        // Adding a new key value pair to configuration
        Config(List("Marty", "McFly"))

        // Calling list to display the current configuration
        Config(List("--list"))
        assertEquals("Marty = McFly", outContent.toString.trim)
    }
}

object ConfigTest {
    // Create CONFIG file. We also create TIME_MACHINE as we need the parent directory to be present
    @BeforeClass
    def setUp(): Unit = {
        Try(Files.createDirectory(Paths.get(TIME_MACHINE)))
        Try(Files.createFile(Paths.get(CONFIG)))
    }

    // Delete CONFIG file and the parent directory.
    @AfterClass
    def tearDown(): Unit = {
        Try(Files.delete(Paths.get(CONFIG)))
        Try(Files.delete(Paths.get(TIME_MACHINE)))
    }

} 
开发者ID:durgaswaroop,项目名称:delorean,代码行数:55,代码来源:ConfigTest.scala


示例8: ClientEventProcessor

//设置package包名称以及导入依赖的类
package org.argus.jc.incremental.jawa
package remote

import java.io.{PrintStream, PrintWriter}


class ClientEventProcessor(client: Client) {
  def process(event: Event) {
    event match {
      case MessageEvent(kind, text, source, line, column) =>
        client.message(kind, text, source, line, column)

      case ProgressEvent(text, done) =>
        client.progress(text, done)

      case DebugEvent(text) =>
        client.debug(text)

      case TraceEvent(message, lines) =>
        client.trace(new ServerException(message, lines))

      case GeneratedEvent(source, module, name) =>
        client.generated(source, module, name)

      case DeletedEvent(module) =>
        client.deleted(module)

      case SourceProcessedEvent(source) =>
        client.processed(source)

      case CompilationEndEvent() =>
        client.compilationEnd()
    }
  }
}

class ServerException(message: String, lines: Array[String]) extends Exception {
  override def getMessage = message

  override def printStackTrace(s: PrintWriter) {
    lines.foreach(s.println)
  }

  override def printStackTrace(s: PrintStream) {
    lines.foreach(s.println)
  }
} 
开发者ID:arguslab,项目名称:argus-cit-intellij,代码行数:48,代码来源:ClientEventProcessor.scala


示例9: System

//设置package包名称以及导入依赖的类
package java.lang

import java.io.{InputStream, PrintStream}
import java.util.Properties
import scala.scalanative.native._
import scala.scalanative.runtime.time

final class System private ()

object System {
  def arraycopy(src: Object,
                srcPos: scala.Int,
                dest: Object,
                destPos: scala.Int,
                length: scala.Int): Unit = {
    scalanative.runtime.Array.copy(src, srcPos, dest, destPos, length)
  }

  def exit(status: Int): Unit = {
    Runtime.getRuntime().exit(status)
  }

  def identityHashCode(x: Object): scala.Int =
    x.cast[Word].hashCode

  def getenv(name: String): String                      = ???
  def clearProperty(key: String): String                = ???
  def getProperties(): Properties                       = ???
  def getProperty(key: String): String                  = ???
  def getProperty(key: String, default: String): String = ???
  def setProperty(key: String, value: String): String   = ???

  def nanoTime(): CLong = time.scalanative_nano_time

  var in: InputStream  = _
  var out: PrintStream = new PrintStream(new CFileOutputStream(stdio.stdout))
  var err: PrintStream = new PrintStream(new CFileOutputStream(stdio.stderr))

  private class CFileOutputStream(stream: Ptr[stdio.FILE])
      extends java.io.OutputStream {
    private val buf = stdlib.malloc(1)
    def write(b: Int): Unit = {
      !buf = b.toUByte.toByte
      stdio.fwrite(buf, 1, 1, stream)
    }
  }
} 
开发者ID:shuodata,项目名称:scala-native,代码行数:48,代码来源:System.scala


示例10: UrlPrinterTest

//设置package包名称以及导入依赖的类
package webcrawler

import java.io.PrintStream

import org.mockito.Mockito._
import org.scalatest.{FreeSpec, Matchers}

class UrlPrinterTest extends FreeSpec with Matchers {
  "A UrlPrinter" - {
    val out = mock(classOf[PrintStream])
    val printer = new UrlPrinter(out)
    "should print" - {
      "the root" in {
        printer.printRoot("hello")

        verify(out).println("Visiting root: hello")
      }

      "the urls" in {
        val urls = List("/one", "/two")
        printer.printUrls(urls)

        verify(out).println("|_ /one")
        verify(out).println("|_ /two")
      }
    }
  }
} 
开发者ID:memoizr,项目名称:web-crawler-kata,代码行数:29,代码来源:UrlPrinterTest.scala


示例11: write

//设置package包名称以及导入依赖的类
package fr.cnrs.liris.accio.core.report

import java.io.{BufferedOutputStream, FileOutputStream, PrintStream}
import java.nio.file.Path

import fr.cnrs.liris.accio.core.thrift
import fr.cnrs.liris.util.io.FileUtils


  def write(reports: Seq[thrift.Report], path: Path): Unit = {
    val reportStats = new ReportStatistics(reports)
    FileUtils.safeDelete(path)
    val out = new PrintStream(new BufferedOutputStream(new FileOutputStream(path.toFile)))
    try {
      print(reportStats, out)
    } finally {
      out.close()
    }
  }
} 
开发者ID:privamov,项目名称:alp,代码行数:21,代码来源:ReportCreator.scala


示例12: printSummary

//设置package包名称以及导入依赖的类
package fr.cnrs.liris.accio.core.report

import java.io.PrintStream

import fr.cnrs.liris.accio.lib.stats.{AggregatedStats, Distribution}
import fr.cnrs.liris.util.MathUtils.roundAt6


  private def printSummary(out: PrintStream, metric: String, stats: AggregatedStats) = {
    out.print(f"$metric%20s | ${stats.n}%10s")
    if (stats.n > 0) {
      out.print(f" | ${roundAt6(stats.min)}%10s")
      if (stats.n > 1) {
        out.print(f" | ${roundAt6(stats.max)}%10s | ${roundAt6(stats.avg)}%10s | ${roundAt6(stats.stddev)}%10s")
      }
    }
    out.println()
  }

  private def bold(str: String) = if (useAnsi) s"\033[1m$str\033[0m" else str
} 
开发者ID:privamov,项目名称:alp,代码行数:22,代码来源:TextReportCreator.scala


示例13: prompt

//设置package包名称以及导入依赖的类
package org.kneelawk.simplecursemodpackdownloader.console

import java.io.Console
import java.io.PrintStream
import java.io.InputStream
import java.io.BufferedReader
import java.io.InputStreamReader

trait ConsoleInterface {
  def prompt(fmt: String, args: Object*): String

  def promptHiddenInput(fmt: String, args: Object*): String
}

class DefaultConsoleInterface(console: Console) extends ConsoleInterface {
  override def prompt(fmt: String, args: Object*) = console.readLine(fmt, args)

  override def promptHiddenInput(fmt: String, args: Object*) = new String(console.readPassword(fmt, args))
}

class EclipseConsoleInterface(out: PrintStream, in: InputStream) extends ConsoleInterface {
  val reader = new BufferedReader(new InputStreamReader(in))
  
  override def prompt(fmt: String, args: Object*) = {
    out.printf(fmt, args)
    reader.readLine()
  }

  override def promptHiddenInput(fmt: String, args: Object*) = {
    out.printf(fmt, args)
    reader.readLine()
  }
}

object ConsoleInterfaceFactory {
  def getConsoleInterface: ConsoleInterface = {
    val console = System.console()
    if (console != null) {
      return new DefaultConsoleInterface(console)
    } else if (System.in != null) {
      return new EclipseConsoleInterface(System.out, System.in)
    } else {
      return null
    }
  }
} 
开发者ID:Kneelawk,项目名称:SimpleCurseModpackDownloader,代码行数:47,代码来源:ConsoleInterface.scala


示例14: RecentChangesBackend

//设置package包名称以及导入依赖的类
package org.vincibean.wikimedia.event.streams

import java.io.PrintStream
import java.net.ServerSocket

import akka.NotUsed
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.client.RequestBuilding.Get
import akka.http.scaladsl.model.sse.ServerSentEvent
import akka.http.scaladsl.unmarshalling.Unmarshal
import akka.http.scaladsl.unmarshalling.sse.EventStreamUnmarshalling._
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.Source
import play.api.libs.json.{JsObject, Json}

object RecentChangesBackend {

  def main(args: Array[String]): Unit = {
    implicit val system = ActorSystem()
    implicit val mat = ActorMaterializer()
    import system.dispatcher

    val outStream = new PrintStream(
      new ServerSocket(8124).accept().getOutputStream)
    val printStreamFun = printStream(outStream) _

    Http()
      .singleRequest(
        Get("https://stream.wikimedia.org/v2/stream/recentchange"))
      .flatMap(httpResp =>
        Unmarshal(httpResp).to[Source[ServerSentEvent, NotUsed]])
      .map(_.map(event => stringToJson(event.data)))
      .foreach(_.runForeach(printStreamFun))
  }

  def stringToJson(message: String): JsObject = {
    val json = Json.parse(message)
    Json.obj(
      "user" -> json \ "user",
      "pageUrl" -> s"""${(json \ "server_url")
        .as[String]}/wiki/${(json \ "title")
        .as[String]
        .replaceAll(" ", "_")}""",
      "id" -> json \ "id",
      "timestamp" -> (json \ "timestamp").as[Long]
    )
  }

  def printStream(outStream: PrintStream)(json: JsObject): Unit = {
    outStream.println(json.toString)
    outStream.flush()
  }

} 
开发者ID:Vincibean,项目名称:WikimediaEventStreams,代码行数:56,代码来源:RecentChangesBackend.scala


示例15: PrintStreamReporter

//设置package包名称以及导入依赖的类
package com.chrisomeara.pillar.core

import java.io.PrintStream
import java.util.Date

import com.datastax.driver.core.Session

class PrintStreamReporter(stream: PrintStream) extends Reporter {
  override def initializing(session: Session, keyspace: String, replicationOptions: ReplicationOptions) {
    stream.println(s"Initializing $keyspace")
  }

  override def migrating(session: Session, dateRestriction: Option[Date]) {
    stream.println(s"Migrating with date restriction $dateRestriction")
  }

  override def applying(migration: Migration) {
    stream.println(s"Applying ${migration.authoredAt.getTime}: ${migration.description}")
  }

  override def reversing(migration: Migration) {
    stream.println(s"Reversing ${migration.authoredAt.getTime}: ${migration.description}")
  }

  override def destroying(session: Session, keyspace: String) {
    stream.println(s"Destroying $keyspace")
  }
} 
开发者ID:comeara,项目名称:pillar-core,代码行数:29,代码来源:PrintStreamReporter.scala


示例16: PrintStreamReporterSpec

//设置package包名称以及导入依赖的类
package com.chrisomeara.pillar.core

import java.io.{ByteArrayOutputStream, PrintStream}
import java.util.Date

import com.datastax.driver.core.Session
import org.scalatest._
import org.scalatest.mock.MockitoSugar

class PrintStreamReporterSpec extends FunSpec with MockitoSugar with Matchers with OneInstancePerTest {
  val session = mock[Session]
  val migration = Migration("creates things table", new Date(1370489972546L), Seq("up"), Some(Seq("down")))
  val output = new ByteArrayOutputStream()
  val stream = new PrintStream(output)
  val reporter = new PrintStreamReporter(stream)
  val keyspace = "myks"

  describe("#initializing") {
    it("should print to the stream") {
      reporter.initializing(session, keyspace, ReplicationOptions.default)
      output.toString should equal("Initializing myks\n")
    }
  }

  describe("#migrating") {
    describe("without date restriction") {
      it("should print to the stream") {
        reporter.migrating(session, None)
        output.toString should equal("Migrating with date restriction None\n")
      }
    }
  }

  describe("#applying") {
    it("should print to the stream") {
      reporter.applying(migration)
      output.toString should equal("Applying 1370489972546: creates things table\n")
    }
  }

  describe("#reversing") {
    it("should print to the stream") {
      reporter.reversing(migration)
      output.toString should equal("Reversing 1370489972546: creates things table\n")
    }
  }

  describe("#destroying") {
    it("should print to the stream") {
      reporter.destroying(session, keyspace)
      output.toString should equal("Destroying myks\n")
    }
  }
} 
开发者ID:comeara,项目名称:pillar-core,代码行数:55,代码来源:PrintStreamReporterSpec.scala


示例17: Fuser

//设置package包名称以及导入依赖的类
package org.symnet.auxiliary

import java.io.{File, FilenameFilter, PrintStream}

import scala.io.Source

object Fuser {

  val seflTemplate =
    """
      |package org.change.v2.runners.sefl
      |
      |import org.change.v2.analysis.expression.concrete.nonprimitive._
      |import org.change.v2.analysis.expression.concrete.{ConstantValue, SymbolicValue}
      |import org.change.v2.analysis.processingmodels.Instruction
      |import org.change.v2.analysis.processingmodels.instructions._
      |
      |
      |object SEFLCodeAndLinks {
      |
      |  val i: Map[String, Instruction] = Map(
      |    _code_
      |  )
      |
      |  val l: Map[String, String] = Map(
      |    _links_
      |  )
      |
      |}
      |
    """.stripMargin

  def main(args: Array[String]): Unit = {
    val seflsFolder = new File("src/main/resources/sefls")
    val linksFolder = seflsFolder

    val seflCode = seflsFolder.listFiles(new FilenameFilter {
      override def accept(dir: File, name: String): Boolean = name.endsWith(".sefl")
    }).map(Source.fromFile(_).mkString).mkString(",\n")

    val linksCode = linksFolder.listFiles(new FilenameFilter {
      override def accept(dir: File, name: String): Boolean = name.endsWith(".links")
    }).map(Source.fromFile(_).mkString).mkString(",\n")

    new PrintStream(new File("SEFLCodeAndLinks.scala")).print(
      seflTemplate.replace("_code_", seflCode).replace("_links_", linksCode))
  }
} 
开发者ID:radustoenescu,项目名称:sefl-fuser,代码行数:49,代码来源:Fuser.scala


示例18: FetchSpecMain

//设置package包名称以及导入依赖的类
package io.eels.cli

import java.io.PrintStream

import io.eels.{Constants, SourceParser}
import io.eels.component.hive.{HiveSource, HiveSpec}
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs.FileSystem
import org.apache.hadoop.hive.conf.HiveConf

object FetchSpecMain {

  implicit val fs = FileSystem.get(new Configuration)
  implicit val hiveConf = new HiveConf

  def apply(args: Seq[String], out: PrintStream = System.out): Unit = {

    val parser = new scopt.OptionParser[Options]("eel") {
      head("eel fetch-spec", Constants.EelVersion)

      opt[String]("dataset") required() action { (source, o) =>
        o.copy(source = source)
      } text "specify dataset, eg hive:database:table"
    }

    parser.parse(args, Options()) match {
      case Some(options) =>
        val builder = SourceParser(options.source).getOrElse(sys.error(s"Unsupported source ${options.source}"))
        val source = builder()
        source match {
          case hive: HiveSource =>
            val spec = hive.spec
            val json = HiveSpec.writeAsJson(spec.copy(tables = spec.tables.filter(_.tableName == hive.tableName)))
            println(json)
          case _ =>
            sys.error(s"Unsupported source $source")
        }
      case _ =>
    }
  }

  case class Options(source: String = null)
} 
开发者ID:51zero,项目名称:eel-sdk,代码行数:44,代码来源:FetchSpecMain.scala


示例19: ShowSchemaMain

//设置package包名称以及导入依赖的类
package io.eels.cli

import java.io.PrintStream

import io.eels.{Constants, SourceParser}
import io.eels.component.avro.AvroSchemaFn
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs.FileSystem
import org.apache.hadoop.hive.conf.HiveConf

object ShowSchemaMain {

  implicit val fs = FileSystem.get(new Configuration)
  implicit val hiveConf = new HiveConf

  def apply(args: Seq[String], out: PrintStream = System.out): Unit = {

    val parser = new scopt.OptionParser[Options]("eel") {
      head("eel schema", Constants.EelVersion)

      opt[String]("source") required() action { (source, o) =>
        o.copy(source = source)
      } text "specify source, eg hive:database:table or parquet:/path/to/file"
    }

    parser.parse(args, Options()) match {
      case Some(options) =>
        val builder = SourceParser(options.source).getOrElse(sys.error(s"Unsupported source ${options.source}"))
        val source = builder()
        val schema = source.schema
        val avroSchema = AvroSchemaFn.toAvro(schema)
        out.println(avroSchema)
      case _ =>
    }
  }

  case class Options(source: String = "")
} 
开发者ID:51zero,项目名称:eel-sdk,代码行数:39,代码来源:ShowSchemaMain.scala


示例20: ApplySpecMain

//设置package包名称以及导入依赖的类
package io.eels.cli

import java.io.PrintStream
import java.nio.file.{Path, Paths}

import io.eels.{Constants, SourceParser}
import io.eels.component.hive.{HiveOps, HiveSource, HiveSpec}
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs.FileSystem
import org.apache.hadoop.hive.conf.HiveConf
import org.apache.hadoop.hive.metastore.HiveMetaStoreClient

object ApplySpecMain {

  implicit val fs = FileSystem.get(new Configuration)
  implicit val hiveConf = new HiveConf
  implicit val client = new HiveMetaStoreClient(hiveConf)

  def apply(args: Seq[String], out: PrintStream = System.out): Unit = {

    val parser = new scopt.OptionParser[Options]("eel") {
      head("eel apply-spec", Constants.EelVersion)

      opt[String]("dataset") required() action { (source, o) =>
        o.copy(source = source)
      } text "specify dataset, eg hive:database:table"

      opt[String]("spec") required() action { (schema, o) =>
        o.copy(specPath = Paths.get(schema))
      } text "specify path to eel spec"
    }

    parser.parse(args, Options()) match {
      case Some(options) =>
        val builder = SourceParser(options.source).getOrElse(sys.error(s"Unsupported source ${options.source}"))
        val source = builder()
        source match {
          case hive: HiveSource =>
            HiveOps.applySpec(HiveSpec(options.specPath), false)
          case _ =>
            sys.error(s"Unsupported source $source")
        }
      case _ =>
    }
  }

  case class Options(source: String = null, specPath: Path = null)
} 
开发者ID:51zero,项目名称:eel-sdk,代码行数:49,代码来源:ApplySpecMain.scala



注:本文中的java.io.PrintStream类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala Suite类代码示例发布时间:2022-05-23
下一篇:
Scala URLEncoder类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap