Skip to content

Commit

Permalink
Removed Unique in favor of rapid.Unique
Browse files Browse the repository at this point in the history
  • Loading branch information
darkfrog26 committed Jan 2, 2025
1 parent 83b055d commit bcccc40
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 84 deletions.
6 changes: 3 additions & 3 deletions all/src/test/scala/spec/AirportSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import lightdb.lucene.LuceneStore
import lightdb.store.StoreManager
import lightdb.store.split.SplitStoreManager
import lightdb.upgrade.DatabaseUpgrade
import lightdb.{Id, LightDB, Unique}
import lightdb.{Id, LightDB}
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AsyncWordSpec
import rapid.{AsyncTaskSpec, Task}
import rapid.{AsyncTaskSpec, Task, Unique}
import scribe.{rapid => logger}

import java.nio.file.Path
Expand Down Expand Up @@ -146,7 +146,7 @@ class AirportSpec extends AsyncWordSpec with AsyncTaskSpec with Matchers {
val vip: I[Boolean] = field.index("vip", _.vip)
// val vipKeys: ValueStore[String, Airport] = ValueStore[String, Airport]("vipKeys", doc => if (doc.vip) List(doc._id.value) else Nil, this, persistence = Persistence.Cached)

override def id(value: String = Unique()): Id[Airport] = {
override def id(value: String = Unique().sync()): Id[Airport] = {
val index = value.indexOf('/')
val v = if (index != -1) {
value.substring(index + 1)
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ val developerURL: String = "https://matthicks.com"

name := projectName
ThisBuild / organization := org
ThisBuild / version := "2.0.1"
ThisBuild / version := "2.1.0-SNAPSHOT"
ThisBuild / scalaVersion := scala213
ThisBuild / crossScalaVersions := allScalaVersions
ThisBuild / scalacOptions ++= Seq("-unchecked", "-deprecation")
Expand Down
3 changes: 2 additions & 1 deletion core/src/main/scala/lightdb/Id.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package lightdb

import fabric.rw._
import rapid.Unique

case class Id[Doc](value: String) extends AnyVal {
def bytes: Array[Byte] = {
Expand All @@ -17,7 +18,7 @@ object Id {

implicit def rw[T]: RW[Id[T]] = _rw.asInstanceOf[RW[Id[T]]]

def apply[T](value: String = Unique()): Id[T] = new Id[T](value)
def apply[T](value: String = Unique().sync()): Id[T] = new Id[T](value)

def toString[T](id: Id[T]): String = id.value
}
75 changes: 0 additions & 75 deletions core/src/main/scala/lightdb/Unique.scala

This file was deleted.

4 changes: 2 additions & 2 deletions core/src/main/scala/lightdb/doc/DocumentModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import lightdb.facet.{FacetConfig, FacetValue}
import lightdb.field.Field._
import lightdb.field.{Field, FieldGetter}
import lightdb.filter.FilterBuilder
import rapid.Task
import rapid.{Task, Unique}

import scala.language.implicitConversions

Expand All @@ -18,7 +18,7 @@ trait DocumentModel[Doc <: Document[Doc]] {

val _id: UniqueIndex[Doc, Id[Doc]] = field.unique("_id", (doc: Doc) => doc._id)

def id(value: String = Unique()): Id[Doc] = Id(value)
def id(value: String = Unique().sync()): Id[Doc] = Id(value)

def init[Model <: DocumentModel[Doc]](collection: Collection[Doc, Model]): Task[Unit] = Task.unit

Expand Down
5 changes: 3 additions & 2 deletions h2/src/main/scala/lightdb/h2/H2Store.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import lightdb.doc.{Document, DocumentModel}
import lightdb.sql.connect.{ConnectionManager, SQLConfig, SingleConnectionManager}
import lightdb.sql.{SQLDatabase, SQLStore}
import lightdb.store.{Store, StoreManager, StoreMode}
import lightdb.{LightDB, Unique}
import lightdb.LightDB
import rapid.Unique

import java.nio.file.Path
import java.sql.Connection
Expand Down Expand Up @@ -38,7 +39,7 @@ class H2Store[Doc <: Document[Doc], Model <: DocumentModel[Doc]](name: String,

object H2Store extends StoreManager {
def config(file: Option[Path]): SQLConfig = SQLConfig(
jdbcUrl = s"jdbc:h2:${file.map(_.toFile.getCanonicalPath).map(p => s"file:$p").getOrElse(s"test:${Unique()}")};NON_KEYWORDS=VALUE,USER,SEARCH"
jdbcUrl = s"jdbc:h2:${file.map(_.toFile.getCanonicalPath).map(p => s"file:$p").getOrElse(s"test:${Unique().sync()}")};NON_KEYWORDS=VALUE,USER,SEARCH"
)

def apply[Doc <: Document[Doc], Model <: DocumentModel[Doc]](name: String,
Expand Down

0 comments on commit bcccc40

Please sign in to comment.