-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduced workarounds to work with Solr 7.x. Also added a
FileNameDataProcessor.
- Loading branch information
Pascal Essiembre
authored and
Pascal Essiembre
committed
Feb 2, 2018
1 parent
ae483a5
commit 99d8a50
Showing
8 changed files
with
367 additions
and
105 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -23,3 +23,4 @@ classes/ | |
/.project | ||
/.settings | ||
/dist/ | ||
/gradle.properties |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#Tue Aug 29 16:24:53 CEST 2017 | ||
#Fri Feb 02 17:11:26 EST 2018 | ||
versionString=6.4.0_b01 | ||
buildNumber=154 | ||
buildDate=2017-08-29-1624 | ||
buildNumber=162 | ||
buildDate=2018-02-02-1711 |
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
219 changes: 156 additions & 63 deletions
219
src/main/java/net/semanticmetadata/lire/solr/LireRequestHandler.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
29 changes: 29 additions & 0 deletions
29
src/main/java/net/semanticmetadata/lire/solr/indexing/FileNameDataProcessor.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,29 @@ | ||
package net.semanticmetadata.lire.solr.indexing; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
|
||
/** | ||
* This data processor removes the path from the file to keep only | ||
* the last segment (the actual file name), and store it as the title. The | ||
* same file name is used for the identifier, minus the extension (if any). | ||
* @author Pascal Essiembre | ||
*/ | ||
public class FileNameDataProcessor implements ImageDataProcessor { | ||
|
||
@Override | ||
public CharSequence getTitle(String filename) { | ||
return StringUtils.substringAfterLast( | ||
filename.replace('\\', '/'), "/"); | ||
} | ||
|
||
@Override | ||
public CharSequence getIdentifier(String filename) { | ||
return StringUtils.substringBefore(StringUtils.substringAfterLast( | ||
filename.replace('\\', '/'), "/"), "."); | ||
} | ||
|
||
@Override | ||
public CharSequence getAdditionalFields(String filename) { | ||
return ""; | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
src/main/java/net/semanticmetadata/lire/solr/tools/RandomAccessBinaryDocValues.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,88 @@ | ||
package net.semanticmetadata.lire.solr.tools; | ||
|
||
import java.io.IOException; | ||
import java.util.function.Supplier; | ||
|
||
import org.apache.lucene.index.BinaryDocValues; | ||
import org.apache.lucene.util.BytesRef; | ||
|
||
|
||
/** | ||
* Wraps a {@link BinaryDocValues} creation strategy so it can be reset | ||
* if needed. This is a hack to port liresolr to Lucene 7+ (which enforces | ||
* ordered doc values) until a more formal solution is in place. | ||
* @author Pascal Essiembre | ||
*/ | ||
public class RandomAccessBinaryDocValues extends BinaryDocValues { | ||
|
||
private final Supplier<BinaryDocValues> supplier; | ||
private BinaryDocValues docValues; | ||
|
||
public RandomAccessBinaryDocValues(Supplier<BinaryDocValues> supplier) { | ||
super(); | ||
this.supplier = supplier; | ||
this.docValues = supplier.get(); | ||
} | ||
|
||
@Override | ||
public BytesRef binaryValue() throws IOException { | ||
if (docValues == null) { | ||
return new BytesRef(BytesRef.EMPTY_BYTES); | ||
} | ||
return docValues.binaryValue(); | ||
} | ||
|
||
@Override | ||
public boolean advanceExact(int target) throws IOException { | ||
resetIfNeeded(target); | ||
if (docValues == null) { | ||
return false; | ||
} | ||
return docValues.advanceExact(target); | ||
} | ||
|
||
@Override | ||
public int docID() { | ||
if (docValues == null) { | ||
return NO_MORE_DOCS; | ||
} | ||
return docValues.docID(); | ||
} | ||
|
||
@Override | ||
public int nextDoc() throws IOException { | ||
if (docValues == null) { | ||
return NO_MORE_DOCS; | ||
} | ||
return docValues.nextDoc(); | ||
} | ||
|
||
@Override | ||
public int advance(int target) throws IOException { | ||
resetIfNeeded(target); | ||
if (docValues == null) { | ||
return NO_MORE_DOCS; | ||
} | ||
return docValues.advance(target); | ||
} | ||
|
||
@Override | ||
public long cost() { | ||
if (docValues == null) { | ||
return 0; | ||
} | ||
return docValues.cost(); | ||
} | ||
|
||
private void resetIfNeeded(int target) { | ||
if (docValues == null) { | ||
docValues = supplier.get(); | ||
} else { | ||
int id = docValues.docID(); | ||
if (id != -1 && id != NO_MORE_DOCS | ||
&& target < docValues.docID()) { | ||
docValues = supplier.get(); | ||
} | ||
} | ||
} | ||
} |