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

The following examples show how to use org.elasticsearch.common.io.stream.StreamInput#readOptionalBoolean() . 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: OrderBy.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    int numOrderBy = in.readVInt();
    reverseFlags = new boolean[numOrderBy];

    for (int i = 0; i <  numOrderBy; i++) {
        reverseFlags[i] = in.readBoolean();
    }

    orderBySymbols = new ArrayList<>(numOrderBy);
    for (int i = 0; i < numOrderBy; i++) {
        orderBySymbols.add(Symbol.fromStream(in));
    }

    nullsFirst = new Boolean[numOrderBy];
    for (int i = 0; i < numOrderBy; i++) {
        nullsFirst[i] = in.readOptionalBoolean();
    }
}
 
Example 2
Source File: IndexWarmersMetaData.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public IndexWarmersMetaData readFrom(StreamInput in) throws IOException {
    Entry[] entries = new Entry[in.readVInt()];
    for (int i = 0; i < entries.length; i++) {
        String name = in.readString();
        String[] types = in.readStringArray();
        BytesReference source = null;
        if (in.readBoolean()) {
            source = in.readBytesReference();
        }
        Boolean queryCache;
        queryCache = in.readOptionalBoolean();
        entries[i] = new Entry(name, types, queryCache, source);
    }
    return new IndexWarmersMetaData(entries);
}
 
Example 3
Source File: AliasMetaData.java    From crate with Apache License 2.0 6 votes vote down vote up
public AliasMetaData(StreamInput in) throws IOException {
    alias = in.readString();
    if (in.readBoolean()) {
        filter = CompressedXContent.readCompressedString(in);
    } else {
        filter = null;
    }
    if (in.readBoolean()) {
        indexRouting = in.readString();
    } else {
        indexRouting = null;
    }
    if (in.readBoolean()) {
        searchRouting = in.readString();
        searchRoutingValues = Collections.unmodifiableSet(Sets.newHashSet(Strings.splitStringByCommaToArray(searchRouting)));
    } else {
        searchRouting = null;
        searchRoutingValues = emptySet();
    }
    writeIndex = in.readOptionalBoolean();
}
 
Example 4
Source File: InternalSearchResponse.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    hits = readSearchHits(in);
    if (in.readBoolean()) {
        aggregations = InternalAggregations.readAggregations(in);
    }
    if (in.readBoolean()) {
        suggest = Suggest.readSuggest(Suggest.Fields.SUGGEST, in);
    }
    timedOut = in.readBoolean();

    terminatedEarly = in.readOptionalBoolean();

    if (in.getVersion().onOrAfter(Version.V_2_2_0) && in.readBoolean()) {
        profileResults = new InternalProfileShardResults(in);
    } else {
        profileResults = null;
    }
}
 
Example 5
Source File: ShardSearchLocalRequest.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
protected void innerReadFrom(StreamInput in) throws IOException {
    index = in.readString();
    shardId = in.readVInt();
    searchType = SearchType.fromId(in.readByte());
    numberOfShards = in.readVInt();
    if (in.readBoolean()) {
        scroll = readScroll(in);
    }

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

    types = in.readStringArray();
    filteringAliases = in.readStringArray();
    nowInMillis = in.readVLong();

    templateSource = in.readBytesReference();
    if (in.readBoolean()) {
        template = Template.readTemplate(in);
    }
    requestCache = in.readOptionalBoolean();
}
 
Example 6
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 7
Source File: GetWarmersResponse.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();
    ImmutableOpenMap.Builder<String, List<IndexWarmersMetaData.Entry>> indexMapBuilder = ImmutableOpenMap.builder();
    for (int i = 0; i < size; i++) {
        String key = in.readString();
        int valueSize = in.readVInt();
        List<IndexWarmersMetaData.Entry> warmerEntryBuilder = new ArrayList<>();
        for (int j = 0; j < valueSize; j++) {
            String name = in.readString();
            String[] types = in.readStringArray();
            BytesReference source = in.readBytesReference();
            Boolean queryCache = null;
            queryCache = in.readOptionalBoolean();
            warmerEntryBuilder.add(new IndexWarmersMetaData.Entry(
                            name,
                            types,
                            queryCache,
                            source)
            );
        }
        indexMapBuilder.put(key, Collections.unmodifiableList(warmerEntryBuilder));
    }
    warmers = indexMapBuilder.build();
}
 
