use of com.yahoo.document.DataType in project vespa by vespa-engine.
the class NewDocumentType method getAllTypes.
public DataTypeCollection getAllTypes() {
DataTypeRepo repo = new DataTypeRepo();
Set<Name> seen = new HashSet<>();
Deque<NewDocumentType> stack = new LinkedList<>();
stack.push(this);
while (!stack.isEmpty()) {
NewDocumentType docType = stack.pop();
if (seen.contains(docType.name)) {
// base type
continue;
}
seen.add(docType.name);
for (DataType dataType : docType.getTypes()) {
if (repo.getDataType(dataType.getId()) == null) {
repo.add(dataType);
}
}
stack.addAll(docType.inherits.values());
}
return repo;
}
use of com.yahoo.document.DataType in project vespa by vespa-engine.
the class DocumentModelBuilder method extractDataTypesFromFields.
private static void extractDataTypesFromFields(NewDocumentType dt, Collection<Field> fields) {
for (Field f : fields) {
DataType type = f.getDataType();
if (testAddType(dt, type)) {
extractNestedTypes(dt, type);
addType(dt, type);
}
}
}
use of com.yahoo.document.DataType in project vespa by vespa-engine.
the class FieldOperationApplierForStructs method copyFields.
private void copyFields(SDDocumentType structType, SDDocumentType sdoc) {
// find all fields in OTHER types that have this type:
List<SDDocumentType> list = new ArrayList<>();
list.add(sdoc);
list.addAll(sdoc.getTypes());
for (SDDocumentType anyType : list) {
Iterator<Field> fields = anyType.fieldIterator();
while (fields.hasNext()) {
SDField field = (SDField) fields.next();
DataType structUsedByField = field.getFirstStructRecursive();
if (structUsedByField == null) {
continue;
}
if (structUsedByField.getName().equals(structType.getName())) {
// this field is using this type!!
field.populateWithStructFields(sdoc, field.getName(), field.getDataType(), field.isHeader(), 0);
field.populateWithStructMatching(sdoc, field.getName(), field.getDataType(), field.getMatching());
}
}
}
}
use of com.yahoo.document.DataType in project vespa by vespa-engine.
the class TextMatch method process.
@Override
public void process(boolean validate) {
for (SDField field : search.allConcreteFields()) {
if (field.getMatching().getType() != Matching.Type.TEXT)
continue;
ScriptExpression script = field.getIndexingScript();
if (script == null)
continue;
DataType fieldType = field.getDataType();
if (fieldType instanceof CollectionDataType) {
fieldType = ((CollectionDataType) fieldType).getNestedType();
}
if (fieldType != DataType.STRING)
continue;
Set<String> dynamicSummary = new TreeSet<>();
Set<String> staticSummary = new TreeSet<>();
new IndexingOutputs(search, deployLogger, rankProfileRegistry, queryProfiles).findSummaryTo(search, field, dynamicSummary, staticSummary);
MyVisitor visitor = new MyVisitor(dynamicSummary);
visitor.visit(script);
if (!visitor.requiresTokenize)
continue;
ExpressionConverter converter = new MyStringTokenizer(search, findAnnotatorConfig(search, field));
field.setIndexingScript((ScriptExpression) converter.convert(script));
}
}
use of com.yahoo.document.DataType in project vespa by vespa-engine.
the class AddExtraFieldsToDocument method addSdField.
private void addSdField(Search search, SDDocumentType document, SDField field, boolean validate) {
if (field.getIndexToCount() == 0 && field.getAttributes().isEmpty()) {
return;
}
for (Attribute atr : field.getAttributes().values()) {
if (atr.getName().equals(field.getName() + "_position")) {
DataType type = PositionDataType.INSTANCE;
if (atr.getCollectionType().equals(Attribute.CollectionType.ARRAY)) {
type = DataType.getArray(type);
}
addField(search, document, new SDField(document, atr.getName(), type), validate);
} else if (!atr.getName().equals(field.getName())) {
addField(search, document, new SDField(document, atr.getName(), atr.getDataType()), validate);
}
}
addField(search, document, field, validate);
}
Aggregations