You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 15, 2022. It is now read-only.
Having get/getCounter makes interacting with cockroach a lot easier since you normally know what type of value you're expecting (i.e.: bytes or counter).
That said, calling one version on the wrong type currently succeeds and returns a None. That's probably undesirable.
Similarly, scan and scanCounters currently skip values of the wrong type. If a client needs to scan both, this is inefficient.
This can be solved by introducing a Value type that has a Bytes and Counter implementation. Consider this signature:
sealedtraitValuecaseclassBytesValue(bytes: Bytes) extendsValuecaseclassCounterValue(value: Long) extendsValueclassClient {
defget(key: Bytes):Future[Option[Value]]
defgetBytes(key: Bytes):Future[Option[Bytes]] // fails when reading a counterdefgetCounter(key: Bytes):Future[Option[Long]] // fails when reading a counterdefscan(from: Bytes, to: Bytes):Future[Spool[(Bytes, Value)]]
defscanByteValues(from: Bytes, to: Bytes):Future[Spool[(Bytes, Bytes)]] // skips countersdefscanCounterValues(from: Bytes, to: Bytes):Future[Spool[(Bytes, Long)]] // skips bytes
}
Arguably, we could use Either[Bytes, Long] but would make pattern matching less explicit (case Right(counter) vs. case CounterValue(counter))