tflobbe commented on a change in pull request #677: SOLR-13257: support for 
stable replica routing preferences
URL: https://github.com/apache/lucene-solr/pull/677#discussion_r302296475
 
 

 ##########
 File path: 
solr/core/src/java/org/apache/solr/handler/component/HttpShardHandlerFactory.java
 ##########
 @@ -449,9 +556,83 @@ private static boolean hasReplicaType(Object o, String 
preferred) {
     }
   }
 
+  private final ReplicaListTransformerFactory randomRltFactory = (String 
configSpec, SolrQueryRequest request,
+      ReplicaListTransformerFactory fallback) -> 
shufflingReplicaListTransformer;
+  private ReplicaListTransformerFactory stableRltFactory;
+  private ReplicaListTransformerFactory defaultRltFactory;
+
+  /**
+   * Private class responsible for applying pairwise sort based on inherent 
replica attributes,
+   * and subsequently reordering any equivalent replica sets according to 
behavior specified
+   * by the baseReplicaListTransformer.
+   */
+  private static final class TopLevelReplicaListTransformer implements 
ReplicaListTransformer {
+
+    private final NodePreferenceRulesComparator replicaComp;
+    private final ReplicaListTransformer baseReplicaListTransformer;
+
+    public TopLevelReplicaListTransformer(NodePreferenceRulesComparator 
replicaComp, ReplicaListTransformer baseReplicaListTransformer) {
+      this.replicaComp = replicaComp;
+      this.baseReplicaListTransformer = baseReplicaListTransformer;
+    }
+
+    @Override
+    public void transform(List<?> choices) {
 
 Review comment:
   I may be very wrong here, but I think the output of this method would be the 
same (or at least the same in practice) if we first run the transformer on all 
the list (which essentially either shuffles it or uses the new affinity code to 
define the order) and then run the `choices.sort(replicaComp)`, since this last 
one is stable, and will maintain the order of equal elements.
   If that's the case, this method could be much simpler, and we don't need to 
find the boundaries, etc, plus the transformer gets called only once instead of 
once per group.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to