Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Sensei needs to be able to support the old format of serialization (s…

…tuff Java serialized data into protobuf).
  • Loading branch information...
commit 85dbecdb6b702a22ea789d0a8f71a9533398ce0c 1 parent dc6cff9
jhartman authored
Showing with 3,548 additions and 115 deletions.
  1. +11 −0 protobuf/sensei-generic-req.proto
  2. +11 −0 protobuf/sensei-generic-res.proto
  3. +10 −0 protobuf/sensei-req.proto
  4. +10 −0 protobuf/sensei-res.proto
  5. +11 −0 protobuf/sensei-sys-req.proto
  6. +11 −0 protobuf/sensei-sys-res.proto
  7. +1 −1  sensei-core/pom.xml
  8. +3 −0  sensei-core/src/main/java/com/sensei/search/nodes/SenseiServer.java
  9. +0 −89 sensei-core/src/main/java/com/sensei/search/req/SenseiJavaSerializer.java
  10. +252 −0 sensei-core/src/main/java/com/sensei/search/req/protobuf/ProtoConvertUtil.java
  11. +138 −0 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiGenericBPOConverter.java
  12. +503 −0 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiGenericRequestBPO.java
  13. +503 −0 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiGenericResultBPO.java
  14. +54 −0 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiReqProtoSerializer.java
  15. +400 −0 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiRequestBPO.java
  16. +88 −0 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiRequestBPOConverter.java
  17. +400 −0 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiResultBPO.java
  18. +55 −0 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiSysReqProtoSerializer.java
  19. +400 −0 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiSysRequestBPO.java
  20. +89 −0 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiSysRequestBPOConverter.java
  21. +400 −0 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiSysResultBPO.java
  22. +5 −4 sensei-core/src/main/java/com/sensei/search/svc/impl/CoreSenseiServiceImpl.java
  23. +5 −21 sensei-core/src/main/java/com/sensei/search/svc/impl/SysSenseiCoreServiceImpl.java
  24. +188 −0 sensei-core/src/test/java/com/sensei/test/TestSerialization.java
