Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol v1 add limit add cache #21

Merged
merged 27 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
dea990a
WIP
miguelbranco80 Dec 27, 2024
04ec32a
fmtAll
bgaidioz Feb 14, 2025
40274e6
Disable using the CacheManager in TableServiceGrpcImpl.
bgaidioz Feb 12, 2025
1243a38
Fix test code.
bgaidioz Feb 12, 2025
567ed07
Fix warning.
bgaidioz Feb 12, 2025
de0962e
Dropped code
bgaidioz Feb 12, 2025
fbd78f0
Removed ChronicleQueue dependencies
bgaidioz Feb 14, 2025
6acc20e
Add LIMIT
bgaidioz Feb 12, 2025
70275f7
fixup! Add LIMIT
bgaidioz Feb 12, 2025
52e41f3
Add output to EXPLAIN
bgaidioz Feb 13, 2025
3d5b69b
simplify killSwitch logic
bgaidioz Feb 13, 2025
b4b1733
Added an "events" table that is failing if using dates outside a spec…
bgaidioz Feb 13, 2025
fd55a49
Ref protocol-das 1.0.0-beta3
bgaidioz Feb 13, 2025
7121e6f
Moved row streaming logic around
bgaidioz Feb 14, 2025
439b751
Version that works
bgaidioz Feb 14, 2025
6d79aa0
Version with a limited cache entry size
bgaidioz Feb 14, 2025
cf87333
fixup! Version with a limited cache entry size
bgaidioz Feb 14, 2025
5f3863f
fixup! fixup! Version with a limited cache entry size
bgaidioz Feb 14, 2025
9c6ed1f
Final fixes
bgaidioz Feb 14, 2025
592f940
Final fixes
bgaidioz Feb 14, 2025
62cb05b
Fixed test code (NOT_FOUND => INVALID_ARGUMENT)
bgaidioz Feb 14, 2025
144ce87
fmtAll
bgaidioz Feb 14, 2025
b31ac0a
Moved cache files to a specific package
bgaidioz Feb 14, 2025
42d76ba
Made the cache parameterized
bgaidioz Feb 17, 2025
f65fb31
Made the cache parameterized
bgaidioz Feb 17, 2025
35ac697
Made the cache parameterized
bgaidioz Feb 17, 2025
f01f68f
Addressed comments
bgaidioz Feb 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
image: sbtscala/scala-sbt:eclipse-temurin-jammy-21.0.2_13_1.9.9_2.12.19
steps:
- uses: actions/checkout@v4
- run: sbt headerCheckAll
- run: sbt headerCheckAll javafmtCheckAll scalafmtCheckAll
test:
runs-on: self-hosted
container:
Expand Down
152 changes: 24 additions & 128 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,136 +1,32 @@
version = 2.7.5
version = "3.8.3"
runner.dialect = "scala213"
style = "IntelliJ"
maxColumn = 120

optIn.forceBlankLineBeforeDocstring = true
trailingCommas = "never"

align {
openParenCallSite = false
openParenDefnSite = false
preset=some
stripMargin = false
tokens = []
}

assumeStandardLibraryStripMargin = true
binPack.parentConstructors = "never"

continuationIndent {
callSite = 2
ctorSite = 4
defnSite = 4
extendSite = 4
}

indentOperator.include = "^.*=$"
rewrite.rules = [Imports, RedundantParens, SortModifiers]
rewrite.imports.sort = ascii
rewrite.imports.groups = [
["java.?\\..*"],
["sbt\\..*"],
["scala\\..*"],
["org\\..*"],
["com\\..*"],
]
newlines.alwaysBeforeElseAfterCurlyIf = false
danglingParentheses {
ctrlSite = true
defnSite = true
}


docstrings.style = "Asterisk" // JavaDoc
includeCurlyBraceInSelectChains = true
includeNoParensInSelectChains = false

literals {
double = "Lower"
float = "Lower"
hexDigits = "Lower"
hexPrefix = "Lower"
long = "Upper"
}

newlines {
afterCurlyLambdaParams = squash
afterCurlyLambdaParams=squash
alwaysBeforeElseAfterCurlyIf = false
beforeCurlyLambdaParams = multilineWithCaseOnly
beforeMultiline = fold
beforeMultilineDef = false
implicitParamListModifierPrefer = before
}

rewrite {
redundantBraces {
generalExpressions = false
ifElseExpressions = false
methodBodies = false
parensForOneLineApply = true
stringInterpolation = true
}
rules = [
RedundantBraces,
RedundantParens,
SortModifiers,
SortImports
]
redundantBraces {
generalExpressions = false
methodBodies = false
ifElseExpressions = false
parensForOneLineApply = true
stringInterpolation = true
}
sortModifiers {
order = [
"implicit",
"final",
"sealed",
"abstract",
"override",
"private",
"protected",
"lazy"
]
}
}