Example 8
Source File: MappingMetaData.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
public MappingMetaData readFrom(StreamInput in) throws IOException {
    String type = in.readString();
    CompressedXContent source = CompressedXContent.readCompressedString(in);
    // id
    Id id = new Id(in.readBoolean() ? in.readString() : null);
    // routing
    Routing routing = new Routing(in.readBoolean(), in.readBoolean() ? in.readString() : null);
    // timestamp

    boolean enabled = in.readBoolean();
    String path = in.readOptionalString();
    String format = in.readString();
    String defaultTimestamp = in.readOptionalString();
    Boolean ignoreMissing = null;

    ignoreMissing = in.readOptionalBoolean();

    final Timestamp timestamp = new Timestamp(enabled, path, format, defaultTimestamp, ignoreMissing);
    final boolean hasParentField = in.readBoolean();
    final long mappingVersion = in.readLong();

    ParsedVersion version = new ParsedVersion(null, VersionType.INTERNAL);
    boolean hasVersionPath = in.readBoolean();
    if (hasVersionPath) {
        String versionPath = in.readString();
        VersionType versionType = VersionType.fromValue(in.readByte());
        version = new ParsedVersion(versionPath, versionType);
    }
    return new MappingMetaData(type, source, id, routing, timestamp, hasParentField, version, mappingVersion);
}
 
Example 9
Source File: ResizeRequest.java    From crate with Apache License 2.0 5 votes vote down vote up
public ResizeRequest(StreamInput in) throws IOException {
    super(in);
    targetIndexRequest = new CreateIndexRequest(in);
    sourceIndex = in.readString();
    type = in.readEnum(ResizeType.class);
    copySettings = in.readOptionalBoolean();
}
 
Example 10
Source File: FileUriCollectPhase.java    From crate with Apache License 2.0 5 votes vote down vote up
public FileUriCollectPhase(StreamInput in) throws IOException {
    super(in);
    compression = in.readOptionalString();
    sharedStorage = in.readOptionalBoolean();
    targetUri = Symbols.fromStream(in);

    int numNodes = in.readVInt();
    List<String> nodes = new ArrayList<>(numNodes);
    for (int i = 0; i < numNodes; i++) {
        nodes.add(in.readString());
    }
    this.executionNodes = nodes;
    toCollect = Symbols.listFromStream(in);
    inputFormat = InputFormat.values()[in.readVInt()];
}
 
Example 11
Source File: SnapshotInfo.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs snapshot information from stream input
 */
public SnapshotInfo(final StreamInput in) throws IOException {
    snapshotId = new SnapshotId(in);
    int size = in.readVInt();
    List<String> indicesListBuilder = new ArrayList<>();
    for (int i = 0; i < size; i++) {
        indicesListBuilder.add(in.readString());
    }
    indices = Collections.unmodifiableList(indicesListBuilder);
    state = in.readBoolean() ? SnapshotState.fromValue(in.readByte()) : null;
    reason = in.readOptionalString();
    startTime = in.readVLong();
    endTime = in.readVLong();
    totalShards = in.readVInt();
    successfulShards = in.readVInt();
    size = in.readVInt();
    if (size > 0) {
        List<SnapshotShardFailure> failureBuilder = new ArrayList<>();
        for (int i = 0; i < size; i++) {
            failureBuilder.add(new SnapshotShardFailure(in));
        }
        shardFailures = Collections.unmodifiableList(failureBuilder);
    } else {
        shardFailures = Collections.emptyList();
    }
    version = in.readBoolean() ? Version.readVersion(in) : null;
    includeGlobalState = in.readOptionalBoolean();
}
 
Example 12
Source File: PathHierarchyAggregationBuilder.java    From elasticsearch-aggregation-pathhierarchy with MIT License 5 votes vote down vote up
/**
 * Read from a stream
 *
 */
