Skip to content

Commit

Permalink
Some externalizers for Lucene objects do not implement getId()
Browse files Browse the repository at this point in the history
* some methods do not need to be public
* fix some style issues
* remove unneeded @SuppressWarnings("boxing")
  • Loading branch information
anistor authored and tristantarrant committed Sep 13, 2018
1 parent 2279668 commit b574480
Show file tree
Hide file tree
Showing 15 changed files with 34 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,50 @@
* @author Sanne Grinovero
* @since 5.0
*/
@SuppressWarnings("boxing")
public interface ExternalizerIds {

/**
* @see org.infinispan.lucene.FileListCacheKey.Externalizer
*/
static final Integer FILE_LIST_CACHE_KEY = 1300;
Integer FILE_LIST_CACHE_KEY = 1300;

/**
* @see org.infinispan.lucene.FileMetadata.Externalizer
*/
static final Integer FILE_METADATA = 1301;
Integer FILE_METADATA = 1301;

/**
* @see org.infinispan.lucene.FileCacheKey.Externalizer
*/
static final Integer FILE_CACHE_KEY = 1302;
Integer FILE_CACHE_KEY = 1302;

/**
* @see org.infinispan.lucene.ChunkCacheKey.Externalizer
*/
static final Integer CHUNK_CACHE_KEY = 1303;
Integer CHUNK_CACHE_KEY = 1303;

/**
* @see org.infinispan.lucene.FileReadLockKey.Externalizer
*/
static final Integer FILE_READLOCK_KEY = 1304;
Integer FILE_READLOCK_KEY = 1304;

/**
* @see org.infinispan.lucene.FileListCacheKey.Externalizer
*/
static final Integer FILE_LIST_CACHE_VALUE = 1305;
Integer FILE_LIST_CACHE_VALUE = 1305;

/**
* @see org.infinispan.lucene.impl.FileListCacheValueDelta.Externalizer
*/
static final Integer FILE_LIST_VALUE_DELTA = 1306;
Integer FILE_LIST_VALUE_DELTA = 1306;

/**
* @see org.infinispan.lucene.impl.AddOperation.AddOperationExternalizer
*/
static final Integer FILE_LIST_DELTA_ADD = 1307;
Integer FILE_LIST_DELTA_ADD = 1307;

/**
* @see org.infinispan.lucene.impl.DeleteOperation
*/
static final Integer FILE_LIST_DELTA_DEL = 1308;

Integer FILE_LIST_DELTA_DEL = 1308;
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ public Integer getId() {
*/
private static void assureNumberOfClausesLimit(int numberOfClauses) {
final int maxClauseLimit = BooleanQuery.getMaxClauseCount();
if (numberOfClauses>maxClauseLimit) {
if (numberOfClauses > maxClauseLimit) {
BooleanQuery.setMaxClauseCount(numberOfClauses);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
import org.infinispan.commons.marshall.AbstractExternalizer;

public class LuceneBytesRefExternalizer extends AbstractExternalizer<BytesRef> {

@Override
public Integer getId() {
return ExternalizerIds.LUCENE_BYTES_REF;
}

@Override
public Set<Class<? extends BytesRef>> getTypeClasses() {
return Collections.singleton(BytesRef.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,20 @@ static void writeObjectStatic(final ObjectOutput output, final FieldDoc sortFiel
output.writeInt(sortField.shardIndex);
final Object[] fields = sortField.fields;
UnsignedNumeric.writeUnsignedInt(output, fields.length);
for (int i=0; i<fields.length; i++) {
for (int i = 0; i < fields.length; i++) {
output.writeObject(fields[i]);
}
}

public static FieldDoc readObjectStatic(final ObjectInput input) throws IOException, ClassNotFoundException {
static FieldDoc readObjectStatic(final ObjectInput input) throws IOException, ClassNotFoundException {
final float score = input.readFloat();
final int doc = UnsignedNumeric.readUnsignedInt(input);
final int shardId = input.readInt();
final int fieldsArrayLenght = UnsignedNumeric.readUnsignedInt(input);
Object[] fields = new Object[fieldsArrayLenght];
for (int i=0; i<fieldsArrayLenght; i++) {
for (int i = 0; i < fieldsArrayLenght; i++) {
fields[i] = input.readObject();
}
return new FieldDoc(doc, score, fields, shardId);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@
import org.infinispan.commons.marshall.AbstractExternalizer;

/**
*
* @author gustavonalle
* @since 7.1
*/
public class LuceneMatchAllQueryExternalizer extends AbstractExternalizer<MatchAllDocsQuery> {

@Override
public Integer getId() {
return ExternalizerIds.LUCENE_QUERY_MATCH_ALL;
}

@Override
public Set<Class<? extends MatchAllDocsQuery>> getTypeClasses() {
return Collections.singleton(MatchAllDocsQuery.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @since 9.1
*/
public class LucenePrefixQueryExternalizer extends AbstractExternalizer<PrefixQuery> {

@Override
public Set<Class<? extends PrefixQuery>> getTypeClasses() {
return Collections.singleton(PrefixQuery.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private static void writeObjectStatic(final ObjectOutput output, final ScoreDoc
output.writeInt(sortField.shardIndex);
}

private static ScoreDoc readObjectStatic(final ObjectInput input) throws IOException, ClassNotFoundException {
private static ScoreDoc readObjectStatic(final ObjectInput input) throws IOException {
final float score = input.readFloat();
final int doc = UnsignedNumeric.readUnsignedInt(input);
final int shardId = input.readInt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Set<Class<? extends Sort>> getTypeClasses() {
public Sort readObject(final ObjectInput input) throws IOException, ClassNotFoundException {
final int count = UnsignedNumeric.readUnsignedInt(input);
SortField[] sortfields = new SortField[count];
for (int i=0; i<count; i++) {
for (int i = 0; i < count; i++) {
sortfields[i] = LuceneSortFieldExternalizer.readObjectStatic(input);
}
Sort sort = new Sort();
Expand All @@ -36,7 +36,7 @@ public void writeObject(final ObjectOutput output, final Sort sort) throws IOExc
final SortField[] sortFields = sort.getSort();
final int count = sortFields.length;
UnsignedNumeric.writeUnsignedInt(output, count);
for (int i=0; i<count; i++) {
for (int i = 0; i < count; i++) {
LuceneSortFieldExternalizer.writeObjectStatic(output, sortFields[i]);
}
}
Expand All @@ -45,5 +45,4 @@ public void writeObject(final ObjectOutput output, final Sort sort) throws IOExc
public Integer getId() {
return ExternalizerIds.LUCENE_SORT;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ static void writeObjectStatic(final ObjectOutput output, final SortField sortFie
output.writeBoolean(sortField.getReverse());
}

public static SortField readObjectStatic(final ObjectInput input) throws IOException, ClassNotFoundException {
static SortField readObjectStatic(final ObjectInput input) throws IOException, ClassNotFoundException {
final String fieldName = input.readUTF();
final Type sortType = (Type) input.readObject();
final boolean reverseSort = input.readBoolean();
return new SortField(fieldName, sortType, reverseSort);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,4 @@ public void writeObject(final ObjectOutput output, final Term term) throws IOExc
public Integer getId() {
return ExternalizerIds.LUCENE_TERM;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ public void writeObject(final ObjectOutput output, final TermQuery query) throws
public Integer getId() {
return ExternalizerIds.LUCENE_QUERY_TERM;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public TopDocs readObject(final ObjectInput input) throws IOException, ClassNotF
final float maxScore = input.readFloat();
final int scoreCount = UnsignedNumeric.readUnsignedInt(input);
final ScoreDoc[] scoreDocs = new ScoreDoc[scoreCount];
for (int i=0; i<scoreCount; i++) {
for (int i = 0; i < scoreCount; i++) {
scoreDocs[i] = (ScoreDoc) input.readObject();
}
return new TopDocs(totalHits, scoreDocs, maxScore);
Expand All @@ -46,5 +46,4 @@ public void writeObject(final ObjectOutput output, final TopDocs topDocs) throws
public Integer getId() {
return ExternalizerIds.LUCENE_TOPDOCS;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public TopFieldDocs readObject(final ObjectInput input) throws IOException, Clas
final float maxScore = input.readFloat();
final int sortFieldsCount = UnsignedNumeric.readUnsignedInt(input);
final SortField[] sortFields = new SortField[sortFieldsCount];
for (int i=0; i<sortFieldsCount; i++) {
for (int i = 0; i < sortFieldsCount; i++) {
sortFields[i] = LuceneSortFieldExternalizer.readObjectStatic(input);
}
final int scoreDocsCount = UnsignedNumeric.readUnsignedInt(input);
final ScoreDoc[] scoreDocs = new ScoreDoc[scoreDocsCount];
for (int i=0; i<scoreDocsCount; i++) {
for (int i = 0; i < scoreDocsCount; i++) {
scoreDocs[i] = (ScoreDoc) input.readObject();
}
return new TopFieldDocs(totalHits, scoreDocs, sortFields, maxScore);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* @since 9.1
*/
public class LuceneWildcardQueryExternalizer implements AdvancedExternalizer<WildcardQuery> {

@Override
public Set<Class<? extends WildcardQuery>> getTypeClasses() {
return Collections.singleton(WildcardQuery.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* @author anistor@redhat.com
* @since 6.0
*/
@SuppressWarnings("boxing")
public interface ExternalizerIds {

Integer PROTOBUF_VALUE_WRAPPER = 1700;
Expand Down

0 comments on commit b574480

Please sign in to comment.