Java Code Examples for org.elasticsearch.common.io.stream.StreamInput#readByte()

The following examples show how to use org.elasticsearch.common.io.stream.StreamInput#readByte() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultiGetShardRequest.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    int size = in.readVInt();
    locations = new IntArrayList(size);
    items = new ArrayList<>(size);

    for (int i = 0; i < size; i++) {
        locations.add(in.readVInt());
        items.add(MultiGetRequest.Item.readItem(in));
    }

    preference = in.readOptionalString();
    refresh = in.readBoolean();
    byte realtime = in.readByte();
    if (realtime == 0) {
        this.realtime = false;
    } else if (realtime == 1) {
        this.realtime = true;
    }
    ignoreErrorsOnGeneratedFields = in.readBoolean();
}
 
Example 2
Source File: DistributedResultRequest.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    jobId = new UUID(in.readLong(), in.readLong());
    executionPhaseId = in.readVInt();
    bucketIdx = in.readVInt();
    isLast = in.readBoolean();
    inputId = in.readByte();

    boolean failure = in.readBoolean();
    if (failure) {
        throwable = in.readThrowable();
    } else {
        StreamBucket bucket = new StreamBucket(streamers);
        bucket.readFrom(in);
        rows = bucket;
    }
}
 
Example 3
Source File: MultiGetRequest.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    preference = in.readOptionalString();
    refresh = in.readBoolean();
    byte realtime = in.readByte();
    if (realtime == 0) {
        this.realtime = false;
    } else if (realtime == 1) {
        this.realtime = true;
    }
    ignoreErrorsOnGeneratedFields = in.readBoolean();

    int size = in.readVInt();
    items = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        items.add(Item.readItem(in));
    }
}
 
Example 4
Source File: FieldStats.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
public static FieldStats read(StreamInput in) throws IOException {
    FieldStats stats;
    byte type = in.readByte();
    switch (type) {
        case 0:
            stats = new Long();
            break;
        case 1:
            stats = new Float();
            break;
        case 2:
            stats = new Double();
            break;
        case 3:
            stats = new Text();
            break;
        case 4:
            stats = new Date();
            break;
        default:
            throw new IllegalArgumentException("Illegal type [" + type + "]");
    }
    stats.type = type;
    stats.readFrom(in);
    return stats;
}
 
Example 5
Source File: InternalOrder.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
/**
 * Reads an order from the given input (based on the id of the order).
 *
 * @see Streams#writeOrder(InternalOrder, org.elasticsearch.common.io.stream.StreamOutput)
 */
public static InternalOrder readOrder(StreamInput in) throws IOException {
    byte id = in.readByte();
    switch (id) {
        case 1: return (InternalOrder) Histogram.Order.KEY_ASC;
        case 2: return (InternalOrder) Histogram.Order.KEY_DESC;
        case 3: return (InternalOrder) Histogram.Order.COUNT_ASC;
        case 4: return (InternalOrder) Histogram.Order.COUNT_DESC;
        case 0:
            boolean asc = in.readBoolean();
            String key = in.readString();
            return new InternalOrder.Aggregation(key, asc);
        default:
            throw new RuntimeException("unknown histogram order");
    }
}
 
Example 6
Source File: ShardFetchRequest.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    id = in.readLong();
    size = in.readVInt();
    docIds = new int[size];
    for (int i = 0; i < size; i++) {
        docIds[i] = in.readVInt();
    }
    byte flag = in.readByte();
    if (flag == 1) {
        lastEmittedDoc = Lucene.readFieldDoc(in);
    } else if (flag == 2) {
        lastEmittedDoc = Lucene.readScoreDoc(in);
    } else if (flag != 0) {
        throw new IOException("Unknown flag: " + flag);
    }
}
 
Example 7
Source File: UnassignedInfo.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
UnassignedInfo(StreamInput in) throws IOException {
    this.reason = Reason.values()[(int) in.readByte()];
    this.unassignedTimeMillis = in.readLong();
    // As System.nanoTime() cannot be compared across different JVMs, reset it to now.
    // This means that in master failover situations, elapsed delay time is forgotten.
    this.unassignedTimeNanos = System.nanoTime();
    this.message = in.readOptionalString();
    this.failure = in.readThrowable();
}
 
Example 8
Source File: RecoverySource.java    From crate with Apache License 2.0 5 votes vote down vote up
public static RecoverySource readFrom(StreamInput in) throws IOException {
    Type type = Type.values()[in.readByte()];
    switch (type) {
        case EMPTY_STORE: return EmptyStoreRecoverySource.INSTANCE;
        case EXISTING_STORE: return new ExistingStoreRecoverySource(in);
        case PEER: return PeerRecoverySource.INSTANCE;
        case SNAPSHOT: return new SnapshotRecoverySource(in);
        case LOCAL_SHARDS: return LocalShardsRecoverySource.INSTANCE;
        default: throw new IllegalArgumentException("unknown recovery type: " + type.name());
    }
}
 
Example 9
Source File: GetRequest.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    type = in.readString();
    id = in.readString();
    routing = in.readOptionalString();
    preference = in.readOptionalString();
    refresh = in.readBoolean();
    int size = in.readInt();
    if (size >= 0) {
        fields = new String[size];
        for (int i = 0; i < size; i++) {
            fields[i] = in.readString();
        }
    }
    byte realtime = in.readByte();
    if (realtime == 0) {
        this.realtime = false;
    } else if (realtime == 1) {
        this.realtime = true;
    }
    this.ignoreErrorsOnGeneratedFields = in.readBoolean();

    this.versionType = VersionType.fromValue(in.readByte());
    this.version = in.readLong();

    fetchSourceContext = FetchSourceContext.optionalReadFromStream(in);
}
 
