MCPcopy Create free account
hub / github.com/apache/solr / SolrRules

Class SolrRules

solr/modules/sql/src/java/org/apache/solr/handler/sql/SolrRules.java:44–222  ·  view source on GitHub ↗

Rules and relational operators for SolrRel#CONVENTION calling convention.

Source from the content-addressed store, hash-verified

42
43/** Rules and relational operators for {@link SolrRel#CONVENTION} calling convention. */
44class SolrRules {
45 static final RelOptRule[] RULES = {
46 SolrSortRule.SORT_RULE,
47 SolrFilterRule.FILTER_RULE,
48 SolrProjectRule.PROJECT_RULE,
49 SolrAggregateRule.AGGREGATE_RULE,
50 };
51
52 static List<String> solrFieldNames(final RelDataType rowType) {
53 return SqlValidatorUtil.uniquify(
54 new AbstractList<>() {
55 @Override
56 public String get(int index) {
57 return rowType.getFieldList().get(index).getName();
58 }
59
60 @Override
61 public int size() {
62 return rowType.getFieldCount();
63 }
64 },
65 true);
66 }
67
68 /** Translator from {@link RexNode} to strings in Solr's expression language. */
69 static class RexToSolrTranslator extends RexVisitorImpl<String> {
70 private final List<String> inFields;
71
72 RexToSolrTranslator(List<String> inFields) {
73 super(true);
74 this.inFields = inFields;
75 }
76
77 @Override
78 public String visitInputRef(RexInputRef inputRef) {
79 return inFields.get(inputRef.getIndex());
80 }
81
82 @Override
83 public String visitCall(RexCall call) {
84 final List<String> strings = visitList(call.operands);
85 if (call.getKind() == SqlKind.CAST) {
86 return strings.get(0);
87 }
88
89 return super.visitCall(call);
90 }
91
92 private List<String> visitList(List<RexNode> list) {
93 final List<String> strings = new ArrayList<>();
94 for (RexNode node : list) {
95 strings.add(node.accept(this));
96 }
97 return strings;
98 }
99 }
100
101 /**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…