Skip to content

Commit

Permalink
Remove type mapping
Browse files Browse the repository at this point in the history
Signed-off-by: Vacha Shah <[email protected]>
  • Loading branch information
VachaShah committed Mar 30, 2022
1 parent 677b623 commit 1e01fbe
Show file tree
Hide file tree
Showing 40 changed files with 4 additions and 2,041 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ public abstract class WriteResponseBase implements JsonpSerializable {

private final ShardStatistics shards;

@Nullable
private final String type;

private final long version;

@Nullable
Expand All @@ -81,7 +78,6 @@ protected WriteResponseBase(AbstractBuilder<?> builder) {
this.result = ApiTypeHelper.requireNonNull(builder.result, this, "result");
this.seqNo = ApiTypeHelper.requireNonNull(builder.seqNo, this, "seqNo");
this.shards = ApiTypeHelper.requireNonNull(builder.shards, this, "shards");
this.type = builder.type;
this.version = ApiTypeHelper.requireNonNull(builder.version, this, "version");
this.forcedRefresh = builder.forcedRefresh;

Expand Down Expand Up @@ -129,14 +125,6 @@ public final ShardStatistics shards() {
return this.shards;
}

/**
* API name: {@code _type}
*/
@Nullable
public final String type() {
return this.type;
}

/**
* Required - API name: {@code _version}
*/
Expand Down Expand Up @@ -180,11 +168,6 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) {
generator.writeKey("_shards");
this.shards.serialize(generator, mapper);

if (this.type != null) {
generator.writeKey("_type");
generator.write(this.type);

}
generator.writeKey("_version");
generator.write(this.version);

Expand All @@ -211,9 +194,6 @@ protected abstract static class AbstractBuilder<BuilderT extends AbstractBuilder

private ShardStatistics shards;

@Nullable
private String type;

private Long version;

@Nullable
Expand Down Expand Up @@ -274,14 +254,6 @@ public final BuilderT shards(Function<ShardStatistics.Builder, ObjectBuilder<Sha
return this.shards(fn.apply(new ShardStatistics.Builder()).build());
}

/**
* API name: {@code _type}
*/
public final BuilderT type(@Nullable String value) {
this.type = value;
return self();
}

/**
* Required - API name: {@code _version}
*/
Expand Down Expand Up @@ -312,7 +284,6 @@ protected static <BuilderT extends AbstractBuilder<BuilderT>> void setupWriteRes
op.add(AbstractBuilder::result, Result._DESERIALIZER, "result");
op.add(AbstractBuilder::seqNo, JsonpDeserializer.longDeserializer(), "_seq_no");
op.add(AbstractBuilder::shards, ShardStatistics._DESERIALIZER, "_shards");
op.add(AbstractBuilder::type, JsonpDeserializer.stringDeserializer(), "_type");
op.add(AbstractBuilder::version, JsonpDeserializer.longDeserializer(), "_version");
op.add(AbstractBuilder::forcedRefresh, JsonpDeserializer.booleanDeserializer(), "forced_refresh");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ public class BulkRequest extends RequestBase implements NdJsonpSerializable, Jso
@Nullable
private final Time timeout;

@Nullable
private final String type;

@Nullable
private final WaitForActiveShards waitForActiveShards;

Expand All @@ -116,7 +113,6 @@ private BulkRequest(Builder builder) {
this.requireAlias = builder.requireAlias;
this.routing = builder.routing;
this.timeout = builder.timeout;
this.type = builder.type;
this.waitForActiveShards = builder.waitForActiveShards;
this.operations = ApiTypeHelper.unmodifiableRequired(builder.operations, this, "operations");

Expand Down Expand Up @@ -224,16 +220,6 @@ public final Time timeout() {
return this.timeout;
}

/**
* Default document type for items which don't provide one
* <p>
* API name: {@code type}
*/
@Nullable
public final String type() {
return this.type;
}

/**
* Sets the number of shard copies that must be active before proceeding with
* the bulk operation. Defaults to 1, meaning the primary shard only. Set to
Expand Down Expand Up @@ -304,9 +290,6 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder<B
@Nullable
private Time timeout;

@Nullable
private String type;

@Nullable
private WaitForActiveShards waitForActiveShards;

Expand Down Expand Up @@ -457,16 +440,6 @@ public final Builder timeout(Function<Time.Builder, ObjectBuilder<Time>> fn) {
return this.timeout(fn.apply(new Time.Builder()).build());
}

/**
* Default document type for items which don't provide one
* <p>
* API name: {@code type}
*/
public final Builder type(@Nullable String value) {
this.type = value;
return this;
}

/**
* Sets the number of shard copies that must be active before proceeding with
* the bulk operation. Defaults to 1, meaning the primary shard only. Set to
Expand Down Expand Up @@ -559,14 +532,11 @@ public BulkRequest build() {
// Request path
request -> {
final int _index = 1 << 0;
final int _type = 1 << 1;

int propsSet = 0;

if (request.index() != null)
propsSet |= _index;
if (request.type() != null)
propsSet |= _type;

if (propsSet == 0) {
StringBuilder buf = new StringBuilder();
Expand All @@ -580,15 +550,6 @@ public BulkRequest build() {
buf.append("/_bulk");
return buf.toString();
}
if (propsSet == (_index | _type)) {
StringBuilder buf = new StringBuilder();
buf.append("/");
SimpleEndpoint.pathEncode(request.index, buf);
buf.append("/");
SimpleEndpoint.pathEncode(request.type, buf);
buf.append("/_bulk");
return buf.toString();
}
throw SimpleEndpoint.noPathTemplateFound("path");

},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ public class CountRequest extends RequestBase implements JsonpSerializable {
@Nullable
private final Long terminateAfter;

private final List<String> type;

// ---------------------------------------------------------------------------------------------

private CountRequest(Builder builder) {
Expand All @@ -137,7 +135,6 @@ private CountRequest(Builder builder) {
this.query = builder.query;
this.routing = builder.routing;
this.terminateAfter = builder.terminateAfter;
this.type = ApiTypeHelper.unmodifiable(builder.type);

}

Expand Down Expand Up @@ -312,15 +309,6 @@ public final Long terminateAfter() {
return this.terminateAfter;
}

/**
* A comma-separated list of types to restrict the results
* <p>
* API name: {@code type}
*/
public final List<String> type() {
return this.type;
}

/**
* Serialize this object to JSON.
*/
Expand Down Expand Up @@ -395,9 +383,6 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder<C
@Nullable
private Long terminateAfter;

@Nullable
private List<String> type;

/**
* Whether to ignore if a wildcard indices expression resolves into no concrete
* indices. (This includes <code>_all</code> string or when no indices have been
Expand Down Expand Up @@ -603,30 +588,6 @@ public final Builder terminateAfter(@Nullable Long value) {
return this;
}

/**
* A comma-separated list of types to restrict the results
* <p>
* API name: {@code type}
* <p>
* Adds all elements of <code>list</code> to <code>type</code>.
*/
public final Builder type(List<String> list) {
this.type = _listAddAll(this.type, list);
return this;
}

/**
* A comma-separated list of types to restrict the results
* <p>
* API name: {@code type}
* <p>
* Adds one or more values to <code>type</code>.
*/
public final Builder type(String value, String... values) {
this.type = _listAdd(this.type, value, values);
return this;
}

/**
* Builds a {@link CountRequest}.
*
Expand Down Expand Up @@ -670,14 +631,11 @@ protected static void setupCountRequestDeserializer(ObjectDeserializer<CountRequ
// Request path
request -> {
final int _index = 1 << 0;
final int _type = 1 << 1;

int propsSet = 0;

if (ApiTypeHelper.isDefined(request.index()))
propsSet |= _index;
if (ApiTypeHelper.isDefined(request.type()))
propsSet |= _type;

if (propsSet == 0) {
StringBuilder buf = new StringBuilder();
Expand All @@ -691,15 +649,6 @@ protected static void setupCountRequestDeserializer(ObjectDeserializer<CountRequ
buf.append("/_count");
return buf.toString();
}
if (propsSet == (_index | _type)) {
StringBuilder buf = new StringBuilder();
buf.append("/");
SimpleEndpoint.pathEncode(request.index.stream().map(v -> v).collect(Collectors.joining(",")), buf);
buf.append("/");
SimpleEndpoint.pathEncode(request.type.stream().map(v -> v).collect(Collectors.joining(",")), buf);
buf.append("/_count");
return buf.toString();
}
throw SimpleEndpoint.noPathTemplateFound("path");

},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ public class CreateRequest<TDocument> extends RequestBase implements JsonpSerial
@Nullable
private final Time timeout;

@Nullable
private final String type;

@Nullable
private final Long version;

Expand All @@ -113,7 +110,6 @@ private CreateRequest(Builder<TDocument> builder) {
this.refresh = builder.refresh;
this.routing = builder.routing;
this.timeout = builder.timeout;
this.type = builder.type;
this.version = builder.version;
this.versionType = builder.versionType;
this.waitForActiveShards = builder.waitForActiveShards;
Expand Down Expand Up @@ -188,16 +184,6 @@ public final Time timeout() {
return this.timeout;
}

/**
* The type of the document
* <p>
* API name: {@code type}
*/
@Nullable
public final String type() {
return this.type;
}

/**
* Explicit version number for concurrency control
* <p>
Expand Down Expand Up @@ -274,9 +260,6 @@ public static class Builder<TDocument> extends ObjectBuilderBase
@Nullable
private Time timeout;

@Nullable
private String type;

@Nullable
private Long version;

Expand Down Expand Up @@ -363,16 +346,6 @@ public final Builder<TDocument> timeout(Function<Time.Builder, ObjectBuilder<Tim
return this.timeout(fn.apply(new Time.Builder()).build());
}

/**
* The type of the document
* <p>
* API name: {@code type}
*/
public final Builder<TDocument> type(@Nullable String value) {
this.type = value;
return this;
}

/**
* Explicit version number for concurrency control
* <p>
Expand Down Expand Up @@ -479,14 +452,11 @@ public static <TDocument> JsonpDeserializer<CreateRequest<TDocument>> createCrea
request -> {
final int _index = 1 << 0;
final int _id = 1 << 1;
final int _type = 1 << 2;

int propsSet = 0;

propsSet |= _index;
propsSet |= _id;
if (request.type() != null)
propsSet |= _type;

if (propsSet == (_index | _id)) {
StringBuilder buf = new StringBuilder();
Expand All @@ -497,17 +467,6 @@ public static <TDocument> JsonpDeserializer<CreateRequest<TDocument>> createCrea
SimpleEndpoint.pathEncode(request.id, buf);
return buf.toString();
}
if (propsSet == (_index | _type | _id)) {
StringBuilder buf = new StringBuilder();
buf.append("/");
SimpleEndpoint.pathEncode(request.index, buf);
buf.append("/");
SimpleEndpoint.pathEncode(request.type, buf);
buf.append("/");
SimpleEndpoint.pathEncode(request.id, buf);
buf.append("/_create");
return buf.toString();
}
throw SimpleEndpoint.noPathTemplateFound("path");

},
Expand Down
Loading

0 comments on commit 1e01fbe

Please sign in to comment.