Search in sources :

Example 1 with Entry

use of org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry in project elasticsearch by elastic.

the class ShapeBuilders method register.

public static void register(List<Entry> namedWriteables) {
    namedWriteables.add(new Entry(ShapeBuilder.class, PointBuilder.TYPE.shapeName(), PointBuilder::new));
    namedWriteables.add(new Entry(ShapeBuilder.class, CircleBuilder.TYPE.shapeName(), CircleBuilder::new));
    namedWriteables.add(new Entry(ShapeBuilder.class, EnvelopeBuilder.TYPE.shapeName(), EnvelopeBuilder::new));
    namedWriteables.add(new Entry(ShapeBuilder.class, MultiPointBuilder.TYPE.shapeName(), MultiPointBuilder::new));
    namedWriteables.add(new Entry(ShapeBuilder.class, LineStringBuilder.TYPE.shapeName(), LineStringBuilder::new));
    namedWriteables.add(new Entry(ShapeBuilder.class, MultiLineStringBuilder.TYPE.shapeName(), MultiLineStringBuilder::new));
    namedWriteables.add(new Entry(ShapeBuilder.class, PolygonBuilder.TYPE.shapeName(), PolygonBuilder::new));
    namedWriteables.add(new Entry(ShapeBuilder.class, MultiPolygonBuilder.TYPE.shapeName(), MultiPolygonBuilder::new));
    namedWriteables.add(new Entry(ShapeBuilder.class, GeometryCollectionBuilder.TYPE.shapeName(), GeometryCollectionBuilder::new));
}
Also used : Entry(org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry)

Example 2 with Entry

use of org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry in project elasticsearch by elastic.

the class IndicesModule method registerBuiltinWritables.

private void registerBuiltinWritables() {
    namedWritables.add(new Entry(Condition.class, MaxAgeCondition.NAME, MaxAgeCondition::new));
    namedWritables.add(new Entry(Condition.class, MaxDocsCondition.NAME, MaxDocsCondition::new));
}
Also used : MaxAgeCondition(org.elasticsearch.action.admin.indices.rollover.MaxAgeCondition) MaxDocsCondition(org.elasticsearch.action.admin.indices.rollover.MaxDocsCondition) Condition(org.elasticsearch.action.admin.indices.rollover.Condition) Entry(org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry)

Example 3 with Entry

use of org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry in project elasticsearch by elastic.

the class ClusterModule method registerCustom.

private static <T extends NamedWriteable> void registerCustom(List<Entry> entries, Class<T> category, String name, Reader<? extends T> reader, Reader<NamedDiff> diffReader) {
    entries.add(new Entry(category, name, reader));
    entries.add(new Entry(NamedDiff.class, name, diffReader));
}
Also used : Entry(org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry)

Example 4 with Entry

use of org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry in project elasticsearch by elastic.

the class DocValueFormatTests method testSerialization.

