use of com.yahoo.searchdefinition.parser.ParseException in project vespa by vespa-engine.
the class SearchBuilder method createFromDirectory.
public static SearchBuilder createFromDirectory(String dir, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException {
SearchBuilder builder = new SearchBuilder(MockApplicationPackage.fromSearchDefinitionDirectory(dir), rankProfileRegistry, queryProfileRegistry);
for (Iterator<Path> i = Files.list(new File(dir).toPath()).filter(p -> p.getFileName().toString().endsWith(".sd")).iterator(); i.hasNext(); ) {
builder.importFile(i.next());
}
builder.build(true, new BaseDeployLogger());
return builder;
}
use of com.yahoo.searchdefinition.parser.ParseException in project vespa by vespa-engine.
the class SearchBuilder method importString.
private String importString(String str, String searchDefDir, DeployLogger deployLogger) throws ParseException {
Search search;
SimpleCharStream stream = new SimpleCharStream(str);
try {
search = new SDParser(stream, deployLogger, app, rankProfileRegistry).search(docTypeMgr, searchDefDir);
} catch (TokenMgrError e) {
throw new ParseException("Unknown symbol: " + e.getMessage());
} catch (ParseException pe) {
throw new ParseException(stream.formatException(Exceptions.toMessageString(pe)));
}
return importRawSearch(search);
}
use of com.yahoo.searchdefinition.parser.ParseException in project vespa by vespa-engine.
the class MockApplicationPackage method getSearchDefinitions.
@Override
public List<NamedReader> getSearchDefinitions() {
ArrayList<NamedReader> readers = new ArrayList<>();
SearchBuilder searchBuilder = new SearchBuilder(this, new RankProfileRegistry(), queryProfileRegistry);
for (String sd : searchDefinitions) {
try {
String name = searchBuilder.importString(sd);
readers.add(new NamedReader(name + ApplicationPackage.SD_NAME_SUFFIX, new StringReader(sd)));
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
return readers;
}
use of com.yahoo.searchdefinition.parser.ParseException in project vespa by vespa-engine.
the class Deriver method getUnprocessingSearchBuilder.
public static SearchBuilder getUnprocessingSearchBuilder(List<String> sds) {
SearchBuilder builder = new UnprocessingSearchBuilder();
try {
for (String s : sds) {
builder.importFile(s);
}
} catch (ParseException | IOException e) {
throw new IllegalArgumentException(e);
}
builder.build();
return builder;
}
use of com.yahoo.searchdefinition.parser.ParseException in project vespa by vespa-engine.
the class Deriver method getSearchBuilder.
public static SearchBuilder getSearchBuilder(List<String> sds) {
SearchBuilder builder = new SearchBuilder();
try {
for (String s : sds) {
builder.importFile(s);
}
} catch (ParseException | IOException e) {
throw new IllegalArgumentException(e);
}
builder.build();
return builder;
}
Aggregations