continuationIndent {
callSite = 2
defnSite = 4
ctorSite = 4
extendSite = 4
callSite = false
defnSite = false
}

align {
preset=some
tokens = []
openParenCallSite = false
openParenDefnSite = false
preset = some
stripMargin = false
tokens = []
}

danglingParentheses {
defnSite = true
ctrlSite = true
openParenDefnSite = false
openParenCallSite = false
}

docstrings.style = Asterisk
docstrings.wrap = fold
optIn.configStyleArguments = false
spaces {
afterKeywordBeforeParen = true
afterSymbolicDefs = false
beforeContextBoundColon = "Never"
inByNameTypes = true
inParentheses = false
neverAroundInfixTypes = []
afterKeywordBeforeParen = true
inByNameTypes = true
afterSymbolicDefs = false
}

literals {
long = "Upper"
float = "Lower"
double = "Lower"
hexPrefix = "Lower"
hexDigits = "Lower"
}

docstrings {
style = "Asterisk" // JavaDoc
}

binPack {
parentConstructors = "Never"
inImportCurlyBraces = false
}
continuationIndent.defnSite = 4
runner.optimizer.maxVisitsPerToken = 15000
115 changes: 47 additions & 68 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import sbt.Keys._
import sbt._

import java.nio.file.Paths
import sbt.*
import sbt.Keys.*

ThisBuild / credentials += Credentials(
"GitHub Package Registry",
"maven.pkg.github.com",
"raw-labs",
sys.env.getOrElse("GITHUB_TOKEN", "")
)
sys.env.getOrElse("GITHUB_TOKEN", ""))

lazy val commonSettings = Seq(
homepage := Some(url("https://www.raw-labs.com/")),
Expand All @@ -18,68 +15,28 @@ lazy val commonSettings = Seq(
// Use cached resolution of dependencies
// http://www.scala-sbt.org/0.13/docs/Cached-Resolution.html
updateOptions := updateOptions.in(Global).value.withCachedResolution(true),
resolvers += "RAW Labs GitHub Packages" at "https://maven.pkg.github.com/raw-labs/_"
)
resolvers += "RAW Labs GitHub Packages" at "https://maven.pkg.github.com/raw-labs/_")

lazy val buildSettings = Seq(
scalaVersion := "2.12.18",
javacOptions ++= Seq(
"-source",
"21",
"-target",
"21"
),
scalacOptions ++= Seq(
"-feature",
"-unchecked",
// When compiling in encrypted drives in Linux, the max size of a name is reduced to around 140
// https://unix.stackexchange.com/a/32834
"-Xmax-classfile-name",
"140",
"-deprecation",
"-Xlint:-stars-align,_",
"-Ywarn-dead-code",
"-Ywarn-macros:after", // Fix for false warning of unused implicit arguments in traits/interfaces.
"-Ypatmat-exhaust-depth",
"160"
)
)
lazy val buildSettings = Seq(scalaVersion := "2.13.15")

lazy val compileSettings = Seq(
Compile / doc / sources := Seq.empty,
Compile / packageDoc / mappings := Seq(),
Compile / packageSrc / publishArtifact := true,
Compile / packageDoc / publishArtifact := false,
Compile / packageBin / packageOptions += Package.ManifestAttributes(
"Automatic-Module-Name" -> name.value.replace('-', '.')
),
// Ensure Java annotations get compiled first, so that they are accessible from Scala.
compileOrder := CompileOrder.JavaThenScala
"Automatic-Module-Name" -> name.value.replace('-', '.')),
// Ensure Java-based DAS SDK code is compiled first, so it is accessible from Scala.
compileOrder := CompileOrder.JavaThenScala,
// Ensure we fork new JVM for run, so we can set JVM flags.
Compile / run / fork := true
)

lazy val testSettings = Seq(
// Ensuring tests are run in a forked JVM for isolation.
// Ensure we fork new JVM for run, so we can set JVM flags.
Test / fork := true,
// Disabling parallel execution of tests.
//Test / parallelExecution := false,
// Pass system properties starting with "raw." to the forked JVMs.
Test / javaOptions ++= {
import scala.collection.JavaConverters._
val props = System.getProperties
props
.stringPropertyNames()
.asScala
.filter(_.startsWith("raw."))
.map(key => s"-D$key=${props.getProperty(key)}")
.toSeq
},
// Set up heap dump options for out-of-memory errors.
Test / javaOptions ++= Seq(
"-XX:+HeapDumpOnOutOfMemoryError",
s"-XX:HeapDumpPath=${Paths.get(sys.env.getOrElse("SBT_FORK_OUTPUT_DIR", "target/test-results")).resolve("heap-dumps")}"
),
Test / publishArtifact := true
)
// Required for publishing test artifacts.
Test / publishArtifact := true)

val isCI = sys.env.getOrElse("CI", "false").toBoolean

