mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-25 09:28:27 +00:00
XContent refactoring, closes #367.
This commit is contained in:
parent
4822517d5d
commit
38aeba438d
@ -23,7 +23,7 @@ import org.elasticsearch.action.index.IndexRequest;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.common.StopWatch;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.node.Node;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -28,10 +28,9 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.TextXContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
@ -141,7 +140,7 @@ public class CreateIndexRequest extends MasterNodeOperationRequest {
|
||||
*/
|
||||
public CreateIndexRequest settings(Map source) {
|
||||
try {
|
||||
TextXContentBuilder builder = XContentFactory.contentTextBuilder(XContentType.JSON);
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
|
||||
builder.map(source);
|
||||
settings(builder.string());
|
||||
} catch (IOException e) {
|
||||
@ -192,7 +191,7 @@ public class CreateIndexRequest extends MasterNodeOperationRequest {
|
||||
*/
|
||||
public CreateIndexRequest mapping(String type, Map source) {
|
||||
try {
|
||||
TextXContentBuilder builder = XContentFactory.contentTextBuilder(XContentType.JSON);
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
|
||||
builder.map(source);
|
||||
return mapping(type, builder.string());
|
||||
} catch (IOException e) {
|
||||
|
@ -27,10 +27,9 @@ import org.elasticsearch.common.Required;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.TextXContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
@ -137,7 +136,7 @@ public class PutMappingRequest extends MasterNodeOperationRequest {
|
||||
*/
|
||||
@Required public PutMappingRequest source(Map mappingSource) {
|
||||
try {
|
||||
TextXContentBuilder builder = XContentFactory.contentTextBuilder(XContentType.JSON);
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
|
||||
builder.map(mappingSource);
|
||||
return source(builder.string());
|
||||
} catch (IOException e) {
|
||||
|
@ -26,9 +26,9 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.TextXContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
@ -114,7 +114,7 @@ public class UpdateSettingsRequest extends MasterNodeOperationRequest {
|
||||
*/
|
||||
public UpdateSettingsRequest settings(Map source) {
|
||||
try {
|
||||
TextXContentBuilder builder = XContentFactory.contentTextBuilder(XContentType.JSON);
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
|
||||
builder.map(source);
|
||||
settings(builder.string());
|
||||
} catch (IOException e) {
|
||||
|
@ -32,10 +32,9 @@ import org.elasticsearch.common.Unicode;
|
||||
import org.elasticsearch.common.io.FastByteArrayOutputStream;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.BinaryXContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -184,7 +183,7 @@ public class CountRequest extends BroadcastOperationRequest {
|
||||
*/
|
||||
@Required public CountRequest query(Map querySource) {
|
||||
try {
|
||||
BinaryXContentBuilder builder = XContentFactory.contentBinaryBuilder(contentType);
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
|
||||
builder.map(querySource);
|
||||
return query(builder);
|
||||
} catch (IOException e) {
|
||||
|
@ -32,10 +32,9 @@ import org.elasticsearch.common.io.FastByteArrayOutputStream;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.BinaryXContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -147,7 +146,7 @@ public class DeleteByQueryRequest extends IndicesReplicationOperationRequest {
|
||||
*/
|
||||
@Required public DeleteByQueryRequest query(Map querySource) {
|
||||
try {
|
||||
BinaryXContentBuilder builder = XContentFactory.contentBinaryBuilder(contentType);
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
|
||||
builder.map(querySource);
|
||||
return query(builder);
|
||||
} catch (IOException e) {
|
||||
|
@ -28,9 +28,9 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.rest.action.support.RestXContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -30,10 +30,9 @@ import org.elasticsearch.common.Unicode;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.BinaryXContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
@ -49,8 +48,8 @@ import static org.elasticsearch.action.Actions.*;
|
||||
* {@link #source(byte[])} to be set.
|
||||
*
|
||||
* <p>The source (content to index) can be set in its bytes form using ({@link #source(byte[])}),
|
||||
* its string form ({@link #source(String)}) or using a {@link org.elasticsearch.common.xcontent.builder.XContentBuilder}
|
||||
* ({@link #source(org.elasticsearch.common.xcontent.builder.XContentBuilder)}).
|
||||
* its string form ({@link #source(String)}) or using a {@link org.elasticsearch.common.xcontent.XContentBuilder}
|
||||
* ({@link #source(org.elasticsearch.common.xcontent.XContentBuilder)}).
|
||||
*
|
||||
* <p>If the {@link #id(String)} is not set, it will be automatically generated.
|
||||
*
|
||||
@ -238,7 +237,7 @@ public class IndexRequest extends ShardReplicationOperationRequest {
|
||||
*/
|
||||
@Required public IndexRequest source(Map source, XContentType contentType) throws ElasticSearchGenerationException {
|
||||
try {
|
||||
BinaryXContentBuilder builder = XContentFactory.contentBinaryBuilder(contentType);
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
|
||||
builder.map(source);
|
||||
return source(builder);
|
||||
} catch (IOException e) {
|
||||
@ -249,7 +248,7 @@ public class IndexRequest extends ShardReplicationOperationRequest {
|
||||
/**
|
||||
* Sets the document source to index.
|
||||
*
|
||||
* <p>Note, its preferable to either set it using {@link #source(org.elasticsearch.common.xcontent.builder.XContentBuilder)}
|
||||
* <p>Note, its preferable to either set it using {@link #source(org.elasticsearch.common.xcontent.XContentBuilder)}
|
||||
* or using the {@link #source(byte[])}.
|
||||
*/
|
||||
@Required public IndexRequest source(String source) {
|
||||
|
@ -34,10 +34,9 @@ import org.elasticsearch.common.Unicode;
|
||||
import org.elasticsearch.common.io.FastByteArrayOutputStream;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.BinaryXContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.search.Scroll;
|
||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
|
||||
@ -324,7 +323,7 @@ public class MoreLikeThisRequest implements ActionRequest {
|
||||
* more like this documents.
|
||||
*/
|
||||
public MoreLikeThisRequest searchSource(SearchSourceBuilder sourceBuilder) {
|
||||
FastByteArrayOutputStream bos = sourceBuilder.buildAsUnsafeBytes();
|
||||
FastByteArrayOutputStream bos = sourceBuilder.buildAsUnsafeBytes(Requests.CONTENT_TYPE);
|
||||
this.searchSource = bos.unsafeByteArray();
|
||||
this.searchSourceOffset = 0;
|
||||
this.searchSourceLength = bos.size();
|
||||
@ -347,7 +346,7 @@ public class MoreLikeThisRequest implements ActionRequest {
|
||||
|
||||
public MoreLikeThisRequest searchSource(Map searchSource) {
|
||||
try {
|
||||
BinaryXContentBuilder builder = XContentFactory.contentBinaryBuilder(contentType);
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
|
||||
builder.map(searchSource);
|
||||
return searchSource(builder);
|
||||
} catch (IOException e) {
|
||||
|
@ -32,10 +32,9 @@ import org.elasticsearch.common.io.FastByteArrayOutputStream;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.BinaryXContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.search.Scroll;
|
||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
|
||||
@ -217,7 +216,7 @@ public class SearchRequest implements ActionRequest {
|
||||
* The source of the search request.
|
||||
*/
|
||||
public SearchRequest source(SearchSourceBuilder sourceBuilder) {
|
||||
FastByteArrayOutputStream bos = sourceBuilder.buildAsUnsafeBytes();
|
||||
FastByteArrayOutputStream bos = sourceBuilder.buildAsUnsafeBytes(Requests.CONTENT_TYPE);
|
||||
this.source = bos.unsafeByteArray();
|
||||
this.sourceOffset = 0;
|
||||
this.sourceLength = bos.size();
|
||||
@ -243,7 +242,7 @@ public class SearchRequest implements ActionRequest {
|
||||
*/
|
||||
public SearchRequest source(Map source) {
|
||||
try {
|
||||
BinaryXContentBuilder builder = XContentFactory.contentBinaryBuilder(contentType);
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
|
||||
builder.map(source);
|
||||
return source(builder);
|
||||
} catch (IOException e) {
|
||||
@ -300,7 +299,7 @@ public class SearchRequest implements ActionRequest {
|
||||
* Allows to provide additional source that will be used as well.
|
||||
*/
|
||||
public SearchRequest extraSource(SearchSourceBuilder sourceBuilder) {
|
||||
FastByteArrayOutputStream bos = sourceBuilder.buildAsUnsafeBytes();
|
||||
FastByteArrayOutputStream bos = sourceBuilder.buildAsUnsafeBytes(Requests.CONTENT_TYPE);
|
||||
this.extraSource = bos.unsafeByteArray();
|
||||
this.extraSourceOffset = 0;
|
||||
this.extraSourceLength = bos.size();
|
||||
@ -310,7 +309,7 @@ public class SearchRequest implements ActionRequest {
|
||||
|
||||
public SearchRequest extraSource(Map extraSource) {
|
||||
try {
|
||||
BinaryXContentBuilder builder = XContentFactory.contentBinaryBuilder(contentType);
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
|
||||
builder.map(extraSource);
|
||||
return extraSource(builder);
|
||||
} catch (IOException e) {
|
||||
|
@ -23,7 +23,7 @@ import org.elasticsearch.action.ActionResponse;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.search.SearchHits;
|
||||
import org.elasticsearch.search.facets.Facets;
|
||||
import org.elasticsearch.search.internal.InternalSearchResponse;
|
||||
|
@ -59,7 +59,7 @@ public class Requests {
|
||||
/**
|
||||
* The content type used to generate request builders (query / search).
|
||||
*/
|
||||
public static XContentType CONTENT_TYPE = XContentType.XSON;
|
||||
public static XContentType CONTENT_TYPE = XContentType.SMILE;
|
||||
|
||||
public static IndexRequest indexRequest() {
|
||||
return new IndexRequest();
|
||||
|
@ -26,7 +26,7 @@ import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -25,7 +25,7 @@ import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse;
|
||||
import org.elasticsearch.client.IndicesAdminClient;
|
||||
import org.elasticsearch.client.action.admin.indices.support.BaseIndicesRequestBuilder;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -26,7 +26,7 @@ import org.elasticsearch.action.support.replication.ReplicationType;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.action.support.BaseRequestBuilder;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilder;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -26,8 +26,8 @@ import org.elasticsearch.action.support.replication.ReplicationType;
|
||||
import org.elasticsearch.client.Client;
|
||||
import org.elasticsearch.client.action.support.BaseRequestBuilder;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Map;
|
||||
@ -91,7 +91,7 @@ public class IndexRequestBuilder extends BaseRequestBuilder<IndexRequest, IndexR
|
||||
/**
|
||||
* Sets the document source to index.
|
||||
*
|
||||
* <p>Note, its preferable to either set it using {@link #setSource(org.elasticsearch.common.xcontent.builder.XContentBuilder)}
|
||||
* <p>Note, its preferable to either set it using {@link #setSource(org.elasticsearch.common.xcontent.XContentBuilder)}
|
||||
* or using the {@link #setSource(byte[])}.
|
||||
*/
|
||||
public IndexRequestBuilder setSource(String source) {
|
||||
|
@ -23,7 +23,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
@ -30,9 +30,9 @@ import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.cluster.metadata;
|
||||
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.indexer.IndexerName;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class IndexerMetaData {
|
||||
|
||||
private final IndexerName indexerName;
|
||||
|
||||
private final Settings settings;
|
||||
|
||||
private IndexerMetaData(IndexerName indexerName, Settings settings) {
|
||||
this.indexerName = indexerName;
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
public IndexerName indexerName() {
|
||||
return indexerName;
|
||||
}
|
||||
|
||||
public Settings settings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private IndexerName indexerName;
|
||||
|
||||
private Settings settings = ImmutableSettings.Builder.EMPTY_SETTINGS;
|
||||
|
||||
public Builder(IndexerName indexerName) {
|
||||
this.indexerName = indexerName;
|
||||
}
|
||||
|
||||
public Builder settings(Settings.Builder settings) {
|
||||
this.settings = settings.build();
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder settings(Settings settings) {
|
||||
this.settings = settings;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IndexerMetaData build() {
|
||||
return new IndexerMetaData(indexerName, settings);
|
||||
}
|
||||
|
||||
public static void toXContent(IndexerMetaData indexerMetaData, XContentBuilder builder, ToXContent.Params params) throws IOException {
|
||||
builder.startObject(indexerMetaData.indexerName().name());
|
||||
|
||||
builder.field("type", indexerMetaData.indexerName().type());
|
||||
|
||||
builder.startObject("settings");
|
||||
for (Map.Entry<String, String> entry : indexerMetaData.settings().getAsMap().entrySet()) {
|
||||
builder.field(entry.getKey(), entry.getValue());
|
||||
}
|
||||
builder.endObject();
|
||||
|
||||
builder.endObject();
|
||||
}
|
||||
|
||||
public static IndexerMetaData fromXContent(XContentParser parser, @Nullable Settings globalSettings) throws IOException {
|
||||
String name = parser.currentName();
|
||||
ImmutableSettings.Builder settingsBuilder = null;
|
||||
String type = null;
|
||||
|
||||
String currentFieldName = null;
|
||||
XContentParser.Token token = parser.nextToken();
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
if (token == XContentParser.Token.FIELD_NAME) {
|
||||
currentFieldName = parser.currentName();
|
||||
} else if (token == XContentParser.Token.START_OBJECT) {
|
||||
if ("settings".equals(currentFieldName)) {
|
||||
settingsBuilder = ImmutableSettings.settingsBuilder().globalSettings(globalSettings);
|
||||
while ((token = parser.nextToken()) != XContentParser.Token.END_OBJECT) {
|
||||
String key = parser.currentName();
|
||||
token = parser.nextToken();
|
||||
String value = parser.text();
|
||||
settingsBuilder.put(key, value);
|
||||
}
|
||||
}
|
||||
} else if (token.isValue()) {
|
||||
if ("type".equals(currentFieldName)) {
|
||||
type = parser.text();
|
||||
}
|
||||
}
|
||||
}
|
||||
Builder builder = new Builder(new IndexerName(name, type));
|
||||
if (settingsBuilder != null) {
|
||||
builder.settings(settingsBuilder);
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public static IndexerMetaData readFrom(StreamInput in, Settings globalSettings) throws IOException {
|
||||
Builder builder = new Builder(new IndexerName(in.readUTF(), in.readUTF()));
|
||||
builder.settings(ImmutableSettings.readSettingsFromStream(in, globalSettings));
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public static void writeTo(IndexerMetaData indexerMetaData, StreamOutput out) throws IOException {
|
||||
out.writeUTF(indexerMetaData.indexerName().type());
|
||||
out.writeUTF(indexerMetaData.indexerName().name());
|
||||
ImmutableSettings.writeSettingsToStream(indexerMetaData.settings(), out);
|
||||
}
|
||||
}
|
||||
}
|
@ -25,12 +25,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.TextXContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.*;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.indices.IndexMissingException;
|
||||
|
||||
@ -281,7 +276,7 @@ public class MetaData implements Iterable<IndexMetaData> {
|
||||
}
|
||||
|
||||
public static String toXContent(MetaData metaData) throws IOException {
|
||||
TextXContentBuilder builder = XContentFactory.contentTextBuilder(XContentType.JSON);
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
|
||||
builder.startObject();
|
||||
toXContent(metaData, builder, ToXContent.EMPTY_PARAMS);
|
||||
builder.endObject();
|
||||
|
@ -28,7 +28,7 @@ public class Bytes {
|
||||
|
||||
public static ThreadLocal<ThreadLocals.CleanableValue<byte[]>> cachedBytes = new ThreadLocal<ThreadLocals.CleanableValue<byte[]>>() {
|
||||
@Override protected ThreadLocals.CleanableValue<byte[]> initialValue() {
|
||||
return new ThreadLocals.CleanableValue<byte[]>(new byte[256]);
|
||||
return new ThreadLocals.CleanableValue<byte[]>(new byte[1024]);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -178,6 +178,13 @@ public class FastByteArrayOutputStream extends OutputStream {
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Seeks back to the given position. Size will become the seeked location.
|
||||
*/
|
||||
public void seek(int position) {
|
||||
this.count = position;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the buffer's contents into a string decoding bytes using the
|
||||
* platform's default character set. The length of the new <tt>String</tt>
|
||||
|
@ -20,13 +20,12 @@
|
||||
package org.elasticsearch.common.xcontent;
|
||||
|
||||
import org.elasticsearch.common.Booleans;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* An interface allowing to transfer an object to "XContent" using an {@link org.elasticsearch.common.xcontent.builder.XContentBuilder}.
|
||||
* An interface allowing to transfer an object to "XContent" using an {@link XContentBuilder}.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
|
@ -17,15 +17,15 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.xcontent.builder;
|
||||
package org.elasticsearch.common.xcontent;
|
||||
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.Unicode;
|
||||
import org.elasticsearch.common.io.FastByteArrayOutputStream;
|
||||
import org.elasticsearch.common.joda.time.DateTimeZone;
|
||||
import org.elasticsearch.common.joda.time.ReadableInstant;
|
||||
import org.elasticsearch.common.joda.time.format.DateTimeFormatter;
|
||||
import org.elasticsearch.common.joda.time.format.ISODateTimeFormat;
|
||||
import org.elasticsearch.common.xcontent.XContentGenerator;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.support.XContentMapConverter;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -37,7 +37,7 @@ import java.util.Map;
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public abstract class XContentBuilder<T extends XContentBuilder> {
|
||||
public final class XContentBuilder {
|
||||
|
||||
public static enum FieldCaseConversion {
|
||||
/**
|
||||
@ -62,168 +62,187 @@ public abstract class XContentBuilder<T extends XContentBuilder> {
|
||||
XContentBuilder.globalFieldCaseConversion = globalFieldCaseConversion;
|
||||
}
|
||||
|
||||
protected XContentGenerator generator;
|
||||
private XContentGenerator generator;
|
||||
|
||||
protected T builder;
|
||||
private final FastByteArrayOutputStream bos;
|
||||
|
||||
protected FieldCaseConversion fieldCaseConversion = globalFieldCaseConversion;
|
||||
private FieldCaseConversion fieldCaseConversion = globalFieldCaseConversion;
|
||||
|
||||
protected StringBuilder cachedStringBuilder = new StringBuilder();
|
||||
private StringBuilder cachedStringBuilder;
|
||||
|
||||
public T fieldCaseConversion(FieldCaseConversion fieldCaseConversion) {
|
||||
public static XContentBuilder cachedBuilder(XContent xContent) throws IOException {
|
||||
return new XContentBuilder(FastByteArrayOutputStream.Cached.cached(), xContent);
|
||||
}
|
||||
|
||||
public static XContentBuilder builder(XContent xContent) throws IOException {
|
||||
return new XContentBuilder(new FastByteArrayOutputStream(), xContent);
|
||||
}
|
||||
|
||||
public XContentBuilder(FastByteArrayOutputStream bos, XContent xContent) throws IOException {
|
||||
this.bos = bos;
|
||||
this.generator = xContent.createGenerator(bos);
|
||||
}
|
||||
|
||||
public XContentBuilder fieldCaseConversion(FieldCaseConversion fieldCaseConversion) {
|
||||
this.fieldCaseConversion = fieldCaseConversion;
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public XContentType contentType() {
|
||||
return generator.contentType();
|
||||
}
|
||||
|
||||
public T prettyPrint() {
|
||||
public XContentBuilder prettyPrint() {
|
||||
generator.usePrettyPrint();
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T startObject(String name) throws IOException {
|
||||
public XContentBuilder startObject(String name) throws IOException {
|
||||
field(name);
|
||||
startObject();
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T startObject() throws IOException {
|
||||
public XContentBuilder startObject() throws IOException {
|
||||
generator.writeStartObject();
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T endObject() throws IOException {
|
||||
public XContentBuilder endObject() throws IOException {
|
||||
generator.writeEndObject();
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T array(String name, String... values) throws IOException {
|
||||
public XContentBuilder array(String name, String... values) throws IOException {
|
||||
startArray(name);
|
||||
for (String value : values) {
|
||||
value(value);
|
||||
}
|
||||
endArray();
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T array(String name, Object... values) throws IOException {
|
||||
public XContentBuilder array(String name, Object... values) throws IOException {
|
||||
startArray(name);
|
||||
for (Object value : values) {
|
||||
value(value);
|
||||
}
|
||||
endArray();
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T startArray(String name) throws IOException {
|
||||
public XContentBuilder startArray(String name) throws IOException {
|
||||
field(name);
|
||||
startArray();
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T startArray() throws IOException {
|
||||
public XContentBuilder startArray() throws IOException {
|
||||
generator.writeStartArray();
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T endArray() throws IOException {
|
||||
public XContentBuilder endArray() throws IOException {
|
||||
generator.writeEndArray();
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T field(String name) throws IOException {
|
||||
public XContentBuilder field(String name) throws IOException {
|
||||
if (fieldCaseConversion == FieldCaseConversion.UNDERSCORE) {
|
||||
if (cachedStringBuilder == null) {
|
||||
cachedStringBuilder = new StringBuilder();
|
||||
}
|
||||
name = Strings.toUnderscoreCase(name, cachedStringBuilder);
|
||||
} else if (fieldCaseConversion == FieldCaseConversion.CAMELCASE) {
|
||||
if (cachedStringBuilder == null) {
|
||||
cachedStringBuilder = new StringBuilder();
|
||||
}
|
||||
name = Strings.toCamelCase(name, cachedStringBuilder);
|
||||
}
|
||||
generator.writeFieldName(name);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T field(String name, char[] value, int offset, int length) throws IOException {
|
||||
public XContentBuilder field(String name, char[] value, int offset, int length) throws IOException {
|
||||
field(name);
|
||||
if (value == null) {
|
||||
generator.writeNull();
|
||||
} else {
|
||||
generator.writeString(value, offset, length);
|
||||
}
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T field(String name, String value) throws IOException {
|
||||
public XContentBuilder field(String name, String value) throws IOException {
|
||||
field(name);
|
||||
if (value == null) {
|
||||
generator.writeNull();
|
||||
} else {
|
||||
generator.writeString(value);
|
||||
}
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T field(String name, Integer value) throws IOException {
|
||||
public XContentBuilder field(String name, Integer value) throws IOException {
|
||||
return field(name, value.intValue());
|
||||
}
|
||||
|
||||
public T field(String name, int value) throws IOException {
|
||||
public XContentBuilder field(String name, int value) throws IOException {
|
||||
field(name);
|
||||
generator.writeNumber(value);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T field(String name, Long value) throws IOException {
|
||||
public XContentBuilder field(String name, Long value) throws IOException {
|
||||
return field(name, value.longValue());
|
||||
}
|
||||
|
||||
public T field(String name, long value) throws IOException {
|
||||
public XContentBuilder field(String name, long value) throws IOException {
|
||||
field(name);
|
||||
generator.writeNumber(value);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T field(String name, Float value) throws IOException {
|
||||
public XContentBuilder field(String name, Float value) throws IOException {
|
||||
return field(name, value.floatValue());
|
||||
}
|
||||
|
||||
public T field(String name, float value) throws IOException {
|
||||
public XContentBuilder field(String name, float value) throws IOException {
|
||||
field(name);
|
||||
generator.writeNumber(value);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public T field(String name, Double value) throws IOException {
|
||||
public XContentBuilder field(String name, Double value) throws IOException {
|
||||
return field(name, value.doubleValue());
|
||||
}
|
||||
|
||||
public T field(String name, double value) throws IOException {
|
||||
public XContentBuilder field(String name, double value) throws IOException {
|
||||
field(name);
|
||||
generator.writeNumber(value);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T field(String name, Map<String, Object> value) throws IOException {
|
||||
public XContentBuilder field(String name, Map<String, Object> value) throws IOException {
|
||||
field(name);
|
||||
value(value);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T field(String name, List<Object> value) throws IOException {
|
||||
public XContentBuilder field(String name, List<Object> value) throws IOException {
|
||||
startArray(name);
|
||||
for (Object o : value) {
|
||||
value(o);
|
||||
}
|
||||
endArray();
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T field(String name, Object value) throws IOException {
|
||||
public XContentBuilder field(String name, Object value) throws IOException {
|
||||
if (value == null) {
|
||||
nullField(name);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
Class type = value.getClass();
|
||||
if (type == String.class) {
|
||||
@ -251,147 +270,143 @@ public abstract class XContentBuilder<T extends XContentBuilder> {
|
||||
} else {
|
||||
field(name, value.toString());
|
||||
}
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T field(String name, boolean value) throws IOException {
|
||||
public XContentBuilder field(String name, boolean value) throws IOException {
|
||||
field(name);
|
||||
generator.writeBoolean(value);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T field(String name, byte[] value) throws IOException {
|
||||
public XContentBuilder field(String name, byte[] value) throws IOException {
|
||||
field(name);
|
||||
generator.writeBinary(value);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T field(String name, ReadableInstant date) throws IOException {
|
||||
public XContentBuilder field(String name, ReadableInstant date) throws IOException {
|
||||
field(name);
|
||||
return value(date);
|
||||
}
|
||||
|
||||
public T field(String name, ReadableInstant date, DateTimeFormatter formatter) throws IOException {
|
||||
public XContentBuilder field(String name, ReadableInstant date, DateTimeFormatter formatter) throws IOException {
|
||||
field(name);
|
||||
return value(date, formatter);
|
||||
}
|
||||
|
||||
public T field(String name, Date date) throws IOException {
|
||||
public XContentBuilder field(String name, Date date) throws IOException {
|
||||
field(name);
|
||||
return value(date);
|
||||
}
|
||||
|
||||
public T field(String name, Date date, DateTimeFormatter formatter) throws IOException {
|
||||
public XContentBuilder field(String name, Date date, DateTimeFormatter formatter) throws IOException {
|
||||
field(name);
|
||||
return value(date, formatter);
|
||||
}
|
||||
|
||||
public T nullField(String name) throws IOException {
|
||||
public XContentBuilder nullField(String name) throws IOException {
|
||||
generator.writeNullField(name);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T nullValue() throws IOException {
|
||||
public XContentBuilder nullValue() throws IOException {
|
||||
generator.writeNull();
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T rawField(String fieldName, byte[] content) throws IOException {
|
||||
generator.writeRawFieldStart(fieldName);
|
||||
return raw(content);
|
||||
public XContentBuilder rawField(String fieldName, byte[] content) throws IOException {
|
||||
generator.writeRawField(fieldName, content, bos);
|
||||
return this;
|
||||
}
|
||||
|
||||
public T rawField(String fieldName, InputStream content) throws IOException {
|
||||
generator.writeRawFieldStart(fieldName);
|
||||
return raw(content);
|
||||
public XContentBuilder rawField(String fieldName, InputStream content) throws IOException {
|
||||
generator.writeRawField(fieldName, content, bos);
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract T raw(byte[] content) throws IOException;
|
||||
|
||||
public abstract T raw(InputStream content) throws IOException;
|
||||
|
||||
public T value(Boolean value) throws IOException {
|
||||
public XContentBuilder value(Boolean value) throws IOException {
|
||||
return value(value.booleanValue());
|
||||
}
|
||||
|
||||
public T value(boolean value) throws IOException {
|
||||
public XContentBuilder value(boolean value) throws IOException {
|
||||
generator.writeBoolean(value);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T value(ReadableInstant date) throws IOException {
|
||||
public XContentBuilder value(ReadableInstant date) throws IOException {
|
||||
return value(date, defaultDatePrinter);
|
||||
}
|
||||
|
||||
public T value(ReadableInstant date, DateTimeFormatter dateTimeFormatter) throws IOException {
|
||||
public XContentBuilder value(ReadableInstant date, DateTimeFormatter dateTimeFormatter) throws IOException {
|
||||
return value(dateTimeFormatter.print(date));
|
||||
}
|
||||
|
||||
public T value(Date date) throws IOException {
|
||||
public XContentBuilder value(Date date) throws IOException {
|
||||
return value(date, defaultDatePrinter);
|
||||
}
|
||||
|
||||
public T value(Date date, DateTimeFormatter dateTimeFormatter) throws IOException {
|
||||
public XContentBuilder value(Date date, DateTimeFormatter dateTimeFormatter) throws IOException {
|
||||
return value(dateTimeFormatter.print(date.getTime()));
|
||||
}
|
||||
|
||||
public T value(Integer value) throws IOException {
|
||||
public XContentBuilder value(Integer value) throws IOException {
|
||||
return value(value.intValue());
|
||||
}
|
||||
|
||||
public T value(int value) throws IOException {
|
||||
public XContentBuilder value(int value) throws IOException {
|
||||
generator.writeNumber(value);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T value(Long value) throws IOException {
|
||||
public XContentBuilder value(Long value) throws IOException {
|
||||
return value(value.longValue());
|
||||
}
|
||||
|
||||
public T value(long value) throws IOException {
|
||||
public XContentBuilder value(long value) throws IOException {
|
||||
generator.writeNumber(value);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T value(Float value) throws IOException {
|
||||
public XContentBuilder value(Float value) throws IOException {
|
||||
return value(value.floatValue());
|
||||
}
|
||||
|
||||
public T value(float value) throws IOException {
|
||||
public XContentBuilder value(float value) throws IOException {
|
||||
generator.writeNumber(value);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T value(Double value) throws IOException {
|
||||
public XContentBuilder value(Double value) throws IOException {
|
||||
return value(value.doubleValue());
|
||||
}
|
||||
|
||||
public T value(double value) throws IOException {
|
||||
public XContentBuilder value(double value) throws IOException {
|
||||
generator.writeNumber(value);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T value(String value) throws IOException {
|
||||
public XContentBuilder value(String value) throws IOException {
|
||||
generator.writeString(value);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T value(byte[] value) throws IOException {
|
||||
public XContentBuilder value(byte[] value) throws IOException {
|
||||
generator.writeBinary(value);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T map(Map<String, Object> map) throws IOException {
|
||||
public XContentBuilder map(Map<String, Object> map) throws IOException {
|
||||
XContentMapConverter.writeMap(generator, map);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T value(Map<String, Object> map) throws IOException {
|
||||
public XContentBuilder value(Map<String, Object> map) throws IOException {
|
||||
XContentMapConverter.writeMap(generator, map);
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T value(Object value) throws IOException {
|
||||
public XContentBuilder value(Object value) throws IOException {
|
||||
Class type = value.getClass();
|
||||
if (type == String.class) {
|
||||
value((String) value);
|
||||
@ -416,12 +431,12 @@ public abstract class XContentBuilder<T extends XContentBuilder> {
|
||||
} else {
|
||||
throw new IOException("Type not allowed [" + type + "]");
|
||||
}
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public T flush() throws IOException {
|
||||
public XContentBuilder flush() throws IOException {
|
||||
generator.flush();
|
||||
return builder;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
@ -432,13 +447,28 @@ public abstract class XContentBuilder<T extends XContentBuilder> {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract T reset() throws IOException;
|
||||
public byte[] unsafeBytes() throws IOException {
|
||||
close();
|
||||
return bos.unsafeByteArray();
|
||||
}
|
||||
|
||||
public abstract byte[] unsafeBytes() throws IOException;
|
||||
public int unsafeBytesLength() throws IOException {
|
||||
close();
|
||||
return bos.size();
|
||||
}
|
||||
|
||||
public abstract int unsafeBytesLength() throws IOException;
|
||||
public FastByteArrayOutputStream unsafeStream() throws IOException {
|
||||
close();
|
||||
return bos;
|
||||
}
|
||||
|
||||
public abstract byte[] copiedBytes() throws IOException;
|
||||
public byte[] copiedBytes() throws IOException {
|
||||
close();
|
||||
return bos.copiedByteArray();
|
||||
}
|
||||
|
||||
public abstract String string() throws IOException;
|
||||
public String string() throws IOException {
|
||||
close();
|
||||
return Unicode.fromBytes(bos.unsafeByteArray(), 0, bos.size());
|
||||
}
|
||||
}
|
@ -21,17 +21,16 @@ package org.elasticsearch.common.xcontent;
|
||||
|
||||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
import org.elasticsearch.ElasticSearchParseException;
|
||||
import org.elasticsearch.common.xcontent.builder.BinaryXContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.builder.TextXContentBuilder;
|
||||
import org.elasticsearch.common.jackson.smile.SmileConstants;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||
import org.elasticsearch.common.xcontent.xson.XsonXContent;
|
||||
import org.elasticsearch.common.xcontent.smile.SmileXContent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* A one stop to use {@link org.elasticsearch.common.xcontent.XContent} and {@link org.elasticsearch.common.xcontent.builder.XContentBuilder}.
|
||||
* A one stop to use {@link org.elasticsearch.common.xcontent.XContent} and {@link XContentBuilder}.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
@ -43,32 +42,32 @@ public class XContentFactory {
|
||||
|
||||
static {
|
||||
contents = new XContent[2];
|
||||
contents[0] = new JsonXContent();
|
||||
contents[1] = new XsonXContent();
|
||||
contents[0] = JsonXContent.jsonXContent;
|
||||
contents[1] = SmileXContent.smileXContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a binary content builder using JSON format ({@link org.elasticsearch.common.xcontent.XContentType#JSON}.
|
||||
* Returns a content builder using JSON format ({@link org.elasticsearch.common.xcontent.XContentType#JSON}.
|
||||
*/
|
||||
public static BinaryXContentBuilder jsonBuilder() throws IOException {
|
||||
return contentBinaryBuilder(XContentType.JSON);
|
||||
public static XContentBuilder jsonBuilder() throws IOException {
|
||||
return contentBuilder(XContentType.JSON);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a binary content builder using XSON format ({@link org.elasticsearch.common.xcontent.XContentType#XSON}.
|
||||
* Returns a content builder using SMILE format ({@link org.elasticsearch.common.xcontent.XContentType#SMILE}.
|
||||
*/
|
||||
public static BinaryXContentBuilder xsonBuilder() throws IOException {
|
||||
return contentBinaryBuilder(XContentType.XSON);
|
||||
public static XContentBuilder smileBuilder() throws IOException {
|
||||
return contentBuilder(XContentType.SMILE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a binary content builder for the provided content type.
|
||||
*/
|
||||
public static BinaryXContentBuilder contentBuilder(XContentType type) throws IOException {
|
||||
public static XContentBuilder contentBuilder(XContentType type) throws IOException {
|
||||
if (type == XContentType.JSON) {
|
||||
return JsonXContent.contentBinaryBuilder();
|
||||
} else if (type == XContentType.XSON) {
|
||||
return XsonXContent.contentBinaryBuilder();
|
||||
return JsonXContent.contentBuilder();
|
||||
} else if (type == XContentType.SMILE) {
|
||||
return SmileXContent.contentBuilder();
|
||||
}
|
||||
throw new ElasticSearchIllegalArgumentException("No matching content type for " + type);
|
||||
}
|
||||
@ -76,21 +75,11 @@ public class XContentFactory {
|
||||
/**
|
||||
* Returns a binary content builder for the provided content type.
|
||||
*/
|
||||
public static BinaryXContentBuilder contentBinaryBuilder(XContentType type) throws IOException {
|
||||
public static XContentBuilder unCachedContentBuilder(XContentType type) throws IOException {
|
||||
if (type == XContentType.JSON) {
|
||||
return JsonXContent.contentBinaryBuilder();
|
||||
} else if (type == XContentType.XSON) {
|
||||
return XsonXContent.contentBinaryBuilder();
|
||||
}
|
||||
throw new ElasticSearchIllegalArgumentException("No matching content type for " + type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a textual content builder for the provided content type. Note, XSON does not support this... .
|
||||
*/
|
||||
public static TextXContentBuilder contentTextBuilder(XContentType type) throws IOException {
|
||||
if (type == XContentType.JSON) {
|
||||
return JsonXContent.contentTextBuilder();
|
||||
return JsonXContent.unCachedContentBuilder();
|
||||
} else if (type == XContentType.SMILE) {
|
||||
return SmileXContent.unCachedContentBuilder();
|
||||
}
|
||||
throw new ElasticSearchIllegalArgumentException("No matching content type for " + type);
|
||||
}
|
||||
@ -164,8 +153,11 @@ public class XContentFactory {
|
||||
if (second == -1) {
|
||||
return null;
|
||||
}
|
||||
if (first == 0x00 && second == 0x00) {
|
||||
return XContentType.XSON;
|
||||
if (first == SmileConstants.HEADER_BYTE_1 && second == SmileConstants.HEADER_BYTE_2) {
|
||||
int third = si.read();
|
||||
if (third == SmileConstants.HEADER_BYTE_3) {
|
||||
return XContentType.SMILE;
|
||||
}
|
||||
}
|
||||
if (first == '{' || second == '{') {
|
||||
return XContentType.JSON;
|
||||
@ -187,8 +179,8 @@ public class XContentFactory {
|
||||
*/
|
||||
public static XContentType xContentType(byte[] data, int offset, int length) {
|
||||
length = length < GUESS_HEADER_LENGTH ? length : GUESS_HEADER_LENGTH;
|
||||
if (length > 1 && data[offset] == 0x00 && data[offset + 1] == 0x00) {
|
||||
return XContentType.XSON;
|
||||
if (length > 2 && data[offset] == SmileConstants.HEADER_BYTE_1 && data[offset + 1] == SmileConstants.HEADER_BYTE_2 && data[offset + 2] == SmileConstants.HEADER_BYTE_3) {
|
||||
return XContentType.SMILE;
|
||||
}
|
||||
for (int i = offset; i < length; i++) {
|
||||
if (data[i] == '{') {
|
||||
|
@ -19,7 +19,10 @@
|
||||
|
||||
package org.elasticsearch.common.xcontent;
|
||||
|
||||
import org.elasticsearch.common.io.FastByteArrayOutputStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
@ -81,7 +84,9 @@ public interface XContentGenerator {
|
||||
|
||||
void writeObjectFieldStart(String fieldName) throws IOException;
|
||||
|
||||
void writeRawFieldStart(String fieldName) throws IOException;
|
||||
void writeRawField(String fieldName, byte[] content, FastByteArrayOutputStream bos) throws IOException;
|
||||
|
||||
void writeRawField(String fieldName, InputStream content, FastByteArrayOutputStream bos) throws IOException;
|
||||
|
||||
void flush() throws IOException;
|
||||
|
||||
|
@ -31,9 +31,9 @@ public enum XContentType {
|
||||
*/
|
||||
JSON(0),
|
||||
/**
|
||||
* An optimized binary form of JSON.
|
||||
* The jackson based smile binary format. Fast and compact binary format.
|
||||
*/
|
||||
XSON(1);
|
||||
SMILE(1);
|
||||
|
||||
public static XContentType fromRestContentType(String contentType) {
|
||||
if (contentType == null) {
|
||||
@ -43,8 +43,8 @@ public enum XContentType {
|
||||
return JSON;
|
||||
}
|
||||
|
||||
if ("application/xson".equals(contentType) || "xson".equalsIgnoreCase(contentType)) {
|
||||
return XSON;
|
||||
if ("application/smile".equals(contentType) || "smile".equalsIgnoreCase(contentType)) {
|
||||
return SMILE;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.xcontent.builder;
|
||||
|
||||
import org.elasticsearch.common.Unicode;
|
||||
import org.elasticsearch.common.io.FastByteArrayOutputStream;
|
||||
import org.elasticsearch.common.io.Streams;
|
||||
import org.elasticsearch.common.xcontent.XContent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class BinaryXContentBuilder extends XContentBuilder<BinaryXContentBuilder> {
|
||||
|
||||
private final FastByteArrayOutputStream bos;
|
||||
|
||||
private final XContent xContent;
|
||||
|
||||
private byte[] bytes;
|
||||
|
||||
public BinaryXContentBuilder(XContent xContent) throws IOException {
|
||||
this.bos = new FastByteArrayOutputStream();
|
||||
this.xContent = xContent;
|
||||
this.generator = xContent.createGenerator(bos);
|
||||
this.builder = this;
|
||||
}
|
||||
|
||||
@Override public BinaryXContentBuilder raw(byte[] json) throws IOException {
|
||||
flush();
|
||||
bos.write(json);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public BinaryXContentBuilder raw(InputStream content) throws IOException {
|
||||
flush();
|
||||
if (bytes == null) {
|
||||
bytes = new byte[Streams.BUFFER_SIZE];
|
||||
}
|
||||
Streams.copy(content, bos, bytes);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public BinaryXContentBuilder reset() throws IOException {
|
||||
fieldCaseConversion = globalFieldCaseConversion;
|
||||
bos.reset();
|
||||
this.generator = xContent.createGenerator(bos);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FastByteArrayOutputStream unsafeStream() throws IOException {
|
||||
flush();
|
||||
return bos;
|
||||
}
|
||||
|
||||
@Override public byte[] unsafeBytes() throws IOException {
|
||||
flush();
|
||||
return bos.unsafeByteArray();
|
||||
}
|
||||
|
||||
@Override public int unsafeBytesLength() throws IOException {
|
||||
flush();
|
||||
return bos.size();
|
||||
}
|
||||
|
||||
@Override public byte[] copiedBytes() throws IOException {
|
||||
flush();
|
||||
return bos.copiedByteArray();
|
||||
}
|
||||
|
||||
@Override public String string() throws IOException {
|
||||
flush();
|
||||
return Unicode.fromBytes(bos.unsafeByteArray(), 0, bos.size());
|
||||
}
|
||||
}
|
@ -1,137 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.xcontent.builder;
|
||||
|
||||
import org.apache.lucene.util.UnicodeUtil;
|
||||
import org.elasticsearch.common.Unicode;
|
||||
import org.elasticsearch.common.io.FastByteArrayOutputStream;
|
||||
import org.elasticsearch.common.io.FastCharArrayWriter;
|
||||
import org.elasticsearch.common.io.Streams;
|
||||
import org.elasticsearch.common.xcontent.XContent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class TextXContentBuilder extends XContentBuilder<TextXContentBuilder> {
|
||||
|
||||
private final FastCharArrayWriter writer;
|
||||
|
||||
private final XContent xContent;
|
||||
|
||||
final UnicodeUtil.UTF8Result utf8Result = new UnicodeUtil.UTF8Result();
|
||||
|
||||
public TextXContentBuilder(XContent xContent) throws IOException {
|
||||
this.writer = new FastCharArrayWriter();
|
||||
this.xContent = xContent;
|
||||
this.generator = xContent.createGenerator(writer);
|
||||
this.builder = this;
|
||||
}
|
||||
|
||||
@Override public TextXContentBuilder raw(byte[] content) throws IOException {
|
||||
flush();
|
||||
Unicode.UTF16Result result = Unicode.unsafeFromBytesAsUtf16(content);
|
||||
writer.write(result.result, 0, result.length);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public TextXContentBuilder raw(InputStream content) throws IOException {
|
||||
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
|
||||
Streams.copy(content, os);
|
||||
flush();
|
||||
Unicode.UTF16Result result = Unicode.unsafeFromBytesAsUtf16(os.unsafeByteArray(), 0, os.size());
|
||||
writer.write(result.result, 0, result.length);
|
||||
return this;
|
||||
}
|
||||
|
||||
public TextXContentBuilder reset() throws IOException {
|
||||
fieldCaseConversion = globalFieldCaseConversion;
|
||||
writer.reset();
|
||||
generator = xContent.createGenerator(writer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String string() throws IOException {
|
||||
flush();
|
||||
return writer.toStringTrim();
|
||||
}
|
||||
|
||||
public FastCharArrayWriter unsafeChars() throws IOException {
|
||||
flush();
|
||||
return writer;
|
||||
}
|
||||
|
||||
@Override public byte[] unsafeBytes() throws IOException {
|
||||
return utf8().result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this AFTER {@link #unsafeBytes()}.
|
||||
*/
|
||||
@Override public int unsafeBytesLength() {
|
||||
return utf8Result.length;
|
||||
}
|
||||
|
||||
@Override public byte[] copiedBytes() throws IOException {
|
||||
flush();
|
||||
byte[] ret = new byte[utf8Result.length];
|
||||
System.arraycopy(utf8Result.result, 0, ret, 0, ret.length);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the byte[] that represents the utf8 of the json written up until now.
|
||||
* Note, the result is shared within this instance, so copy the byte array if needed
|
||||
* or use {@link #utf8copied()}.
|
||||
*/
|
||||
public UnicodeUtil.UTF8Result utf8() throws IOException {
|
||||
flush();
|
||||
|
||||
// ignore whitepsaces
|
||||
int st = 0;
|
||||
int len = writer.size();
|
||||
char[] val = writer.unsafeCharArray();
|
||||
|
||||
while ((st < len) && (val[st] <= ' ')) {
|
||||
st++;
|
||||
len--;
|
||||
}
|
||||
while ((st < len) && (val[len - 1] <= ' ')) {
|
||||
len--;
|
||||
}
|
||||
|
||||
UnicodeUtil.UTF16toUTF8(val, st, len, utf8Result);
|
||||
|
||||
return utf8Result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copied byte[] that represnts the utf8 o fthe json written up until now.
|
||||
*/
|
||||
public byte[] utf8copied() throws IOException {
|
||||
utf8();
|
||||
byte[] result = new byte[utf8Result.length];
|
||||
System.arraycopy(utf8Result.result, 0, result, 0, utf8Result.length);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -19,19 +19,12 @@
|
||||
|
||||
package org.elasticsearch.common.xcontent.json;
|
||||
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.common.io.FastStringReader;
|
||||
import org.elasticsearch.common.jackson.JsonEncoding;
|
||||
import org.elasticsearch.common.jackson.JsonFactory;
|
||||
import org.elasticsearch.common.jackson.JsonGenerator;
|
||||
import org.elasticsearch.common.jackson.JsonParser;
|
||||
import org.elasticsearch.common.thread.ThreadLocals;
|
||||
import org.elasticsearch.common.xcontent.XContent;
|
||||
import org.elasticsearch.common.xcontent.XContentGenerator;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.BinaryXContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.builder.TextXContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
@ -42,71 +35,25 @@ import java.io.*;
|
||||
*/
|
||||
public class JsonXContent implements XContent {
|
||||
|
||||
public static class CachedBinaryBuilder {
|
||||
|
||||
private static final ThreadLocal<ThreadLocals.CleanableValue<BinaryXContentBuilder>> cache = new ThreadLocal<ThreadLocals.CleanableValue<BinaryXContentBuilder>>() {
|
||||
@Override protected ThreadLocals.CleanableValue<BinaryXContentBuilder> initialValue() {
|
||||
try {
|
||||
BinaryXContentBuilder builder = new BinaryXContentBuilder(new JsonXContent());
|
||||
return new ThreadLocals.CleanableValue<BinaryXContentBuilder>(builder);
|
||||
} catch (IOException e) {
|
||||
throw new ElasticSearchException("Failed to create json generator", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the cached thread local generator, with its internal {@link StringBuilder} cleared.
|
||||
*/
|
||||
static BinaryXContentBuilder cached() throws IOException {
|
||||
ThreadLocals.CleanableValue<BinaryXContentBuilder> cached = cache.get();
|
||||
cached.get().reset();
|
||||
return cached.get();
|
||||
}
|
||||
public static XContentBuilder contentBuilder() throws IOException {
|
||||
return XContentBuilder.cachedBuilder(jsonXContent);
|
||||
}
|
||||
|
||||
public static class CachedTextBuilder {
|
||||
|
||||
private static final ThreadLocal<ThreadLocals.CleanableValue<TextXContentBuilder>> cache = new ThreadLocal<ThreadLocals.CleanableValue<TextXContentBuilder>>() {
|
||||
@Override protected ThreadLocals.CleanableValue<TextXContentBuilder> initialValue() {
|
||||
try {
|
||||
TextXContentBuilder builder = new TextXContentBuilder(new JsonXContent());
|
||||
return new ThreadLocals.CleanableValue<TextXContentBuilder>(builder);
|
||||
} catch (IOException e) {
|
||||
throw new ElasticSearchException("Failed to create json generator", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the cached thread local generator, with its internal {@link StringBuilder} cleared.
|
||||
*/
|
||||
static TextXContentBuilder cached() throws IOException {
|
||||
ThreadLocals.CleanableValue<TextXContentBuilder> cached = cache.get();
|
||||
cached.get().reset();
|
||||
return cached.get();
|
||||
}
|
||||
public static XContentBuilder unCachedContentBuilder() throws IOException {
|
||||
return XContentBuilder.builder(jsonXContent);
|
||||
}
|
||||
|
||||
public static BinaryXContentBuilder contentBuilder() throws IOException {
|
||||
return contentBinaryBuilder();
|
||||
}
|
||||
private final static JsonFactory jsonFactory;
|
||||
public final static JsonXContent jsonXContent;
|
||||
|
||||
public static BinaryXContentBuilder contentBinaryBuilder() throws IOException {
|
||||
return CachedBinaryBuilder.cached();
|
||||
}
|
||||
|
||||
public static TextXContentBuilder contentTextBuilder() throws IOException {
|
||||
return CachedTextBuilder.cached();
|
||||
}
|
||||
|
||||
|
||||
private final JsonFactory jsonFactory;
|
||||
|
||||
public JsonXContent() {
|
||||
static {
|
||||
jsonFactory = new JsonFactory();
|
||||
jsonFactory.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
|
||||
jsonFactory.configure(JsonGenerator.Feature.QUOTE_FIELD_NAMES, true);
|
||||
jsonXContent = new JsonXContent();
|
||||
}
|
||||
|
||||
private JsonXContent() {
|
||||
}
|
||||
|
||||
@Override public XContentType type() {
|
||||
|
@ -19,11 +19,15 @@
|
||||
|
||||
package org.elasticsearch.common.xcontent.json;
|
||||
|
||||
import org.elasticsearch.common.Bytes;
|
||||
import org.elasticsearch.common.io.FastByteArrayOutputStream;
|
||||
import org.elasticsearch.common.io.Streams;
|
||||
import org.elasticsearch.common.jackson.JsonGenerator;
|
||||
import org.elasticsearch.common.xcontent.XContentGenerator;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
@ -144,9 +148,17 @@ public class JsonXContentGenerator implements XContentGenerator {
|
||||
generator.writeObjectFieldStart(fieldName);
|
||||
}
|
||||
|
||||
@Override public void writeRawFieldStart(String fieldName) throws IOException {
|
||||
@Override public void writeRawField(String fieldName, byte[] content, FastByteArrayOutputStream bos) throws IOException {
|
||||
generator.writeRaw(", \"" + fieldName + "\" : ");
|
||||
flush();
|
||||
bos.write(content);
|
||||
}
|
||||
|
||||
@Override public void writeRawField(String fieldName, InputStream content, FastByteArrayOutputStream bos) throws IOException {
|
||||
generator.writeRaw(", \"" + fieldName + "\" : ");
|
||||
flush();
|
||||
byte[] bytes = Bytes.cachedBytes.get().get();
|
||||
Streams.copy(content, bos, bytes);
|
||||
}
|
||||
|
||||
@Override public void flush() throws IOException {
|
||||
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.xcontent.smile;
|
||||
|
||||
import org.elasticsearch.common.io.FastStringReader;
|
||||
import org.elasticsearch.common.jackson.JsonEncoding;
|
||||
import org.elasticsearch.common.jackson.smile.SmileFactory;
|
||||
import org.elasticsearch.common.jackson.smile.SmileGenerator;
|
||||
import org.elasticsearch.common.xcontent.*;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContentParser;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* A JSON based content implementation using Jackson.
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class SmileXContent implements XContent {
|
||||
|
||||
public static XContentBuilder contentBuilder() throws IOException {
|
||||
return XContentBuilder.cachedBuilder(smileXContent);
|
||||
}
|
||||
|
||||
public static XContentBuilder unCachedContentBuilder() throws IOException {
|
||||
return XContentBuilder.builder(smileXContent);
|
||||
}
|
||||
|
||||
private final static SmileFactory smileFactory;
|
||||
public final static SmileXContent smileXContent;
|
||||
|
||||
static {
|
||||
smileFactory = new SmileFactory();
|
||||
smileFactory.configure(SmileGenerator.Feature.ENCODE_BINARY_AS_7BIT, false); // for now, this is an overhead, might make sense for web sockets
|
||||
smileXContent = new SmileXContent();
|
||||
}
|
||||
|
||||
private SmileXContent() {
|
||||
}
|
||||
|
||||
@Override public XContentType type() {
|
||||
return XContentType.SMILE;
|
||||
}
|
||||
|
||||
@Override public XContentGenerator createGenerator(OutputStream os) throws IOException {
|
||||
return new SmileXContentGenerator(smileFactory.createJsonGenerator(os, JsonEncoding.UTF8));
|
||||
}
|
||||
|
||||
@Override public XContentGenerator createGenerator(Writer writer) throws IOException {
|
||||
return new SmileXContentGenerator(smileFactory.createJsonGenerator(writer));
|
||||
}
|
||||
|
||||
@Override public XContentParser createParser(String content) throws IOException {
|
||||
return new SmileXContentParser(smileFactory.createJsonParser(new FastStringReader(content)));
|
||||
}
|
||||
|
||||
@Override public XContentParser createParser(InputStream is) throws IOException {
|
||||
return new SmileXContentParser(smileFactory.createJsonParser(is));
|
||||
}
|
||||
|
||||
@Override public XContentParser createParser(byte[] data) throws IOException {
|
||||
return new SmileXContentParser(smileFactory.createJsonParser(data));
|
||||
}
|
||||
|
||||
@Override public XContentParser createParser(byte[] data, int offset, int length) throws IOException {
|
||||
return new SmileXContentParser(smileFactory.createJsonParser(data, offset, length));
|
||||
}
|
||||
|
||||
@Override public XContentParser createParser(Reader reader) throws IOException {
|
||||
return new JsonXContentParser(smileFactory.createJsonParser(reader));
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.xcontent.smile;
|
||||
|
||||
import org.elasticsearch.common.io.FastByteArrayOutputStream;
|
||||
import org.elasticsearch.common.jackson.JsonGenerator;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContentGenerator;
|
||||
import org.elasticsearch.common.xcontent.support.XContentMapConverter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class SmileXContentGenerator extends JsonXContentGenerator {
|
||||
|
||||
public SmileXContentGenerator(JsonGenerator generator) {
|
||||
super(generator);
|
||||
}
|
||||
|
||||
@Override public XContentType contentType() {
|
||||
return XContentType.SMILE;
|
||||
}
|
||||
|
||||
@Override public void writeRawField(String fieldName, byte[] content, FastByteArrayOutputStream bos) throws IOException {
|
||||
writeFieldName(fieldName);
|
||||
// crap here, need to find a better way... (at least don't create the map and direct parser to generator)
|
||||
XContentMapConverter.writeMap(this, SmileXContent.smileXContent.createParser(content).map());
|
||||
}
|
||||
}
|
@ -17,36 +17,22 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.xcontent.xson;
|
||||
package org.elasticsearch.common.xcontent.smile;
|
||||
|
||||
import org.elasticsearch.common.jackson.JsonParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.json.JsonXContentParser;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public enum XsonType {
|
||||
public class SmileXContentParser extends JsonXContentParser {
|
||||
|
||||
START_ARRAY((byte) 0x01),
|
||||
END_ARRAY((byte) 0x02),
|
||||
START_OBJECT((byte) 0x03),
|
||||
END_OBJECT((byte) 0x04),
|
||||
FIELD_NAME((byte) 0x05),
|
||||
VALUE_STRING((byte) 0x06),
|
||||
VALUE_BINARY((byte) 0x07),
|
||||
VALUE_INTEGER((byte) 0x08),
|
||||
VALUE_LONG((byte) 0x09),
|
||||
VALUE_FLOAT((byte) 0x0A),
|
||||
VALUE_DOUBLE((byte) 0x0B),
|
||||
VALUE_BOOLEAN((byte) 0x0C),
|
||||
VALUE_NULL((byte) 0x0D),;
|
||||
|
||||
public static final int HEADER = 0x00;
|
||||
|
||||
private final byte code;
|
||||
|
||||
XsonType(byte code) {
|
||||
this.code = code;
|
||||
public SmileXContentParser(JsonParser parser) {
|
||||
super(parser);
|
||||
}
|
||||
|
||||
public byte code() {
|
||||
return code;
|
||||
@Override public XContentType contentType() {
|
||||
return XContentType.SMILE;
|
||||
}
|
||||
}
|
@ -19,9 +19,9 @@
|
||||
|
||||
package org.elasticsearch.common.xcontent.support;
|
||||
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentGenerator;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.xcontent.xson;
|
||||
|
||||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.ElasticSearchIllegalStateException;
|
||||
import org.elasticsearch.common.io.FastByteArrayInputStream;
|
||||
import org.elasticsearch.common.thread.ThreadLocals;
|
||||
import org.elasticsearch.common.xcontent.XContent;
|
||||
import org.elasticsearch.common.xcontent.XContentGenerator;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.BinaryXContentBuilder;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* A binary representation of content (basically, JSON encoded in optimized binary format).
|
||||
*
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XsonXContent implements XContent {
|
||||
|
||||
public static class CachedBinaryBuilder {
|
||||
|
||||
private static final ThreadLocal<ThreadLocals.CleanableValue<BinaryXContentBuilder>> cache = new ThreadLocal<ThreadLocals.CleanableValue<BinaryXContentBuilder>>() {
|
||||
@Override protected ThreadLocals.CleanableValue<BinaryXContentBuilder> initialValue() {
|
||||
try {
|
||||
BinaryXContentBuilder builder = new BinaryXContentBuilder(new XsonXContent());
|
||||
return new ThreadLocals.CleanableValue<BinaryXContentBuilder>(builder);
|
||||
} catch (IOException e) {
|
||||
throw new ElasticSearchException("Failed to create xson generator", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the cached thread local generator, with its internal {@link StringBuilder} cleared.
|
||||
*/
|
||||
static BinaryXContentBuilder cached() throws IOException {
|
||||
ThreadLocals.CleanableValue<BinaryXContentBuilder> cached = cache.get();
|
||||
cached.get().reset();
|
||||
return cached.get();
|
||||
}
|
||||
}
|
||||
|
||||
public static BinaryXContentBuilder contentBinaryBuilder() throws IOException {
|
||||
return CachedBinaryBuilder.cached();
|
||||
}
|
||||
|
||||
@Override public XContentType type() {
|
||||
return XContentType.XSON;
|
||||
}
|
||||
|
||||
@Override public XContentGenerator createGenerator(OutputStream os) throws IOException {
|
||||
return new XsonXContentGenerator(os);
|
||||
}
|
||||
|
||||
@Override public XContentGenerator createGenerator(Writer writer) throws IOException {
|
||||
throw new ElasticSearchIllegalStateException("Can't create generator over xson with textual data");
|
||||
}
|
||||
|
||||
@Override public XContentParser createParser(String content) throws IOException {
|
||||
throw new ElasticSearchIllegalStateException("Can't create parser over xson for textual data");
|
||||
}
|
||||
|
||||
@Override public XContentParser createParser(InputStream is) throws IOException {
|
||||
return new XsonXContentParser(is);
|
||||
}
|
||||
|
||||
@Override public XContentParser createParser(byte[] data) throws IOException {
|
||||
return new XsonXContentParser(new FastByteArrayInputStream(data));
|
||||
}
|
||||
|
||||
@Override public XContentParser createParser(byte[] data, int offset, int length) throws IOException {
|
||||
return new XsonXContentParser(new FastByteArrayInputStream(data, offset, length));
|
||||
}
|
||||
|
||||
@Override public XContentParser createParser(Reader reader) throws IOException {
|
||||
throw new ElasticSearchIllegalStateException("Can't create parser over xson for textual data");
|
||||
}
|
||||
}
|
@ -1,211 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.xcontent.xson;
|
||||
|
||||
import org.apache.lucene.util.UnicodeUtil;
|
||||
import org.elasticsearch.common.Unicode;
|
||||
import org.elasticsearch.common.xcontent.XContentGenerator;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.support.AbstractXContentGenerator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XsonXContentGenerator extends AbstractXContentGenerator implements XContentGenerator {
|
||||
|
||||
private final OutputStream out;
|
||||
|
||||
public XsonXContentGenerator(OutputStream out) throws IOException {
|
||||
this.out = out;
|
||||
outInt(XsonType.HEADER);
|
||||
}
|
||||
|
||||
@Override public XContentType contentType() {
|
||||
return XContentType.XSON;
|
||||
}
|
||||
|
||||
@Override public void usePrettyPrint() {
|
||||
// irrelevant
|
||||
}
|
||||
|
||||
@Override public void writeStartArray() throws IOException {
|
||||
out.write(XsonType.START_ARRAY.code());
|
||||
}
|
||||
|
||||
@Override public void writeEndArray() throws IOException {
|
||||
out.write(XsonType.END_ARRAY.code());
|
||||
}
|
||||
|
||||
@Override public void writeStartObject() throws IOException {
|
||||
out.write(XsonType.START_OBJECT.code());
|
||||
}
|
||||
|
||||
@Override public void writeEndObject() throws IOException {
|
||||
out.write(XsonType.END_OBJECT.code());
|
||||
}
|
||||
|
||||
@Override public void writeFieldName(String name) throws IOException {
|
||||
out.write(XsonType.FIELD_NAME.code());
|
||||
outUTF(name);
|
||||
}
|
||||
|
||||
@Override public void writeString(String text) throws IOException {
|
||||
out.write(XsonType.VALUE_STRING.code());
|
||||
outUTF(text);
|
||||
}
|
||||
|
||||
@Override public void writeString(char[] text, int offset, int len) throws IOException {
|
||||
writeString(new String(text, offset, len));
|
||||
}
|
||||
|
||||
@Override public void writeBinary(byte[] data, int offset, int len) throws IOException {
|
||||
out.write(XsonType.VALUE_BINARY.code());
|
||||
outVInt(len);
|
||||
out.write(data, offset, len);
|
||||
}
|
||||
|
||||
@Override public void writeBinary(byte[] data) throws IOException {
|
||||
out.write(XsonType.VALUE_BINARY.code());
|
||||
outVInt(data.length);
|
||||
out.write(data);
|
||||
}
|
||||
|
||||
@Override public void writeNumber(int v) throws IOException {
|
||||
out.write(XsonType.VALUE_INTEGER.code());
|
||||
outInt(v);
|
||||
}
|
||||
|
||||
@Override public void writeNumber(long v) throws IOException {
|
||||
out.write(XsonType.VALUE_LONG.code());
|
||||
outLong(v);
|
||||
}
|
||||
|
||||
@Override public void writeNumber(double d) throws IOException {
|
||||
out.write(XsonType.VALUE_DOUBLE.code());
|
||||
outDouble(d);
|
||||
}
|
||||
|
||||
@Override public void writeNumber(float f) throws IOException {
|
||||
out.write(XsonType.VALUE_FLOAT.code());
|
||||
outFloat(f);
|
||||
}
|
||||
|
||||
@Override public void writeBoolean(boolean state) throws IOException {
|
||||
out.write(XsonType.VALUE_BOOLEAN.code());
|
||||
outBoolean(state);
|
||||
}
|
||||
|
||||
@Override public void writeNull() throws IOException {
|
||||
out.write(XsonType.VALUE_NULL.code());
|
||||
}
|
||||
|
||||
@Override public void writeRawFieldStart(String fieldName) throws IOException {
|
||||
writeFieldName(fieldName);
|
||||
}
|
||||
|
||||
@Override public void flush() throws IOException {
|
||||
out.flush();
|
||||
}
|
||||
|
||||
@Override public void close() throws IOException {
|
||||
out.close();
|
||||
}
|
||||
|
||||
|
||||
private void outShort(short v) throws IOException {
|
||||
out.write((byte) (v >> 8));
|
||||
out.write((byte) v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an int as four bytes.
|
||||
*/
|
||||
private void outInt(int i) throws IOException {
|
||||
out.write((byte) (i >> 24));
|
||||
out.write((byte) (i >> 16));
|
||||
out.write((byte) (i >> 8));
|
||||
out.write((byte) i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an int in a variable-length format. Writes between one and
|
||||
* five bytes. Smaller values take fewer bytes. Negative numbers are not
|
||||
* supported.
|
||||
*/
|
||||
private void outVInt(int i) throws IOException {
|
||||
while ((i & ~0x7F) != 0) {
|
||||
out.write((byte) ((i & 0x7f) | 0x80));
|
||||
i >>>= 7;
|
||||
}
|
||||
out.write((byte) i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a long as eight bytes.
|
||||
*/
|
||||
private void outLong(long i) throws IOException {
|
||||
outInt((int) (i >> 32));
|
||||
outInt((int) i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes an long in a variable-length format. Writes between one and five
|
||||
* bytes. Smaller values take fewer bytes. Negative numbers are not
|
||||
* supported.
|
||||
*/
|
||||
private void outVLong(long i) throws IOException {
|
||||
while ((i & ~0x7F) != 0) {
|
||||
out.write((byte) ((i & 0x7f) | 0x80));
|
||||
i >>>= 7;
|
||||
}
|
||||
out.write((byte) i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a string.
|
||||
*/
|
||||
private void outUTF(String s) throws IOException {
|
||||
UnicodeUtil.UTF8Result utf8Result = Unicode.unsafeFromStringAsUtf8(s);
|
||||
outVInt(utf8Result.length);
|
||||
out.write(utf8Result.result, 0, utf8Result.length);
|
||||
}
|
||||
|
||||
private void outFloat(float v) throws IOException {
|
||||
outInt(Float.floatToIntBits(v));
|
||||
}
|
||||
|
||||
private void outDouble(double v) throws IOException {
|
||||
outLong(Double.doubleToLongBits(v));
|
||||
}
|
||||
|
||||
|
||||
private static byte ZERO = 0;
|
||||
private static byte ONE = 1;
|
||||
|
||||
/**
|
||||
* Writes a boolean.
|
||||
*/
|
||||
private void outBoolean(boolean b) throws IOException {
|
||||
out.write(b ? ONE : ZERO);
|
||||
}
|
||||
}
|
@ -1,383 +0,0 @@
|
||||
/*
|
||||
* Licensed to Elastic Search and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. Elastic Search licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.xcontent.xson;
|
||||
|
||||
import org.elasticsearch.common.Bytes;
|
||||
import org.elasticsearch.common.Unicode;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.support.AbstractXContentParser;
|
||||
|
||||
import java.io.EOFException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* @author kimchy (shay.banon)
|
||||
*/
|
||||
public class XsonXContentParser extends AbstractXContentParser {
|
||||
|
||||
private final InputStream is;
|
||||
|
||||
private Token currentToken;
|
||||
|
||||
private XsonType xsonType;
|
||||
|
||||
private NumberType currentNumberType;
|
||||
|
||||
private String currentName;
|
||||
|
||||
private Unicode.UTF16Result utf16Result;
|
||||
|
||||
private int valueInt;
|
||||
private long valueLong;
|
||||
private float valueFloat;
|
||||
private double valueDouble;
|
||||
private boolean valueBoolean;
|
||||
private byte[] valueBytes;
|
||||
|
||||
public XsonXContentParser(InputStream is) throws IOException {
|
||||
this.is = is;
|
||||
int header = inInt();
|
||||
if (header != XsonType.HEADER) {
|
||||
throw new IOException("Not xson type header");
|
||||
}
|
||||
}
|
||||
|
||||
@Override public XContentType contentType() {
|
||||
return XContentType.XSON;
|
||||
}
|
||||
|
||||
@Override public Token nextToken() throws IOException {
|
||||
byte tokenType = (byte) is.read();
|
||||
if (tokenType == -1) {
|
||||
xsonType = null;
|
||||
currentToken = null;
|
||||
currentNumberType = null;
|
||||
return null;
|
||||
} else if (tokenType == XsonType.START_ARRAY.code()) {
|
||||
xsonType = XsonType.START_ARRAY;
|
||||
currentToken = Token.START_ARRAY;
|
||||
} else if (tokenType == XsonType.END_ARRAY.code()) {
|
||||
xsonType = XsonType.END_ARRAY;
|
||||
currentToken = Token.END_ARRAY;
|
||||
} else if (tokenType == XsonType.START_OBJECT.code()) {
|
||||
xsonType = XsonType.START_OBJECT;
|
||||
currentToken = Token.START_OBJECT;
|
||||
} else if (tokenType == XsonType.END_OBJECT.code()) {
|
||||
xsonType = XsonType.END_OBJECT;
|
||||
currentToken = Token.END_OBJECT;
|
||||
} else if (tokenType == XsonType.FIELD_NAME.code()) {
|
||||
xsonType = XsonType.FIELD_NAME;
|
||||
currentToken = Token.FIELD_NAME;
|
||||
// read the field name (interned)
|
||||
currentName = inUTF().intern();
|
||||
} else if (tokenType == XsonType.VALUE_STRING.code()) {
|
||||
xsonType = XsonType.VALUE_STRING;
|
||||
currentToken = Token.VALUE_STRING;
|
||||
inUtf16();
|
||||
} else if (tokenType == XsonType.VALUE_BINARY.code()) {
|
||||
xsonType = XsonType.VALUE_BINARY;
|
||||
currentToken = Token.VALUE_STRING;
|
||||
int length = inVInt();
|
||||
valueBytes = new byte[length];
|
||||
inBytes(valueBytes, 0, length);
|
||||
} else if (tokenType == XsonType.VALUE_INTEGER.code()) {
|
||||
xsonType = XsonType.VALUE_INTEGER;
|
||||
currentToken = Token.VALUE_NUMBER;
|
||||
currentNumberType = NumberType.INT;
|
||||
valueInt = inInt();
|
||||
} else if (tokenType == XsonType.VALUE_LONG.code()) {
|
||||
xsonType = XsonType.VALUE_LONG;
|
||||
currentToken = Token.VALUE_NUMBER;
|
||||
currentNumberType = NumberType.LONG;
|
||||
valueLong = inLong();
|
||||
} else if (tokenType == XsonType.VALUE_FLOAT.code()) {
|
||||
xsonType = XsonType.VALUE_FLOAT;
|
||||
currentToken = Token.VALUE_NUMBER;
|
||||
currentNumberType = NumberType.FLOAT;
|
||||
valueFloat = inFloat();
|
||||
} else if (tokenType == XsonType.VALUE_DOUBLE.code()) {
|
||||
xsonType = XsonType.VALUE_DOUBLE;
|
||||
currentToken = Token.VALUE_NUMBER;
|
||||
currentNumberType = NumberType.DOUBLE;
|
||||
valueDouble = inDouble();
|
||||
} else if (tokenType == XsonType.VALUE_BOOLEAN.code()) {
|
||||
xsonType = XsonType.VALUE_BOOLEAN;
|
||||
currentToken = Token.VALUE_BOOLEAN;
|
||||
valueBoolean = inBoolean();
|
||||
} else if (tokenType == XsonType.VALUE_NULL.code()) {
|
||||
xsonType = XsonType.VALUE_NULL;
|
||||
currentToken = Token.VALUE_NULL;
|
||||
}
|
||||
return currentToken;
|
||||
}
|
||||
|
||||
@Override public void skipChildren() throws IOException {
|
||||
if (xsonType != XsonType.START_OBJECT && xsonType != XsonType.START_ARRAY) {
|
||||
return;
|
||||
}
|
||||
int open = 1;
|
||||
|
||||
/* Since proper matching of start/end markers is handled
|
||||
* by nextToken(), we'll just count nesting levels here
|
||||
*/
|
||||
while (true) {
|
||||
nextToken();
|
||||
if (xsonType == null) {
|
||||
return;
|
||||
}
|
||||
switch (xsonType) {
|
||||
case START_OBJECT:
|
||||
case START_ARRAY:
|
||||
++open;
|
||||
break;
|
||||
case END_OBJECT:
|
||||
case END_ARRAY:
|
||||
if (--open == 0) {
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public Token currentToken() {
|
||||
return currentToken;
|
||||
}
|
||||
|
||||
@Override public String currentName() throws IOException {
|
||||
return currentName;
|
||||
}
|
||||
|
||||
@Override public String text() throws IOException {
|
||||
return new String(utf16Result.result, 0, utf16Result.length);
|
||||
}
|
||||
|
||||
@Override public char[] textCharacters() throws IOException {
|
||||
return utf16Result.result;
|
||||
}
|
||||
|
||||
@Override public int textLength() throws IOException {
|
||||
return utf16Result.length;
|
||||
}
|
||||
|
||||
@Override public int textOffset() throws IOException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override public Number numberValue() throws IOException {
|
||||
if (currentNumberType == NumberType.INT) {
|
||||
return valueInt;
|
||||
} else if (currentNumberType == NumberType.LONG) {
|
||||
return valueLong;
|
||||
} else if (currentNumberType == NumberType.FLOAT) {
|
||||
return valueFloat;
|
||||
} else if (currentNumberType == NumberType.DOUBLE) {
|
||||
return valueDouble;
|
||||
}
|
||||
throw new IOException("No number type");
|
||||
}
|
||||
|
||||
@Override public NumberType numberType() throws IOException {
|
||||
return currentNumberType;
|
||||
}
|
||||
|
||||
@Override public boolean estimatedNumberType() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override public byte[] binaryValue() throws IOException {
|
||||
return valueBytes;
|
||||
}
|
||||
|
||||
@Override protected boolean doBooleanValue() throws IOException {
|
||||
return valueBoolean;
|
||||
}
|
||||
|
||||
@Override protected short doShortValue() throws IOException {
|
||||
if (currentNumberType == NumberType.INT) {
|
||||
return (short) valueInt;
|
||||
} else if (currentNumberType == NumberType.LONG) {
|
||||
return (short) valueLong;
|
||||
} else if (currentNumberType == NumberType.FLOAT) {
|
||||
return (short) valueFloat;
|
||||
} else if (currentNumberType == NumberType.DOUBLE) {
|
||||
return (short) valueDouble;
|
||||
}
|
||||
throw new IOException("No number type");
|
||||
}
|
||||
|
||||
@Override protected int doIntValue() throws IOException {
|
||||
if (currentNumberType == NumberType.INT) {
|
||||
return valueInt;
|
||||
} else if (currentNumberType == NumberType.LONG) {
|
||||
return (int) valueLong;
|
||||
} else if (currentNumberType == NumberType.FLOAT) {
|
||||
return (int) valueFloat;
|
||||
} else if (currentNumberType == NumberType.DOUBLE) {
|
||||
return (int) valueDouble;
|
||||
}
|
||||
throw new IOException("No number type");
|
||||
}
|
||||
|
||||
@Override protected long doLongValue() throws IOException {
|
||||
if (currentNumberType == NumberType.LONG) {
|
||||
return valueLong;
|
||||
} else if (currentNumberType == NumberType.INT) {
|
||||
return (long) valueInt;
|
||||
} else if (currentNumberType == NumberType.FLOAT) {
|
||||
return (long) valueFloat;
|
||||
} else if (currentNumberType == NumberType.DOUBLE) {
|
||||
return (long) valueDouble;
|
||||
}
|
||||
throw new IOException("No number type");
|
||||
}
|
||||
|
||||
@Override protected float doFloatValue() throws IOException {
|
||||
if (currentNumberType == NumberType.FLOAT) {
|
||||
return valueFloat;
|
||||
} else if (currentNumberType == NumberType.INT) {
|
||||
return (float) valueInt;
|
||||
} else if (currentNumberType == NumberType.LONG) {
|
||||
return (float) valueLong;
|
||||
} else if (currentNumberType == NumberType.DOUBLE) {
|
||||
return (float) valueDouble;
|
||||
}
|
||||
throw new IOException("No number type");
|
||||
}
|
||||
|
||||
@Override protected double doDoubleValue() throws IOException {
|
||||
if (currentNumberType == NumberType.DOUBLE) {
|
||||
return valueDouble;
|
||||
} else if (currentNumberType == NumberType.INT) {
|
||||
return (double) valueInt;
|
||||
} else if (currentNumberType == NumberType.FLOAT) {
|
||||
return (double) valueFloat;
|
||||
} else if (currentNumberType == NumberType.LONG) {
|
||||
return (double) valueLong;
|
||||
}
|
||||
throw new IOException("No number type");
|
||||
}
|
||||
|
||||
@Override public void close() {
|
||||
try {
|
||||
is.close();
|
||||
} catch (IOException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
private short inShort() throws IOException {
|
||||
return (short) (((is.read() & 0xFF) << 8) | (is.read() & 0xFF));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads four bytes and returns an int.
|
||||
*/
|
||||
private int inInt() throws IOException {
|
||||
return ((is.read() & 0xFF) << 24) | ((is.read() & 0xFF) << 16)
|
||||
| ((is.read() & 0xFF) << 8) | (is.read() & 0xFF);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an int stored in variable-length format. Reads between one and
|
||||
* five bytes. Smaller values take fewer bytes. Negative numbers are not
|
||||
* supported.
|
||||
*/
|
||||
private int inVInt() throws IOException {
|
||||
int b = is.read();
|
||||
int i = b & 0x7F;
|
||||
for (int shift = 7; (b & 0x80) != 0; shift += 7) {
|
||||
b = is.read();
|
||||
i |= (b & 0x7F) << shift;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads eight bytes and returns a long.
|
||||
*/
|
||||
private long inLong() throws IOException {
|
||||
return (((long) inInt()) << 32) | (inInt() & 0xFFFFFFFFL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a long stored in variable-length format. Reads between one and
|
||||
* nine bytes. Smaller values take fewer bytes. Negative numbers are not
|
||||
* supported.
|
||||
*/
|
||||
private long readVLong() throws IOException {
|
||||
int b = is.read();
|
||||
long i = b & 0x7F;
|
||||
for (int shift = 7; (b & 0x80) != 0; shift += 7) {
|
||||
b = is.read();
|
||||
i |= (b & 0x7FL) << shift;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
private String inUTF() throws IOException {
|
||||
inUtf16();
|
||||
return new String(utf16Result.result, 0, utf16Result.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a string.
|
||||
*/
|
||||
private void inUtf16() throws IOException {
|
||||
int length = inVInt();
|
||||
byte[] bytes = Bytes.cachedBytes.get().get();
|
||||
if (bytes == null || length > bytes.length) {
|
||||
bytes = new byte[(int) (length * 1.25)];
|
||||
Bytes.cachedBytes.get().set(bytes);
|
||||
}
|
||||
inBytes(bytes, 0, length);
|
||||
utf16Result = Unicode.fromBytesAsUtf16(bytes, 0, length);
|
||||
}
|
||||
|
||||
private float inFloat() throws IOException {
|
||||
return Float.intBitsToFloat(inInt());
|
||||
}
|
||||
|
||||
private double inDouble() throws IOException {
|
||||
return Double.longBitsToDouble(inLong());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a boolean.
|
||||
*/
|
||||
private boolean inBoolean() throws IOException {
|
||||
byte ch = (byte) is.read();
|
||||
if (ch < 0)
|
||||
throw new EOFException();
|
||||
return (ch != 0);
|
||||
}
|
||||
|
||||
private void inBytes(byte[] b, int offset, int len) throws IOException {
|
||||
int n = 0;
|
||||
while (n < len) {
|
||||
int count = is.read(b, offset + n, len - n);
|
||||
if (count < 0)
|
||||
throw new EOFException();
|
||||
n += count;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -27,11 +27,7 @@ import org.elasticsearch.common.blobstore.*;
|
||||
import org.elasticsearch.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.BinaryXContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.*;
|
||||
import org.elasticsearch.gateway.GatewayException;
|
||||
import org.elasticsearch.gateway.shared.SharedStorageGateway;
|
||||
|
||||
@ -108,9 +104,9 @@ public abstract class BlobStoreGateway extends SharedStorageGateway {
|
||||
|
||||
@Override public void write(MetaData metaData) throws GatewayException {
|
||||
final String newMetaData = "metadata-" + (currentIndex + 1);
|
||||
BinaryXContentBuilder builder;
|
||||
XContentBuilder builder;
|
||||
try {
|
||||
builder = XContentFactory.contentBinaryBuilder(XContentType.JSON);
|
||||
builder = XContentFactory.contentBuilder(XContentType.JSON);
|
||||
builder.prettyPrint();
|
||||
builder.startObject();
|
||||
MetaData.Builder.toXContent(metaData, builder, ToXContent.EMPTY_PARAMS);
|
||||
|
@ -40,11 +40,7 @@ import org.elasticsearch.common.inject.Module;
|
||||
import org.elasticsearch.common.io.FileSystemUtils;
|
||||
import org.elasticsearch.common.io.Streams;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.BinaryXContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.*;
|
||||
import org.elasticsearch.env.NodeEnvironment;
|
||||
import org.elasticsearch.gateway.Gateway;
|
||||
import org.elasticsearch.gateway.GatewayException;
|
||||
@ -241,7 +237,7 @@ public class LocalGateway extends AbstractLifecycleComponent<Gateway> implements
|
||||
|
||||
try {
|
||||
LocalGatewayMetaState stateToWrite = builder.build();
|
||||
BinaryXContentBuilder xContentBuilder = XContentFactory.contentBinaryBuilder(XContentType.JSON);
|
||||
XContentBuilder xContentBuilder = XContentFactory.contentBuilder(XContentType.JSON);
|
||||
xContentBuilder.prettyPrint();
|
||||
xContentBuilder.startObject();
|
||||
LocalGatewayMetaState.Builder.toXContent(stateToWrite, xContentBuilder, ToXContent.EMPTY_PARAMS);
|
||||
@ -298,7 +294,7 @@ public class LocalGateway extends AbstractLifecycleComponent<Gateway> implements
|
||||
|
||||
try {
|
||||
LocalGatewayStartedShards stateToWrite = builder.build();
|
||||
BinaryXContentBuilder xContentBuilder = XContentFactory.contentBinaryBuilder(XContentType.JSON);
|
||||
XContentBuilder xContentBuilder = XContentFactory.contentBuilder(XContentType.JSON);
|
||||
xContentBuilder.prettyPrint();
|
||||
xContentBuilder.startObject();
|
||||
LocalGatewayStartedShards.Builder.toXContent(stateToWrite, xContentBuilder, ToXContent.EMPTY_PARAMS);
|
||||
|
@ -24,8 +24,8 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
|
@ -25,8 +25,8 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.index.shard.ShardId;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -31,6 +31,7 @@ import org.elasticsearch.common.io.stream.CachedStreamInput;
|
||||
import org.elasticsearch.common.io.stream.LZFStreamInput;
|
||||
import org.elasticsearch.common.thread.ThreadLocals;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.cache.field.data.FieldDataCache;
|
||||
import org.elasticsearch.index.field.data.FieldData;
|
||||
@ -129,6 +130,7 @@ public class ScriptFieldsFunction implements FieldsFunction {
|
||||
if (source != null) {
|
||||
return source;
|
||||
}
|
||||
XContentParser parser = null;
|
||||
try {
|
||||
Document doc = reader.document(docId, SourceFieldSelector.INSTANCE);
|
||||
Fieldable sourceField = doc.getFieldable(SourceFieldMapper.NAME);
|
||||
@ -138,12 +140,18 @@ public class ScriptFieldsFunction implements FieldsFunction {
|
||||
LZFStreamInput siLzf = CachedStreamInput.cachedLzf(siBytes);
|
||||
XContentType contentType = XContentFactory.xContentType(siLzf);
|
||||
siLzf.resetToBufferStart();
|
||||
this.source = XContentFactory.xContent(contentType).createParser(siLzf).map();
|
||||
parser = XContentFactory.xContent(contentType).createParser(siLzf);
|
||||
this.source = parser.map();
|
||||
} else {
|
||||
this.source = XContentFactory.xContent(source).createParser(source).map();
|
||||
parser = XContentFactory.xContent(source).createParser(source);
|
||||
this.source = parser.map();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ElasticSearchParseException("failed to parse source", e);
|
||||
} finally {
|
||||
if (parser != null) {
|
||||
parser.close();
|
||||
}
|
||||
}
|
||||
return this.source;
|
||||
}
|
||||
|
@ -21,10 +21,10 @@ package org.elasticsearch.index.gateway;
|
||||
|
||||
import org.elasticsearch.common.collect.ImmutableList;
|
||||
import org.elasticsearch.common.collect.Lists;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
@ -86,7 +86,7 @@ public class CommitPoints implements Iterable<CommitPoint> {
|
||||
}
|
||||
|
||||
public static byte[] toXContent(CommitPoint commitPoint) throws Exception {
|
||||
XContentBuilder builder = XContentFactory.contentBinaryBuilder(XContentType.JSON).prettyPrint();
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON).prettyPrint();
|
||||
builder.startObject();
|
||||
builder.field("version", commitPoint.version());
|
||||
builder.field("name", commitPoint.name());
|
||||
|
@ -27,7 +27,7 @@ import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.lucene.all.AllField;
|
||||
import org.elasticsearch.common.lucene.all.AllTermQuery;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.mapper.AllFieldMapper;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
|
@ -21,8 +21,8 @@ package org.elasticsearch.index.mapper.xcontent;
|
||||
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -24,8 +24,8 @@ import org.apache.lucene.document.Fieldable;
|
||||
import org.elasticsearch.common.Booleans;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -27,8 +27,8 @@ import org.apache.lucene.search.NumericRangeQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.util.NumericUtils;
|
||||
import org.elasticsearch.common.Numbers;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericFloatAnalyzer;
|
||||
import org.elasticsearch.index.field.data.FieldData;
|
||||
|
@ -30,8 +30,8 @@ import org.elasticsearch.common.Numbers;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.joda.FormatDateTimeFormatter;
|
||||
import org.elasticsearch.common.joda.Joda;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericDateAnalyzer;
|
||||
import org.elasticsearch.index.field.data.FieldData;
|
||||
|
@ -27,11 +27,7 @@ import org.elasticsearch.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.common.compress.CompressedString;
|
||||
import org.elasticsearch.common.lucene.search.TermFilter;
|
||||
import org.elasticsearch.common.thread.ThreadLocals;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.*;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
|
||||
@ -422,7 +418,7 @@ public class XContentDocumentMapper implements DocumentMapper, ToXContent {
|
||||
|
||||
@Override public void refreshSource() throws FailedToGenerateSourceMapperException {
|
||||
try {
|
||||
XContentBuilder builder = XContentFactory.contentTextBuilder(XContentType.JSON);
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON);
|
||||
builder.startObject();
|
||||
toXContent(builder, ToXContent.EMPTY_PARAMS);
|
||||
builder.endObject();
|
||||
|
@ -27,8 +27,8 @@ import org.apache.lucene.search.NumericRangeQuery;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.util.NumericUtils;
|
||||
import org.elasticsearch.common.Numbers;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericDoubleAnalyzer;
|
||||
import org.elasticsearch.index.field.data.FieldData;
|
||||
|
@ -26,7 +26,7 @@ import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.search.*;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.lucene.search.TermFilter;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.field.data.FieldData;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
|
@ -28,8 +28,8 @@ import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.util.NumericUtils;
|
||||
import org.elasticsearch.common.Numbers;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericFloatAnalyzer;
|
||||
import org.elasticsearch.index.field.data.FieldData;
|
||||
|
@ -23,8 +23,8 @@ import org.apache.lucene.document.Field;
|
||||
import org.elasticsearch.ElasticSearchIllegalArgumentException;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.lucene.geo.GeoHashUtils;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.support.XContentMapValues;
|
||||
import org.elasticsearch.index.mapper.FieldMapperListener;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
|
@ -23,7 +23,7 @@ import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.mapper.IdFieldMapper;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
|
@ -24,7 +24,7 @@ import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.mapper.IndexFieldMapper;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
|
||||
|
@ -28,8 +28,8 @@ import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.util.NumericUtils;
|
||||
import org.elasticsearch.common.Numbers;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericIntegerAnalyzer;
|
||||
import org.elasticsearch.index.field.data.FieldData;
|
||||
|
@ -28,8 +28,8 @@ import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.util.NumericUtils;
|
||||
import org.elasticsearch.common.Numbers;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericLongAnalyzer;
|
||||
import org.elasticsearch.index.field.data.FieldData;
|
||||
|
@ -21,7 +21,7 @@ package org.elasticsearch.index.mapper.xcontent;
|
||||
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.mapper.FieldMapper;
|
||||
import org.elasticsearch.index.mapper.FieldMapperListener;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
|
@ -28,7 +28,7 @@ import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.util.NumericUtils;
|
||||
import org.elasticsearch.common.thread.ThreadLocals;
|
||||
import org.elasticsearch.common.trove.TIntObjectHashMap;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.field.data.FieldData;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
|
@ -25,8 +25,8 @@ import org.elasticsearch.common.collect.ImmutableMap;
|
||||
import org.elasticsearch.common.joda.FormatDateTimeFormatter;
|
||||
import org.elasticsearch.common.joda.Joda;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.index.mapper.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -28,8 +28,8 @@ import org.apache.lucene.search.Query;
|
||||
import org.apache.lucene.util.NumericUtils;
|
||||
import org.elasticsearch.common.Numbers;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.analysis.NumericIntegerAnalyzer;
|
||||
import org.elasticsearch.index.field.data.FieldData;
|
||||
|
@ -24,7 +24,7 @@ import org.elasticsearch.ElasticSearchParseException;
|
||||
import org.elasticsearch.common.compress.lzf.LZFDecoder;
|
||||
import org.elasticsearch.common.compress.lzf.LZFEncoder;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
import org.elasticsearch.index.mapper.SourceFieldMapper;
|
||||
|
||||
|
@ -22,8 +22,8 @@ package org.elasticsearch.index.mapper.xcontent;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.index.analysis.NamedAnalyzer;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
|
@ -24,7 +24,7 @@ import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
import org.elasticsearch.index.mapper.TypeFieldMapper;
|
||||
|
||||
|
@ -23,7 +23,7 @@ import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.mapper.MapperParsingException;
|
||||
import org.elasticsearch.index.mapper.MergeMappingException;
|
||||
import org.elasticsearch.index.mapper.Uid;
|
||||
|
@ -20,7 +20,7 @@
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.collect.Lists;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -20,10 +20,9 @@
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.io.FastByteArrayOutputStream;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.common.xcontent.builder.BinaryXContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilderException;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -39,7 +38,7 @@ public abstract class BaseQueryBuilder implements XContentQueryBuilder {
|
||||
|
||||
@Override public FastByteArrayOutputStream buildAsUnsafeBytes(XContentType contentType) throws QueryBuilderException {
|
||||
try {
|
||||
BinaryXContentBuilder builder = XContentFactory.contentBinaryBuilder(contentType);
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
|
||||
toXContent(builder, EMPTY_PARAMS);
|
||||
return builder.unsafeStream();
|
||||
} catch (Exception e) {
|
||||
@ -53,7 +52,7 @@ public abstract class BaseQueryBuilder implements XContentQueryBuilder {
|
||||
|
||||
@Override public byte[] buildAsBytes(XContentType contentType) throws QueryBuilderException {
|
||||
try {
|
||||
XContentBuilder builder = XContentFactory.contentBinaryBuilder(contentType);
|
||||
XContentBuilder builder = XContentFactory.contentBuilder(contentType);
|
||||
toXContent(builder, EMPTY_PARAMS);
|
||||
return builder.copiedBytes();
|
||||
} catch (Exception e) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -20,7 +20,7 @@
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.collect.Maps;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilderException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilderException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.lucene.geo.GeoBoundingBoxFilter;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilderException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -21,7 +21,7 @@ package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.lucene.geo.GeoDistance;
|
||||
import org.elasticsearch.common.unit.DistanceUnit;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -22,7 +22,7 @@ package org.elasticsearch.index.query.xcontent;
|
||||
import org.elasticsearch.common.collect.Lists;
|
||||
import org.elasticsearch.common.lucene.geo.GeoHashUtils;
|
||||
import org.elasticsearch.common.lucene.geo.GeoPolygonFilter;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilderException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilderException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.collect.Lists;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.trove.ExtTObjectFloatHashMap;
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilderException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilderException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
package org.elasticsearch.index.query.xcontent;
|
||||
|
||||
import org.elasticsearch.common.xcontent.builder.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.index.query.QueryBuilderException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user