jpountz commented on a change in pull request #1440:
URL: https://github.com/apache/lucene-solr/pull/1440#discussion_r412304782



##########
File path: 
lucene/codecs/src/java/org/apache/lucene/codecs/simpletext/SimpleTextSegmentInfoFormat.java
##########
@@ -171,133 +168,17 @@ public SegmentInfo read(Directory directory, String 
segmentName, byte[] segmentI
       SortField[] sortField = new SortField[numSortFields];
       for (int i = 0; i < numSortFields; ++i) {
         SimpleTextUtil.readLine(input, scratch);
-        assert StringHelper.startsWith(scratch.get(), SI_SORT_FIELD);
-        final String field = readString(SI_SORT_FIELD.length, scratch);
+        assert StringHelper.startsWith(scratch.get(), SI_SORT_NAME);
+        final String provider = readString(SI_SORT_NAME.length, scratch);
 
         SimpleTextUtil.readLine(input, scratch);
         assert StringHelper.startsWith(scratch.get(), SI_SORT_TYPE);
-        final String typeAsString = readString(SI_SORT_TYPE.length, scratch);
-
-        final SortField.Type type;
-        SortedSetSelector.Type selectorSet = null;
-        SortedNumericSelector.Type selectorNumeric = null;
-        switch (typeAsString) {
-          case "string":
-            type = SortField.Type.STRING;
-            break;
-          case "long":
-            type = SortField.Type.LONG;
-            break;
-          case "int":
-            type = SortField.Type.INT;
-            break;
-          case "double":
-            type = SortField.Type.DOUBLE;
-            break;
-          case "float":
-            type = SortField.Type.FLOAT;
-            break;
-          case "multi_valued_string":
-            type = SortField.Type.STRING;
-            selectorSet = readSetSelector(input, scratch);
-            break;
-          case "multi_valued_long":
-            type = SortField.Type.LONG;
-            selectorNumeric = readNumericSelector(input, scratch);
-            break;
-          case "multi_valued_int":
-            type = SortField.Type.INT;
-            selectorNumeric = readNumericSelector(input, scratch);
-            break;
-          case "multi_valued_double":
-            type = SortField.Type.DOUBLE;
-            selectorNumeric = readNumericSelector(input, scratch);
-            break;
-          case "multi_valued_float":
-            type = SortField.Type.FLOAT;
-            selectorNumeric = readNumericSelector(input, scratch);
-            break;
-          default:
-            throw new CorruptIndexException("unable to parse sort type string: 
" + typeAsString, input);
-        }
 
         SimpleTextUtil.readLine(input, scratch);
-        assert StringHelper.startsWith(scratch.get(), SI_SORT_REVERSE);
-        final boolean reverse = 
Boolean.parseBoolean(readString(SI_SORT_REVERSE.length, scratch));
-
-        SimpleTextUtil.readLine(input, scratch);
-        assert StringHelper.startsWith(scratch.get(), SI_SORT_MISSING);
-        final String missingLastAsString = readString(SI_SORT_MISSING.length, 
scratch);
-        final Object missingValue;
-        switch (type) {
-          case STRING:
-            switch (missingLastAsString) {
-              case "null":
-                missingValue = null;
-                break;
-              case "first":
-                missingValue = SortField.STRING_FIRST;
-                break;
-              case "last":
-                missingValue = SortField.STRING_LAST;
-                break;
-              default:
-                throw new CorruptIndexException("unable to parse missing 
string: " + typeAsString, input);
-            }
-            break;
-          case LONG:
-            switch (missingLastAsString) {
-              case "null":
-                missingValue = null;
-                break;
-              default:
-                missingValue = Long.parseLong(missingLastAsString);
-                break;
-            }
-            break;
-          case INT:
-            switch (missingLastAsString) {
-              case "null":
-                missingValue = null;
-                break;
-              default:
-                missingValue = Integer.parseInt(missingLastAsString);
-                break;
-            }
-            break;
-          case DOUBLE:
-            switch (missingLastAsString) {
-              case "null":
-                missingValue = null;
-                break;
-              default:
-                missingValue = Double.parseDouble(missingLastAsString);
-                break;
-            }
-            break;
-          case FLOAT:
-            switch (missingLastAsString) {
-              case "null":
-                missingValue = null;
-                break;
-              default:
-                missingValue = Float.parseFloat(missingLastAsString);
-                break;
-            }
-            break;
-          default:
-            throw new AssertionError();
-        }
-        if (selectorSet != null) {
-          sortField[i] = new SortedSetSortField(field, reverse);
-        } else if (selectorNumeric != null) {
-          sortField[i] = new SortedNumericSortField(field, type, reverse);
-        } else {
-          sortField[i] = new SortField(field, type, reverse);
-        }
-        if (missingValue != null) {
-          sortField[i].setMissingValue(missingValue);
-        }
+        assert StringHelper.startsWith(scratch.get(), SI_SORT_BYTES);
+        BytesRef serializedSort = 
SimpleTextUtil.fromBytesRefString(readString(SI_SORT_BYTES.length, scratch));
+        final ByteArrayDataInput bytes = new 
ByteArrayDataInput(serializedSort.bytes, serializedSort.offset, 
serializedSort.length);
+        sortField[i] = 
SortFieldProvider.forName(provider).loadSortField(bytes);

Review comment:
       assert that the bytes have been fully consumed?

##########
File path: 
lucene/backward-codecs/src/java/org/apache/lucene/codecs/lucene84/package.html
##########
@@ -0,0 +1,42 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->

Review comment:
       Two licenses?

##########
File path: lucene/core/src/java/org/apache/lucene/search/SortField.java
##########
@@ -392,4 +491,31 @@ public SortField rewrite(IndexSearcher searcher) throws 
IOException {
   public boolean needsScores() {
     return type == Type.SCORE;
   }
+
+  /**
+   * Returns an {@link IndexSorter} used for sorting index segments by this 
SortField.
+   *
+   * If the SortField cannot be used for index sorting (for example, if it 
uses scores or
+   * other query-dependent values) then this method should return {@code null}
+   *
+   * SortFields that implement this method should also implement a constructor 
that
+   * takes a {@link DataInput} for deserialization, to match the {@link 
IndexSorter#serialize(DataOutput)}
+   * method on the returned IndexSorter
+   */

Review comment:
       make it `lucene.internal`?




----------------------------------------------------------------
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:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to