From 60a49981a54f088017151fb8ac55a3d6c46a00eb Mon Sep 17 00:00:00 2001 From: Alex Michael Berry Date: Fri, 12 Apr 2024 01:00:24 -0400 Subject: [PATCH] removing storage repo --- README.md | 6 -- .../dev/ligature/bend/modules/Boolean.scala | 6 +- .../scala/dev/ligature/bend/modules/Int.scala | 6 +- .../dev/ligature/bend/modules/String.scala | 6 +- build.sbt | 16 +--- ligature-sqlite/README.md | 32 ------- .../scala/dev/ligature/sqlite/Ecoding.scala | 23 ----- .../dev/ligature/sqlite/LigatureQueryTx.scala | 67 ------------- .../dev/ligature/sqlite/LigatureSqlite.scala | 95 ------------------- .../ligature/sqlite/LigatureSqliteSuite.scala | 34 ------- 10 files changed, 7 insertions(+), 284 deletions(-) delete mode 100644 ligature-sqlite/README.md delete mode 100644 ligature-sqlite/src/main/scala/dev/ligature/sqlite/Ecoding.scala delete mode 100644 ligature-sqlite/src/main/scala/dev/ligature/sqlite/LigatureQueryTx.scala delete mode 100644 ligature-sqlite/src/main/scala/dev/ligature/sqlite/LigatureSqlite.scala delete mode 100644 ligature-sqlite/src/test/scala/dev/ligature/sqlite/LigatureSqliteSuite.scala diff --git a/README.md b/README.md index d3fc91e9..da4bdfce 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,5 @@ # ligature-scala -**Note** - -This project isn't currently being worked on. -See https://github.com/almibe/ligature-fs and https://ligature.dev for more info. - An implementation of [Ligature knowledge graph](https://ligature.dev) library written in Scala for the JVM. ### Projects @@ -15,7 +10,6 @@ An implementation of [Ligature knowledge graph](https://ligature.dev) library wr | ligature-test-suite | A shared test suite for Ligature instances. | | idgen | A basic implementation of nanoid for use with Ligature. | | ligature-in-memory | An in-memory implementation of Ligature. | -| ligature-xodus | An implementation of Ligature using Xodus's key-value store for persistence. | | bend | A scripting language for working with Ligature. | | gaze | A utility library for parsing text/data structures. | diff --git a/bend/src/main/scala/dev/ligature/bend/modules/Boolean.scala b/bend/src/main/scala/dev/ligature/bend/modules/Boolean.scala index 9d12493e..af01247c 100644 --- a/bend/src/main/scala/dev/ligature/bend/modules/Boolean.scala +++ b/bend/src/main/scala/dev/ligature/bend/modules/Boolean.scala @@ -10,8 +10,6 @@ import dev.ligature.bend.HostFunction import dev.ligature.bend.TaggedField import dev.ligature.bend.Tag import dev.ligature.bend.Field -import jetbrains.exodus.bindings.BooleanBinding -import jetbrains.exodus.ArrayByteIterable val boolModule: BendValue.Module = BendValue.Module( Map( @@ -58,7 +56,7 @@ val boolModule: BendValue.Module = BendValue.Module( case Seq(BendValue.Bool(value)) => Right( ( - BendValue.Bytes(BooleanBinding.booleanToEntry(value).getBytesUnsafe().toSeq), + ???,///BendValue.Bytes(BooleanBinding.booleanToEntry(value).getBytesUnsafe().toSeq), environment ) ) @@ -76,7 +74,7 @@ val boolModule: BendValue.Module = BendValue.Module( case Seq(BendValue.Bytes(value)) => Right( ( - BendValue.Bool(BooleanBinding.entryToBoolean(ArrayByteIterable(value.toArray))), + ???, //BendValue.Bool(BooleanBinding.entryToBoolean(ArrayByteIterable(value.toArray))), environment ) ) diff --git a/bend/src/main/scala/dev/ligature/bend/modules/Int.scala b/bend/src/main/scala/dev/ligature/bend/modules/Int.scala index 10a24ae1..35dc8909 100644 --- a/bend/src/main/scala/dev/ligature/bend/modules/Int.scala +++ b/bend/src/main/scala/dev/ligature/bend/modules/Int.scala @@ -9,8 +9,6 @@ import dev.ligature.bend.TaggedField import dev.ligature.bend.Tag import dev.ligature.bend.BendValue import dev.ligature.bend.Field -import jetbrains.exodus.bindings.LongBinding -import jetbrains.exodus.ArrayByteIterable val intModule: BendValue.Module = BendValue.Module( Map( @@ -43,7 +41,7 @@ val intModule: BendValue.Module = BendValue.Module( case Seq(BendValue.Int(value)) => Right( ( - BendValue.Bytes(LongBinding.longToEntry(value).getBytesUnsafe().toSeq), + ???,//BendValue.Bytes(LongBinding.longToEntry(value).getBytesUnsafe().toSeq), environment ) ) @@ -62,7 +60,7 @@ val intModule: BendValue.Module = BendValue.Module( case Seq(BendValue.Bytes(value)) => Right( ( - BendValue.Int(LongBinding.entryToLong(ArrayByteIterable(value.toArray))), + ???,//BendValue.Int(LongBinding.entryToLong(ArrayByteIterable(value.toArray))), environment ) ) diff --git a/bend/src/main/scala/dev/ligature/bend/modules/String.scala b/bend/src/main/scala/dev/ligature/bend/modules/String.scala index 09418d89..b57011f5 100644 --- a/bend/src/main/scala/dev/ligature/bend/modules/String.scala +++ b/bend/src/main/scala/dev/ligature/bend/modules/String.scala @@ -9,8 +9,6 @@ import dev.ligature.bend.TaggedField import dev.ligature.bend.Tag import dev.ligature.bend.BendValue import dev.ligature.bend.Field -import jetbrains.exodus.bindings.StringBinding -import jetbrains.exodus.ArrayByteIterable val stringModule: BendValue.Module = BendValue.Module( Map( @@ -51,7 +49,7 @@ val stringModule: BendValue.Module = BendValue.Module( case Seq(BendValue.String(value)) => Right( ( - BendValue.Bytes(StringBinding.stringToEntry(value).getBytesUnsafe().toSeq), + ???,//BendValue.Bytes(StringBinding.stringToEntry(value).getBytesUnsafe().toSeq), environment ) ) @@ -70,7 +68,7 @@ val stringModule: BendValue.Module = BendValue.Module( case Seq(BendValue.Bytes(value)) => Right( ( - BendValue.String(StringBinding.entryToString(ArrayByteIterable(value.toArray))), + ???,//BendValue.String(StringBinding.entryToString(ArrayByteIterable(value.toArray))), environment ) ) diff --git a/build.sbt b/build.sbt index ab89e66f..fa5012fc 100644 --- a/build.sbt +++ b/build.sbt @@ -12,7 +12,6 @@ val tsidVersion = "1.1.0" val ulidVersion = "5.2.3" val gsonVerison = "2.10.1" val furyVersion = "0.4.1" -val sqliteDep = "3.45.2.0" lazy val ligature = project .in(file("ligature")) @@ -50,7 +49,6 @@ lazy val bend = project libraryDependencies += "org.furyio" % "fury-core" % furyVersion, libraryDependencies += "com.github.f4b6a3" % "ulid-creator" % ulidVersion, libraryDependencies += "io.hypersistence" % "tsid" % tsidVersion, - libraryDependencies += "org.jetbrains.xodus" % "xodus-environment" % xodusVersion, libraryDependencies += "ch.qos.logback" % "logback-classic" % logBackVersion, libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % scalaLoggingVersion, libraryDependencies += "org.scalameta" %% "munit" % munitVersion % Test @@ -69,7 +67,7 @@ lazy val ligatureZeroMQ = project libraryDependencies += "org.scalameta" %% "munit" % munitVersion % Test, fork := true ) - .dependsOn(bend, ligature, ligatureInMemory, ligatureXodus) + .dependsOn(bend, ligature, ligatureInMemory) lazy val ligatureTestSuite = project .in(file("ligature-test-suite")) @@ -90,18 +88,6 @@ lazy val ligatureInMemory = project .dependsOn(ligature, idgen, ligatureTestSuite % Test) .disablePlugins(RevolverPlugin) -lazy val ligatureSqlite = project - .in(file("ligature-sqlite")) - .settings( - name := "ligature-sqlite", - scalaVersion := scala3Version, - libraryDependencies += "org.xerial" % "sqlite-jdbc" % sqliteVersion, - libraryDependencies += "org.furyio" % "fury-core" % furyVersion, - libraryDependencies += "org.scalameta" %% "munit" % munitVersion % Test - ) - .dependsOn(ligature, idgen, ligatureTestSuite % Test) - .disablePlugins(RevolverPlugin) - disablePlugins(RevolverPlugin) addCommandAlias("cd", "project") diff --git a/ligature-sqlite/README.md b/ligature-sqlite/README.md deleted file mode 100644 index 2cc853ce..00000000 --- a/ligature-sqlite/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# ligature-xodus - -Below is table showing how Ligature is stored in Xodus. -Note that Identifier is a Ligature Identifier and ID is an internal ID that users will never see, -and is only used for internal references. - -| Store Name | Scodec Pseudocode | Description | -|----------------|----------------------------------|-----------------------------------| -| Counters | String -> Long | Counter Name -> Counter Value | -| DataSetToId | String -> Long | Dataset Name -> Dataset Id | -| IdToDataset | Long -> String | Dataset Id -> Dataset Name | -| EAV | Long ~ Long ~ Long ~ Byte ~ Long | Dataset Id ~ Id ~ Id ~ Type ~ Id | -| EVA | Similar to above | Similar to above | -| AEV | Similar to above | Similar to above | -| AVE | Similar to above | Similar to above | -| VEA | Similar to above | Similar to above | -| VAE | Similar to above | Similar to above | -| IdentifierToId | Long ~ String -> Long | Dataset Id ~ Identifier -> Id | -| IdToIdentifier | Long ~ Long -> String | Dataset Id ~ Id -> Identifier | -| StringToId | Long ~ String -> Long | Dataset Id ~ String -> Literal Id | -| IdToString | Long ~ Long -> String | Dataset Id ~ Literal Id -> String | -| BytesToId | Long ~ Bytes -> Long | Dataset Id ~ Bytes -> Id | -| IdToBytes | Long ~ Long -> Bytes | Dataset Id ~ Id -> Bytes | - -I don't need lookups for long (and double if I add them) since I can just use the actual values. - -| Type Codes | Value | -|------------|------------| -| 0 | Identifier | -| 1 | String | -| 2 | Long | -| 3 | Bytes | diff --git a/ligature-sqlite/src/main/scala/dev/ligature/sqlite/Ecoding.scala b/ligature-sqlite/src/main/scala/dev/ligature/sqlite/Ecoding.scala deleted file mode 100644 index 9a005fdd..00000000 --- a/ligature-sqlite/src/main/scala/dev/ligature/sqlite/Ecoding.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package dev.ligature.xodus - -import io.fury.Fury -import dev.ligature.LigatureValue -import jetbrains.exodus.ByteIterable -import jetbrains.exodus.ArrayByteIterable - -val fury = Fury - .builder() - .withScalaOptimizationEnabled(true) - .requireClassRegistration(false) - .withRefTracking(true) - .build() - -def encodeLigatureValue(value: LigatureValue): ByteIterable = - ArrayByteIterable(fury.serialize(value)) - -def decodeLigatureValue(value: ByteIterable): LigatureValue = - fury.deserialize(value.getBytesUnsafe()).asInstanceOf[LigatureValue] diff --git a/ligature-sqlite/src/main/scala/dev/ligature/sqlite/LigatureQueryTx.scala b/ligature-sqlite/src/main/scala/dev/ligature/sqlite/LigatureQueryTx.scala deleted file mode 100644 index a58600b6..00000000 --- a/ligature-sqlite/src/main/scala/dev/ligature/sqlite/LigatureQueryTx.scala +++ /dev/null @@ -1,67 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -package dev.ligature.sqlite - -import dev.ligature.* - -/** Represents a QueryTx within the context of a Ligature instance and a single - * Dataset - */ -class LigatureQueryTx() extends QueryTx { - override def matchStatements( - source: Option[LigatureValue.Identifier], - label: Option[LigatureValue.Identifier], - target: Option[LigatureValue] - ): Iterator[Statement] = ??? - // val entities = (source, label, target) match - // case (None, None, None) => - // tx.getAll("statement") - // case (Some(source), None, None) => - // tx.find("statement", "entity", source.value) - // case (None, Some(label), None) => - // tx.find("statement", "attribute", label.value) - // case (None, None, Some(target)) => - // tx.find("statement", "valueType", valueType(target)) - // .intersect(tx.find("statement", "value", valueToPersist(target))) - // case (Some(source), Some(label), None) => - // tx.find("statement", "entity", source.value) - // .intersect(tx.find("statement", "attribute", label.value)) - // case (Some(source), None, Some(target)) => - // tx.find("statement", "entity", source.value) - // .intersect(tx.find("statement", "valueType", valueType(target))) - // .intersect(tx.find("statement", "value", valueToPersist(target))) - // case (None, Some(label), Some(target)) => - // tx.find("statement", "attribute", label.value) - // .intersect(tx.find("statement", "valueType", valueType(target))) - // .intersect(tx.find("statement", "value", valueToPersist(target))) - // case (Some(source), Some(label), Some(target)) => - // tx.find("statement", "entity", source.value) - // .intersect(tx.find("statement", "attribute", label.value)) - // .intersect(tx.find("statement", "valueType", valueType(target))) - // .intersect(tx.find("statement", "value", valueToPersist(target))) - // entitiesToStatements(entities) -} - -// def entitiesToStatements(entities: EntityIterable): Iterator[Statement] = -// val buffer = ListBuffer[Statement]() -// entities.forEach(entity => -// val source: LigatureValue.Identifier = -// LigatureValue.Identifier(entity.getProperty("entity").asInstanceOf[String]) -// val label: LigatureValue.Identifier = -// LigatureValue.Identifier(entity.getProperty("attribute").asInstanceOf[String]) -// val target = intToTypeCode(entity.getProperty("valueType").asInstanceOf[Int]) match -// case TypeCode.IdentifierType => LigatureValue.Identifier(entity.getProperty("value").asInstanceOf[String]) -// case TypeCode.IntType => LigatureValue.IntegerValue(entity.getProperty("value").asInstanceOf[Long]) -// case TypeCode.StringType => -// LigatureValue.StringValue(entity.getProperty("value").asInstanceOf[String]) -// case TypeCode.BytesType => -// val value = entity.getProperty("value").asInstanceOf[ByteIterable] -// decodeLigatureValue(value) -// case TypeCode.RecordType => -// val value = entity.getProperty("value").asInstanceOf[ByteIterable] -// decodeLigatureValue(value) -// buffer += Statement(source, label, target) -// ) -// buffer.iterator diff --git a/ligature-sqlite/src/main/scala/dev/ligature/sqlite/LigatureSqlite.scala b/ligature-sqlite/src/main/scala/dev/ligature/sqlite/LigatureSqlite.scala deleted file mode 100644 index c111bc73..00000000 --- a/ligature-sqlite/src/main/scala/dev/ligature/sqlite/LigatureSqlite.scala +++ /dev/null @@ -1,95 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ - -package dev.ligature.xodus - -import dev.ligature.{Ligature, QueryTx} - - -import scala.jdk.CollectionConverters.* -import java.nio.file.Path -import dev.ligature.Statement -import dev.ligature.LigatureValue -import dev.ligature.DatasetName -import scala.math.Ordered.orderingToOrdered -import java.sql.DriverManager -import java.sql.Connection - -def createLigatureSqlite(path: Path): Ligature = - val connection = DriverManager.getConnection("jdbc:sqlite:test.db"); - val statement = connection.createStatement(); - statement.setQueryTimeout(30); // set timeout to 30 sec. - statement.executeUpdate("drop table if exists person"); - statement.executeUpdate("create table person (id integer, name string)"); - statement.executeUpdate("insert into person values(1, 'leo')"); - statement.executeUpdate("insert into person values(2, 'yui')"); - val rs = statement.executeQuery("select * from person"); - println("name = " + rs.getString("name")); - println("id = " + rs.getInt("id")); - val ligatureInstance = LigatureSqlite(connection) - ligatureInstance - -private final class LigatureSqlite(connection: Connection) extends Ligature { - override def allDatasets(): Iterator[DatasetName] = ??? - - override def createDataset(graph: DatasetName): Unit = ??? - - override def deleteDataset(graph: DatasetName): Unit = ??? - - override def matchDatasetsPrefix(prefix: String): Iterator[DatasetName] = ??? - - override def graphExists(graph: DatasetName): Boolean = ??? - - override def matchDatasetsRange(start: String, end: String): Iterator[DatasetName] = ??? - - override def allStatements(graph: DatasetName): Iterator[Statement] = ??? - - override def addStatements(graph: DatasetName, statements: Iterator[Statement]): Unit = ??? - - override def removeStatements(graph: DatasetName, edges: Iterator[Statement]): Unit = ??? - - override def query[T](graph: DatasetName)(fn: QueryTx => T): T = ??? - - override def close(): Unit = ??? -} - -def targetValue(value: LigatureValue): Any = - value match - case LigatureValue.IntegerValue(value) => value - case LigatureValue.StringValue(value) => value - case LigatureValue.Identifier(value) => value - case LigatureValue.BytesValue(value) => value - case LigatureValue.Record(value) => value - -def valueToPersist(value: LigatureValue): Comparable[?] = - value match - case LigatureValue.IntegerValue(value) => value - case LigatureValue.StringValue(value) => value - case LigatureValue.Identifier(value) => value - case value: LigatureValue.BytesValue => encodeLigatureValue(value) - case value: LigatureValue.Record => encodeLigatureValue(value) - -enum TypeCode(val code: Int): - case IdentifierType extends TypeCode(0) - case IntType extends TypeCode(1) - case StringType extends TypeCode(2) - case BytesType extends TypeCode(3) - case RecordType extends TypeCode(4) - -def intToTypeCode(code: Int): TypeCode = - code match - case 0 => TypeCode.IdentifierType - case 1 => TypeCode.IntType - case 2 => TypeCode.StringType - case 3 => TypeCode.BytesType - case 4 => TypeCode.RecordType - case _ => ??? - -def valueType(value: LigatureValue): Int = - value match - case LigatureValue.IntegerValue(_) => TypeCode.IntType.code - case LigatureValue.StringValue(_) => TypeCode.StringType.code - case LigatureValue.Identifier(_) => TypeCode.IdentifierType.code - case LigatureValue.BytesValue(_) => TypeCode.BytesType.code - case LigatureValue.Record(_) => TypeCode.RecordType.code diff --git a/ligature-sqlite/src/test/scala/dev/ligature/sqlite/LigatureSqliteSuite.scala b/ligature-sqlite/src/test/scala/dev/ligature/sqlite/LigatureSqliteSuite.scala deleted file mode 100644 index a76cc954..00000000 --- a/ligature-sqlite/src/test/scala/dev/ligature/sqlite/LigatureSqliteSuite.scala +++ /dev/null @@ -1,34 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -package dev.ligature.sqlite - -import dev.ligature.Ligature -import dev.ligature.testsuite.LigatureTestSuite -import java.nio.file._ -import java.io.File -import dev.ligature.sqlite.createXodusLigature - -class LigatureXodusSpec extends LigatureTestSuite { - - override def createLigature(): Ligature = createXodusLigature(path) - - var path: Path = null - - override def beforeEach(context: BeforeEach): Unit = - path = Files.createTempDirectory("LigatureXodusTest") - - override def afterEach(context: AfterEach): Unit = { - def deleteRecursively(file: File): Unit = { - if (file.isDirectory) { - file.listFiles.foreach(deleteRecursively) - } - if (file.exists && !file.delete) { - throw new Exception(s"Unable to delete ${file.getAbsolutePath}") - } - } - - deleteRecursively(path.toFile) - } -}