Skip to content

Commit 1c701c0

Browse files
committed
update luence version to 9.12.3
1 parent bbd05b4 commit 1c701c0

17 files changed

Lines changed: 37 additions & 2808 deletions

File tree

modules/indexing/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373

7474
<dependency>
7575
<groupId>org.apache.lucene</groupId>
76-
<artifactId>lucene-analyzers-common</artifactId>
76+
<artifactId>lucene-analysis-common</artifactId>
7777
<version>${lucene.version}</version>
7878
</dependency>
7979

modules/indexing/src/main/java/org/apache/ignite/cache/FullTextLucene.java

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,9 @@
5252
import org.apache.ignite.internal.util.typedef.internal.U;
5353
import org.apache.lucene.analysis.Analyzer;
5454
import org.apache.lucene.analysis.standard.StandardAnalyzer;
55-
import org.apache.lucene.document.DateTools;
56-
import org.apache.lucene.document.Document;
57-
import org.apache.lucene.document.DoubleDocValuesField;
58-
import org.apache.lucene.document.DoublePoint;
59-
import org.apache.lucene.document.Field;
60-
import org.apache.lucene.document.FieldType;
61-
import org.apache.lucene.document.FloatDocValuesField;
62-
import org.apache.lucene.document.FloatPoint;
63-
import org.apache.lucene.document.IntPoint;
64-
import org.apache.lucene.document.LongPoint;
65-
import org.apache.lucene.document.NumericDocValuesField;
66-
import org.apache.lucene.document.StoredField;
67-
import org.apache.lucene.document.StringField;
68-
import org.apache.lucene.document.TextField;
55+
import org.apache.lucene.document.*;
6956
import org.apache.lucene.document.Field.Store;
70-
import org.apache.lucene.index.DirectoryReader;
71-
import org.apache.lucene.index.IndexReader;
72-
import org.apache.lucene.index.IndexWriterConfig;
73-
import org.apache.lucene.index.Term;
57+
import org.apache.lucene.index.*;
7458
import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
7559
import org.apache.lucene.queryparser.classic.QueryParser;
7660
import org.apache.lucene.search.BooleanClause;
@@ -171,7 +155,7 @@ private static String cacheName(String schema,String table){
171155
if(schema==null || schema.isEmpty()){
172156
return table;
173157
}
174-
if(table==null || table.length()==0){
158+
if(table==null || table.isEmpty()){
175159
return schema.toUpperCase();
176160
}
177161
if(ctx.cache().cacheNames().contains(schema)){
@@ -191,7 +175,6 @@ else if(ctx.cache().cacheNames().contains(schema.toUpperCase())){
191175
* @return Object.
192176
* @throws IgniteCheckedException If failed.
193177
*/
194-
@SuppressWarnings("unchecked")
195178
private static <Z> Z unmarshall(byte[] bytes, ClassLoader ldr,CacheObjectContext coctx) throws IgniteCheckedException {
196179
if (coctx == null) // For tests.
197180
return (Z)JdbcUtils.deserialize(bytes, null);
@@ -619,7 +602,7 @@ public static LuceneIndexAccess getIndexAccess(Connection conn,String schema,Str
619602

620603
if (!access.typeFields.containsKey(table) || access.typeFields.get(table).isEmpty()) {
621604
//fill indexed fields
622-
if(table!=null && table.length()!=0){
605+
if(table!=null && !table.isEmpty()){
623606

624607
// read index desc form FTL.INDEXES
625608
if(conn!=null){
@@ -841,7 +824,7 @@ protected static ResultSet search(Connection conn, String forschema, String tabl
841824
// this is just to query the result set columns
842825
return result;
843826
}
844-
if (text == null || text.trim().length() == 0) {
827+
if (text == null || text.trim().isEmpty()) {
845828
return result;
846829
}
847830
try {
@@ -1336,11 +1319,11 @@ else if (obj instanceof short[]) {
13361319
doc.add(row);
13371320
}
13381321
else if (obj instanceof float[]) {
1339-
row = new FloatPoint(idxdField, (float[])obj);
1322+
row = new KnnFloatVectorField(idxdField, (float[])obj, VectorSimilarityFunction.COSINE);
13401323
doc.add(row);
13411324
}
13421325
else if (obj instanceof double[]) {
1343-
row = new DoublePoint(idxdField, (double[])obj);
1326+
row = new KnnFloatVectorField(idxdField, doubleToFloat((double[])obj),VectorSimilarityFunction.COSINE);
13441327
doc.add(row);
13451328
}
13461329
} catch (Exception e) {
@@ -1349,5 +1332,17 @@ else if (obj instanceof double[]) {
13491332
}
13501333
return true;
13511334
}
1335+
1336+
1337+
/**
1338+
* 将 double 数组转换为 float 数组
1339+
*/
1340+
public static float[] doubleToFloat(double[] doubleVector) {
1341+
float[] floatVector = new float[doubleVector.length];
1342+
for (int i = 0; i < doubleVector.length; i++) {
1343+
floatVector[i] = (float) doubleVector[i];
1344+
}
1345+
return floatVector;
1346+
}
13521347
}
13531348

modules/indexing/src/main/java/org/apache/ignite/cache/LuceneIndexAccess.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,6 @@ public static LuceneIndexAccess getIndexAccess(GridKernalContext ctx, String cac
382382
* set.
383383
*
384384
* @param access the index writer/searcher wrapper
385-
* @param indexPath the index path
386385
*/
387386
public static void removeIndexAccess(LuceneIndexAccess access) {
388387
synchronized (INDEX_ACCESS) {
@@ -394,6 +393,4 @@ public static void removeIndexAccess(LuceneIndexAccess access) {
394393
}
395394
}
396395
}
397-
398-
399396
}

modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/opt/GridLuceneIndex.java

Lines changed: 11 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -17,76 +17,36 @@
1717

1818
package org.apache.ignite.internal.processors.query.h2.opt;
1919

20-
import java.io.FileInputStream;
21-
import java.io.IOException;
22-
import java.io.InputStream;
23-
import java.net.URL;
24-
import java.nio.charset.Charset;
25-
import java.nio.charset.StandardCharsets;
26-
import java.sql.SQLException;
27-
import java.util.Collection;
28-
import java.util.HashSet;
29-
import java.util.Iterator;
30-
import java.util.Map;
31-
import java.util.Set;
32-
import java.util.concurrent.atomic.AtomicLong;
33-
3420
import org.apache.ignite.IgniteCheckedException;
3521
import org.apache.ignite.cache.FullTextLucene;
36-
import org.apache.ignite.cache.FullTextQueryIndex;
37-
import org.apache.ignite.cache.LuceneConfiguration;
3822
import org.apache.ignite.cache.LuceneIndexAccess;
39-
import org.apache.ignite.cache.QueryIndex;
40-
import org.apache.ignite.cache.query.TextQuery;
4123
import org.apache.ignite.internal.GridKernalContext;
4224
import org.apache.ignite.internal.processors.cache.CacheObject;
4325
import org.apache.ignite.internal.processors.cache.CacheObjectContext;
44-
import org.apache.ignite.internal.processors.cache.query.ScoredCacheEntry;
4526
import org.apache.ignite.internal.processors.cache.GridCacheAdapter;
27+
import org.apache.ignite.internal.processors.cache.query.ScoredCacheEntry;
4628
import org.apache.ignite.internal.processors.cache.version.GridCacheVersion;
47-
import org.apache.ignite.internal.processors.query.GridQueryIndexDescriptor;
4829
import org.apache.ignite.internal.processors.query.GridQueryTypeDescriptor;
49-
import org.apache.ignite.internal.processors.query.QueryUtils;
50-
import org.apache.ignite.internal.util.GridAtomicLong;
30+
import org.apache.ignite.internal.processors.query.QueryIndexDescriptorImpl;
5131
import org.apache.ignite.internal.util.GridCloseableIteratorAdapter;
5232
import org.apache.ignite.internal.util.lang.GridCloseableIterator;
53-
import org.apache.ignite.internal.util.offheap.unsafe.GridUnsafeMemory;
54-
import org.apache.ignite.internal.util.typedef.X;
5533
import org.apache.ignite.internal.util.typedef.internal.U;
5634
import org.apache.ignite.lang.IgniteBiTuple;
57-
import org.apache.ignite.spi.indexing.IndexingQueryFilter;
5835
import org.apache.ignite.spi.indexing.IndexingQueryCacheFilter;
59-
import org.apache.lucene.analysis.Analyzer;
60-
import org.apache.lucene.analysis.standard.StandardAnalyzer;
61-
import org.apache.lucene.document.BinaryDocValuesField;
62-
import org.apache.lucene.document.Document;
63-
import org.apache.lucene.document.Field;
64-
import org.apache.lucene.document.FieldType;
65-
import org.apache.lucene.document.LongPoint;
66-
import org.apache.lucene.document.StoredField;
67-
import org.apache.lucene.document.StringField;
68-
import org.apache.lucene.document.TextField;
69-
70-
36+
import org.apache.ignite.spi.indexing.IndexingQueryFilter;
37+
import org.apache.lucene.document.*;
7138
import org.apache.lucene.index.Term;
7239
import org.apache.lucene.queryparser.classic.MultiFieldQueryParser;
7340
import org.apache.lucene.queryparser.classic.QueryParser.Operator;
74-
import org.apache.lucene.search.BooleanClause;
75-
import org.apache.lucene.search.BooleanQuery;
76-
import org.apache.lucene.search.IndexSearcher;
77-
import org.apache.lucene.search.Query;
78-
import org.apache.lucene.search.ScoreDoc;
79-
import org.apache.lucene.search.Sort;
80-
import org.apache.lucene.search.SortField;
81-
import org.apache.lucene.search.TermQuery;
82-
import org.apache.lucene.search.TopDocs;
41+
import org.apache.lucene.search.*;
8342
import org.apache.lucene.util.BytesRef;
8443
import org.h2.util.JdbcUtils;
8544
import org.jetbrains.annotations.Nullable;
86-
import org.apache.ignite.internal.processors.query.QueryIndexDescriptorImpl;
45+
46+
import java.io.IOException;
47+
import java.util.Map;
8748

8849
import static org.apache.ignite.internal.processors.query.QueryUtils.KEY_FIELD_NAME;
89-
import static org.apache.ignite.internal.processors.query.QueryUtils.VAL_FIELD_NAME;
9050

9151

9252

@@ -330,12 +290,12 @@ else if(item.startsWith("author:")){
330290

331291
if(orderBy!=null){
332292
String[] sorts = orderBy.split(",");
333-
Sort sortObj = new Sort();
293+
334294
SortField[] sf = new SortField[sorts.length];
335295
for(int j=0;j<sorts.length;j++){
336296
sf[j] = new SortField(sorts[j],SortField.Type.DOUBLE,true);
337297
}
338-
sortObj.setSort(sf);
298+
Sort sortObj = new Sort(sf);
339299
docs = searcher.search(query.build(), limit, sortObj);
340300
}
341301
else{
@@ -344,7 +304,6 @@ else if(item.startsWith("author:")){
344304
}
345305
catch (Exception e) {
346306
//U.closeQuiet(indexAccess.reader);
347-
348307
throw new IgniteCheckedException(e);
349308
}
350309

@@ -391,7 +350,6 @@ private class It<K, V> extends GridCloseableIteratorAdapter<IgniteBiTuple<K, V>
391350
/**
392351
* Constructor.
393352
*
394-
* @param reader Reader.
395353
* @param searcher Searcher.
396354
* @param docs Docs.
397355
* @param filters Filters over result.
@@ -415,7 +373,6 @@ private It(IndexSearcher searcher, ScoreDoc[] docs, IndexingQueryCacheFilter fil
415373
* @return Object.
416374
* @throws IgniteCheckedException If failed.
417375
*/
418-
@SuppressWarnings("unchecked")
419376
private <Z> Z unmarshall(byte[] bytes, ClassLoader ldr) throws IgniteCheckedException {
420377
if (coctx == null) // For tests.
421378
return (Z)JdbcUtils.deserialize(bytes, null);
@@ -428,7 +385,6 @@ private <Z> Z unmarshall(byte[] bytes, ClassLoader ldr) throws IgniteCheckedExce
428385
*
429386
* @throws IgniteCheckedException If failed.
430387
*/
431-
@SuppressWarnings("unchecked")
432388
private void findNext() throws IgniteCheckedException {
433389
curr = null;
434390
ClassLoader ldr = null;
@@ -445,9 +401,8 @@ private void findNext() throws IgniteCheckedException {
445401
float score;
446402

447403
try {
448-
doc = searcher.doc(docs[idx].doc);
404+
doc = searcher.storedFields().document(docs[idx].doc);
449405
score = docs[idx].score;
450-
451406
idx++;
452407
}
453408
catch (IOException e) {

modules/rest-http/README.txt

Lines changed: 0 additions & 78 deletions
This file was deleted.

0 commit comments

Comments
 (0)