Comments (7)
If you agree I'll open a draft PR.
from elastic4s.
Shall we do these in separate PRs ?
What's the advantage of bringing the inner classes to top level?
from elastic4s.
-
At first, I'd like to point out inner classes become different concrete ones according to the class hierarchy, for example:
trait A { case class Inner(v: Int) } object B extends A object C extends A B.Inner(1) == B.Inner(1) // true B.Inner(1) == C.Inner(1) // false
It's because
B.A
andC.A
have different FQCNs. Single FQCN has following benefits other than equality checking: -
Implicit resolution without import tax
class RichInt(a: Int) { def plus(b: Int) = a + b } object RichInt { implicit def apply(a: Int): RichInt = new RichInt(a) } def plus1(a: RichInt) = a.plus(b) plus1(23) == 24 // true
We still need
import RichInt._
to directly use1.plus(3)
, so we need to exposure some implicit conversions for the entry points at least. But after that we can provide well-organized implicit conversions as well as type safety.I used this technique for Redisreact to provide typesafe, out-of-box serialization not relying on
(_: Any).toString
. I'd like to bring it to Elasitc4s as well in near future. -
Avoid boxing/unboxing overhead using Value classes
By extending
AnyVal
we can avoid runtime overhead caused by creating tons of intermediate wrapper instances. However, it's not supported for inner classes:scala> class A // defined class A scala> class B(val a: A) extends AnyVal // defined class B scala> class Outer { class C(val a: A) extends AnyVal } //<console>:8: error: value class may not be a member of another class // class Outer { class C(val a: A) extends AnyVal } // ^
from elastic4s.
Actually it's not necessary to make it top-level, the point is to give it single FQCN. So it's ok in the previous example:
object Outer { class C(val a: A) extends AnyVal }
// it works because there's only one FQCN for `Outer.C`
from elastic4s.
Ok I see. What classes are you wanting to be top level? Happy for you to do a PR.
from elastic4s.
Couldn't check all of them yet, but basically want to avoid any unnecessary path-dependent class.
I'll do a draft in one or a few weeks, so let's discuss more on that PR.
from elastic4s.
Ok lets do that. 0.90.4 is out this week or next so will be doing the next release for that.
from elastic4s.
Related Issues (20)
- Multisearch ignores memory circuit breaker errors
- Update to cats-effect 3.5+
- Add runtime fields support to `MappingDefinitionLike` HOT 2
- Implement ScriptScoreQuery HOT 2
- opensearch compatibility HOT 9
- Add support for PIT in search
- ElasticProperties accepts invalid input and runs with only single node HOT 1
- [Force merge index] Can not force merge asynchronously
- WAND optimization with a numeric track_total_hits parameter
- Using REST API compatibility
- Support for highlights in TopHitsAggregation
- Elasticsearch server version for tests is not up-to-date and tests are failing when updating HOT 2
- SearchHit.sourceAsString adds superfluous type metadata HOT 2
- IndicesExistsRequest with allowNoIndices = true always returns true HOT 1
- `getIndex` doesn't support date math in index aliases HOT 1
- `indexExists` always returns `true` if index string contains `*` HOT 2
- `.sourceExclude` and `.sourceInclude` are mutually exclusive HOT 1
- docAsUpsert not working as expected
- ElasticSource does not clear it's scroll HOT 1
- Add Synonyms API support HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elastic4s.