Expand All @@ -88,16 +45,11 @@ lazy val publishSettings = Seq(
publish / skip := false,
publishMavenStyle := true,
publishTo := Some(
"GitHub raw-labs Apache Maven Packages" at "https://maven.pkg.github.com/raw-labs/das-server-scala"
),
publishConfiguration := publishConfiguration.value.withOverwrite(isCI)
)
"GitHub raw-labs Apache Maven Packages" at "https://maven.pkg.github.com/raw-labs/das-server-scala"),
publishConfiguration := publishConfiguration.value.withOverwrite(isCI))

lazy val strictBuildSettings = commonSettings ++ compileSettings ++ buildSettings ++ testSettings ++ Seq(
scalacOptions ++= Seq(
"-Xfatal-warnings"
)
)
lazy val strictBuildSettings =
commonSettings ++ compileSettings ++ buildSettings ++ testSettings ++ Seq(scalacOptions ++= Seq("-Xfatal-warnings"))

lazy val root = (project in file("."))
.enablePlugins(BuildInfoPlugin)
Expand All @@ -108,6 +60,33 @@ lazy val root = (project in file("."))
strictBuildSettings,
publishSettings,
libraryDependencies ++= Seq(
"com.raw-labs" %% "das-sdk-scala" % "0.1.4" % "compile->compile;test->test"
)
)
// Logging
// Using SLF4j as the facade, Logback as the implementation, Loki for log aggregation and with Scala support.
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.5",
"ch.qos.logback" % "logback-classic" % "1.5.12",
"org.slf4j" % "slf4j-api" % "2.0.16",
"org.slf4j" % "log4j-over-slf4j" % "2.0.16",
"org.slf4j" % "jcl-over-slf4j" % "2.0.16",
"org.slf4j" % "jul-to-slf4j" % "2.0.16",
"com.github.loki4j" % "loki-logback-appender" % "1.5.2",
// Configuration
"com.typesafe" % "config" % "1.4.3",
// Protocol DAS
"com.raw-labs" %% "protocol-das" % "1.0.0-beta3",
// Akka Streams
"com.typesafe.akka" %% "akka-actor-typed" % "2.8.8",
"com.typesafe.akka" %% "akka-actor" % "2.8.8",
"com.typesafe.akka" %% "akka-stream" % "2.8.8",
"com.typesafe.akka" %% "akka-actor-testkit-typed" % "2.8.8",
"com.typesafe.akka" %% "akka-testkit" % "2.8.8",
// Jackson databind
"com.fasterxml.jackson.core" % "jackson-databind" % "2.18.2" % Test,
// gRPC Testing
"io.grpc" % "grpc-inprocess" % "1.62.2",
// Web UI
"com.typesafe.akka" %% "akka-http" % "10.5.3",
"com.lihaoyi" %% "scalatags" % "0.13.1",
// Postgres
"org.postgresql" % "postgresql" % "42.7.4" % Test,
// Testing
"org.scalatest" %% "scalatest" % "3.2.19" % Test))
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ autoCompilerPlugins := true

addDependencyTreePlugin

libraryDependencies += "commons-io" % "commons-io" % "2.11.0"
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")

addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0")
addSbtPlugin("com.lightbend.sbt" % "sbt-java-formatter" % "0.8.0")

addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.10.0")

Expand Down
27 changes: 27 additions & 0 deletions src/main/java/com/rawlabs/das/sdk/DASException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2024 RAW Labs S.A.
*
* Use of this software is governed by the Business Source License
* included in the file licenses/BSL.txt.
*
* As of the Change Date specified in that file, in accordance with
* the Business Source License, use of this software will be governed
* by the Apache License, Version 2.0, included in the file
* licenses/APL.txt.
*/

package com.rawlabs.das.sdk;

/**
* Top-level Exception. Message contains information that WILL BE shared with the end-user, so
* ensure it does not leak sensitive information.
*/
public class DASException extends RuntimeException {
public DASException(String message) {
super(message);
}

public DASException(String message, Throwable cause) {
super(message, cause);
}
}
23 changes: 23 additions & 0 deletions src/main/java/com/rawlabs/das/sdk/DASExecuteResult.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2024 RAW Labs S.A.
*
* Use of this software is governed by the Business Source License
* included in the file licenses/BSL.txt.
*
* As of the Change Date specified in that file, in accordance with
* the Business Source License, use of this software will be governed
* by the Apache License, Version 2.0, included in the file
* licenses/APL.txt.
*/

package com.rawlabs.das.sdk;

import com.rawlabs.protocol.das.v1.tables.Row;
import java.io.Closeable;
import java.util.Iterator;

/** Represents an executable result set: an Iterator over Rows that must be closed. */
public interface DASExecuteResult extends Iterator<Row>, Closeable {
// No additional methods; just a combination of Iterator<Row> and Closeable.
// Implementations should properly handle resource cleanup in close().
}
Loading