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

The following examples show how to use org.elasticsearch.common.io.stream.StreamInput#readOptionalString() . 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: Segment.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    name = in.readString();
    generation = Long.parseLong(name.substring(1), Character.MAX_RADIX);
    committed = in.readBoolean();
    search = in.readBoolean();
    docCount = in.readInt();
    delDocCount = in.readInt();
    sizeInBytes = in.readLong();
    version = Lucene.parseVersionLenient(in.readOptionalString(), null);
    compound = in.readOptionalBoolean();
    mergeId = in.readOptionalString();
    memoryInBytes = in.readLong();
    if (in.readBoolean()) {
        // verbose mode
        ramTree = readRamTree(in);
    }
}
 
Example 2
Source File: ExplainRequest.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);
    type = in.readString();
    id = in.readString();
    routing = in.readOptionalString();
    preference = in.readOptionalString();
    source = in.readBytesReference();
    filteringAlias = in.readStringArray();
    if (in.readBoolean()) {
        fields = in.readStringArray();
    }

    fetchSourceContext = FetchSourceContext.optionalReadFromStream(in);
    nowInMillis = in.readVLong();
}
 
Example 3
Source File: ElasticsearchException.java    From crate with Apache License 2.0 6 votes vote down vote up
/**
 * Deserializes stacktrace elements as well as suppressed exceptions from the given output stream and
 * adds it to the given exception.
 */
public static <T extends Throwable> T readStackTrace(T throwable, StreamInput in) throws IOException {
    final int stackTraceElements = in.readVInt();
    StackTraceElement[] stackTrace = new StackTraceElement[stackTraceElements];
    for (int i = 0; i < stackTraceElements; i++) {
        final String declaringClasss = in.readString();
        final String fileName = in.readOptionalString();
        final String methodName = in.readString();
        final int lineNumber = in.readVInt();
        stackTrace[i] = new StackTraceElement(declaringClasss, methodName, fileName, lineNumber);
    }
    throwable.setStackTrace(stackTrace);

    int numSuppressed = in.readVInt();
    for (int i = 0; i < numSuppressed; i++) {
        throwable.addSuppressed(in.readException());
    }
    return throwable;
}
 
Example 4
Source File: ExtendedAnalyzeRequest.java    From elasticsearch-extended-analyze with Apache License 2.0 6 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    text = in.readStringArray();
    analyzer = in.readOptionalString();
    tokenizer = in.readOptionalString();
    int size = in.readVInt();
    if (size > 0) {
        tokenFilters = new String[size];
        for (int i = 0; i < size; i++) {
            tokenFilters[i] = in.readString();
        }
    }
    field = in.readOptionalString();
    shortAttributeName = in.readBoolean();
    int attSize = in.readVInt();
    if (size > 0) {
        attributes = new String[attSize];
        for (int i = 0; i < attSize; i++) {
            attributes[i] = in.readString();
        }
    }
}
 
Example 5
Source File: ExistsRequest.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);
    minScore = in.readFloat();
    routing = in.readOptionalString();
    preference = in.readOptionalString();
    source = in.readBytesReference();
    types = in.readStringArray();

}
 
Example 6
Source File: AllocateUnassignedDecision.java    From crate with Apache License 2.0 5 votes vote down vote up
public AllocateUnassignedDecision(StreamInput in) throws IOException {
    super(in);
    allocationStatus = in.readOptionalWriteable(AllocationStatus::readFrom);
    allocationId = in.readOptionalString();
    reuseStore = in.readBoolean();
    remainingDelayInMillis = in.readVLong();
    configuredDelayInMillis = in.readVLong();
}
 
Example 7
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 8
Source File: SearchIntoRequest.java    From elasticsearch-inout-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    routing = in.readOptionalString();
    preference = in.readOptionalString();
    querySourceUnsafe = false;
    source = in.readBytesReference();
    types = in.readStringArray();
}
 
Example 9
Source File: AlreadyExpiredException.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public AlreadyExpiredException(StreamInput in) throws IOException{
    super(in);
    index = in.readOptionalString();
    type = in.readOptionalString();
    id = in.readOptionalString();
    timestamp = in.readLong();
    ttl = in.readLong();
    now = in.readLong();
}
 
