├── inst ├── WORDLIST └── extdata │ ├── twitter.avro │ ├── twitter.snappy.avro │ └── twitter.avsc ├── CRAN-RELEASE ├── NEWS.md ├── .Rbuildignore ├── cran-comments.md ├── NAMESPACE ├── .travis.yml ├── tests ├── testthat.R └── testthat │ └── test_sparkavro.R ├── .gitignore ├── R ├── utils.R ├── dependencies.R └── sparkavro.R ├── sparkavro.Rproj ├── DESCRIPTION ├── README.md ├── man ├── spark_write_avro.Rd └── spark_read_avro.Rd └── LICENSE /inst/WORDLIST: -------------------------------------------------------------------------------- 1 | apache 2 | avro 3 | Avro 4 | DataFrame 5 | dplyr 6 | https 7 | sparklyr 8 | -------------------------------------------------------------------------------- /inst/extdata/twitter.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chezou/sparkavro/HEAD/inst/extdata/twitter.avro -------------------------------------------------------------------------------- /inst/extdata/twitter.snappy.avro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chezou/sparkavro/HEAD/inst/extdata/twitter.snappy.avro -------------------------------------------------------------------------------- /CRAN-RELEASE: -------------------------------------------------------------------------------- 1 | This package was submitted to CRAN on 2020-01-08. 2 | Once it is accepted, delete this file and tag the release (commit fed5d8cabf). 3 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # sparkavro 0.3.0 2 | - Support Spark 2.4 3 | 4 | # sparkavro 0.2.0 5 | - Support Spark 2.3 6 | 7 | # sparkavro 0.1.0 8 | 9 | - Initial release on CRAN 10 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^CRAN-RELEASE$ 2 | ^.*\.Rproj$ 3 | ^\.Rproj\.user$ 4 | derby.log$ 5 | sparkavro.Rcheck$ 6 | log4j.spark.log.*$ 7 | ^README\.md$ 8 | ^\.travis\.yml$ 9 | ^cran-comments\.md$ 10 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Test environments 2 | * local macOSX install, R 3.6.2 3 | * Ubuntu 16.04.6 LTS (on travis-ci), R 3.6.2 4 | * win-builder (release) 5 | 6 | ## R CMD check results 7 | 0 errors | 0 warnings | 0 notes 8 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | S3method(spark_write_avro,spark_jobj) 4 | S3method(spark_write_avro,tbl_spark) 5 | export(spark_read_avro) 6 | export(spark_write_avro) 7 | import(DBI) 8 | import(sparklyr) 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # R for travis: see documentation at https://docs.travis-ci.com/user/languages/r 2 | 3 | language: R 4 | sudo: false 5 | cache: packages 6 | 7 | apt_packages: 8 | - openjdk-8-jdk 9 | env: 10 | - JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64" 11 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(sparkavro) 3 | 4 | if(identical(Sys.getenv("NOT_CRAN"), "true")) { # testthat::skip_on_cran 5 | cat(sprintf("Starting tests\n")) 6 | test_check("sparkavro") 7 | }else{ 8 | cat("Skipping Tests\n") 9 | } 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | .Ruserdata 5 | sparkavro.Rcheck/ 6 | 7 | # RStudio files 8 | .Rproj.user 9 | 10 | # Spark log 11 | log4j.spark* 12 | /configure 13 | /bin/ 14 | .cache-main 15 | .settings 16 | .classpath 17 | 18 | derby.log 19 | -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | spark_expect_jobj_class <- get("spark_expect_jobj_class", 2 | envir = asNamespace("sparklyr")) 3 | 4 | spark_normalize_path <- get("spark_normalize_path", 5 | envir = asNamespace("sparklyr")) 6 | 7 | spark_sqlresult_from_dplyr <- get("spark_sqlresult_from_dplyr", 8 | envir = asNamespace("sparklyr")) 9 | -------------------------------------------------------------------------------- /sparkavro.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source 21 | -------------------------------------------------------------------------------- /inst/extdata/twitter.avsc: -------------------------------------------------------------------------------- 1 | { 2 | "type" : "record", 3 | "name" : "twitter_schema", 4 | "namespace" : "com.miguno.avro", 5 | "fields" : [ { 6 | "name" : "username", 7 | "type" : "string", 8 | "doc" : "Name of the user account on Twitter.com" 9 | }, { 10 | "name" : "tweet", 11 | "type" : "string", 12 | "doc" : "The content of the user's Twitter message" 13 | }, { 14 | "name" : "timestamp", 15 | "type" : "long", 16 | "doc" : "Unix epoch time in seconds" 17 | } ], 18 | "doc:" : "A basic schema for storing Twitter messages" 19 | } 20 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: sparkavro 2 | Type: Package 3 | Title: Load Avro file into 'Apache Spark' 4 | Version: 0.3.0 5 | Author: Aki Ariga 6 | Maintainer: Aki Ariga 7 | Description: Load Avro Files into 'Apache Spark' using 'sparklyr'. This 8 | allows to read files from 'Apache Avro' . 9 | License: Apache License 2.0 | file LICENSE 10 | BugReports: https://github.com/chezou/sparkavro 11 | Encoding: UTF-8 12 | LazyData: true 13 | Imports: 14 | sparklyr, 15 | dplyr, 16 | DBI 17 | RoxygenNote: 7.0.2 18 | Suggests: 19 | testthat 20 | Language: en-us 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Travis-CI Build Status](https://travis-ci.org/chezou/sparkavro.svg?branch=master)](https://travis-ci.org/chezou/sparkavro) 2 | 3 | # sparkavro 4 | 5 | Load Avro data into Spark with sparklyr. It is a wrapper of [spark-avro](https://github.com/databricks/spark-avro) 6 | 7 | ## Installation 8 | 9 | Install using `{devtools}` as follows: 10 | 11 | ```r 12 | devtools::install_github("chezou/sparkavro") 13 | ``` 14 | 15 | ## Usage 16 | 17 | ```r 18 | library(sparklyr) 19 | library(sparkavro) 20 | sc <- spark_connect(master = "spark://HOST:PORT") 21 | df <- spark_read_avro(sc, "test_table", "/user/foo/test.avro") 22 | 23 | spark_write_avro(df, "/tmp/output") 24 | ``` 25 | 26 | Example data are from https://github.com/miguno/avro-cli-examples 27 | -------------------------------------------------------------------------------- /tests/testthat/test_sparkavro.R: -------------------------------------------------------------------------------- 1 | library(sparklyr) 2 | 3 | library(sparkavro) 4 | library(dplyr) 5 | if(!exists("sc")){ 6 | spark_install() 7 | sc <- spark_connect(master="local") 8 | } 9 | 10 | test_that("read existing avro", { 11 | df <- spark_read_avro(sc, "twitter", system.file("extdata", "twitter.avro", package="sparkavro"), memory = FALSE) 12 | expect_equal(df %>% collect() %>% length(), 3) 13 | }) 14 | 15 | test_that("write Spark DataFrame into avro", { 16 | df <- spark_read_avro(sc, "twitter", system.file("extdata", "twitter.avro", package="sparkavro"), memory = FALSE) 17 | df2 <- df %>% filter(username == "miguno") 18 | filename <- tempfile("test", fileext=".avro") 19 | spark_write_avro(df2, filename) 20 | expect_true(file.exists(filename)) 21 | }) 22 | -------------------------------------------------------------------------------- /man/spark_write_avro.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sparkavro.R 3 | \name{spark_write_avro} 4 | \alias{spark_write_avro} 5 | \title{Write a Spark DataFrame to a Avro file} 6 | \usage{ 7 | spark_write_avro(x, path, mode = NULL, options = list()) 8 | } 9 | \arguments{ 10 | \item{x}{A Spark DataFrame or dplyr operation} 11 | 12 | \item{path}{The path to the file. Needs to be accessible from the cluster. 13 | Supports the \samp{"hdfs://"}, \samp{"s3n://"} and \samp{"file://"} protocols.} 14 | 15 | \item{mode}{Specifies the behavior when data or table already exists.} 16 | 17 | \item{options}{A list of strings with additional options. See \url{http://spark.apache.org/docs/latest/sql-programming-guide.html#configuration}.} 18 | } 19 | \description{ 20 | Serialize a Spark DataFrame to the 21 | \href{https://parquet.apache.org/}{Parquet} format. 22 | } 23 | \concept{Spark serialization routines} 24 | -------------------------------------------------------------------------------- /R/dependencies.R: -------------------------------------------------------------------------------- 1 | spark_dependencies <- function(spark_version, scala_version, ...) { 2 | spark_avro_version = "" 3 | spark_avro_lib = "com.databricks" 4 | if (spark_version < "2.0.0") { 5 | spark_avro_version = "2.0.1" 6 | } else if (spark_version < "2.2.0") { 7 | spark_avro_version = "3.2.0" 8 | } else if (spark_version < "2.4.0") { 9 | spark_avro_version = "4.0.0" 10 | } else { 11 | spark_avro_lib = "org.apache.spark" 12 | # Full semantic version is needed, so 2.4 -> 2.4.0 13 | if (nchar(as.character(spark_version)) == 3) { 14 | spark_avro_version = numeric_version(paste0(spark_version, ".0")) 15 | } else spark_avro_version = spark_version 16 | } 17 | 18 | sparklyr::spark_dependency( 19 | jars = c( 20 | ), 21 | packages = c( 22 | sprintf("%s:spark-avro_%s:%s", spark_avro_lib, scala_version, spark_avro_version) 23 | ) 24 | ) 25 | } 26 | 27 | #' @import sparklyr 28 | .onLoad <- function(libname, pkgname) { 29 | sparklyr::register_extension(pkgname) 30 | } 31 | -------------------------------------------------------------------------------- /man/spark_read_avro.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sparkavro.R 3 | \name{spark_read_avro} 4 | \alias{spark_read_avro} 5 | \title{Reads a Avro File into Apache Spark} 6 | \usage{ 7 | spark_read_avro( 8 | sc, 9 | name, 10 | path, 11 | readOptions = list(), 12 | repartition = 0L, 13 | memory = TRUE, 14 | overwrite = TRUE 15 | ) 16 | } 17 | \arguments{ 18 | \item{sc}{An active \code{spark_connection}.} 19 | 20 | \item{name}{The name to assign to the newly generated table.} 21 | 22 | \item{path}{The path to the file. Needs to be accessible from the cluster. 23 | Supports the \samp{"hdfs://"}, \samp{"s3n://"} and \samp{"file://"} protocols.} 24 | 25 | \item{readOptions}{A list of strings with additional options.} 26 | 27 | \item{repartition}{The number of partitions used to distribute the 28 | generated table. Use 0 (the default) to avoid partitioning.} 29 | 30 | \item{memory}{Boolean; should the data be loaded eagerly into memory? (That 31 | is, should the table be cached?)} 32 | 33 | \item{overwrite}{Boolean; overwrite the table with the given name if it 34 | already exists?} 35 | } 36 | \description{ 37 | Reads a Avro file into Apache Spark using sparklyr. 38 | } 39 | \examples{ 40 | \dontrun{ 41 | ## If you haven't got a Spark cluster, you can install Spark locally like this 42 | library(sparklyr) 43 | spark_install(version = "2.0.1") 44 | 45 | sc <- spark_connect(master = "local") 46 | df <- spark_read_avro( 47 | sc, 48 | "twitter", 49 | system.file("extdata/twitter.avro", package = "sparkavro"), 50 | repartition = FALSE, 51 | memory = FALSE, 52 | overwrite = FALSE 53 | ) 54 | 55 | spark_disconnect(sc) 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /R/sparkavro.R: -------------------------------------------------------------------------------- 1 | #' Reads a Avro File into Apache Spark 2 | #' 3 | #' Reads a Avro file into Apache Spark using sparklyr. 4 | #' 5 | #' @param sc An active \code{spark_connection}. 6 | #' @param name The name to assign to the newly generated table. 7 | #' @param path The path to the file. Needs to be accessible from the cluster. 8 | #' Supports the \samp{"hdfs://"}, \samp{"s3n://"} and \samp{"file://"} protocols. 9 | #' @param readOptions A list of strings with additional options. 10 | #' @param repartition The number of partitions used to distribute the 11 | #' generated table. Use 0 (the default) to avoid partitioning. 12 | #' @param memory Boolean; should the data be loaded eagerly into memory? (That 13 | #' is, should the table be cached?) 14 | #' @param overwrite Boolean; overwrite the table with the given name if it 15 | #' already exists? 16 | #' 17 | #' @examples 18 | #' \dontrun{ 19 | #' ## If you haven't got a Spark cluster, you can install Spark locally like this 20 | #' library(sparklyr) 21 | #' spark_install(version = "2.0.1") 22 | #' 23 | #' sc <- spark_connect(master = "local") 24 | #' df <- spark_read_avro( 25 | #' sc, 26 | #' "twitter", 27 | #' system.file("extdata/twitter.avro", package = "sparkavro"), 28 | #' repartition = FALSE, 29 | #' memory = FALSE, 30 | #' overwrite = FALSE 31 | #' ) 32 | #' 33 | #' spark_disconnect(sc) 34 | #' } 35 | #' @import sparklyr 36 | #' @import DBI 37 | #' @export 38 | spark_read_avro <- function(sc, 39 | name, 40 | path, 41 | readOptions = list(), 42 | repartition = 0L, 43 | memory = TRUE, 44 | overwrite = TRUE) { 45 | if (overwrite && name %in% dbListTables(sc)) { 46 | dbRemoveTable(sc, name) 47 | } 48 | 49 | options <- sparklyr::hive_context(sc) %>% 50 | sparklyr::invoke("read") %>% 51 | sparklyr::invoke("format", "com.databricks.spark.avro") 52 | 53 | 54 | lapply(names(readOptions), function(optionName) { 55 | options <<- invoke(options, "option", optionName, readOptions[[optionName]]) 56 | }) 57 | 58 | df <- sparklyr::invoke(options, "load", list(spark_normalize_path(path))) 59 | 60 | sparklyr::invoke(df, "registerTempTable", name) 61 | 62 | if (memory) { 63 | DBI::dbGetQuery(sc, paste("CACHE TABLE", DBI::dbQuoteIdentifier(sc, name))) 64 | DBI::dbGetQuery(sc, paste("SELECT count(*) FROM", DBI::dbQuoteIdentifier(sc, name))) 65 | } 66 | 67 | dplyr::tbl(sc, name) 68 | } 69 | 70 | #' Write a Spark DataFrame to a Avro file 71 | #' 72 | #' Serialize a Spark DataFrame to the 73 | #' \href{https://avro.apache.org/}{Avro} format. 74 | #' 75 | #' @param x A Spark DataFrame or dplyr operation 76 | #' @param path The path to the file. Needs to be accessible from the cluster. 77 | #' Supports the \samp{"hdfs://"}, \samp{"s3n://"} and \samp{"file://"} protocols. 78 | #' @param mode Specifies the behavior when data or table already exists. 79 | #' @param options A list of strings with additional options. See \url{http://spark.apache.org/docs/latest/sql-programming-guide.html#configuration}. 80 | #' 81 | #' @family Spark serialization routines 82 | #' 83 | #' @export 84 | spark_write_avro <- function(x, path, mode = NULL, options = list()) { 85 | UseMethod("spark_write_avro") 86 | } 87 | 88 | #' @export 89 | spark_write_avro.tbl_spark <- function(x, path, mode = NULL, options = list()) { 90 | sqlResult <- spark_sqlresult_from_dplyr(x) 91 | spark_data_write_avro(sqlResult, spark_normalize_path(path), mode, options) 92 | } 93 | 94 | #' @export 95 | spark_write_avro.spark_jobj <- function(x, path, mode = NULL, options = list()) { 96 | spark_expect_jobj_class(x, "org.apache.spark.sql.DataFrame") 97 | spark_data_write_avro(x, normalizePath(path), mode, options) 98 | } 99 | 100 | #' @import sparklyr 101 | spark_data_write_avro <- function(df, path, mode = NULL, writeOptions = list()) { 102 | options <- sparklyr::invoke(df, "write") 103 | 104 | if (!is.null(mode)) { 105 | if (is.list(mode)) { 106 | lapply(mode, function(m) { 107 | options <<- sparklyr::invoke(options, "mode", m) 108 | }) 109 | } 110 | else if (is.character(mode)) { 111 | options <- sparklyr::invoke(options, "mode", mode) 112 | } 113 | else { 114 | stop("Unsupported type ", typeof(mode), " for mode parameter.") 115 | } 116 | } 117 | 118 | lapply(names(writeOptions), function(writeOptionName) { 119 | options <<- sparklyr::invoke(options, "option", writeOptionName, writeOptions[[writeOptionName]]) 120 | }) 121 | 122 | sparklyr::invoke(options, "format", "com.databricks.spark.avro") %>% sparklyr::invoke("save", path) 123 | invisible(TRUE) 124 | } 125 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2017 Aki Ariga 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. --------------------------------------------------------------------------------