当前位置: 首页>>代码示例>>Java>>正文


Java Nullable类代码示例

本文整理汇总了Java中org.elasticsearch.common.Nullable的典型用法代码示例。如果您正苦于以下问题:Java Nullable类的具体用法?Java Nullable怎么用?Java Nullable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Nullable类属于org.elasticsearch.common包,在下文中一共展示了Nullable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: compressor

import org.elasticsearch.common.Nullable; //导入依赖的package包/类
@Nullable
public static Compressor compressor(BytesReference bytes) {
    for (Compressor compressor : compressors) {
        if (compressor.isCompressed(bytes)) {
            // bytes should be either detected as compressed or as xcontent,
            // if we have bytes that can be either detected as compressed or
            // as a xcontent, we have a problem
            assert XContentFactory.xContentType(bytes) == null;
            return compressor;
        }
    }

    XContentType contentType = XContentFactory.xContentType(bytes);
    if (contentType == null) {
        throw new NotXContentException("Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes");
    }

    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:20,代码来源:CompressorFactory.java

示例2: initializeShard

import org.elasticsearch.common.Nullable; //导入依赖的package包/类
/**
 * Moves a shard from unassigned to initialize state
 *
 * @param existingAllocationId allocation id to use. If null, a fresh allocation id is generated.
 * @return                     the initialized shard
 */
public ShardRouting initializeShard(ShardRouting unassignedShard, String nodeId, @Nullable String existingAllocationId,
                                    long expectedSize, RoutingChangesObserver routingChangesObserver) {
    ensureMutable();
    assert unassignedShard.unassigned() : "expected an unassigned shard " + unassignedShard;
    ShardRouting initializedShard = unassignedShard.initialize(nodeId, existingAllocationId, expectedSize);
    node(nodeId).add(initializedShard);
    inactiveShardCount++;
    if (initializedShard.primary()) {
        inactivePrimaryCount++;
    }
    addRecovery(initializedShard);
    assignedShardsAdd(initializedShard);
    routingChangesObserver.shardInitialized(unassignedShard, initializedShard);
    return initializedShard;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:RoutingNodes.java

示例3: loadTranslogIdFromCommit

import org.elasticsearch.common.Nullable; //导入依赖的package包/类
/**
 * Reads the current stored translog ID from the IW commit data. If the id is not found, recommits the current
 * translog id into lucene and returns null.
 */
@Nullable
private Translog.TranslogGeneration loadTranslogIdFromCommit(IndexWriter writer) throws IOException {
    // commit on a just opened writer will commit even if there are no changes done to it
    // we rely on that for the commit data translog id key
    final Map<String, String> commitUserData = commitDataAsMap(writer);
    if (commitUserData.containsKey("translog_id")) {
        assert commitUserData.containsKey(Translog.TRANSLOG_UUID_KEY) == false : "legacy commit contains translog UUID";
        return new Translog.TranslogGeneration(null, Long.parseLong(commitUserData.get("translog_id")));
    } else if (commitUserData.containsKey(Translog.TRANSLOG_GENERATION_KEY)) {
        if (commitUserData.containsKey(Translog.TRANSLOG_UUID_KEY) == false) {
            throw new IllegalStateException("commit doesn't contain translog UUID");
        }
        final String translogUUID = commitUserData.get(Translog.TRANSLOG_UUID_KEY);
        final long translogGen = Long.parseLong(commitUserData.get(Translog.TRANSLOG_GENERATION_KEY));
        return new Translog.TranslogGeneration(translogUUID, translogGen);
    }
    return null;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:InternalEngine.java

示例4: FreqTermsEnum

import org.elasticsearch.common.Nullable; //导入依赖的package包/类
public FreqTermsEnum(IndexReader reader, String field, boolean needDocFreq, boolean needTotalTermFreq, @Nullable Query filter, BigArrays bigArrays) throws IOException {
    super(reader, field, needTotalTermFreq ? PostingsEnum.FREQS : PostingsEnum.NONE, filter);
    this.bigArrays = bigArrays;
    this.needDocFreqs = needDocFreq;
    this.needTotalTermFreqs = needTotalTermFreq;
    if (needDocFreq) {
        termDocFreqs = bigArrays.newIntArray(INITIAL_NUM_TERM_FREQS_CACHED, false);
    } else {
        termDocFreqs = null;
    }
    if (needTotalTermFreq) {
        termsTotalFreqs = bigArrays.newLongArray(INITIAL_NUM_TERM_FREQS_CACHED, false);
    } else {
        termsTotalFreqs = null;
    }
    cachedTermOrds = new BytesRefHash(INITIAL_NUM_TERM_FREQS_CACHED, bigArrays);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:FreqTermsEnum.java

示例5: loadTranslogIdFromCommit

import org.elasticsearch.common.Nullable; //导入依赖的package包/类
/**
 * Reads the current stored translog ID from the IW commit data. If the id is not found, recommits the current
 * translog id into lucene and returns null.
 */
@Nullable
private Translog.TranslogGeneration loadTranslogIdFromCommit(IndexWriter writer) throws IOException {
    // commit on a just opened writer will commit even if there are no changes done to it
    // we rely on that for the commit data translog id key
    final Map<String, String> commitUserData = writer.getCommitData();
    if (commitUserData.containsKey("translog_id")) {
        assert commitUserData.containsKey(Translog.TRANSLOG_UUID_KEY) == false : "legacy commit contains translog UUID";
        return new Translog.TranslogGeneration(null, Long.parseLong(commitUserData.get("translog_id")));
    } else if (commitUserData.containsKey(Translog.TRANSLOG_GENERATION_KEY)) {
        if (commitUserData.containsKey(Translog.TRANSLOG_UUID_KEY) == false) {
            throw new IllegalStateException("commit doesn't contain translog UUID");
        }
        final String translogUUID = commitUserData.get(Translog.TRANSLOG_UUID_KEY);
        final long translogGen = Long.parseLong(commitUserData.get(Translog.TRANSLOG_GENERATION_KEY));
        return new Translog.TranslogGeneration(translogUUID, translogGen);
    }
    return null;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:23,代码来源:InternalEngine.java

示例6: parseDoubleParam

import org.elasticsearch.common.Nullable; //导入依赖的package包/类
/**
 * Extracts a 0-1 inclusive double from the settings map, otherwise throws an exception
 *
 * @param settings      Map of settings provided to this model
 * @param name          Name of parameter we are attempting to extract
 * @param defaultValue  Default value to be used if value does not exist in map
 * @return Double value extracted from settings map
 */
protected double parseDoubleParam(@Nullable Map<String, Object> settings, String name, double defaultValue) throws ParseException {
    if (settings == null) {
        return defaultValue;
    }

    Object value = settings.get(name);
    if (value == null) {
        return defaultValue;
    } else if (value instanceof Number) {
        double v = ((Number) value).doubleValue();
        if (v >= 0 && v <= 1) {
            settings.remove(name);
            return v;
        }

        throw new ParseException("Parameter [" + name + "] must be between 0-1 inclusive.  Provided"
                + "value was [" + v + "]", 0);
    }

    throw new ParseException("Parameter [" + name + "] must be a double, type `"
            + value.getClass().getSimpleName() + "` provided instead", 0);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:31,代码来源:MovAvgModel.java

示例7: persistMetadata

import org.elasticsearch.common.Nullable; //导入依赖的package包/类
void persistMetadata(ShardRouting newRouting, @Nullable ShardRouting currentRouting) throws IOException {
    assert newRouting != null : "newRouting must not be null";

    // only persist metadata if routing information that is persisted in shard state metadata actually changed
    if (currentRouting == null
        || currentRouting.primary() != newRouting.primary()
        || currentRouting.allocationId().equals(newRouting.allocationId()) == false) {
        assert currentRouting == null || currentRouting.isSameAllocation(newRouting);
        final String writeReason;
        if (currentRouting == null) {
            writeReason = "initial state with allocation id [" + newRouting.allocationId() + "]";
        } else {
            writeReason = "routing changed from " + currentRouting + " to " + newRouting;
        }
        logger.trace("{} writing shard state, reason [{}]", shardId, writeReason);
        final ShardStateMetaData newShardStateMetadata = new ShardStateMetaData(newRouting.primary(), getIndexUUID(), newRouting.allocationId());
        ShardStateMetaData.FORMAT.write(newShardStateMetadata, shardPath().getShardStatePath());
    } else {
        logger.trace("{} skip writing shard state, has been written before", shardId);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:IndexShard.java

示例8: createSearchContext

import org.elasticsearch.common.Nullable; //导入依赖的package包/类
public DefaultSearchContext createSearchContext(ShardSearchRequest request, TimeValue timeout, @Nullable Engine.Searcher searcher)
    throws IOException {
    IndexService indexService = indicesService.indexServiceSafe(request.shardId().getIndex());
    IndexShard indexShard = indexService.getShard(request.shardId().getId());
    SearchShardTarget shardTarget = new SearchShardTarget(clusterService.localNode().getId(), indexShard.shardId());
    Engine.Searcher engineSearcher = searcher == null ? indexShard.acquireSearcher("search") : searcher;

    final DefaultSearchContext searchContext = new DefaultSearchContext(idGenerator.incrementAndGet(), request, shardTarget,
        engineSearcher, indexService, indexShard, bigArrays, threadPool.estimatedTimeInMillisCounter(), timeout, fetchPhase);
    boolean success = false;
    try {
        // we clone the query shard context here just for rewriting otherwise we
        // might end up with incorrect state since we are using now() or script services
        // during rewrite and normalized / evaluate templates etc.
        request.rewrite(new QueryShardContext(searchContext.getQueryShardContext()));
        assert searchContext.getQueryShardContext().isCachable();
        success = true;
    } finally {
        if (success == false) {
            IOUtils.closeWhileHandlingException(searchContext);
        }
    }
    return searchContext;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:SearchService.java

示例9: parseBoolParam

import org.elasticsearch.common.Nullable; //导入依赖的package包/类
/**
 * Extracts a boolean from the settings map, otherwise throws an exception
 *
 * @param settings      Map of settings provided to this model
 * @param name          Name of parameter we are attempting to extract
 * @param defaultValue  Default value to be used if value does not exist in map
 * @return Boolean value extracted from settings map
 */
protected boolean parseBoolParam(@Nullable Map<String, Object> settings, String name, boolean defaultValue) throws ParseException {
    if (settings == null) {
        return defaultValue;
    }

    Object value = settings.get(name);
    if (value == null) {
        return defaultValue;
    } else if (value instanceof Boolean) {
        settings.remove(name);
        return (Boolean)value;
    }

    throw new ParseException("Parameter [" + name + "] must be a boolean, type `"
            + value.getClass().getSimpleName() + "` provided instead", 0);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:MovAvgModel.java

示例10: writeMapWithConsistentOrder

import org.elasticsearch.common.Nullable; //导入依赖的package包/类
/**
 * write map to stream with consistent order
 * to make sure every map generated bytes order are same.
 * This method is compatible with {@code StreamInput.readMap} and {@code StreamInput.readGenericValue}
 * This method only will handle the map keys order, not maps contained within the map
 */
public void writeMapWithConsistentOrder(@Nullable Map<String, ? extends Object> map)
    throws IOException {
    if (map == null) {
        writeByte((byte) -1);
        return;
    }
    assert false == (map instanceof LinkedHashMap);
    this.writeByte((byte) 10);
    this.writeVInt(map.size());
    Iterator<? extends Map.Entry<String, ?>> iterator =
        map.entrySet().stream().sorted((a, b) -> a.getKey().compareTo(b.getKey())).iterator();
    while (iterator.hasNext()) {
        Map.Entry<String, ?> next = iterator.next();
        this.writeString(next.getKey());
        this.writeGenericValue(next.getValue());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:24,代码来源:StreamOutput.java

示例11: docValueFormat

import org.elasticsearch.common.Nullable; //导入依赖的package包/类
/** Return a {@link DocValueFormat} that can be used to display and parse
 *  values as returned by the fielddata API.
 *  The default implementation returns a {@link DocValueFormat#RAW}. */
public DocValueFormat docValueFormat(@Nullable String format, DateTimeZone timeZone) {
    if (format != null) {
        throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] does not support custom formats");
    }
    if (timeZone != null) {
        throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] does not support custom time zones");
    }
    return DocValueFormat.RAW;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:MappedFieldType.java

示例12: WriterProjection

import org.elasticsearch.common.Nullable; //导入依赖的package包/类
public WriterProjection(List<Symbol> inputs,
                        Symbol uri,
                        boolean isDirectoryUri,
                        @Nullable CompressionType compressionType,
                        Map<ColumnIdent, Symbol> overwrites,
                        @Nullable List<String> outputNames,
                        OutputFormat outputFormat) {
    this.inputs = inputs;
    this.uri = uri;
    this.isDirectoryUri = isDirectoryUri;
    this.overwrites = overwrites;
    this.outputNames = outputNames;
    this.outputFormat = outputFormat;
    this.compressionType = compressionType;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:16,代码来源:WriterProjection.java

示例13: bodyMessage

import org.elasticsearch.common.Nullable; //导入依赖的package包/类
static String bodyMessage(@Nullable HttpEntity entity) throws IOException {
    if (entity == null) {
        return "No error body.";
    } else {
        return "body=" + EntityUtils.toString(entity);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:RemoteScrollableHitSource.java

示例14: globalBlockLevel

import org.elasticsearch.common.Nullable; //导入依赖的package包/类
/**
 * Cluster level block to check before request execution. Returning null means that no blocks need to be checked.
 */
@Nullable
protected ClusterBlockLevel globalBlockLevel() {
    return null;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:TransportReplicationAction.java

示例15: FilterSettings

import org.elasticsearch.common.Nullable; //导入依赖的package包/类
public FilterSettings(@Nullable Integer maxNumTerms, @Nullable Integer minTermFreq, @Nullable Integer maxTermFreq,
                      @Nullable Integer minDocFreq, @Nullable Integer maxDocFreq, @Nullable Integer minWordLength,
                      @Nullable Integer maxWordLength) {
    this.maxNumTerms = maxNumTerms;
    this.minTermFreq = minTermFreq;
    this.maxTermFreq = maxTermFreq;
    this.minDocFreq = minDocFreq;
    this.maxDocFreq = maxDocFreq;
    this.minWordLength = minWordLength;
    this.maxWordLength = maxWordLength;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:12,代码来源:TermVectorsRequest.java


注:本文中的org.elasticsearch.common.Nullable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。