Skip to content

Commit

Permalink
scalafmt
Browse files Browse the repository at this point in the history
  • Loading branch information
rmgk committed Nov 11, 2023
1 parent b6d4ec9 commit b479caa
Show file tree
Hide file tree
Showing 59 changed files with 192 additions and 174 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ class AddWinsLastWriterWinsMap[K, V](
}

object AddWinsLastWriterWinsMap {
type LatticeType[K, V] = AddWinsMapLattice[K, LastWriterWins[V]]
type LatticeType[K, V] = AddWinsMapLattice[K, LastWriterWins[V]]
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ object HTML {
else
List(
td(button("disconnect", onclick := leftClickHandler(rr.disconnect()))),
td(button("request", onclick := leftClickHandler{
dataManager.requestMissingFrom(rr)
()
})),
td(button(
"request",
onclick := leftClickHandler {
dataManager.requestMissingFrom(rr)
()
}
)),
td(table(
dataManager.contextOf(rr).map(dotsToRows).asModifierL
))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ case class CliConnections(
// Argument(_.text("add random data on a time").valueName("milliseconds"))
)


class FbdcCli(settings: CliConnections) {

val exData = new FbdcExampleData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ class AWSetTest extends munit.ScalaCheckSuite {
}
property("convergence") {
forAll {
(addedA: List[Int], removedA: List[Int], addedB: List[Int], removedB: List[Int],networkGen: NetworkGenerator) =>
(addedA: List[Int], removedA: List[Int], addedB: List[Int], removedB: List[Int], networkGen: NetworkGenerator) =>
val network = networkGen.make()
val aea = new AntiEntropy[AddWinsSet[Int]]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[AddWinsSet[Int]]("b", network, mutable.Buffer("a"))
val aea = new AntiEntropy[AddWinsSet[Int]]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[AddWinsSet[Int]]("b", network, mutable.Buffer("a"))

val setaAdded = addedA.foldLeft(AntiEntropyContainer[AddWinsSet[Int]](aea)) {
case (set, e) => set.add(using set.replicaID)(e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,16 @@ class EWFlagTest extends munit.ScalaCheckSuite {
property("convergence") {
forAll { (enableA: Short, opsA: List[Boolean], opsB: List[Boolean], networkGen: NetworkGenerator) =>
val network = networkGen.make()
val aea = new AntiEntropy[EnableWinsFlag]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[EnableWinsFlag]("b", network, mutable.Buffer("a"))

val aea = new AntiEntropy[EnableWinsFlag]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[EnableWinsFlag]("b", network, mutable.Buffer("a"))

val fa0 = opsA.foldLeft(AntiEntropyContainer[EnableWinsFlag](aea)) {
case (f, false) => f.disable()
case (f, true) => f.enable(using f.replicaID)()
case (f, true) => f.enable(using f.replicaID)()
}
val fb0 = opsB.foldLeft(AntiEntropyContainer[EnableWinsFlag](aeb)) {
case (f, false) => f.disable()
case (f, true) => f.enable(using f.replicaID)()
case (f, true) => f.enable(using f.replicaID)()
}

AntiEntropy.sync(aea, aeb)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class GCounterTest extends munit.ScalaCheckSuite {
property("convergence") {
forAll { (incA: Short, incB: Short, networkGen: NetworkGenerator) =>
val network = networkGen.make()
val aea = new AntiEntropy[GrowOnlyCounter]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[GrowOnlyCounter]("b", network, mutable.Buffer("a"))
val aea = new AntiEntropy[GrowOnlyCounter]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[GrowOnlyCounter]("b", network, mutable.Buffer("a"))

val ca0 = (0 until incA.toInt).foldLeft(AntiEntropyContainer[GrowOnlyCounter](aea)) {
case (c, _) => c.inc()(using c.replicaID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ class GListTest extends munit.ScalaCheckSuite {
property("convergence") {
forAll { (base: List[Int], insertedA: List[Int], insertedB: List[Int], networkGen: NetworkGenerator) =>
val network = networkGen.make()
val aea = new AntiEntropy[GrowOnlyList[Int]]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[GrowOnlyList[Int]]("b", network, mutable.Buffer("a"))
val aea = new AntiEntropy[GrowOnlyList[Int]]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[GrowOnlyList[Int]]("b", network, mutable.Buffer("a"))

val la0 = base.reverse.foldLeft(AntiEntropyContainer[GrowOnlyList[Int]](aea)) {
case (l, e) => l.insertGL(0, e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ class GSetTest extends munit.ScalaCheckSuite {
property("convergence") {
forAll { (insertedA: List[Int], insertedB: List[Int], networkGen: NetworkGenerator) =>
val network = networkGen.make()
val aea = new AntiEntropy[GrowOnlySet[Int]]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[GrowOnlySet[Int]]("b", network, mutable.Buffer("a"))
val aea = new AntiEntropy[GrowOnlySet[Int]]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[GrowOnlySet[Int]]("b", network, mutable.Buffer("a"))

val sa0 = insertedA.foldLeft(AntiEntropyContainer[GrowOnlySet[Int]](aea)) {
case (set, e) => set.insert(e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ class MultiVersionRegisterTest extends munit.ScalaCheckSuite {
forAll {
(valuesA: List[Int], nClearA: Short, valuesB: List[Int], nClearB: Short, networkGen: NetworkGenerator) =>
val network = networkGen.make()
val aea = new AntiEntropy[MultiVersionRegister[Int]]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[MultiVersionRegister[Int]]("b", network, mutable.Buffer("a"))
val aea = new AntiEntropy[MultiVersionRegister[Int]]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[MultiVersionRegister[Int]]("b", network, mutable.Buffer("a"))

val opsA = Random.shuffle(valuesA.indices ++ List.fill(nClearA.toInt)(-1))
val opsB = Random.shuffle(valuesB.indices ++ List.fill(nClearB.toInt)(-1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class ORMapTest extends munit.ScalaCheckSuite {
val queryResult = removed.queryKey(k).elements

assertEquals(
queryResult, empty.elements,
queryResult,
empty.elements,
s"Querying a removed key should produce the same result as querying an empty CRDT, but $queryResult does not equal ${empty.elements}"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ class PosNegCounterTest extends munit.ScalaCheckSuite {
property("convergence") {
forAll { (incA: Byte, decA: Byte, incB: Byte, decB: Byte, networkGen: NetworkGenerator) =>
val network = networkGen.make()
val aea = new AntiEntropy[PosNegCounter]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[PosNegCounter]("b", network, mutable.Buffer("a"))
val aea = new AntiEntropy[PosNegCounter]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[PosNegCounter]("b", network, mutable.Buffer("a"))

val incedA = (0 until incA.toInt).foldLeft(AntiEntropyContainer[PosNegCounter](aea)) {
case (c, _) => c.inc()(using c.replicaID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ class ResettableCounterTest extends munit.ScalaCheckSuite {
nOpsB1: (Byte, Byte, Byte, Byte),
nOpsA2: (Byte, Byte, Byte, Byte),
nOpsB2: (Byte, Byte, Byte, Byte),
networkGen: NetworkGenerator
networkGen: NetworkGenerator
) =>
{
val network = networkGen.make()
val aea = new AntiEntropy[ResettableCounter]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[ResettableCounter]("b", network, mutable.Buffer("a"))
val aea = new AntiEntropy[ResettableCounter]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[ResettableCounter]("b", network, mutable.Buffer("a"))

val opsA1 = Random.shuffle(List.fill(nOpsA1._1.toInt)(0) ++ List.fill(nOpsA1._2.toInt)(1) ++ List.fill(
nOpsA1._3.toInt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class TowPSetTest extends munit.ScalaCheckSuite {
forAll {
(insertA: List[Int], removeA: List[Int], insertB: List[Int], removeB: List[Int], networkGen: NetworkGenerator) =>
val network = networkGen.make()
val aea = new AntiEntropy[TwoPhaseSet[Int]]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[TwoPhaseSet[Int]]("b", network, mutable.Buffer("a"))
val aea = new AntiEntropy[TwoPhaseSet[Int]]("a", network, mutable.Buffer("b"))
val aeb = new AntiEntropy[TwoPhaseSet[Int]]("b", network, mutable.Buffer("a"))

val insertedA = insertA.foldLeft(AntiEntropyContainer[TwoPhaseSet[Int]](aea)) {
case (s, e) => s.insert(e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class DataManager[State: JsonValueCodec: DottedLattice: Bottom: HasDots](
Binding[Dots => Unit]("requestMissing")

val pushStateBinding: PushBinding[TransferState] =
given JsonValueCodec[TransferState] = JsonCodecMaker.make
given JsonValueCodec[TransferState] = JsonCodecMaker.make
@unused
given IdenticallyTransmittable[TransferState] = IdenticallyTransmittable[TransferState]()
Binding[TransferState => Unit]("pushState")
Expand Down Expand Up @@ -137,7 +137,7 @@ class DataManager[State: JsonValueCodec: DottedLattice: Bottom: HasDots](
deltas
}
registry.remotes.foreach { remote =>
//val ctx = contexts.now.getOrElse(remote, Dots.empty)
// val ctx = contexts.now.getOrElse(remote, Dots.empty)
pushDeltas(deltas.view, remote)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import com.github.plokhotnyuk.jsoniter_scala.macros.{CodecMakerConfig, JsonCodec
import kofre.base.Uid
import kofre.datatypes.alternatives.ResettableCounter
import kofre.datatypes.contextual.{AddWinsSet, EnableWinsFlag, MultiVersionRegister, ObserveRemoveMap, ReplicatedList}
import kofre.datatypes.{Epoche, GrowOnlyCounter, GrowOnlyList, GrowOnlyMap, GrowOnlySet, LastWriterWins, PosNegCounter, TwoPhaseSet}
import kofre.datatypes.{
Epoche, GrowOnlyCounter, GrowOnlyList, GrowOnlyMap, GrowOnlySet, LastWriterWins, PosNegCounter, TwoPhaseSet
}
import kofre.dotted.Dotted
import kofre.datatypes.experiments.AuctionInterface.AuctionData
import kofre.time.{ArrayRanges, Dot, Dots, Time}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class RecursiveCompositionTest extends munit.FunSuite {
val exampleComposition: Component = Container(
List(
Label("Do you Accept?"),
Container (
Container(
List(
Button("Yes"),
Button("Ok")
Expand All @@ -31,7 +31,7 @@ class RecursiveCompositionTest extends munit.FunSuite {
)

test("composition is serializable") {
val bytes = writeToArray(exampleComposition)
val bytes = writeToArray(exampleComposition)
val roundtripped = readFromArray[Component](bytes)
assertEquals(roundtripped, exampleComposition)
}
Expand Down
1 change: 0 additions & 1 deletion Modules/Example Todolist/src/main/scala/todo/Codecs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import kofre.time.Dot
import loci.transmitter.IdenticallyTransmittable
import rescala.extra.replication.DeltaFor


object Codecs {

implicit val taskRefCodec: JsonValueCodec[TaskRef] = JsonCodecMaker.make
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class TodoAppUI(val storagePrefix: String) {
}

val taskrefs = TaskReferences(toggleAll.event, storagePrefix)
val taskOps = new TaskOps(taskrefs, replicaId)
val taskOps = new TaskOps(taskrefs, replicaId)

val deltaEvt = Evt[Dotted[ReplicatedList[TaskRef]]]()

Expand Down
1 change: 0 additions & 1 deletion Modules/Graph-Compiler/src/main/scala/api/Filter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import clangast.decl.CFunctionDecl
import clangast.types.CType
import compiler.MacroCompiler


case class Filter[V](input: Event[V], cType: WithContext[CType], f: WithContext[CFunctionDecl]) extends Event[V] {
override def inputs: List[ReSource] = List(input)

Expand Down
1 change: 0 additions & 1 deletion Modules/Graph-Compiler/src/main/scala/api/Fold.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import clangast.expr.CExpr
import clangast.types.CType
import compiler.MacroCompiler


case class Fold[V](init: WithContext[CExpr], cType: WithContext[CType], lines: List[FLine[_, V]]) extends Event[V] {
override def inputs: List[ReSource] = lines.map(_.input)

Expand Down
1 change: 0 additions & 1 deletion Modules/Graph-Compiler/src/main/scala/api/Map1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import clangast.decl.CFunctionDecl
import clangast.types.{CType, CVoidType}
import compiler.MacroCompiler


case class Map1[A, R](input: Event[A], cType: WithContext[CType], f: WithContext[CFunctionDecl]) extends Event[R] {
override def inputs: List[ReSource] = List(input)

Expand Down
1 change: 0 additions & 1 deletion Modules/Graph-Compiler/src/main/scala/api/Map2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import clangast.decl.CFunctionDecl
import clangast.types.CType
import compiler.MacroCompiler


case class Map2[A, B, R](l: Event[A], r: Event[B], cType: WithContext[CType], f: WithContext[CFunctionDecl])
extends Event[R] {
override def inputs: List[ReSource] = List(l, r)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import clangast.*
import clangast.given
import clangast.decl.*
import clangast.expr.*
import clangast.expr.binaryop.{CAndExpr, CAssignmentExpr, CEqualsExpr, CGreaterThanExpr, CLessThanExpr, CNotEqualsExpr, COrExpr}
import clangast.expr.binaryop.{
CAndExpr, CAssignmentExpr, CEqualsExpr, CGreaterThanExpr, CLessThanExpr, CNotEqualsExpr, COrExpr
}
import clangast.expr.unaryop.CNotExpr
import clangast.stmt.*
import clangast.stubs.{CJSONH, DyadH, StdBoolH, StdLibH}
Expand Down Expand Up @@ -314,7 +316,6 @@ class GraphCompiler(using Quotes)(
val stillUsed = otherConds ++ otherConds.flatMap(reactiveInputs)
val released = toRelease.filterNot(stillUsed.contains)


@nowarn
val serialization = CEmptyStmt :: sameCond.collect[CStmt] {
case e: CompiledEvent if jsonVars.contains(e) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package clangast.expr


import scala.quoted.{Expr, Quotes}

case class CDeclRefExpr(declName: String) extends CExpr {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package clangast.types


import scala.quoted.{Expr, Quotes}

case class CEnumType(declName: String) extends CType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import clangast.expr.CExpr
import clangast.types.CType
import clangast.{CASTNode, WithContext}


trait MacroCompiler {
inline def compileTree(inline t: Any): WithContext[CASTNode]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ object StandardReactiveMacroCompiler extends ReactiveMacroCompiler {
export impl.*

override inline def compileTree(inline t: Any): WithContext[CASTNode] =
${ compileTreeCode('{t}) }
${ compileTreeCode('{ t }) }

override inline def compileExpr(inline e: Any): WithContext[CExpr] =
${ compileExprCode('{e}) }
${ compileExprCode('{ e }) }

override inline def compileFun(inline f: AnyRef): WithContext[CFunctionDecl] =
${ compileFunCode('{f}) }
${ compileFunCode('{ f }) }

override inline def compileAnonFun(inline f: AnyRef): WithContext[CFunctionDecl] =
${ compileAnonFunCode('{f}) }
${ compileAnonFunCode('{ f }) }

override inline def compileType[T]: WithContext[CType] =
${ compileTypeCode[T] }
Expand All @@ -29,5 +29,5 @@ object StandardReactiveMacroCompiler extends ReactiveMacroCompiler {
${ valNameCode }

override inline def compileGraph(inline appName: String)(inline graph: Any): Unit =
${ compileGraphCode('{appName})('{graph}) }
${ compileGraphCode('{ appName })('{ graph }) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import kofre.base.Uid.asId
import kofre.datatypes.contextual.ReplicatedList
import java.util.concurrent.TimeUnit


@BenchmarkMode(Array(Mode.Throughput))
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Warmup(iterations = 3, time = 1000, timeUnit = TimeUnit.MILLISECONDS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import java.util.concurrent.TimeUnit
@State(Scope.Thread)
class LWWRegisterBench {

var full: NamedDeltaBuffer[LastWriterWins[Int]] = _
var full: NamedDeltaBuffer[LastWriterWins[Int]] = _

@Setup
def setup(): Unit = {
Expand Down
2 changes: 1 addition & 1 deletion Modules/RDTs/src/main/scala/kofre/base/Lattice.scala
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ object Lattice {

override def decompose(a: T): Iterable[T] =
val ordinal = sm.ordinal(a)
val res = lat(ordinal).decompose(a)
val res = lat(ordinal).decompose(a)
// When `a` decomposes into nothing, it is no longer possible to distinguish which alternative of the sum we are dealing with. That is fine when the ordinal is 0 because then we have reached the bottom case for the sum type, but in all other cases we must keep enough information around to figure out the ordinal.
if ordinal != 0 && res.isEmpty
then Iterable(a)
Expand Down
2 changes: 1 addition & 1 deletion Modules/RDTs/src/main/scala/kofre/datatypes/Epoche.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object Epoche {

given hasDots[E: HasDots: Bottom]: HasDots[Epoche[E]] = new {
extension (dotted: Epoche[E])
def dots: Dots = dotted.value.dots
def dots: Dots = dotted.value.dots
def removeDots(dots: Dots): Option[Epoche[E]] = dotted.value.removeDots(dots).map(nv => dotted.copy(value = nv))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object GrowOnlyList {

def empty[E]: GrowOnlyList[E] = GrowOnlyList(Map.empty)

given bottomInstance[E]: Bottom[GrowOnlyList[E]] = Bottom.derived
given bottomInstance[E]: Bottom[GrowOnlyList[E]] = Bottom.derived
given hasDots[E: HasDots]: HasDots[GrowOnlyList[E]] = HasDots.noDots

given Lattice[E]: Lattice[GrowOnlyList[E]] =
Expand Down
4 changes: 2 additions & 2 deletions Modules/RDTs/src/main/scala/kofre/datatypes/GrowOnlySet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ object GrowOnlySet {

def empty[E]: GrowOnlySet[E] = Set.empty

given bottomInstance[E]: Bottom[GrowOnlySet[E]] = Bottom.setBottom
given lattice[E]: Lattice[GrowOnlySet[E]] = Lattice.setLattice
given bottomInstance[E]: Bottom[GrowOnlySet[E]] = Bottom.setBottom
given lattice[E]: Lattice[GrowOnlySet[E]] = Lattice.setLattice

extension [C, E](container: C)
def growOnlySet: syntax[C, E] = syntax(container)
Expand Down
Loading

0 comments on commit b479caa

Please sign in to comment.