-
Notifications
You must be signed in to change notification settings - Fork 551
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
35c1c7e
commit 64940d4
Showing
10 changed files
with
59 additions
and
1,018 deletions.
There are no files selected for viewing
334 changes: 0 additions & 334 deletions
334
sql/src/main/java/io/crate/action/sql/query/CrateSearchService.java
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
sql/src/main/java/io/crate/action/sql/query/LuceneSortGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Licensed to CRATE Technology GmbH ("Crate") under one or more contributor | ||
* license agreements. See the NOTICE file distributed with this work for | ||
* additional information regarding copyright ownership. Crate 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. | ||
* | ||
* However, if you have executed another commercial license agreement | ||
* with Crate these terms will supersede the license and you may use the | ||
* software solely pursuant to the terms of the relevant commercial agreement. | ||
*/ | ||
|
||
package io.crate.action.sql.query; | ||
|
||
import io.crate.analyze.OrderBy; | ||
import io.crate.operation.collect.CollectInputSymbolVisitor; | ||
import io.crate.operation.reference.doc.lucene.LuceneCollectorExpression; | ||
import io.crate.planner.symbol.Symbol; | ||
import org.apache.lucene.search.Sort; | ||
import org.apache.lucene.search.SortField; | ||
import org.elasticsearch.search.internal.SearchContext; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.List; | ||
|
||
public class LuceneSortGenerator { | ||
|
||
@Nullable | ||
private static Sort generateLuceneSort(SearchContext context, | ||
List<Symbol> symbols, | ||
boolean[] reverseFlags, | ||
Boolean[] nullsFirst, | ||
SortSymbolVisitor sortSymbolVisitor) { | ||
if (symbols.isEmpty()) { | ||
return null; | ||
} | ||
SortField[] sortFields = sortSymbolVisitor.generateSortFields(symbols, context, reverseFlags, nullsFirst); | ||
return new Sort(sortFields); | ||
} | ||
|
||
@Nullable | ||
public static Sort generateLuceneSort(SearchContext context, | ||
OrderBy orderBy, | ||
CollectInputSymbolVisitor<LuceneCollectorExpression<?>> inputSymbolVisitor) { | ||
SortSymbolVisitor sortSymbolVisitor = new SortSymbolVisitor(inputSymbolVisitor); | ||
return generateLuceneSort(context, orderBy.orderBySymbols(), orderBy.reverseFlags(), orderBy.nullsFirst(), sortSymbolVisitor); | ||
} | ||
} |
Oops, something went wrong.