use of org.hibernate.search.engine.backend.document.IndexObjectFieldReference in project hibernate-search by hibernate.
the class PojoIndexingProcessorCastedTypeNode method process.
@Override
// As long as T is not a proxy-specific interface, it will also be implemented by the unproxified object
@SuppressWarnings("unchecked")
public final void process(DocumentElement target, T source, PojoIndexingProcessorRootContext context) {
if (source == null) {
return;
}
source = (T) context.sessionContext().runtimeIntrospector().unproxy(source);
// The caster can only cast to the raw type, beyond that we have to use an unchecked cast.
@SuppressWarnings("unchecked") U castedSource = (U) caster.cast(source);
// which may be costly (reflection, ...)
if (isEntityType && context.isDeleted(castedSource)) {
return;
}
DocumentElement parentObject = target;
for (IndexObjectFieldReference objectFieldReference : parentIndexObjectReferences) {
parentObject = parentObject.addObject(objectFieldReference);
}
nested.process(parentObject, castedSource, context);
}
use of org.hibernate.search.engine.backend.document.IndexObjectFieldReference in project infinispan by infinispan.
the class IndexingTagHandler method pushContext.
private void pushContext(FieldDescriptor fieldDescriptor, Descriptor messageDescriptor) {
String fieldPath = messageContext.getFieldPath();
fieldPath = fieldPath != null ? fieldPath + '.' + fieldDescriptor.getName() : fieldDescriptor.getName();
DocumentElement documentElement = null;
if (messageContext.getDocument() != null) {
IndexObjectFieldReference objectReference = indexReferenceHolder.getObjectReference(fieldPath);
if (objectReference != null) {
documentElement = messageContext.getDocument().addObject(objectReference);
}
}
messageContext = new IndexingMessageContext(messageContext, fieldDescriptor, messageDescriptor, documentElement);
}
use of org.hibernate.search.engine.backend.document.IndexObjectFieldReference in project infinispan by infinispan.
the class ProtobufMessageBinder method createIndexReferenceProvider.
private IndexReferenceHolder createIndexReferenceProvider(TypeBindingContext context, int maxDepth) {
final Map<String, IndexFieldReference<?>> fieldReferenceMap = new HashMap<>();
final Map<String, IndexObjectFieldReference> objectReferenceMap = new HashMap<>();
Stack<State> stack = new Stack<>();
stack.push(new State(globalReferenceHolder.getMessageReferenceProviders().get(rootMessageName), "", context.indexSchemaElement(), 0));
while (!stack.isEmpty()) {
State currentState = stack.pop();
fieldReferenceMap.putAll(currentState.bind());
if (currentState.depth == maxDepth) {
continue;
}
for (MessageReferenceProvider.Embedded embedded : currentState.messageReferenceProvider.getEmbedded()) {
String newPath = ("".equals(currentState.path)) ? embedded.getFieldName() : currentState.path + "." + embedded.getFieldName();
String typeName = embedded.getTypeFullName();
MessageReferenceProvider messageReferenceProvider = globalReferenceHolder.getMessageReferenceProviders().get(typeName);
IndexSchemaObjectField indexSchemaElement = currentState.indexSchemaElement.objectField(embedded.getFieldName());
if (embedded.isRepeated()) {
indexSchemaElement.multiValued();
}
objectReferenceMap.put(newPath, indexSchemaElement.toReference());
State state = new State(messageReferenceProvider, newPath, indexSchemaElement, currentState.depth + 1);
stack.push(state);
}
}
return new IndexReferenceHolder(fieldReferenceMap, objectReferenceMap);
}
use of org.hibernate.search.engine.backend.document.IndexObjectFieldReference in project hibernate-search by hibernate.
the class PojoIndexingProcessorOriginalTypeNode method process.
@Override
// As long as T is not a proxy-specific interface, it will also be implemented by the unproxified object
@SuppressWarnings("unchecked")
public final void process(DocumentElement target, T source, PojoIndexingProcessorRootContext context) {
if (source == null) {
return;
}
source = (T) context.sessionContext().runtimeIntrospector().unproxy(source);
// which may be costly (reflection, ...)
if (isEntityType && context.isDeleted(source)) {
return;
}
DocumentElement parentObject = target;
for (IndexObjectFieldReference objectFieldReference : parentIndexObjectReferences) {
parentObject = parentObject.addObject(objectFieldReference);
}
nested.process(parentObject, source, context);
}
Aggregations