Permalink
Browse files

Merge branch 'master' into build/no-more-stages

  • Loading branch information...
djspiewak committed Aug 13, 2018
2 parents 7f6c045 + ad1e230 commit 4089e9b09a648c30e66a2ad8f2f0c37c450f9c10
Showing 309 changed files with 4,914 additions and 4,798 deletions.
View
@@ -639,7 +639,6 @@ offsetdate | `"2015-01-31Z"` | `{ "$offsetdate": "2015-01-31Z" }` |
offsettime | `"10:30:00.000Z"` | `{ "$offsettime": "10:30Z" }` |
interval | `"PT12H34M"` | `{ "$interval": "P7DT12H34M" }` |
binary | `"TE1OTw=="` | `{ "$binary": "TE1OTw==" }` | BASE64-encoded.
object id | `"abc"` | `{ "$oid": "abc" }` |
### CSV
@@ -0,0 +1,29 @@
/*
* 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 agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package quasar.api
/** Configuration required in order to obtain a information about the structure
* of a dataset.
*/
trait SchemaConfig {
/** Representation describing of the structure of a dataset. */
type Schema
}
object SchemaConfig {
type Aux[Schema0] = SchemaConfig { type Schema = Schema0 }
}
@@ -17,7 +17,7 @@
package quasar.api.datasource
import slamdata.Predef._
import quasar.common.resource.ResourcePath
import quasar.api.resource.ResourcePath
import monocle.Prism
import scalaz.{Cord, Equal, ISet, NonEmptyList, Show}
@@ -53,6 +53,9 @@ object DatasourceError extends DatasourceErrorInstances {
final case class PathNotFound(path: ResourcePath)
extends DiscoveryError[Nothing]
final case class PathNotAResource(path: ResourcePath)
extends DiscoveryError[Nothing]
sealed trait ExistentialError[+I] extends DiscoveryError[I]
final case class DatasourceNotFound[I](datasourceId: I)
@@ -102,6 +105,12 @@ object DatasourceError extends DatasourceErrorInstances {
case (t, c, r) => MalformedConfiguration(t, c, r)
}
def pathNotAResource[E >: DiscoveryError[Nothing] <: DatasourceError[_, _]]
: Prism[E, ResourcePath] =
Prism.partial[E, ResourcePath] {
case PathNotAResource(p) => p
} (PathNotAResource(_))
def pathNotFound[E >: DiscoveryError[Nothing] <: DatasourceError[_, _]]
: Prism[E, ResourcePath] =
Prism.partial[E, ResourcePath] {
@@ -123,6 +132,7 @@ sealed abstract class DatasourceErrorInstances {
datasourceUnsupported[DatasourceError[I, C]].getOption(de),
invalidConfiguration[C, DatasourceError[I, C]].getOption(de),
malformedConfiguration[C, DatasourceError[I, C]].getOption(de),
pathNotAResource[DatasourceError[I, C]].getOption(de),
pathNotFound[DatasourceError[I, C]].getOption(de)
)}
}
@@ -141,6 +151,9 @@ sealed abstract class DatasourceErrorInstances {
implicit def showDiscoveryError[I: Show]: Show[DiscoveryError[I]] =
Show.show {
case PathNotAResource(p) =>
Cord("PathNotAResource(") ++ p.show ++ Cord(")")
case PathNotFound(p) =>
Cord("PathNotFound(") ++ p.show ++ Cord(")")
@@ -16,9 +16,10 @@
package quasar.api.datasource
import slamdata.Predef.{Boolean, Exception}
import slamdata.Predef.{Boolean, Exception, Option}
import quasar.Condition
import quasar.common.resource._
import quasar.api.SchemaConfig
import quasar.api.resource._
import scalaz.{\/, ISet}
@@ -27,7 +28,7 @@ import scalaz.{\/, ISet}
* @tparam I identity
* @tparam C configuration
*/
trait Datasources[F[_], G[_], I, C] {
trait Datasources[F[_], G[_], I, C, S <: SchemaConfig] {
import DatasourceError._
/** Adds the datasource described by the given `DatasourceRef` to the
@@ -56,7 +57,7 @@ trait Datasources[F[_], G[_], I, C] {
: F[ExistentialError[I] \/ Boolean]
/** Returns the name and type of the `ResourcePath`s within the specified
* Datasource implied by concatenating each name to `prefixPath`.
* datasource implied by concatenating each name to `prefixPath`.
*/
def prefixedChildPaths(datasourceId: I, prefixPath: ResourcePath)
: F[DiscoveryError[I] \/ G[(ResourceName, ResourcePathType)]]
@@ -68,6 +69,14 @@ trait Datasources[F[_], G[_], I, C] {
def replaceDatasource(datasourceId: I, ref: DatasourceRef[C])
: F[Condition[DatasourceError[I, C]]]
/** Retrieves the schema of the resource at the given `path` with the
* specified datasource according to the provided `schemaConfig`.
*
* Returns `None` if the resource exists but a schema is not available.
*/
def resourceSchema(datasourceId: I, path: ResourcePath, schemaConfig: S)
: F[DiscoveryError[I] \/ Option[schemaConfig.Schema]]
/** The set of supported datasource types. */
def supportedDatasourceTypes: F[ISet[DatasourceType]]
}
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package quasar.common.resource
package quasar.api.resource
import slamdata.Predef.String
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package quasar.common.resource
package quasar.api.resource
import slamdata.Predef._
import quasar.contrib.pathy.{firstSegmentName, rebaseA, stripPrefixA, AFile, APath}
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package quasar.common.resource
package quasar.api.resource
import slamdata.Predef.{Boolean, Int, Product, Serializable, Some}
@@ -14,17 +14,11 @@
* limitations under the License.
*/
package quasar.common
package quasar.api
import slamdata.Predef.{Option, String}
import quasar.contrib.scalaz.MonadError_
package object resource {
type MonadResourceErr[F[_]] = MonadError_[F, ResourceError]
def MonadResourceErr[F[_]](implicit ev: MonadResourceErr[F])
: MonadResourceErr[F] = ev
object /: {
def unapply(p: ResourcePath): Option[(String, ResourcePath)] =
p.uncons.map { case (ResourceName(s), p) => (s, p) }
@@ -0,0 +1,37 @@
/*
* 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 agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package quasar.api.table
import slamdata.Predef._
import java.time.OffsetDateTime
import scala.concurrent.duration.Duration
sealed trait PreparationEvent[I] extends Product with Serializable
object PreparationEvent {
final case class PreparationErrored[I](
tableId: I,
start: OffsetDateTime,
duration: Duration,
t: Throwable) extends PreparationEvent[I]
final case class PreparationSucceeded[I](
tableId: I,
start: OffsetDateTime,
duration: Duration) extends PreparationEvent[I]
}
@@ -16,12 +16,11 @@
package quasar.api.table
import java.time.OffsetDateTime
import slamdata.Predef.{Product, Serializable}
sealed trait PreparationResult[I, A] extends Product with Serializable
object PreparationResult {
final case class Available[I, A](tableId: I, since: OffsetDateTime, value: A) extends PreparationResult[I, A]
final case class Available[I, A](tableId: I, value: A) extends PreparationResult[I, A]
final case class Unavailable[I, A](tableId: I) extends PreparationResult[I, A]
}
@@ -16,22 +16,18 @@
package quasar.api.table
import java.lang.Throwable
import java.time.{Duration, OffsetDateTime}
import slamdata.Predef.{Option, Product, Serializable}
final case class PreparationStatus(prepared: PreparedStatus, ongoing: OngoingStatus)
sealed trait PreparationStatus extends Product with Serializable
sealed trait PreparedStatus
object PreparationStatus {
case object Unprepared
extends PreparationStatus
final case class Preparing(startedAt: OffsetDateTime, previous: Option[Prepared])
extends PreparationStatus
object PreparedStatus {
case object Unprepared extends PreparedStatus
case object Prepared extends PreparedStatus
}
final case class Prepared(startedAt: OffsetDateTime, duration: Duration)
extends PreparationStatus
sealed trait OngoingStatus
final case class Errored(startedAt: OffsetDateTime, duration: Duration, error: Throwable, previous: Option[Prepared])
extends PreparationStatus
object OngoingStatus {
case object NotPreparing extends OngoingStatus
case object Preparing extends OngoingStatus
}
@@ -22,7 +22,7 @@ import scalaz.{Cord, Equal, Show}
import scalaz.std.tuple._
import scalaz.syntax.show._
final case class Table[Q](name: TableName, query: Q)
final case class TableRef[Q](name: TableName, query: Q)
final case class TableName(name: String)
@@ -31,14 +31,14 @@ object TableName {
implicit val showTableName: Show[TableName] = Show.showFromToString
}
object Table {
object TableRef {
import TableName._
implicit def equalTable[Q: Equal]: Equal[Table[Q]] =
implicit def equalTableRef[Q: Equal]: Equal[TableRef[Q]] =
Equal.equalBy(t => (t.name, t.query))
implicit def showTable[Q: Show]: Show[Table[Q]] =
implicit def showTableRef[Q: Show]: Show[TableRef[Q]] =
Show.show { t =>
Cord("Table(") ++ t.name.show ++ Cord(", ") ++ t.query.show ++ Cord(")")
Cord("TableRef(") ++ t.name.show ++ Cord(", ") ++ t.query.show ++ Cord(")")
}
}
@@ -21,8 +21,8 @@ import slamdata.Predef.{Product, Serializable}
sealed trait TableError extends Product with Serializable
object TableError {
sealed trait CreationError extends TableError
final case class NameConflict(name: TableName) extends CreationError
final case class NameConflict(name: TableName) extends TableError
final case class PreparationNotInProgress[I](tableId: I) extends TableError
sealed trait ModificationError[I] extends TableError
final case class PreparationExists[I](tableId: I) extends ModificationError[I]
@@ -28,21 +28,29 @@ import scalaz.\/
* @tparam D materialized table data
*/
trait Tables[F[_], I, Q, D] {
import TableError.{CreationError, ExistenceError, ModificationError, PrePreparationError}
import TableError.{
ExistenceError,
ModificationError,
NameConflict,
PreparationNotInProgress,
PrePreparationError
}
def allTables: Stream[F, (I, Table[Q], PreparationStatus)]
def allTables: Stream[F, (I, TableRef[Q], PreparationStatus)]
def table(tableId: I): F[ExistenceError[I] \/ Table[Q]]
def table(tableId: I): F[ExistenceError[I] \/ TableRef[Q]]
def createTable(table: Table[Q]): F[CreationError \/ I]
def createTable(table: TableRef[Q]): F[NameConflict \/ I]
def replaceTable(tableId: I, table: Table[Q]): F[Condition[ModificationError[I]]]
def replaceTable(tableId: I, table: TableRef[Q]): F[Condition[ModificationError[I]]]
def prepareTable(tableId: I): F[Condition[PrePreparationError[I]]]
def preparationEvents: Stream[F, PreparationEvent[I]]
def preparationStatus(tableId: I): F[ExistenceError[I] \/ PreparationStatus]
def cancelPreparation(tableId: I): F[Condition[ExistenceError[I]]]
def cancelPreparation(tableId: I): F[Condition[PreparationNotInProgress[I]]]
def cancelAllPreparations: F[Unit]
@@ -0,0 +1,22 @@
/*
* 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 agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package quasar.api
object MockSchemaConfig extends SchemaConfig {
object MockSchema
type Schema = MockSchema.type
}
Oops, something went wrong.

0 comments on commit 4089e9b

Please sign in to comment.