Example 10
Source File: SnapshotsInProgress.java    From crate with Apache License 2.0 5 votes vote down vote up
public SnapshotsInProgress(StreamInput in) throws IOException {
    Entry[] entries = new Entry[in.readVInt()];
    for (int i = 0; i < entries.length; i++) {
        final Snapshot snapshot = new Snapshot(in);
        final boolean includeGlobalState = in.readBoolean();
        final boolean partial = in.readBoolean();
        final State state = State.fromValue(in.readByte());
        int indices = in.readVInt();
        List<IndexId> indexBuilder = new ArrayList<>();
        for (int j = 0; j < indices; j++) {
            indexBuilder.add(new IndexId(in.readString(), in.readString()));
        }
        final long startTime = in.readLong();
        ImmutableOpenMap.Builder<ShardId, ShardSnapshotStatus> builder = ImmutableOpenMap.builder();
        final int shards = in.readVInt();
        for (int j = 0; j < shards; j++) {
            ShardId shardId = new ShardId(in);
            builder.put(shardId, new ShardSnapshotStatus(in));
        }
        final long repositoryStateId = in.readLong();
        final String failure = in.readOptionalString();
        final boolean useShardGenerations;
        if (in.getVersion().onOrAfter(SnapshotsService.SHARD_GEN_IN_REPO_DATA_VERSION)) {
            useShardGenerations = in.readBoolean();
        } else {
            useShardGenerations = false;
        }
        entries[i] = new Entry(snapshot,
            includeGlobalState,
            partial,
            state,
            Collections.unmodifiableList(indexBuilder),
            startTime,
            repositoryStateId,
            builder.build(),
            failure,
            useShardGenerations);
    }
    this.entries = Arrays.asList(entries);
}
 
Example 11
Source File: ShardsSyncedFlushResult.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    failureReason = in.readOptionalString();
    int numResponses = in.readInt();
    shardResponses = new HashMap<>();
    for (int i = 0; i < numResponses; i++) {
        ShardRouting shardRouting = ShardRouting.readShardRoutingEntry(in);
        SyncedFlushService.ShardSyncedFlushResponse response = SyncedFlushService.ShardSyncedFlushResponse.readSyncedFlushResponse(in);
        shardResponses.put(shardRouting, response);
    }
    syncId = in.readOptionalString();
    shardId = ShardId.readShardId(in);
    totalShards = in.readInt();
}
 
Example 12
Source File: OsStats.java    From crate with Apache License 2.0 5 votes vote down vote up
Cgroup(final StreamInput in) throws IOException {
    cpuAcctControlGroup = in.readString();
    cpuAcctUsageNanos = in.readLong();
    cpuControlGroup = in.readString();
    cpuCfsPeriodMicros = in.readLong();
    cpuCfsQuotaMicros = in.readLong();
    cpuStat = new CpuStat(in);
    memoryControlGroup = in.readOptionalString();
    memoryLimitInBytes = in.readOptionalString();
    memoryUsageInBytes = in.readOptionalString();
}
 
Example 13
Source File: ActionWriteResponse.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    index = in.readString();
    shardId = in.readVInt();
    nodeId = in.readOptionalString();
    cause = in.readThrowable();
    status = RestStatus.readFrom(in);
    primary = in.readBoolean();
}
 
Example 14
Source File: QueryExplanation.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    index = in.readString();
    valid = in.readBoolean();
    explanation = in.readOptionalString();
    error = in.readOptionalString();
}
 
Example 15
Source File: OsInfo.java    From crate with Apache License 2.0 5 votes vote down vote up
public OsInfo(StreamInput in) throws IOException {
    this.refreshInterval = in.readLong();
    this.availableProcessors = in.readInt();
    this.allocatedProcessors = in.readInt();
    this.name = in.readOptionalString();
    this.arch = in.readOptionalString();
    this.version = in.readOptionalString();
}
 
Example 16
Source File: SearchRequest.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);
    searchType = SearchType.fromId(in.readByte());

    indices = new String[in.readVInt()];
    for (int i = 0; i < indices.length; i++) {
        indices[i] = in.readString();
    }

    routing = in.readOptionalString();
    preference = in.readOptionalString();

    if (in.readBoolean()) {
        scroll = readScroll(in);
    }

    source = in.readBytesReference();
    extraSource = in.readBytesReference();

    types = in.readStringArray();
    indicesOptions = IndicesOptions.readIndicesOptions(in);

    templateSource = in.readBytesReference();
    if (in.readBoolean()) {
        template = Template.readTemplate(in);
    }
    requestCache = in.readOptionalBoolean();
}
 
Example 17
Source File: ActionNotFoundTransportException.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
public ActionNotFoundTransportException(StreamInput in) throws IOException {
    super(in);
    action = in.readOptionalString();
}
 
Example 18
Source File: SQLBulkResponse.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    rowCount = in.readLong();
    errorMessage = in.readOptionalString();
}
 
Example 19
Source File: RestoreInProgress.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/**
 * Reads restore status from stream input
 *
 * @param in stream input
 */
public void readFrom(StreamInput in) throws IOException {
    nodeId = in.readOptionalString();
    state = State.fromValue(in.readByte());
    reason = in.readOptionalString();
}
 
Example 20
Source File: ZenDiscovery.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);
    fromNodeId = in.readOptionalString();
}