public void testSerialization() throws Exception {
    List<Entry> entries = new ArrayList<>();
    entries.add(new Entry(DocValueFormat.class, DocValueFormat.BOOLEAN.getWriteableName(), in -> DocValueFormat.BOOLEAN));
    entries.add(new Entry(DocValueFormat.class, DocValueFormat.DateTime.NAME, DocValueFormat.DateTime::new));
    entries.add(new Entry(DocValueFormat.class, DocValueFormat.Decimal.NAME, DocValueFormat.Decimal::new));
    entries.add(new Entry(DocValueFormat.class, DocValueFormat.GEOHASH.getWriteableName(), in -> DocValueFormat.GEOHASH));
    entries.add(new Entry(DocValueFormat.class, DocValueFormat.IP.getWriteableName(), in -> DocValueFormat.IP));
    entries.add(new Entry(DocValueFormat.class, DocValueFormat.RAW.getWriteableName(), in -> DocValueFormat.RAW));
    NamedWriteableRegistry registry = new NamedWriteableRegistry(entries);
    BytesStreamOutput out = new BytesStreamOutput();
    out.writeNamedWriteable(DocValueFormat.BOOLEAN);
    StreamInput in = new NamedWriteableAwareStreamInput(out.bytes().streamInput(), registry);
    assertSame(DocValueFormat.BOOLEAN, in.readNamedWriteable(DocValueFormat.class));
    DocValueFormat.Decimal decimalFormat = new DocValueFormat.Decimal("###.##");
    out = new BytesStreamOutput();
    out.writeNamedWriteable(decimalFormat);
    in = new NamedWriteableAwareStreamInput(out.bytes().streamInput(), registry);
    DocValueFormat vf = in.readNamedWriteable(DocValueFormat.class);
    assertEquals(DocValueFormat.Decimal.class, vf.getClass());
    assertEquals("###.##", ((DocValueFormat.Decimal) vf).pattern);
    DocValueFormat.DateTime dateFormat = new DocValueFormat.DateTime(Joda.forPattern("epoch_second"), DateTimeZone.forOffsetHours(1));
    out = new BytesStreamOutput();
    out.writeNamedWriteable(dateFormat);
    in = new NamedWriteableAwareStreamInput(out.bytes().streamInput(), registry);
    vf = in.readNamedWriteable(DocValueFormat.class);
    assertEquals(DocValueFormat.DateTime.class, vf.getClass());
    assertEquals("epoch_second", ((DocValueFormat.DateTime) vf).formatter.format());
    assertEquals(DateTimeZone.forOffsetHours(1), ((DocValueFormat.DateTime) vf).timeZone);
    out = new BytesStreamOutput();
    out.writeNamedWriteable(DocValueFormat.GEOHASH);
    in = new NamedWriteableAwareStreamInput(out.bytes().streamInput(), registry);
    assertSame(DocValueFormat.GEOHASH, in.readNamedWriteable(DocValueFormat.class));
    out = new BytesStreamOutput();
    out.writeNamedWriteable(DocValueFormat.IP);
    in = new NamedWriteableAwareStreamInput(out.bytes().streamInput(), registry);
    assertSame(DocValueFormat.IP, in.readNamedWriteable(DocValueFormat.class));
    out = new BytesStreamOutput();
    out.writeNamedWriteable(DocValueFormat.RAW);
    in = new NamedWriteableAwareStreamInput(out.bytes().streamInput(), registry);
    assertSame(DocValueFormat.RAW, in.readNamedWriteable(DocValueFormat.class));
}
Also used : DateTimeZone(org.joda.time.DateTimeZone) Joda(org.elasticsearch.common.joda.Joda) InetAddressPoint(org.apache.lucene.document.InetAddressPoint) BytesRef(org.apache.lucene.util.BytesRef) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) ArrayList(java.util.ArrayList) InetAddresses(org.elasticsearch.common.network.InetAddresses) List(java.util.List) NamedWriteableAwareStreamInput(org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput) NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) StreamInput(org.elasticsearch.common.io.stream.StreamInput) ESTestCase(org.elasticsearch.test.ESTestCase) Entry(org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry) NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) ArrayList(java.util.ArrayList) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) Entry(org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry) NamedWriteableAwareStreamInput(org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput) StreamInput(org.elasticsearch.common.io.stream.StreamInput) NamedWriteableAwareStreamInput(org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput)

Example 5 with Entry

use of org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry in project elasticsearch by elastic.

the class SearchModule method registerSmoothingModels.

public static void registerSmoothingModels(List<Entry> namedWriteables) {
    namedWriteables.add(new NamedWriteableRegistry.Entry(SmoothingModel.class, Laplace.NAME, Laplace::new));
    namedWriteables.add(new NamedWriteableRegistry.Entry(SmoothingModel.class, LinearInterpolation.NAME, LinearInterpolation::new));
    namedWriteables.add(new NamedWriteableRegistry.Entry(SmoothingModel.class, StupidBackoff.NAME, StupidBackoff::new));
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) SmoothingModel(org.elasticsearch.search.suggest.phrase.SmoothingModel) Entry(org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry)

Aggregations

Entry (org.elasticsearch.common.io.stream.NamedWriteableRegistry.Entry)5 NamedWriteableRegistry (org.elasticsearch.common.io.stream.NamedWriteableRegistry)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 InetAddressPoint (org.apache.lucene.document.InetAddressPoint)1 BytesRef (org.apache.lucene.util.BytesRef)1 Condition (org.elasticsearch.action.admin.indices.rollover.Condition)1 MaxAgeCondition (org.elasticsearch.action.admin.indices.rollover.MaxAgeCondition)1 MaxDocsCondition (org.elasticsearch.action.admin.indices.rollover.MaxDocsCondition)1 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)1 NamedWriteableAwareStreamInput (org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput)1 StreamInput (org.elasticsearch.common.io.stream.StreamInput)1 Joda (org.elasticsearch.common.joda.Joda)1 InetAddresses (org.elasticsearch.common.network.InetAddresses)1 SmoothingModel (org.elasticsearch.search.suggest.phrase.SmoothingModel)1 ESTestCase (org.elasticsearch.test.ESTestCase)1 DateTimeZone (org.joda.time.DateTimeZone)1