View
11 protobuf/sensei-generic-req.proto
@@ -0,0 +1,11 @@
+package com.sensei.search.req.protobuf;
+
+option java_package = "com.sensei.search.req.protobuf";
+option java_outer_classname = "SenseiGenericRequestBPO";
+
+option optimize_for = SPEED;
+
+message GenericRequest{
+ required string classname = 1;
+ required bytes val = 2;
+}
View
11 protobuf/sensei-generic-res.proto
@@ -0,0 +1,11 @@
+package com.sensei.search.req.protobuf;
+
+option java_package = "com.sensei.search.req.protobuf";
+option java_outer_classname = "SenseiGenericResultBPO";
+
+option optimize_for = SPEED;
+
+message GenericResult{
+ required string classname = 1;
+ required bytes val = 2;
+}
View
10 protobuf/sensei-req.proto
@@ -0,0 +1,10 @@
+package com.sensei.search.req.protobuf;
+
+option java_package = "com.sensei.search.req.protobuf";
+option java_outer_classname = "SenseiRequestBPO";
+
+option optimize_for = SPEED;
+
+message Request{
+ required bytes val = 1;
+}
View
10 protobuf/sensei-res.proto
@@ -0,0 +1,10 @@
+package com.sensei.search.req.protobuf;
+
+option java_package = "com.sensei.search.req.protobuf";
+option java_outer_classname = "SenseiResultBPO";
+
+option optimize_for = SPEED;
+
+message Result{
+ required bytes val = 1;
+}
View
11 protobuf/sensei-sys-req.proto
@@ -0,0 +1,11 @@
+package com.sensei.search.req.protobuf;
+
+option java_package = "com.sensei.search.req.protobuf";
+option java_outer_classname = "SenseiSysRequestBPO";
+
+option optimize_for = SPEED;
+
+message SysRequest{
+ required bytes val = 1;
+}
+
View
11 protobuf/sensei-sys-res.proto
@@ -0,0 +1,11 @@
+package com.sensei.search.req.protobuf;
+
+option java_package = "com.sensei.search.req.protobuf";
+option java_outer_classname = "SenseiSysResultBPO";
+
+option optimize_for = SPEED;
+
+message SysResult{
+ required bytes val = 1;
+}
+
View
2  sensei-core/pom.xml
@@ -204,7 +204,7 @@
<dependency>
<groupId>com.linkedin</groupId>
<artifactId>norbert_2.8.1</artifactId>
- <version>0.6.11</version>
+ <version>0.6.12</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
View
3  sensei-core/src/main/java/com/sensei/search/nodes/SenseiServer.java
@@ -169,6 +169,9 @@ public void start(boolean available) throws Exception{
_networkServer.registerHandler(senseiMsgHandler, coreSenseiService.getSerializer());
_networkServer.registerHandler(senseiSysMsgHandler, sysSenseiCoreService.getSerializer());
+ _networkServer.registerHandler(senseiMsgHandler, CoreSenseiServiceImpl.PROTO_SERIALIZER);
+ _networkServer.registerHandler(senseiSysMsgHandler, SysSenseiCoreServiceImpl.PROTO_SERIALIZER);
+
if (_externalSvc!=null){
for (AbstractSenseiCoreService svc : _externalSvc){
_networkServer.registerHandler(new SenseiCoreServiceMessageHandler(svc), svc.getSerializer());
View
89 sensei-core/src/main/java/com/sensei/search/req/SenseiJavaSerializer.java
@@ -1,89 +0,0 @@
-package com.sensei.search.req;
-
-import com.linkedin.norbert.network.Serializer;
-import scala.Tuple2;
-
-import java.io.*;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * This is partially a minor fix for the Java Serializer in Norbert and partially a fix because Sensei uses
- * SenseiRequest for both SenseiRequest and SyseiSysRequests, when maybe they should be split up!
- * @param <RequestMsg>
- * @param <ResponseMsg>
- */
-public class SenseiJavaSerializer<RequestMsg, ResponseMsg> implements Serializer<RequestMsg, ResponseMsg> {
- private final Class<RequestMsg> requestClass;
- private final Class<ResponseMsg> responseClass;
- private final String reqName;
- private final String resName;
-
- private SenseiJavaSerializer(Class<RequestMsg> requestClass, Class<ResponseMsg> responseClass,
- String reqName, String resName) {
- this.requestClass = requestClass;
- this.responseClass = responseClass;
- this.reqName = reqName;
- this.resName = resName;
- }
-
- public static <RequestMsg, ResponseMsg> SenseiJavaSerializer<RequestMsg, ResponseMsg> build
- (String reqName, String resName, Class<RequestMsg> requestClass, Class<ResponseMsg> responseClass) {
- return new SenseiJavaSerializer<RequestMsg, ResponseMsg>(requestClass, responseClass, reqName, resName);
- }
-
- public static <RequestMsg, ResponseMsg> SenseiJavaSerializer<RequestMsg, ResponseMsg> build
- (Class<RequestMsg> requestClass, Class<ResponseMsg> responseClass) {
- return new SenseiJavaSerializer<RequestMsg, ResponseMsg>(requestClass, responseClass, requestClass.getName(), responseClass.getName());
- }
-
- public static <RequestMsg, ResponseMsg> SenseiJavaSerializer<RequestMsg, ResponseMsg> build
- (String requestClassName, Class<RequestMsg> requestClass, Class<ResponseMsg> responseClass) {
- return new SenseiJavaSerializer<RequestMsg, ResponseMsg>(requestClass, responseClass, requestClassName, responseClass.getName());
- }
-
- private <T> byte[] toBytes(T message) {
- try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(message);
- return baos.toByteArray();
- } catch (Exception ex) {
- throw new IllegalStateException("Sensei server not properly serializing objects ", ex);
- }
- }
-
- private <T> T fromBytes(byte[] bytes) {
- try {
- ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
- ObjectInputStream ois = new ObjectInputStream(bais);
- return (T) ois.readObject();
- } catch (Exception ex) {
- throw new IllegalStateException("Sensei server not properly serializing objects ", ex);
- }
- }
-
- public String requestName() {
- return reqName;
- }
-
- public String responseName() {
- return resName;
- }
-
- public byte[] requestToBytes(RequestMsg message) {
- return toBytes(message);
- }
-
- public RequestMsg requestFromBytes(byte[] bytes) {
- return fromBytes(bytes);
- }
-
- public byte[] responseToBytes(ResponseMsg message) {
- return toBytes(message);
- }
-
- public ResponseMsg responseFromBytes(byte[] bytes) {
- return fromBytes(bytes);
- }
-}
View
252 sensei-core/src/main/java/com/sensei/search/req/protobuf/ProtoConvertUtil.java
@@ -0,0 +1,252 @@
+package com.sensei.search.req.protobuf;
+/**
+ * @author nnarkhed
+ */
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+
+import com.google.protobuf.ByteString;
+import com.google.protobuf.TextFormat.ParseException;
+
+public class ProtoConvertUtil {
+
+ private final static Logger logger = Logger.getLogger(ProtoConvertUtil.class);
+ public static Object serializeIn(ByteString byteString) throws ParseException{
+ if (byteString==null) return null;
+ try{
+ byte[] bytes = byteString.toByteArray();
+ if (bytes.length==0) return null;
+ ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
+ ObjectInputStream oin = new ObjectInputStream(bin);
+ return oin.readObject();
+ }
+ catch(Exception e){
+ logger.error(e.getMessage(),e);
+ throw new ParseException(e.getMessage());
+ }
+ }
+
+ public static ByteString serializeOut(Object o) throws ParseException{
+ if (o == null) return null;
+ try{
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ ObjectOutputStream oout = new ObjectOutputStream(bout);
+ oout.writeObject(o);
+ oout.flush();
+ byte[] data = bout.toByteArray();
+ return ByteString.copyFrom(data);
+ }
+ catch(Exception e){
+ logger.error(e.getMessage(),e);
+ throw new ParseException(e.getMessage());
+ }
+ }
+
+ /**
+ * serialize out an int array
+ * @param data input integer array
+ * @return serialized integer array in the format - <len><int><int>....
+ * @throws ParseException
+ */
+ public static ByteString serializeData(int[] data) throws ParseException{
+ if (data == null) return null;
+ try{
+ return serializeOut(data);
+ }
+ catch(Exception e){
+ logger.error(e.getMessage(),e);
+ throw new ParseException(e.getMessage());
+ }
+ }
+
+ /**
+ * serialize out an boolean array
+ * @param data input boolean array
+ * @return serialized boolean array in the format - <len><boolean><boolean>...
+ * @throws ParseException
+ */
+ public static ByteString serializeData(boolean[] data) throws ParseException{
+ if (data == null) return null;
+ try{
+ return serializeOut(data);
+ }
+ catch(Exception e){
+ logger.error(e.getMessage(),e);
+ throw new ParseException(e.getMessage());
+ }
+ }
+
+ /**
+ * serialize out an char array
+ * @param data input character array
+ * @return serialized char array in the format - <len><char><char>...
+ * @throws ParseException
+ */
+ public static ByteString serializeData(char[] data) throws ParseException{
+ if (data == null) return null;
+ try{
+ return serializeOut(data);
+ }
+ catch(Exception e){
+ logger.error(e.getMessage(),e);
+ throw new ParseException(e.getMessage());
+ }
+ }
+
+ /**
+ * serialize out an long array
+ * @param data input long array
+ * @return serialized long array in the format - <len><long><long>...
+ * @throws ParseException
+ */
+ public static ByteString serializeData(long[] data) throws ParseException{
+ if (data == null) return null;
+ try{
+ return serializeOut(data);
+ }
+ catch(Exception e){
+ logger.error(e.getMessage(),e);
+ throw new ParseException(e.getMessage());
+ }
+ }
+
+ /**
+ * serialize out a double array
+ * @param data input double array
+ * @return serialized double array in the format - <len><double><double>...
+ * @throws ParseException
+ */
+ public static ByteString serializeData(double[] data) throws ParseException{
+ if (data == null) return null;
+ try{
+ return serializeOut(data);
+ }
+ catch(Exception e){
+ logger.error(e.getMessage(),e);
+ throw new ParseException(e.getMessage());
+ }
+ }
+
+ /**
+ * This function deserializes the input byte string back into an integer array
+ * @param byteString the byte string serialized by serializeData()
+ * @return the deserialized integer array
+ * @throws ParseException
+ */
+ public static int[] toIntArray(ByteString byteString) throws ParseException{
+ if (byteString==null) return null;
+ try{
+ return (int[])serializeIn(byteString);
+ }
+ catch(Exception e){
+ logger.error(e.getMessage(),e);
+ throw new ParseException(e.getMessage());
+ }
+ }
+
+ /**
+ * This function deserializes the input byte string back into an integer array
+ * @param byteString the byte string serialized by serializeData()
+ * @return the deserialized integer array
+ * @throws ParseException
+ */
+ public static Set<Integer> toIntegerSet(ByteString byteString) throws ParseException{
+ if (byteString==null) return null;
+ try{
+ int[] data = (int[])serializeIn(byteString);
+ Set<Integer> intset = null;
+ if (data != null){
+ intset = new HashSet<Integer>(data.length);
+ for (int datum : data){
+ intset.add(datum);
+ }
+ }
+ return intset;
+ }
+ catch(Exception e){
+ logger.error(e.getMessage(),e);
+ throw new ParseException(e.getMessage());
+ }
+ }
+
+ public static char[] toCharArray(ByteString byteString) throws ParseException{
+ // return (short[])serializeIn(byteString);
+ if (byteString==null) return null;
+ try{
+ return (char[])serializeIn(byteString);
+ }
+ catch(Exception e){
+ logger.error(e.getMessage(),e);
+ throw new ParseException(e.getMessage());
+ }
+ }
+
+ /**
+ * This function deserializes the input byte string back into a double array
+ * @param byteString the byte string serialized by serializeData()
+ * @return the deserialized double array
+ * @throws ParseException
+ */
+ public static double[] toDoubleArray(ByteString byteString) throws ParseException{
+ // return (double[])serializeIn(byteString);
+ if (byteString==null) return null;
+ try{
+ return (double[])serializeIn(byteString);
+ }
+ catch(Exception e){
+ logger.error(e.getMessage(),e);
+ throw new ParseException(e.getMessage());
+ }
+ }
+
+ /**
+ * This function deserializes the input byte string back into an long array
+ * @param byteString the byte string serialized by serializeData()
+ * @return the deserialized long array
+ * @throws ParseException
+ */
+ public static long[] toLongArray(ByteString byteString) throws ParseException{
+ // return (long[])serializeIn(byteString);
+ if (byteString==null) return null;
+ try{
+ return (long[])serializeIn(byteString);
+ }
+ catch(Exception e){
+ logger.error(e.getMessage(),e);
+ throw new ParseException(e.getMessage());
+ }
+ }
+
+ /**
+ * This function deserializes the input byte string back into a boolean array
+ * @param byteString the byte string serialized by serializeData()
+ * @return the deserialized boolean array
+ * @throws ParseException
+ */
+ public static boolean[] toBooleanArray(ByteString byteString) throws ParseException{
+ if (byteString==null) return null;
+ try{
+ return (boolean[])serializeIn(byteString);
+ }
+ catch(Exception e){
+ logger.error(e.getMessage(),e);
+ throw new ParseException(e.getMessage());
+ }
+
+ }
+
+ private static byte[] intToByteArray(int data) {
+ byte[] bytes = new byte[4];
+ bytes[0] = (byte) (data & 0x000F);
+ bytes[1] = (byte) ((data & 0x00F0) >> 8);
+ bytes[2] = (byte) ((data & 0x0F00) >> 16);
+ bytes[3] = (byte) ((data & 0xF000) >> 24);
+ return bytes;
+ }
+}
View
138 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiGenericBPOConverter.java
@@ -0,0 +1,138 @@
+package com.sensei.search.req.protobuf;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+import org.apache.log4j.Logger;
+
+import com.google.protobuf.ByteString;
+import com.sensei.search.req.SenseiGenericRequest;
+import com.sensei.search.req.SenseiGenericResult;
+
+public class SenseiGenericBPOConverter
+{
+ private static Logger logger = Logger.getLogger(SenseiGenericBPOConverter.class);
+ public static SenseiGenericRequest convert(SenseiGenericRequestBPO.GenericRequest req)
+ {
+ try
+ {
+ String classname = req.getClassname();
+ ByteString value = req.getVal();
+ byte[] raw = value.toByteArray();
+ ByteArrayInputStream bais = new ByteArrayInputStream(raw);
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ SenseiGenericRequest ret = new SenseiGenericRequest();
+ ret.setClassname(classname);
+ ret.setRequest((Serializable) ois.readObject());
+ return ret;
+ } catch (Exception e)
+ {
+ logger.error("serialize request", e);
+ }
+ return (SenseiGenericRequest) null;
+ }
+ public static SenseiGenericRequestBPO.GenericRequest convert(SenseiGenericRequest req)
+ {
+ SenseiGenericRequestBPO.GenericRequest.Builder builder = SenseiGenericRequestBPO.GenericRequest.newBuilder();
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos;
+ oos = new ObjectOutputStream(baos);
+ oos.writeObject(req.getRequest());
+ oos.close();
+ byte[] raw = baos.toByteArray();
+ builder.setClassname(req.getClassname());
+ builder.setVal(ByteString.copyFrom(raw));
+ return builder.build();
+ } catch (IOException e)
+ {
+ logger.error("deserialize request", e);
+ }
+ return SenseiGenericRequestBPO.GenericRequest.getDefaultInstance();
+ }
+ public static SenseiGenericResult convert(SenseiGenericResultBPO.GenericResult req)
+ {
+ try
+ {
+ String classname = req.getClassname();
+ ByteString value = req.getVal();
+ byte[] raw = value.toByteArray();
+ ByteArrayInputStream bais = new ByteArrayInputStream(raw);
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ SenseiGenericResult ret = new SenseiGenericResult();
+ ret.setClassname(classname);
+ ret.setResult((Serializable) ois.readObject());
+ return ret;
+ } catch (Exception e)
+ {
+ logger.error("serialize result", e);
+ }
+ return (SenseiGenericResult) null;
+ }
+ public static SenseiGenericResultBPO.GenericResult convert(SenseiGenericResult req)
+ {
+ SenseiGenericResultBPO.GenericResult.Builder builder = SenseiGenericResultBPO.GenericResult.newBuilder();
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos;
+ oos = new ObjectOutputStream(baos);
+ oos.writeObject(req.getResult());
+ oos.close();
+ byte[] raw = baos.toByteArray();
+ builder.setClassname(req.getClassname());
+ builder.setVal(ByteString.copyFrom(raw));
+ return builder.build();
+ } catch (IOException e)
+ {
+ logger.error("deserialize result", e);
+ }
+ return SenseiGenericResultBPO.GenericResult.getDefaultInstance();
+ }
+
+ public static byte[] decompress(byte[] output) throws IOException
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(output);
+ GZIPInputStream gzis = new GZIPInputStream(bais);
+ byte[] buf = new byte[2048];
+ List<byte[]> list = new LinkedList<byte[]>();
+ int len = gzis.read(buf, 0, 2048);
+ int i = 0;
+ while(len>0)
+ {
+ byte[] b1 = new byte[len];
+ System.arraycopy(buf, 0, b1, 0, len);
+ list.add(b1);
+ i+= len;
+ len = gzis.read(buf, 0, 2048);
+ }
+ gzis.close();
+ byte[] whole = new byte[i];
+ int start = 0;
+ for(byte[] part : list)
+ {
+ System.arraycopy(part, 0, whole, start, part.length);
+ start += part.length;
+ }
+ return whole;
+ }
+
+ public static byte[] compress(byte[] b) throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ GZIPOutputStream gzos = new GZIPOutputStream(baos);
+ gzos.write(b);
+ gzos.close();
+ byte[] output = baos.toByteArray();
+ return output;
+ }
+}
View
503 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiGenericRequestBPO.java
@@ -0,0 +1,503 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: protobuf/sensei-generic-req.proto
+
+package com.sensei.search.req.protobuf;
+
+public final class SenseiGenericRequestBPO {
+ private SenseiGenericRequestBPO() {}
+ public static void registerAllExtensions(
+ com.google.protobuf.ExtensionRegistry registry) {
+ }
+ public interface GenericRequestOrBuilder
+ extends com.google.protobuf.MessageOrBuilder {
+
+ // required string classname = 1;
+ boolean hasClassname();
+ String getClassname();
+
+ // required bytes val = 2;
+ boolean hasVal();
+ com.google.protobuf.ByteString getVal();
+ }
+ public static final class GenericRequest extends
+ com.google.protobuf.GeneratedMessage
+ implements GenericRequestOrBuilder {
+ // Use GenericRequest.newBuilder() to construct.
+ private GenericRequest(Builder builder) {
+ super(builder);
+ }
+ private GenericRequest(boolean noInit) {}
+
+ private static final GenericRequest defaultInstance;
+ public static GenericRequest getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public GenericRequest getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.sensei.search.req.protobuf.SenseiGenericRequestBPO.internal_static_com_sensei_search_req_protobuf_GenericRequest_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.sensei.search.req.protobuf.SenseiGenericRequestBPO.internal_static_com_sensei_search_req_protobuf_GenericRequest_fieldAccessorTable;
+ }
+
+ private int bitField0_;
+ // required string classname = 1;
+ public static final int CLASSNAME_FIELD_NUMBER = 1;
+ private Object classname_;
+ public boolean hasClassname() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public String getClassname() {
+ Object ref = classname_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ if (com.google.protobuf.Internal.isValidUtf8(bs)) {
+ classname_ = s;
+ }
+ return s;
+ }
+ }
+ private com.google.protobuf.ByteString getClassnameBytes() {
+ Object ref = classname_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8((String) ref);
+ classname_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ // required bytes val = 2;
+ public static final int VAL_FIELD_NUMBER = 2;
+ private com.google.protobuf.ByteString val_;
+ public boolean hasVal() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ public com.google.protobuf.ByteString getVal() {
+ return val_;
+ }
+
+ private void initFields() {
+ classname_ = "";
+ val_ = com.google.protobuf.ByteString.EMPTY;
+ }
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized != -1) return isInitialized == 1;
+
+ if (!hasClassname()) {
+ memoizedIsInitialized = 0;
+ return false;
+ }
+ if (!hasVal()) {
+ memoizedIsInitialized = 0;
+ return false;
+ }
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ getSerializedSize();
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ output.writeBytes(1, getClassnameBytes());
+ }
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ output.writeBytes(2, val_);
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(1, getClassnameBytes());
+ }
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(2, val_);
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ @java.lang.Override
+ protected Object writeReplace() throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
+ public static com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+
+ public static Builder newBuilder() { return Builder.create(); }
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder(com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() { return newBuilder(this); }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder>
+ implements com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequestOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.sensei.search.req.protobuf.SenseiGenericRequestBPO.internal_static_com_sensei_search_req_protobuf_GenericRequest_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.sensei.search.req.protobuf.SenseiGenericRequestBPO.internal_static_com_sensei_search_req_protobuf_GenericRequest_fieldAccessorTable;
+ }
+
+ // Construct using com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ }
+ }
+ private static Builder create() {
+ return new Builder();
+ }
+
+ public Builder clear() {
+ super.clear();
+ classname_ = "";
+ bitField0_ = (bitField0_ & ~0x00000001);
+ val_ = com.google.protobuf.ByteString.EMPTY;
+ bitField0_ = (bitField0_ & ~0x00000002);
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(buildPartial());
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest.getDescriptor();
+ }
+
+ public com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest getDefaultInstanceForType() {
+ return com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest.getDefaultInstance();
+ }
+
+ public com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest build() {
+ com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ private com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest buildParsed()
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(
+ result).asInvalidProtocolBufferException();
+ }
+ return result;
+ }
+
+ public com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest buildPartial() {
+ com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest result = new com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+ to_bitField0_ |= 0x00000001;
+ }
+ result.classname_ = classname_;
+ if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
+ to_bitField0_ |= 0x00000002;
+ }
+ result.val_ = val_;
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest) {
+ return mergeFrom((com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest other) {
+ if (other == com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest.getDefaultInstance()) return this;
+ if (other.hasClassname()) {
+ setClassname(other.getClassname());
+ }
+ if (other.hasVal()) {
+ setVal(other.getVal());
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ if (!hasClassname()) {
+
+ return false;
+ }
+ if (!hasVal()) {
+
+ return false;
+ }
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder(
+ this.getUnknownFields());
+ while (true) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ default: {
+ if (!parseUnknownField(input, unknownFields,
+ extensionRegistry, tag)) {
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ }
+ break;
+ }
+ case 10: {
+ bitField0_ |= 0x00000001;
+ classname_ = input.readBytes();
+ break;
+ }
+ case 18: {
+ bitField0_ |= 0x00000002;
+ val_ = input.readBytes();
+ break;
+ }
+ }
+ }
+ }
+
+ private int bitField0_;
+
+ // required string classname = 1;
+ private Object classname_ = "";
+ public boolean hasClassname() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public String getClassname() {
+ Object ref = classname_;
+ if (!(ref instanceof String)) {
+ String s = ((com.google.protobuf.ByteString) ref).toStringUtf8();
+ classname_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ public Builder setClassname(String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000001;
+ classname_ = value;
+ onChanged();
+ return this;
+ }
+ public Builder clearClassname() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ classname_ = getDefaultInstance().getClassname();
+ onChanged();
+ return this;
+ }
+ void setClassname(com.google.protobuf.ByteString value) {
+ bitField0_ |= 0x00000001;
+ classname_ = value;
+ onChanged();
+ }
+
+ // required bytes val = 2;
+ private com.google.protobuf.ByteString val_ = com.google.protobuf.ByteString.EMPTY;
+ public boolean hasVal() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ public com.google.protobuf.ByteString getVal() {
+ return val_;
+ }
+ public Builder setVal(com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000002;
+ val_ = value;
+ onChanged();
+ return this;
+ }
+ public Builder clearVal() {
+ bitField0_ = (bitField0_ & ~0x00000002);
+ val_ = getDefaultInstance().getVal();
+ onChanged();
+ return this;
+ }
+
+ // @@protoc_insertion_point(builder_scope:com.sensei.search.req.protobuf.GenericRequest)
+ }
+
+ static {
+ defaultInstance = new GenericRequest(true);
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:com.sensei.search.req.protobuf.GenericRequest)
+ }
+
+ private static com.google.protobuf.Descriptors.Descriptor
+ internal_static_com_sensei_search_req_protobuf_GenericRequest_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_com_sensei_search_req_protobuf_GenericRequest_fieldAccessorTable;
+
+ public static com.google.protobuf.Descriptors.FileDescriptor
+ getDescriptor() {
+ return descriptor;
+ }
+ private static com.google.protobuf.Descriptors.FileDescriptor
+ descriptor;
+ static {
+ java.lang.String[] descriptorData = {
+ "\n!protobuf/sensei-generic-req.proto\022\036com" +
+ ".sensei.search.req.protobuf\"0\n\016GenericRe" +
+ "quest\022\021\n\tclassname\030\001 \002(\t\022\013\n\003val\030\002 \002(\014B;\n" +
+ "\036com.sensei.search.req.protobufB\027SenseiG" +
+ "enericRequestBPOH\001"
+ };
+ com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
+ new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
+ public com.google.protobuf.ExtensionRegistry assignDescriptors(
+ com.google.protobuf.Descriptors.FileDescriptor root) {
+ descriptor = root;
+ internal_static_com_sensei_search_req_protobuf_GenericRequest_descriptor =
+ getDescriptor().getMessageTypes().get(0);
+ internal_static_com_sensei_search_req_protobuf_GenericRequest_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_com_sensei_search_req_protobuf_GenericRequest_descriptor,
+ new java.lang.String[] { "Classname", "Val", },
+ com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest.class,
+ com.sensei.search.req.protobuf.SenseiGenericRequestBPO.GenericRequest.Builder.class);
+ return null;
+ }
+ };
+ com.google.protobuf.Descriptors.FileDescriptor
+ .internalBuildGeneratedFileFrom(descriptorData,
+ new com.google.protobuf.Descriptors.FileDescriptor[] {
+ }, assigner);
+ }
+
+ // @@protoc_insertion_point(outer_class_scope)
+}
View
503 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiGenericResultBPO.java
@@ -0,0 +1,503 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: protobuf/sensei-generic-res.proto
+
+package com.sensei.search.req.protobuf;
+
+public final class SenseiGenericResultBPO {
+ private SenseiGenericResultBPO() {}
+ public static void registerAllExtensions(
+ com.google.protobuf.ExtensionRegistry registry) {
+ }
+ public interface GenericResultOrBuilder
+ extends com.google.protobuf.MessageOrBuilder {
+
+ // required string classname = 1;
+ boolean hasClassname();
+ String getClassname();
+
+ // required bytes val = 2;
+ boolean hasVal();
+ com.google.protobuf.ByteString getVal();
+ }
+ public static final class GenericResult extends
+ com.google.protobuf.GeneratedMessage
+ implements GenericResultOrBuilder {
+ // Use GenericResult.newBuilder() to construct.
+ private GenericResult(Builder builder) {
+ super(builder);
+ }
+ private GenericResult(boolean noInit) {}
+
+ private static final GenericResult defaultInstance;
+ public static GenericResult getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public GenericResult getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.sensei.search.req.protobuf.SenseiGenericResultBPO.internal_static_com_sensei_search_req_protobuf_GenericResult_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.sensei.search.req.protobuf.SenseiGenericResultBPO.internal_static_com_sensei_search_req_protobuf_GenericResult_fieldAccessorTable;
+ }
+
+ private int bitField0_;
+ // required string classname = 1;
+ public static final int CLASSNAME_FIELD_NUMBER = 1;
+ private Object classname_;
+ public boolean hasClassname() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public String getClassname() {
+ Object ref = classname_;
+ if (ref instanceof String) {
+ return (String) ref;
+ } else {
+ com.google.protobuf.ByteString bs =
+ (com.google.protobuf.ByteString) ref;
+ String s = bs.toStringUtf8();
+ if (com.google.protobuf.Internal.isValidUtf8(bs)) {
+ classname_ = s;
+ }
+ return s;
+ }
+ }
+ private com.google.protobuf.ByteString getClassnameBytes() {
+ Object ref = classname_;
+ if (ref instanceof String) {
+ com.google.protobuf.ByteString b =
+ com.google.protobuf.ByteString.copyFromUtf8((String) ref);
+ classname_ = b;
+ return b;
+ } else {
+ return (com.google.protobuf.ByteString) ref;
+ }
+ }
+
+ // required bytes val = 2;
+ public static final int VAL_FIELD_NUMBER = 2;
+ private com.google.protobuf.ByteString val_;
+ public boolean hasVal() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ public com.google.protobuf.ByteString getVal() {
+ return val_;
+ }
+
+ private void initFields() {
+ classname_ = "";
+ val_ = com.google.protobuf.ByteString.EMPTY;
+ }
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized != -1) return isInitialized == 1;
+
+ if (!hasClassname()) {
+ memoizedIsInitialized = 0;
+ return false;
+ }
+ if (!hasVal()) {
+ memoizedIsInitialized = 0;
+ return false;
+ }
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ getSerializedSize();
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ output.writeBytes(1, getClassnameBytes());
+ }
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ output.writeBytes(2, val_);
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(1, getClassnameBytes());
+ }
+ if (((bitField0_ & 0x00000002) == 0x00000002)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(2, val_);
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ @java.lang.Override
+ protected Object writeReplace() throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
+ public static com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+
+ public static Builder newBuilder() { return Builder.create(); }
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder(com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() { return newBuilder(this); }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder>
+ implements com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResultOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.sensei.search.req.protobuf.SenseiGenericResultBPO.internal_static_com_sensei_search_req_protobuf_GenericResult_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.sensei.search.req.protobuf.SenseiGenericResultBPO.internal_static_com_sensei_search_req_protobuf_GenericResult_fieldAccessorTable;
+ }
+
+ // Construct using com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ }
+ }
+ private static Builder create() {
+ return new Builder();
+ }
+
+ public Builder clear() {
+ super.clear();
+ classname_ = "";
+ bitField0_ = (bitField0_ & ~0x00000001);
+ val_ = com.google.protobuf.ByteString.EMPTY;
+ bitField0_ = (bitField0_ & ~0x00000002);
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(buildPartial());
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult.getDescriptor();
+ }
+
+ public com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult getDefaultInstanceForType() {
+ return com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult.getDefaultInstance();
+ }
+
+ public com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult build() {
+ com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ private com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult buildParsed()
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(
+ result).asInvalidProtocolBufferException();
+ }
+ return result;
+ }
+
+ public com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult buildPartial() {
+ com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult result = new com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+ to_bitField0_ |= 0x00000001;
+ }
+ result.classname_ = classname_;
+ if (((from_bitField0_ & 0x00000002) == 0x00000002)) {
+ to_bitField0_ |= 0x00000002;
+ }
+ result.val_ = val_;
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult) {
+ return mergeFrom((com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult other) {
+ if (other == com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult.getDefaultInstance()) return this;
+ if (other.hasClassname()) {
+ setClassname(other.getClassname());
+ }
+ if (other.hasVal()) {
+ setVal(other.getVal());
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ if (!hasClassname()) {
+
+ return false;
+ }
+ if (!hasVal()) {
+
+ return false;
+ }
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder(
+ this.getUnknownFields());
+ while (true) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ default: {
+ if (!parseUnknownField(input, unknownFields,
+ extensionRegistry, tag)) {
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ }
+ break;
+ }
+ case 10: {
+ bitField0_ |= 0x00000001;
+ classname_ = input.readBytes();
+ break;
+ }
+ case 18: {
+ bitField0_ |= 0x00000002;
+ val_ = input.readBytes();
+ break;
+ }
+ }
+ }
+ }
+
+ private int bitField0_;
+
+ // required string classname = 1;
+ private Object classname_ = "";
+ public boolean hasClassname() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public String getClassname() {
+ Object ref = classname_;
+ if (!(ref instanceof String)) {
+ String s = ((com.google.protobuf.ByteString) ref).toStringUtf8();
+ classname_ = s;
+ return s;
+ } else {
+ return (String) ref;
+ }
+ }
+ public Builder setClassname(String value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000001;
+ classname_ = value;
+ onChanged();
+ return this;
+ }
+ public Builder clearClassname() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ classname_ = getDefaultInstance().getClassname();
+ onChanged();
+ return this;
+ }
+ void setClassname(com.google.protobuf.ByteString value) {
+ bitField0_ |= 0x00000001;
+ classname_ = value;
+ onChanged();
+ }
+
+ // required bytes val = 2;
+ private com.google.protobuf.ByteString val_ = com.google.protobuf.ByteString.EMPTY;
+ public boolean hasVal() {
+ return ((bitField0_ & 0x00000002) == 0x00000002);
+ }
+ public com.google.protobuf.ByteString getVal() {
+ return val_;
+ }
+ public Builder setVal(com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000002;
+ val_ = value;
+ onChanged();
+ return this;
+ }
+ public Builder clearVal() {
+ bitField0_ = (bitField0_ & ~0x00000002);
+ val_ = getDefaultInstance().getVal();
+ onChanged();
+ return this;
+ }
+
+ // @@protoc_insertion_point(builder_scope:com.sensei.search.req.protobuf.GenericResult)
+ }
+
+ static {
+ defaultInstance = new GenericResult(true);
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:com.sensei.search.req.protobuf.GenericResult)
+ }
+
+ private static com.google.protobuf.Descriptors.Descriptor
+ internal_static_com_sensei_search_req_protobuf_GenericResult_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_com_sensei_search_req_protobuf_GenericResult_fieldAccessorTable;
+
+ public static com.google.protobuf.Descriptors.FileDescriptor
+ getDescriptor() {
+ return descriptor;
+ }
+ private static com.google.protobuf.Descriptors.FileDescriptor
+ descriptor;
+ static {
+ java.lang.String[] descriptorData = {
+ "\n!protobuf/sensei-generic-res.proto\022\036com" +
+ ".sensei.search.req.protobuf\"/\n\rGenericRe" +
+ "sult\022\021\n\tclassname\030\001 \002(\t\022\013\n\003val\030\002 \002(\014B:\n\036" +
+ "com.sensei.search.req.protobufB\026SenseiGe" +
+ "nericResultBPOH\001"
+ };
+ com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
+ new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
+ public com.google.protobuf.ExtensionRegistry assignDescriptors(
+ com.google.protobuf.Descriptors.FileDescriptor root) {
+ descriptor = root;
+ internal_static_com_sensei_search_req_protobuf_GenericResult_descriptor =
+ getDescriptor().getMessageTypes().get(0);
+ internal_static_com_sensei_search_req_protobuf_GenericResult_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_com_sensei_search_req_protobuf_GenericResult_descriptor,
+ new java.lang.String[] { "Classname", "Val", },
+ com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult.class,
+ com.sensei.search.req.protobuf.SenseiGenericResultBPO.GenericResult.Builder.class);
+ return null;
+ }
+ };
+ com.google.protobuf.Descriptors.FileDescriptor
+ .internalBuildGeneratedFileFrom(descriptorData,
+ new com.google.protobuf.Descriptors.FileDescriptor[] {
+ }, assigner);
+ }
+
+ // @@protoc_insertion_point(outer_class_scope)
+}
View
54 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiReqProtoSerializer.java
@@ -0,0 +1,54 @@
+package com.sensei.search.req.protobuf;
+
+import com.google.protobuf.ByteString;
+import com.google.protobuf.InvalidProtocolBufferException;
+import com.google.protobuf.TextFormat;
+import com.linkedin.norbert.network.Serializer;
+import com.sensei.search.req.SenseiRequest;
+import com.sensei.search.req.SenseiResult;
+
+public class SenseiReqProtoSerializer implements Serializer<SenseiRequest, SenseiResult> {
+ public String requestName() {
+ return SenseiRequestBPO.Request.getDescriptor().getName();
+ }
+
+ public String responseName() {
+ return SenseiResultBPO.Result.getDescriptor().getName();
+ }
+
+ public byte[] requestToBytes(SenseiRequest request) {
+ return SenseiRequestBPO.Request.newBuilder().setVal(serialize(request)).build().toByteArray();
+ }
+
+ public byte[] responseToBytes(SenseiResult response) {
+ return SenseiResultBPO.Result.newBuilder().setVal(serialize(response)).build().toByteArray();
+ }
+
+ private <T> ByteString serialize(T obj) {
+ try {
+ return ProtoConvertUtil.serializeOut(obj);
+ } catch (TextFormat.ParseException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public SenseiRequest requestFromBytes(byte[] request) {
+ try {
+ return (SenseiRequest) ProtoConvertUtil.serializeIn(SenseiRequestBPO.Request.newBuilder().mergeFrom(request).build().getVal());
+ } catch (TextFormat.ParseException e) {
+ throw new RuntimeException(e);
+ } catch (InvalidProtocolBufferException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public SenseiResult responseFromBytes(byte[] result) {
+ try {
+ return (SenseiResult) ProtoConvertUtil.serializeIn(SenseiResultBPO.Result.newBuilder().mergeFrom(result).build().getVal());
+ } catch (TextFormat.ParseException e) {
+ throw new RuntimeException(e);
+ } catch (InvalidProtocolBufferException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
View
400 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiRequestBPO.java
@@ -0,0 +1,400 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: protobuf/sensei-req.proto
+
+package com.sensei.search.req.protobuf;
+
+public final class SenseiRequestBPO {
+ private SenseiRequestBPO() {}
+ public static void registerAllExtensions(
+ com.google.protobuf.ExtensionRegistry registry) {
+ }
+ public interface RequestOrBuilder
+ extends com.google.protobuf.MessageOrBuilder {
+
+ // required bytes val = 1;
+ boolean hasVal();
+ com.google.protobuf.ByteString getVal();
+ }
+ public static final class Request extends
+ com.google.protobuf.GeneratedMessage
+ implements RequestOrBuilder {
+ // Use Request.newBuilder() to construct.
+ private Request(Builder builder) {
+ super(builder);
+ }
+ private Request(boolean noInit) {}
+
+ private static final Request defaultInstance;
+ public static Request getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public Request getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.sensei.search.req.protobuf.SenseiRequestBPO.internal_static_com_sensei_search_req_protobuf_Request_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.sensei.search.req.protobuf.SenseiRequestBPO.internal_static_com_sensei_search_req_protobuf_Request_fieldAccessorTable;
+ }
+
+ private int bitField0_;
+ // required bytes val = 1;
+ public static final int VAL_FIELD_NUMBER = 1;
+ private com.google.protobuf.ByteString val_;
+ public boolean hasVal() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public com.google.protobuf.ByteString getVal() {
+ return val_;
+ }
+
+ private void initFields() {
+ val_ = com.google.protobuf.ByteString.EMPTY;
+ }
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized != -1) return isInitialized == 1;
+
+ if (!hasVal()) {
+ memoizedIsInitialized = 0;
+ return false;
+ }
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ getSerializedSize();
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ output.writeBytes(1, val_);
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(1, val_);
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ @java.lang.Override
+ protected Object writeReplace() throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
+ public static com.sensei.search.req.protobuf.SenseiRequestBPO.Request parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiRequestBPO.Request parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiRequestBPO.Request parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiRequestBPO.Request parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiRequestBPO.Request parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiRequestBPO.Request parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiRequestBPO.Request parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.sensei.search.req.protobuf.SenseiRequestBPO.Request parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.sensei.search.req.protobuf.SenseiRequestBPO.Request parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiRequestBPO.Request parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+
+ public static Builder newBuilder() { return Builder.create(); }
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder(com.sensei.search.req.protobuf.SenseiRequestBPO.Request prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() { return newBuilder(this); }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder>
+ implements com.sensei.search.req.protobuf.SenseiRequestBPO.RequestOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.sensei.search.req.protobuf.SenseiRequestBPO.internal_static_com_sensei_search_req_protobuf_Request_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.sensei.search.req.protobuf.SenseiRequestBPO.internal_static_com_sensei_search_req_protobuf_Request_fieldAccessorTable;
+ }
+
+ // Construct using com.sensei.search.req.protobuf.SenseiRequestBPO.Request.newBuilder()
+ private Builder() {
+ maybeForceBuilderInitialization();
+ }
+
+ private Builder(BuilderParent parent) {
+ super(parent);
+ maybeForceBuilderInitialization();
+ }
+ private void maybeForceBuilderInitialization() {
+ if (com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders) {
+ }
+ }
+ private static Builder create() {
+ return new Builder();
+ }
+
+ public Builder clear() {
+ super.clear();
+ val_ = com.google.protobuf.ByteString.EMPTY;
+ bitField0_ = (bitField0_ & ~0x00000001);
+ return this;
+ }
+
+ public Builder clone() {
+ return create().mergeFrom(buildPartial());
+ }
+
+ public com.google.protobuf.Descriptors.Descriptor
+ getDescriptorForType() {
+ return com.sensei.search.req.protobuf.SenseiRequestBPO.Request.getDescriptor();
+ }
+
+ public com.sensei.search.req.protobuf.SenseiRequestBPO.Request getDefaultInstanceForType() {
+ return com.sensei.search.req.protobuf.SenseiRequestBPO.Request.getDefaultInstance();
+ }
+
+ public com.sensei.search.req.protobuf.SenseiRequestBPO.Request build() {
+ com.sensei.search.req.protobuf.SenseiRequestBPO.Request result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(result);
+ }
+ return result;
+ }
+
+ private com.sensei.search.req.protobuf.SenseiRequestBPO.Request buildParsed()
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ com.sensei.search.req.protobuf.SenseiRequestBPO.Request result = buildPartial();
+ if (!result.isInitialized()) {
+ throw newUninitializedMessageException(
+ result).asInvalidProtocolBufferException();
+ }
+ return result;
+ }
+
+ public com.sensei.search.req.protobuf.SenseiRequestBPO.Request buildPartial() {
+ com.sensei.search.req.protobuf.SenseiRequestBPO.Request result = new com.sensei.search.req.protobuf.SenseiRequestBPO.Request(this);
+ int from_bitField0_ = bitField0_;
+ int to_bitField0_ = 0;
+ if (((from_bitField0_ & 0x00000001) == 0x00000001)) {
+ to_bitField0_ |= 0x00000001;
+ }
+ result.val_ = val_;
+ result.bitField0_ = to_bitField0_;
+ onBuilt();
+ return result;
+ }
+
+ public Builder mergeFrom(com.google.protobuf.Message other) {
+ if (other instanceof com.sensei.search.req.protobuf.SenseiRequestBPO.Request) {
+ return mergeFrom((com.sensei.search.req.protobuf.SenseiRequestBPO.Request)other);
+ } else {
+ super.mergeFrom(other);
+ return this;
+ }
+ }
+
+ public Builder mergeFrom(com.sensei.search.req.protobuf.SenseiRequestBPO.Request other) {
+ if (other == com.sensei.search.req.protobuf.SenseiRequestBPO.Request.getDefaultInstance()) return this;
+ if (other.hasVal()) {
+ setVal(other.getVal());
+ }
+ this.mergeUnknownFields(other.getUnknownFields());
+ return this;
+ }
+
+ public final boolean isInitialized() {
+ if (!hasVal()) {
+
+ return false;
+ }
+ return true;
+ }
+
+ public Builder mergeFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ com.google.protobuf.UnknownFieldSet.Builder unknownFields =
+ com.google.protobuf.UnknownFieldSet.newBuilder(
+ this.getUnknownFields());
+ while (true) {
+ int tag = input.readTag();
+ switch (tag) {
+ case 0:
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ default: {
+ if (!parseUnknownField(input, unknownFields,
+ extensionRegistry, tag)) {
+ this.setUnknownFields(unknownFields.build());
+ onChanged();
+ return this;
+ }
+ break;
+ }
+ case 10: {
+ bitField0_ |= 0x00000001;
+ val_ = input.readBytes();
+ break;
+ }
+ }
+ }
+ }
+
+ private int bitField0_;
+
+ // required bytes val = 1;
+ private com.google.protobuf.ByteString val_ = com.google.protobuf.ByteString.EMPTY;
+ public boolean hasVal() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public com.google.protobuf.ByteString getVal() {
+ return val_;
+ }
+ public Builder setVal(com.google.protobuf.ByteString value) {
+ if (value == null) {
+ throw new NullPointerException();
+ }
+ bitField0_ |= 0x00000001;
+ val_ = value;
+ onChanged();
+ return this;
+ }
+ public Builder clearVal() {
+ bitField0_ = (bitField0_ & ~0x00000001);
+ val_ = getDefaultInstance().getVal();
+ onChanged();
+ return this;
+ }
+
+ // @@protoc_insertion_point(builder_scope:com.sensei.search.req.protobuf.Request)
+ }
+
+ static {
+ defaultInstance = new Request(true);
+ defaultInstance.initFields();
+ }
+
+ // @@protoc_insertion_point(class_scope:com.sensei.search.req.protobuf.Request)
+ }
+
+ private static com.google.protobuf.Descriptors.Descriptor
+ internal_static_com_sensei_search_req_protobuf_Request_descriptor;
+ private static
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internal_static_com_sensei_search_req_protobuf_Request_fieldAccessorTable;
+
+ public static com.google.protobuf.Descriptors.FileDescriptor
+ getDescriptor() {
+ return descriptor;
+ }
+ private static com.google.protobuf.Descriptors.FileDescriptor
+ descriptor;
+ static {
+ java.lang.String[] descriptorData = {
+ "\n\031protobuf/sensei-req.proto\022\036com.sensei." +
+ "search.req.protobuf\"\026\n\007Request\022\013\n\003val\030\001 " +
+ "\002(\014B4\n\036com.sensei.search.req.protobufB\020S" +
+ "enseiRequestBPOH\001"
+ };
+ com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
+ new com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner() {
+ public com.google.protobuf.ExtensionRegistry assignDescriptors(
+ com.google.protobuf.Descriptors.FileDescriptor root) {
+ descriptor = root;
+ internal_static_com_sensei_search_req_protobuf_Request_descriptor =
+ getDescriptor().getMessageTypes().get(0);
+ internal_static_com_sensei_search_req_protobuf_Request_fieldAccessorTable = new
+ com.google.protobuf.GeneratedMessage.FieldAccessorTable(
+ internal_static_com_sensei_search_req_protobuf_Request_descriptor,
+ new java.lang.String[] { "Val", },
+ com.sensei.search.req.protobuf.SenseiRequestBPO.Request.class,
+ com.sensei.search.req.protobuf.SenseiRequestBPO.Request.Builder.class);
+ return null;
+ }
+ };
+ com.google.protobuf.Descriptors.FileDescriptor
+ .internalBuildGeneratedFileFrom(descriptorData,
+ new com.google.protobuf.Descriptors.FileDescriptor[] {
+ }, assigner);
+ }
+
+ // @@protoc_insertion_point(outer_class_scope)
+}
View
88 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiRequestBPOConverter.java
@@ -0,0 +1,88 @@
+package com.sensei.search.req.protobuf;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import org.apache.log4j.Logger;
+import com.google.protobuf.ByteString;
+import com.sensei.search.req.SenseiRequest;
+import com.sensei.search.req.SenseiResult;
+
+public class SenseiRequestBPOConverter {
+
+ private static Logger logger = Logger.getLogger(SenseiRequestBPOConverter.class);
+
+ public static SenseiRequest convert(SenseiRequestBPO.Request req)
+ {
+ try
+ {
+ ByteString value = req.getVal();
+ byte[] raw = value.toByteArray();
+ ByteArrayInputStream bais = new ByteArrayInputStream(raw);
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ SenseiRequest ret = (SenseiRequest) ois.readObject();
+ return ret;
+ } catch (Exception e)
+ {
+ logger.error("serialize request", e);
+ }
+ return null;
+ }
+ public static SenseiRequestBPO.Request convert(SenseiRequest req)
+ {
+ SenseiRequestBPO.Request.Builder builder = SenseiRequestBPO.Request.newBuilder();
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos;
+ oos = new ObjectOutputStream(baos);
+ oos.writeObject(req);
+ oos.close();
+ byte[] raw = baos.toByteArray();
+ builder.setVal(ByteString.copyFrom(raw));
+ return builder.build();
+ } catch (IOException e)
+ {
+ logger.error("deserialize request", e);
+ }
+ return SenseiRequestBPO.Request.getDefaultInstance();
+ }
+ public static SenseiResult convert(SenseiResultBPO.Result req)
+ {
+ try
+ {
+ ByteString value = req.getVal();
+ byte[] raw = value.toByteArray();
+ ByteArrayInputStream bais = new ByteArrayInputStream(raw);
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ SenseiResult ret = (SenseiResult) ois.readObject();
+ return ret;
+ } catch (Exception e)
+ {
+ logger.error("serialize result", e);
+ }
+ return null;
+ }
+ public static SenseiResultBPO.Result convert(SenseiResult req)
+ {
+ SenseiResultBPO.Result.Builder builder = SenseiResultBPO.Result.newBuilder();
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos;
+ oos = new ObjectOutputStream(baos);
+ oos.writeObject(req);
+ oos.close();
+ byte[] raw = baos.toByteArray();
+ builder.setVal(ByteString.copyFrom(raw));
+ return builder.build();
+ } catch (IOException e)
+ {
+ logger.error("deserialize result", e);
+ }
+ return SenseiResultBPO.Result.getDefaultInstance();
+ }
+}
View
400 sensei-core/src/main/java/com/sensei/search/req/protobuf/SenseiResultBPO.java
@@ -0,0 +1,400 @@
+// Generated by the protocol buffer compiler. DO NOT EDIT!
+// source: protobuf/sensei-res.proto
+
+package com.sensei.search.req.protobuf;
+
+public final class SenseiResultBPO {
+ private SenseiResultBPO() {}
+ public static void registerAllExtensions(
+ com.google.protobuf.ExtensionRegistry registry) {
+ }
+ public interface ResultOrBuilder
+ extends com.google.protobuf.MessageOrBuilder {
+
+ // required bytes val = 1;
+ boolean hasVal();
+ com.google.protobuf.ByteString getVal();
+ }
+ public static final class Result extends
+ com.google.protobuf.GeneratedMessage
+ implements ResultOrBuilder {
+ // Use Result.newBuilder() to construct.
+ private Result(Builder builder) {
+ super(builder);
+ }
+ private Result(boolean noInit) {}
+
+ private static final Result defaultInstance;
+ public static Result getDefaultInstance() {
+ return defaultInstance;
+ }
+
+ public Result getDefaultInstanceForType() {
+ return defaultInstance;
+ }
+
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.sensei.search.req.protobuf.SenseiResultBPO.internal_static_com_sensei_search_req_protobuf_Result_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.sensei.search.req.protobuf.SenseiResultBPO.internal_static_com_sensei_search_req_protobuf_Result_fieldAccessorTable;
+ }
+
+ private int bitField0_;
+ // required bytes val = 1;
+ public static final int VAL_FIELD_NUMBER = 1;
+ private com.google.protobuf.ByteString val_;
+ public boolean hasVal() {
+ return ((bitField0_ & 0x00000001) == 0x00000001);
+ }
+ public com.google.protobuf.ByteString getVal() {
+ return val_;
+ }
+
+ private void initFields() {
+ val_ = com.google.protobuf.ByteString.EMPTY;
+ }
+ private byte memoizedIsInitialized = -1;
+ public final boolean isInitialized() {
+ byte isInitialized = memoizedIsInitialized;
+ if (isInitialized != -1) return isInitialized == 1;
+
+ if (!hasVal()) {
+ memoizedIsInitialized = 0;
+ return false;
+ }
+ memoizedIsInitialized = 1;
+ return true;
+ }
+
+ public void writeTo(com.google.protobuf.CodedOutputStream output)
+ throws java.io.IOException {
+ getSerializedSize();
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ output.writeBytes(1, val_);
+ }
+ getUnknownFields().writeTo(output);
+ }
+
+ private int memoizedSerializedSize = -1;
+ public int getSerializedSize() {
+ int size = memoizedSerializedSize;
+ if (size != -1) return size;
+
+ size = 0;
+ if (((bitField0_ & 0x00000001) == 0x00000001)) {
+ size += com.google.protobuf.CodedOutputStream
+ .computeBytesSize(1, val_);
+ }
+ size += getUnknownFields().getSerializedSize();
+ memoizedSerializedSize = size;
+ return size;
+ }
+
+ @java.lang.Override
+ protected Object writeReplace() throws java.io.ObjectStreamException {
+ return super.writeReplace();
+ }
+
+ public static com.sensei.search.req.protobuf.SenseiResultBPO.Result parseFrom(
+ com.google.protobuf.ByteString data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiResultBPO.Result parseFrom(
+ com.google.protobuf.ByteString data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiResultBPO.Result parseFrom(byte[] data)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data).buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiResultBPO.Result parseFrom(
+ byte[] data,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws com.google.protobuf.InvalidProtocolBufferException {
+ return newBuilder().mergeFrom(data, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiResultBPO.Result parseFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiResultBPO.Result parseFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiResultBPO.Result parseDelimitedFrom(java.io.InputStream input)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.sensei.search.req.protobuf.SenseiResultBPO.Result parseDelimitedFrom(
+ java.io.InputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ Builder builder = newBuilder();
+ if (builder.mergeDelimitedFrom(input, extensionRegistry)) {
+ return builder.buildParsed();
+ } else {
+ return null;
+ }
+ }
+ public static com.sensei.search.req.protobuf.SenseiResultBPO.Result parseFrom(
+ com.google.protobuf.CodedInputStream input)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input).buildParsed();
+ }
+ public static com.sensei.search.req.protobuf.SenseiResultBPO.Result parseFrom(
+ com.google.protobuf.CodedInputStream input,
+ com.google.protobuf.ExtensionRegistryLite extensionRegistry)
+ throws java.io.IOException {
+ return newBuilder().mergeFrom(input, extensionRegistry)
+ .buildParsed();
+ }
+
+ public static Builder newBuilder() { return Builder.create(); }
+ public Builder newBuilderForType() { return newBuilder(); }
+ public static Builder newBuilder(com.sensei.search.req.protobuf.SenseiResultBPO.Result prototype) {
+ return newBuilder().mergeFrom(prototype);
+ }
+ public Builder toBuilder() { return newBuilder(this); }
+
+ @java.lang.Override
+ protected Builder newBuilderForType(
+ com.google.protobuf.GeneratedMessage.BuilderParent parent) {
+ Builder builder = new Builder(parent);
+ return builder;
+ }
+ public static final class Builder extends
+ com.google.protobuf.GeneratedMessage.Builder<Builder>
+ implements com.sensei.search.req.protobuf.SenseiResultBPO.ResultOrBuilder {
+ public static final com.google.protobuf.Descriptors.Descriptor
+ getDescriptor() {
+ return com.sensei.search.req.protobuf.SenseiResultBPO.internal_static_com_sensei_search_req_protobuf_Result_descriptor;
+ }
+
+ protected com.google.protobuf.GeneratedMessage.FieldAccessorTable
+ internalGetFieldAccessorTable() {
+ return com.sensei.search.req.protobuf.SenseiResultBPO.internal_static_com_sensei_search_req_protobuf_Result_fieldAccessorTable;
+ }
+
+ // Construct using com.sensei.search.req.protobuf.SenseiResultBPO.Result.newBuilder()
+ private Builder() {