Example 10
Source File: Lucene.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
private static Object readMissingValue(StreamInput in) throws IOException {
    final byte id = in.readByte();
    switch (id) {
    case 0:
        return in.readGenericValue();
    case 1:
        return SortField.STRING_FIRST;
    case 2:
        return SortField.STRING_LAST;
    default:
        throw new IOException("Unknown missing value id: " + id);
    }
}
 
Example 11
Source File: InetSocketTransportAddress.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public InetSocketTransportAddress(StreamInput in) throws IOException {
    final int len = in.readByte();
    final byte[] a = new byte[len]; // 4 bytes (IPv4) or 16 bytes (IPv6)
    in.readFully(a);
    InetAddress inetAddress = InetAddress.getByAddress(a);
    int port = in.readInt();
    this.address = new InetSocketAddress(inetAddress, port);
}
 
Example 12
Source File: Rounding.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public static Rounding read(StreamInput in) throws IOException {
    Rounding rounding = null;
    byte id = in.readByte();
    switch (id) {
        case Interval.ID: rounding = new Interval(); break;
        case TimeZoneRounding.TimeUnitRounding.ID: rounding = new TimeZoneRounding.TimeUnitRounding(); break;
        case TimeZoneRounding.TimeIntervalRounding.ID: rounding = new TimeZoneRounding.TimeIntervalRounding(); break;
        case TimeZoneRounding.FactorRounding.ID: rounding = new FactorRounding(); break;
        case OffsetRounding.ID: rounding = new OffsetRounding(); break;
        default: throw new ElasticsearchException("unknown rounding id [" + id + "]");
    }
    rounding.readFrom(in);
    return rounding;
}
 
Example 13
Source File: ValueFormatterStreams.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public static ValueFormatter read(StreamInput in) throws IOException {
    byte id = in.readByte();
    ValueFormatter formatter = null;
    switch (id) {
        case ValueFormatter.Raw.ID: return ValueFormatter.RAW;
        case ValueFormatter.IPv4Formatter.ID: return ValueFormatter.IPv4;
        case ValueFormatter.DateTime.ID: formatter = new ValueFormatter.DateTime(); break;
        case ValueFormatter.Number.Pattern.ID: formatter = new ValueFormatter.Number.Pattern(); break;
        case ValueFormatter.GeoHash.ID: formatter = ValueFormatter.GEOHASH; break;
        case ValueFormatter.BooleanFormatter.ID: formatter = ValueFormatter.BOOLEAN; break;
        default: throw new IllegalArgumentException("Unknown value formatter with id [" + id + "]");
    }
    formatter.readFrom(in);
    return formatter;
}
 
Example 14
Source File: TransportAddress.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * Read from a stream
 */
public TransportAddress(StreamInput in) throws IOException {
    final int len = in.readByte();
    final byte[] a = new byte[len]; // 4 bytes (IPv4) or 16 bytes (IPv6)
    in.readFully(a);
    String host = in.readString(); // the host string was serialized so we can ignore the passed in version
    InetAddress inetAddress = InetAddress.getByAddress(host, a);
    int port = in.readInt();
    this.address = new InetSocketAddress(inetAddress, port);
}
 
Example 15
Source File: NodeOperation.java    From crate with Apache License 2.0 5 votes vote down vote up
public NodeOperation(StreamInput in) throws IOException {
    executionPhase = ExecutionPhases.fromStream(in);
    downstreamExecutionPhaseId = in.readVInt();
    downstreamExecutionPhaseInputId = in.readByte();
    int numExecutionNodes = in.readVInt();

    List<String> executionNodes = new ArrayList<>();
    for (int i = 0; i < numExecutionNodes; i++) {
        executionNodes.add(in.readString());
    }
    this.downstreamNodes = executionNodes;
}
 
Example 16
Source File: UnassignedInfo.java    From crate with Apache License 2.0 5 votes vote down vote up
public UnassignedInfo(StreamInput in) throws IOException {
    this.reason = Reason.values()[(int) in.readByte()];
    this.unassignedTimeMillis = in.readLong();
    // As System.nanoTime() cannot be compared across different JVMs, reset it to now.
    // This means that in master fail-over situations, elapsed delay time is forgotten.
    this.unassignedTimeNanos = System.nanoTime();
    this.delayed = in.readBoolean();
    this.message = in.readOptionalString();
    this.failure = in.readException();
    this.failedAllocations = in.readVInt();
    this.lastAllocationStatus = AllocationStatus.readFrom(in);
}
 
Example 17
Source File: NodeOperation.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    executionPhase = ExecutionPhases.fromStream(in);
    downstreamExecutionPhaseId = in.readVInt();
    downstreamExecutionPhaseInputId = in.readByte();
    int numExecutionNodes = in.readVInt();

    List<String> executionNodes = new ArrayList<>();
    for (int i = 0; i < numExecutionNodes; i++) {
        executionNodes.add(in.readString());
    }
    this.downstreamNodes = executionNodes;
}
 
Example 18
Source File: BlobStartPrefixSyncRequest.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    prefix = in.readByte();
    ShardId.readShardId(in);
}
 
Example 19
Source File: ByteType.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public Byte readValueFrom(StreamInput in) throws IOException {
    return in.readBoolean() ? null : in.readByte();
}
 
Example 20
Source File: BlobStartPrefixSyncRequest.java    From crate with Apache License 2.0 4 votes vote down vote up
public BlobStartPrefixSyncRequest(StreamInput in) throws IOException {
    super(in);
    prefix = in.readByte();
    shardId = new ShardId(in);
}