Permalink
Browse files

Adds the table model (#25)

* Adds the table model
* Adds the tuple model
* Refactorizes folders and packages
  • Loading branch information...
fedefernandez committed Jun 26, 2017
1 parent 029d26e commit 65876ad1db93dd3b814f1bb8015f8b68c5036d2f

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,86 @@
/*
* Copyright 2017 47 Degrees, LLC. <http://www.47deg.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless 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 freestyle.cassandra
package schema
object model {
case class TableDefinition(
keyspace: Option[String],
name: String,
columns: List[ColumnDefinition],
options: List[TableOptions])
case class ColumnDefinition(name: String, cqlType: CQLType, columnType: ColumnType)
sealed trait CQLType
case class CQLList(cqlType: CQLType) extends CQLType
case class CQLMap(cqlTypeK: CQLType, cqlTypeV: CQLType) extends CQLType
case class CQLSet(cqlType: CQLType) extends CQLType
case class CQLTuple(cqlType: CQLType, other: CQLType*) extends CQLType
case object Ascii extends CQLType
case object BigInt extends CQLType
case object Blob extends CQLType
case object Boolean extends CQLType
case object Counter extends CQLType
case object Date extends CQLType
case object Decimal extends CQLType
case object Double extends CQLType
case object Duration extends CQLType
case object Float extends CQLType
case object Inet extends CQLType
case object Int extends CQLType
case object SmallInt extends CQLType
case object Text extends CQLType
case object Time extends CQLType
case object Timestamp extends CQLType
case object TimeUUID extends CQLType
case object TinyInt extends CQLType
case object UDT extends CQLType
case object UUID extends CQLType
case object Varchar extends CQLType
case object VarInt extends CQLType
sealed trait ColumnType
case object RegularColumn extends ColumnType
case object StaticColumn extends ColumnType
case object PrimaryKeyColumn extends ColumnType
case object ClusteringColumn extends ColumnType
sealed trait TableOptions
case class ClusteringOrder(order: List[ColumnOrder])
case object CompactStorage extends TableOptions
case class ColumnOrder(columnName: String, asc: Boolean)
val simpleStrategyClass: String = "SimpleStrategy"
val networkTopologyStrategyClass: String = "NetworkTopologyStrategy"
abstract class KeyspaceReplication(cls: String)
case class SimpleStrategyReplication(replicationFactor: Int)
extends KeyspaceReplication(simpleStrategyClass)
case class NetworkTopologyStrategyReplication(dcs: Map[String, Int])
extends KeyspaceReplication(networkTopologyStrategyClass)
case class Keyspace(
name: String,
replication: KeyspaceReplication,
durableWrites: Option[Boolean])
}
@@ -15,15 +15,15 @@
*/
package freestyle.cassandra
package parser.common
package schema.parser
import cats.implicits._
import io.circe.Decoder.Result
import io.circe.{Decoder, HCursor}
object decoders {
import freestyle.cassandra.parser.common.model._
import freestyle.cassandra.schema.model._
val classField: String = "class"
val replicationFactorField: String = "replication_factor"
@@ -15,7 +15,7 @@
*/
package freestyle.cassandra
package parser.common
package schema.parser
import scala.util.matching.Regex
@@ -15,10 +15,9 @@
*/
package freestyle.cassandra
package parser
package schema.parser
import cats.syntax.either._
import freestyle.cassandra.parser.common._
import io.circe.parser.{parse => circeParse}
import scala.util.parsing.combinator._
@@ -27,7 +26,7 @@ object parsers extends RegexParsers {
import decoders._
import definitions._
import model._
import schema.model._
type ParseResult[T] = Either[String, T]
@@ -14,8 +14,7 @@
* limitations under the License.
*/
package freestyle
package cassandra
package freestyle.cassandra
import java.util.concurrent.{Callable, Executors}
@@ -14,7 +14,8 @@
* limitations under the License.
*/
package freestyle.cassandra.api
package freestyle.cassandra
package api
import cats.{~>, Id}
import com.datastax.driver.core._
@@ -14,8 +14,7 @@
* limitations under the License.
*/
package freestyle
package cassandra
package freestyle.cassandra
package codecs
import java.nio.ByteBuffer
@@ -14,9 +14,10 @@
* limitations under the License.
*/
package freestyle.cassandra.parser
package freestyle.cassandra
package parser
import freestyle.cassandra.parser.common.model._
import freestyle.cassandra.schema.model._
import org.scalacheck.{Arbitrary, Gen}
import Arbitrary._
@@ -14,9 +14,11 @@
* limitations under the License.
*/
package freestyle.cassandra.parser
package freestyle.cassandra
package parser
import freestyle.cassandra.parser.common.model.Keyspace
import freestyle.cassandra.schema.model.Keyspace
import freestyle.cassandra.schema.parser.parsers
import org.scalatest.{Matchers, WordSpec}
import org.scalacheck.Prop._
import org.scalatest.prop.Checkers._
@@ -14,7 +14,8 @@
* limitations under the License.
*/
package freestyle.cassandra.query
package freestyle.cassandra
package query
import org.scalatest.{Matchers, WordSpec}
import StatementGenerator._

0 comments on commit 65876ad

Please sign in to comment.