public PathHierarchyAggregationBuilder(StreamInput in) throws IOException {
    super(in, CoreValuesSourceType.ANY);
    bucketCountThresholds = new PathHierarchyAggregator.BucketCountThresholds(in);
    separator = in.readString();
    minDocCount = in.readVLong();
    minDepth = in.readOptionalVInt();
    maxDepth = in.readOptionalVInt();
    keepBlankPath = in.readOptionalBoolean();
    depth = in.readOptionalVInt();
    order = InternalOrder.Streams.readOrder(in);
}
 
Example 13
Source File: ClusterStatsData.java    From elasticsearch-prometheus-exporter with Apache License 2.0 5 votes vote down vote up
public ClusterStatsData(StreamInput in) throws IOException {
    super(in);
    thresholdEnabled = in.readOptionalBoolean();
    //
    diskLowInBytes = in.readOptionalLong();
    diskHighInBytes = in.readOptionalLong();
    floodStageInBytes = in.readOptionalLong();
    //
    diskLowInPct = in.readOptionalDouble();
    diskHighInPct = in.readOptionalDouble();
    floodStageInPct = in.readOptionalDouble();
}
 
Example 14
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 15
Source File: FsInfo.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    path = in.readOptionalString();
    mount = in.readOptionalString();
    type = in.readOptionalString();
    total = in.readLong();
    free = in.readLong();
    available = in.readLong();
    spins = in.readOptionalBoolean();
    limit = in.readLong();
    limitFree = in.readLong();
    esUsed = in.readLong();
}
 
Example 16
Source File: TopNProjection.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    offset = in.readVInt();
    limit = in.readVInt();

    outputs = Symbol.listFromStream(in);

    int numOrderBy = in.readVInt();

    if (numOrderBy > 0) {
        reverseFlags = new boolean[numOrderBy];

        for (int i = 0; i < reverseFlags.length; i++) {
            reverseFlags[i] = in.readBoolean();
        }

        orderBy = new ArrayList<>(numOrderBy);
        for (int i = 0; i < reverseFlags.length; i++) {
            orderBy.add(Symbol.fromStream(in));
        }

        nullsFirst = new Boolean[numOrderBy];
        for (int i = 0; i < numOrderBy; i++) {
            nullsFirst[i] = in.readOptionalBoolean();
        }
    }
}
 
Example 17
Source File: Suggest.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    text = in.readText();
    score = in.readFloat();
    highlighted = in.readOptionalText();
    collateMatch = in.readOptionalBoolean();
}
 
Example 18
Source File: FileUriCollectPhase.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);
    compression = in.readOptionalString();
    sharedStorage = in.readOptionalBoolean();
    targetUri = Symbol.fromStream(in);

    int numNodes = in.readVInt();
    List<String> nodes = new ArrayList<>(numNodes);
    for (int i = 0; i < numNodes; i++) {
        nodes.add(in.readString());
    }
    this.executionNodes = nodes;
    toCollect = Symbol.listFromStream(in);
}
 
Example 19
Source File: MergePhase.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);
    distributionInfo = DistributionInfo.fromStream(in);
    numUpstreams = in.readVInt();

    int numCols = in.readVInt();
    if (numCols > 0) {
        List<DataType> inputTypes = new ArrayList<>(numCols);
        for (int i = 0; i < numCols; i++) {
            inputTypes.add(DataTypes.fromStream(in));
        }
        this.inputTypes = inputTypes;
    }
    int numExecutionNodes = in.readVInt();

    if (numExecutionNodes > 0) {
        executionNodes = new HashSet<>(numExecutionNodes);
        for (int i = 0; i < numExecutionNodes; i++) {
            executionNodes.add(in.readString());
        }
    }

    sortedInputOutput = in.readBoolean();
    if (sortedInputOutput) {
        int orderByIndicesLength = in.readVInt();
        orderByIndices = new int[orderByIndicesLength];
        reverseFlags = new boolean[orderByIndicesLength];
        nullsFirst = new Boolean[orderByIndicesLength];
        for (int i = 0; i < orderByIndicesLength; i++) {
            orderByIndices[i] = in.readVInt();
            reverseFlags[i] = in.readBoolean();
            nullsFirst[i] = in.readOptionalBoolean();
        }
    }
}
 
Example 20
Source File: BooleanType.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public Boolean readValueFrom(StreamInput in) throws IOException {
    return in.readOptionalBoolean();
}