Closed iilyak closed 9 months ago
I did verify my assumptions via reading code of:
As well as CouchDb and Cloudant documentation.
The term "refactor" refers only to software edits that do not make functional changes, but just rearrange code to make a future functional change easier. The term has no value otherwise.
Please replace the word "refactor" with "change" or some synonym in the description, as clearly the PR makes many function changes in addition to the stated goal of "introducing types".
Please replace the word "refactor" with "change" or some synonym in the description, as clearly the PR makes many function changes in addition to the stated goal of "introducing types".
The goal of this PR is to avoid public API changes. If it does change the protocol then it is a bug in the PR. I'll try harder to prevent the public API changes. Which probably would result in a very different version of this PR.
closing in favor of https://github.com/cloudant-labs/clouseau/pull/84
Refactor
createAnalyzer
to remove polymorphic arguments and useMap[String, Any]
The polymorphism makes it harder to introduce types. Because it requires union types. Which are not natively supported by the version of Scala we use. Elimination of the polymorphism would allow us to introduce types.
The introduction of types is the vehicle to solve type erasure problem we would have to deal with when we upgrade Scala to the next version.
The refactoring is done using following steps
Analyzer
createAnalyzerFromString(name: String)
createAnalyzer(options: Map[String, Any])
createAnalyzerFromStringInt(name: String)
createAnalyzerInt(options: Map[String, Any])
OpenIndexMsg
fromMap(peer: Pid, path: String, map: Map[_, _])
fromAnalyzerName(peer: Pid, path: String, name: String)
fromKVsList(peer: Pid, path: String, options: List[_])
Any
to the concrete typeoptions.get("name").map(_.asInstanceOf[String])
Assumptions
options
passed toOpenIndexMsg
are stringsoptions
String
stopwords
is a liststopwords
are stringsstopwords
fields
value is a listfields
list are tuples(String, String)
(String, String)
patternconfig
is a String in('analyze, config, text)
message in AnalyzerService.handleCall and it should really be named('analyze, analyzerName, text)
.