use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class DocumentScriptTestCase method assertSpanTrees.
private static void assertSpanTrees(FieldValue actual, String... expectedSpanTrees) {
assertTrue(actual instanceof StringFieldValue);
StringFieldValue str = (StringFieldValue) actual;
assertEquals(new ArrayList<>(Arrays.asList(expectedSpanTrees)), new ArrayList<>(str.getSpanTreeMap().keySet()));
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class JsonRenderer method shouldRender.
private boolean shouldRender(String fieldName, Hit hit) {
if (debugRendering)
return true;
if (fieldName.startsWith(VESPA_HIDDEN_FIELD_PREFIX))
return false;
RenderDecision r = lazyRenderAwareCheck(fieldName, hit);
if (r != RenderDecision.DO_NOT_KNOW)
return r.booleanValue();
// this will trigger field decoding, so it is important the lazy decoding magic is done first
Object field = hit.getField(fieldName);
if (field instanceof CharSequence && ((CharSequence) field).length() == 0)
return false;
// StringFieldValue cannot hold a null, so checking length directly is OK:
if (field instanceof StringFieldValue && ((StringFieldValue) field).getString().isEmpty())
return false;
if (field instanceof NanNumber)
return false;
return true;
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class TokenizeExpression method doExecute.
@Override
protected void doExecute(ExecutionContext context) {
StringFieldValue input = (StringFieldValue) context.getValue();
StringFieldValue output = input.clone();
context.setValue(output);
AnnotatorConfig cfg = new AnnotatorConfig(config);
Language lang = context.resolveLanguage(linguistics);
if (lang != null) {
cfg.setLanguage(lang);
}
LinguisticsAnnotator annotator = new LinguisticsAnnotator(linguistics, cfg);
annotator.annotate(output);
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class Base64EncodeExpression method doExecute.
@Override
protected void doExecute(ExecutionContext ctx) {
long input = ((LongFieldValue) ctx.getValue()).getLong();
byte[] output = new byte[8];
for (int i = 0; i < output.length; ++i) {
output[i] = (byte) (input & 0xffL);
input >>>= 8;
}
String encoded = new Base64(0).encodeToString(output);
ctx.setValue(new StringFieldValue(encoded));
}
use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.
the class NormalizeExpression method doExecute.
@Override
protected void doExecute(ExecutionContext context) {
Transformer transformer = linguistics.getTransformer();
context.setValue(new StringFieldValue(transformer.accentDrop(String.valueOf(context.getValue()), context.resolveLanguage(linguistics))));
}
Aggregations