Skip to content

Commit 9c8b8b0

Browse files
committed
HSEARCH-5021 Remove the array check from a vector DefaultInitiator
1 parent e5a206e commit 9c8b8b0

File tree

3 files changed

+4
-22
lines changed

3 files changed

+4
-22
lines changed

integrationtest/mapper/pojo-base/src/test/java/org/hibernate/search/integrationtest/mapper/pojo/mapping/definition/VectorFieldIT.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -346,13 +346,7 @@ class IndexedEntity {
346346
.typeContext( IndexedEntity.class.getName() )
347347
.pathContext( ".notVector" )
348348
.failure(
349-
"Unable to apply property mapping: this property mapping must target an index field of vector type",
350-
"but the resolved field type is non-vector",
351-
"This generally means you need to use a different field annotation"
352-
+ " or to convert property values using a custom ValueBridge or ValueBinder",
353-
"If you are already using a custom ValueBridge or ValueBinder, check its field type",
354-
"encountered type DSL step '",
355-
"expected interface '" + VectorFieldTypeOptionsStep.class.getName() + "'"
349+
"Vectors of java.lang.Integer type are not supported"
356350
) );
357351
}
358352

@@ -372,12 +366,7 @@ class IndexedEntity {
372366
.typeContext( IndexedEntity.class.getName() )
373367
.pathContext( ".bytes" )
374368
.failure(
375-
"Unable to apply property mapping: this property mapping must target an index field of vector type, but the resolved field type is non-vector",
376-
"This generally means you need to use a different field annotation"
377-
+ " or to convert property values using a custom ValueBridge or ValueBinder",
378-
"If you are already using a custom ValueBridge or ValueBinder, check its field type",
379-
"encountered type DSL step '",
380-
"expected interface '" + VectorFieldTypeOptionsStep.class.getName() + "'"
369+
"Vectors of java.lang.Integer type are not supported"
381370
) );
382371
}
383372

mapper/pojo-base/src/main/java/org/hibernate/search/mapper/pojo/mapping/definition/programmatic/impl/PropertyMappingVectorFieldOptionsStepImpl.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,7 @@ public <F> IndexFieldTypeOptionsStep<?, F> initiate(IndexFieldTypeFactory factor
3636
if ( dimension == null ) {
3737
throw log.vectorDimensionNotSpecified();
3838
}
39-
// we consider arrays (byte[] and float[] in particular to be vector types, anything else will be
40-
// treated as a non-vector field and delegated to a regular as(..) call.
41-
if ( clazz.isArray() ) {
42-
return factory.asVector( dimension, clazz );
43-
}
44-
else {
45-
return factory.as( clazz );
46-
}
39+
return factory.asVector( dimension, clazz );
4740
}
4841
},
4942
FieldModelContributorContext::vectorTypeOptionsStep );

util/internal/integrationtest/common/src/main/java/org/hibernate/search/util/impl/integrationtest/common/stub/backend/types/dsl/impl/StubIndexFieldTypeFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public <F> VectorFieldTypeOptionsStep<?, F> asVector(int dimension, Class<F> val
167167
if ( float[].class.equals( valueType ) ) {
168168
return (VectorFieldTypeOptionsStep<?, F>) asFloatVector( dimension );
169169
}
170-
return new StubVectorFieldTypeOptionsStep<>( dimension, valueType );
170+
throw new IllegalArgumentException("Vectors of " + valueType.getName() + " type are not supported.");
171171
}
172172

173173
@Override

0 commit comments

Comments
 (0)