diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-06-15 23:09:44 +0200 |
commit | 72231250ed81e10d66bfe70701e64fa5fe50f712 (patch) | |
tree | 2728bba1131a6f6e5bdf95afec7d7ff9358dac50 /container-search/src/main/java/com/yahoo/prelude/fastsearch/Int64Field.java |
Publish
Diffstat (limited to 'container-search/src/main/java/com/yahoo/prelude/fastsearch/Int64Field.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/prelude/fastsearch/Int64Field.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/fastsearch/Int64Field.java b/container-search/src/main/java/com/yahoo/prelude/fastsearch/Int64Field.java new file mode 100644 index 00000000000..2759f313d52 --- /dev/null +++ b/container-search/src/main/java/com/yahoo/prelude/fastsearch/Int64Field.java @@ -0,0 +1,57 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +/** + * Class representing a integer field in the result set + * + */ +package com.yahoo.prelude.fastsearch; + + +import java.nio.ByteBuffer; + +import com.yahoo.search.result.NanNumber; +import com.yahoo.data.access.Inspector; + + +/** + * @author <a href="mailto:borud@yahoo-inc.com">Bj\u00f8rn Borud</a> + */ +public class Int64Field extends DocsumField { + static final long EMPTY_VALUE = Long.MIN_VALUE; + + public Int64Field(String name) { + super(name); + } + + private Object convert(long value) { + if (value == EMPTY_VALUE) { + return NanNumber.NaN; + } else { + return Long.valueOf(value); + } + } + + public Object decode(ByteBuffer b) { + return convert(b.getLong()); + } + + public Object decode(ByteBuffer b, FastHit hit) { + Object field = decode(b); + hit.setField(name, field); + return field; + } + + public String toString() { + return "field " + getName() + " type int64"; + } + + public int getLength(ByteBuffer b) { + int offset = b.position(); + final int bytelength = Long.SIZE >> 3; + b.position(offset + bytelength); + return bytelength; + } + + public Object convert(Inspector value) { + return convert(value.asLong(EMPTY_VALUE)); + } +} |