parent
1a8495d1d6
commit
cc0f8c2eb1
|
@ -31,6 +31,7 @@ import org.elasticsearch.common.Nullable;
|
|||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.bytes.BytesArray;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.text.StringAndBytesText;
|
||||
import org.elasticsearch.common.text.Text;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -420,11 +421,17 @@ public abstract class StreamInput extends InputStream {
|
|||
return readDoubleArray();
|
||||
case 21:
|
||||
return readBytesRef();
|
||||
case 22:
|
||||
return readGeoPoint();
|
||||
default:
|
||||
throw new IOException("Can't read unknown type [" + type + "]");
|
||||
}
|
||||
}
|
||||
|
||||
public GeoPoint readGeoPoint() throws IOException {
|
||||
return new GeoPoint(readDouble(), readDouble());
|
||||
}
|
||||
|
||||
public int[] readIntArray() throws IOException {
|
||||
int length = readVInt();
|
||||
int[] values = new int[length];
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.elasticsearch.ElasticsearchException;
|
|||
import org.elasticsearch.Version;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
import org.elasticsearch.common.geo.GeoPoint;
|
||||
import org.elasticsearch.common.text.Text;
|
||||
import org.joda.time.ReadableInstant;
|
||||
|
||||
|
@ -408,6 +409,10 @@ public abstract class StreamOutput extends OutputStream {
|
|||
} else if (value instanceof BytesRef) {
|
||||
writeByte((byte) 21);
|
||||
writeBytesRef((BytesRef) value);
|
||||
} else if (type == GeoPoint.class) {
|
||||
writeByte((byte) 22);
|
||||
writeDouble(((GeoPoint) value).lat());
|
||||
writeDouble(((GeoPoint) value).lon());
|
||||
} else {
|
||||
throw new IOException("Can't write type [" + type + "]");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue