Example usage for org.apache.lucene.document InetAddressPoint decode

List of usage examples for org.apache.lucene.document InetAddressPoint decode

Introduction

In this page you can find the example usage for org.apache.lucene.document InetAddressPoint decode.

Prototype

public static InetAddress decode(byte value[]) 

Source Link

Document

Decodes InetAddress value from binary encoding

Usage

From source file:org.codelibs.elasticsearch.action.fieldstats.FieldStats.java

License:Apache License

public static FieldStats readFrom(StreamInput in) throws IOException {
    byte type = in.readByte();
    long maxDoc = in.readLong();
    long docCount = in.readLong();
    long sumDocFreq = in.readLong();
    long sumTotalTermFreq = in.readLong();
    boolean isSearchable = in.readBoolean();
    boolean isAggregatable = in.readBoolean();
    boolean hasMinMax = true;
    if (in.getVersion().onOrAfter(Version.V_5_2_0_UNRELEASED)) {
        hasMinMax = in.readBoolean();//w  w  w  .jav a  2 s  .  co  m
    }
    switch (type) {
    case 0:
        if (hasMinMax) {
            return new Long(maxDoc, docCount, sumDocFreq, sumTotalTermFreq, isSearchable, isAggregatable,
                    in.readLong(), in.readLong());
        } else {
            return new Long(maxDoc, docCount, sumDocFreq, sumTotalTermFreq, isSearchable, isAggregatable);
        }
    case 1:
        if (hasMinMax) {
            return new Double(maxDoc, docCount, sumDocFreq, sumTotalTermFreq, isSearchable, isAggregatable,
                    in.readDouble(), in.readDouble());
        } else {
            return new Double(maxDoc, docCount, sumDocFreq, sumTotalTermFreq, isSearchable, isAggregatable);
        }
    case 2:
        if (hasMinMax) {
            FormatDateTimeFormatter formatter = Joda.forPattern(in.readString());
            return new Date(maxDoc, docCount, sumDocFreq, sumTotalTermFreq, isSearchable, isAggregatable,
                    formatter, in.readLong(), in.readLong());
        } else {
            return new Date(maxDoc, docCount, sumDocFreq, sumTotalTermFreq, isSearchable, isAggregatable);
        }
    case 3:
        if (hasMinMax) {
            return new Text(maxDoc, docCount, sumDocFreq, sumTotalTermFreq, isSearchable, isAggregatable,
                    in.readBytesRef(), in.readBytesRef());
        } else {
            return new Text(maxDoc, docCount, sumDocFreq, sumTotalTermFreq, isSearchable, isAggregatable);
        }

    case 4:
        if (hasMinMax == false) {
            return new Ip(maxDoc, docCount, sumDocFreq, sumTotalTermFreq, isSearchable, isAggregatable);
        }
        int l1 = in.readByte();
        byte[] b1 = new byte[l1];
        in.readBytes(b1, 0, l1);
        int l2 = in.readByte();
        byte[] b2 = new byte[l2];
        in.readBytes(b2, 0, l2);
        InetAddress min = InetAddressPoint.decode(b1);
        InetAddress max = InetAddressPoint.decode(b2);
        return new Ip(maxDoc, docCount, sumDocFreq, sumTotalTermFreq, isSearchable, isAggregatable, min, max);

    default:
        throw new IllegalArgumentException("Unknown type.");
    }
}