本文整理汇总了Java中org.elasticsearch.common.io.stream.Writeable类的典型用法代码示例。如果您正苦于以下问题:Java Writeable类的具体用法?Java Writeable怎么用?Java Writeable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Writeable类属于org.elasticsearch.common.io.stream包,在下文中一共展示了Writeable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: registerPipelineAggregation
import org.elasticsearch.common.io.stream.Writeable; //导入依赖的package包/类
private void registerPipelineAggregation(PipelineAggregationSpec spec) {
if (false == transportClient) {
namedXContents.add(new NamedXContentRegistry.Entry(BaseAggregationBuilder.class, spec.getName(), (p, c) -> {
AggregatorFactories.AggParseContext context = (AggregatorFactories.AggParseContext) c;
return spec.getParser().parse(context.name, context.queryParseContext);
}));
}
namedWriteables.add(
new NamedWriteableRegistry.Entry(PipelineAggregationBuilder.class, spec.getName().getPreferredName(), spec.getReader()));
namedWriteables.add(
new NamedWriteableRegistry.Entry(PipelineAggregator.class, spec.getName().getPreferredName(), spec.getAggregatorReader()));
for (Map.Entry<String, Writeable.Reader<? extends InternalAggregation>> resultReader : spec.getResultReaders().entrySet()) {
namedWriteables
.add(new NamedWriteableRegistry.Entry(InternalAggregation.class, resultReader.getKey(), resultReader.getValue()));
}
}
示例2: copyWriteable
import org.elasticsearch.common.io.stream.Writeable; //导入依赖的package包/类
/**
* Create a copy of an original {@link Writeable} object by running it through a {@link BytesStreamOutput} and
* reading it in again using a provided {@link Writeable.Reader}. The stream that is wrapped around the {@link StreamInput}
* potentially need to use a {@link NamedWriteableRegistry}, so this needs to be provided too (although it can be
* empty if the object that is streamed doesn't contain any {@link NamedWriteable} objects itself.
*/
public static <T extends Writeable> T copyWriteable(T original, NamedWriteableRegistry namedWritabelRegistry,
Writeable.Reader<T> reader) throws IOException {
try (BytesStreamOutput output = new BytesStreamOutput()) {
original.writeTo(output);
try (StreamInput in = new NamedWriteableAwareStreamInput(output.bytes().streamInput(), namedWritabelRegistry)) {
return reader.read(in);
}
}
}
示例3: copyInstance
import org.elasticsearch.common.io.stream.Writeable; //导入依赖的package包/类
/**
* Simulates sending diffs over the wire
*/
public static <T extends Writeable> T copyInstance(T diffs, NamedWriteableRegistry namedWriteableRegistry,
Reader<T> reader) throws IOException {
try (BytesStreamOutput output = new BytesStreamOutput()) {
diffs.writeTo(output);
try (StreamInput in = new NamedWriteableAwareStreamInput(output.bytes().streamInput(), namedWriteableRegistry)) {
return reader.read(in);
}
}
}
示例4: assertSerialization
import org.elasticsearch.common.io.stream.Writeable; //导入依赖的package包/类
/**
* Asserts that testInstance can be correctly.
*/
public static <T extends Writeable> T assertSerialization(T testInstance, NamedWriteableRegistry namedWriteableRegistry,
Reader<T> reader) throws IOException {
T deserializedInstance = copyInstance(testInstance, namedWriteableRegistry, reader);
assertEquals(testInstance, deserializedInstance);
assertEquals(testInstance.hashCode(), deserializedInstance.hashCode());
assertNotSame(testInstance, deserializedInstance);
return deserializedInstance;
}
示例5: AbstractRangeBuilder
import org.elasticsearch.common.io.stream.Writeable; //导入依赖的package包/类
/**
* Read from a stream.
*/
protected AbstractRangeBuilder(StreamInput in, InternalRange.Factory<?, ?> rangeFactory, Writeable.Reader<R> rangeReader)
throws IOException {
super(in, rangeFactory.getValueSourceType(), rangeFactory.getValueType());
this.rangeFactory = rangeFactory;
ranges = in.readList(rangeReader);
keyed = in.readBoolean();
}
示例6: registerAggregation
import org.elasticsearch.common.io.stream.Writeable; //导入依赖的package包/类
private void registerAggregation(AggregationSpec spec) {
if (false == transportClient) {
namedXContents.add(new NamedXContentRegistry.Entry(BaseAggregationBuilder.class, spec.getName(), (p, c) -> {
AggregatorFactories.AggParseContext context = (AggregatorFactories.AggParseContext) c;
return spec.getParser().parse(context.name, context.queryParseContext);
}));
}
namedWriteables.add(
new NamedWriteableRegistry.Entry(AggregationBuilder.class, spec.getName().getPreferredName(), spec.getReader()));
for (Map.Entry<String, Writeable.Reader<? extends InternalAggregation>> t : spec.getResultReaders().entrySet()) {
String writeableName = t.getKey();
Writeable.Reader<? extends InternalAggregation> internalReader = t.getValue();
namedWriteables.add(new NamedWriteableRegistry.Entry(InternalAggregation.class, writeableName, internalReader));
}
}
示例7: registerMetaDataCustom
import org.elasticsearch.common.io.stream.Writeable; //导入依赖的package包/类
private <T extends MetaData.Custom> void registerMetaDataCustom(String name, Writeable.Reader<T> reader,
Writeable.Reader<NamedDiff> diffReader,
CheckedFunction<XContentParser, T, IOException> parser) {
namedWritables.add(new NamedWriteableRegistry.Entry(MetaData.Custom.class, name, reader));
namedWritables.add(new NamedWriteableRegistry.Entry(NamedDiff.class, name, diffReader));
namedXContents.add(new NamedXContentRegistry.Entry(MetaData.Custom.class, new ParseField(name), parser));
}
示例8: registerValueFormat
import org.elasticsearch.common.io.stream.Writeable; //导入依赖的package包/类
/**
* Register a new ValueFormat.
*/
private void registerValueFormat(String name, Writeable.Reader<? extends DocValueFormat> reader) {
namedWriteables.add(new NamedWriteableRegistry.Entry(DocValueFormat.class, name, reader));
}
示例9: ScoreFunctionSpec
import org.elasticsearch.common.io.stream.Writeable; //导入依赖的package包/类
public ScoreFunctionSpec(ParseField name, Writeable.Reader<T> reader, ScoreFunctionParser<T> parser) {
super(name, reader, parser);
}
示例10: addResultReader
import org.elasticsearch.common.io.stream.Writeable; //导入依赖的package包/类
/**
* Add a reader for the shard level results of the aggregation.
*/
public AggregationSpec addResultReader(String writeableName, Writeable.Reader<? extends InternalAggregation> resultReader) {
resultReaders.put(writeableName, resultReader);
return this;
}
示例11: getResultReaders
import org.elasticsearch.common.io.stream.Writeable; //导入依赖的package包/类
/**
* Get the readers that must be registered for this aggregation's results.
*/
public Map<String, Writeable.Reader<? extends InternalAggregation>> getResultReaders() {
return resultReaders;
}
示例12: getAggregatorReader
import org.elasticsearch.common.io.stream.Writeable; //导入依赖的package包/类
/**
* The reader for the {@link PipelineAggregator}.
*/
public Writeable.Reader<? extends PipelineAggregator> getAggregatorReader() {
return aggregatorReader;
}
示例13: SearchExtSpec
import org.elasticsearch.common.io.stream.Writeable; //导入依赖的package包/类
public SearchExtSpec(ParseField name, Writeable.Reader<? extends T> reader,
CheckedFunction<XContentParser, T, IOException> parser) {
super(name, reader, parser);
}
示例14: getReader
import org.elasticsearch.common.io.stream.Writeable; //导入依赖的package包/类
/**
* The reader responsible for reading the behavior from the internode protocol.
*/
public Writeable.Reader<? extends W> getReader() {
return reader;
}
示例15: instanceReader
import org.elasticsearch.common.io.stream.Writeable; //导入依赖的package包/类
@Override
protected Writeable.Reader<ScriptMetaData> instanceReader() {
return ScriptMetaData::new;
}