-
-
Save umeshdangat/702d6b38f7395f857b3bf936cb1eeed0 to your computer and use it in GitHub Desktop.
SerDeQueryInfo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class QueryContextInfo { | |
private long queryId; | |
private double valueOne; | |
private double valueTwo; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static byte[] serialize(QueryContextInfo[] queryContextInfoRecords) { | |
byte[] bytes = new byte[Integer.BYTES + (queryContextInfoRecords.length * (Long.BYTES + 2 * (Double.BYTES)))]; | |
ByteBuffer.wrap(bytes, 0, Integer.BYTES).putInt(queryContextInfoRecords.length); | |
int offset = Integer.BYTES; | |
for (QueryContextInfo queryContextInfo : queryContextInfoRecords) { | |
ByteBuffer.wrap(bytes, offset, Long.BYTES).putLong(queryContextInfo.getQueryId()); | |
ByteBuffer.wrap(bytes, offset + Long.BYTES, Double.BYTES).putDouble(queryContextInfo.getValueOne()); | |
ByteBuffer.wrap(bytes, offset + Long.BYTES + Double.BYTES, Double.BYTES).putDouble(queryContextInfo.getValueTwo()); | |
offset += Long.BYTES + 2 * (Double.BYTES); | |
} | |
return bytes; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
List<ByteBuffer> queryContext = document.getList(ByteBuffer.class, "query_context"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment