Commit 7b1cf84d authored by Yoann Pigné's avatar Yoann Pigné

update java implementation to take into account bugfix #56 in gs-core

parent d89e4128
......@@ -485,10 +485,12 @@ package org.netstream;
* </p>
* <ul class="simple">
* <li>the attribute name (TYPE_STRING format)</li>
* <li>the attribute value type (one of the bytes shown in the &quot;Data
* <li>the attribute'd old value type (one of the bytes shown in the &quot;Data
* Types&quot; section)</li>
* <li>the old attribute value, encoded according to its value type (see the
* &quot;Data Types&quot; section)</li>
* <li>the attribute's new value type (one of the bytes shown in the &quot;Data
* Types&quot; section)</li>
* <li>the new attribute value, encoded according to its value type (see the
* &quot;Data Types&quot; section)</li>
* </ul>
......@@ -528,10 +530,12 @@ package org.netstream;
* <ul class="simple">
* <li>the ID of the considered node (TYPE_STRING format)</li>
* <li>the attribute name (TYPE_STRING format)</li>
* <li>the attribute value type (one of the bytes shown in the &quot;Data
* <li>the attribute's old value type (one of the bytes shown in the &quot;Data
* Types&quot; section)</li>
* <li>the old attribute value, encoded according to its value type (see the
* &quot;Data Types&quot; section)</li>
* <li>the attribute's new value type (one of the bytes shown in the &quot;Data
* Types&quot; section)</li>
* <li>the new attribute value, encoded according to its value type (see the
* &quot;Data Types&quot; section)</li>
* </ul>
......@@ -553,10 +557,10 @@ package org.netstream;
* <tt class="docutils literal">EVENT_ADD_EDGE_ATTR</tt> [0x1C]
* </p>
* <p>
* Add an attribute to a node. Followed by:
* Add an attribute to an edge. Followed by:
* </p>
* <ul class="simple">
* <li>the ID of the considered node (TYPE_STRING format)</li>
* <li>the ID of the considered edge (TYPE_STRING format)</li>
* <li>the attribute name (TYPE_STRING format)</li>
* <li>the attribute value type (one of the bytes shown in the &quot;Data
* Types&quot; section)</li>
......@@ -569,15 +573,17 @@ package org.netstream;
* <tt class="docutils literal">EVENT_CHG_EDGE_ATTR</tt> [0x1D]
* </p>
* <p>
* Change an existing attribute on a given node. Followed by:
* Change an existing attribute on a given edge. Followed by:
* </p>
* <ul class="simple">
* <li>the ID of the considered node (TYPE_STRING format)</li>
* <li>the ID of the considered edge (TYPE_STRING format)</li>
* <li>the attribute name (TYPE_STRING format)</li>
* <li>the attribute value type (one of the bytes shown in the &quot;Data
* <li>the attribute's old value type (one of the bytes shown in the &quot;Data
* Types&quot; section)</li>
* <li>the old attribute value, encoded according to its value type (see the
* &quot;Data Types&quot; section)</li>
* <li>the attribute's new value type (one of the bytes shown in the &quot;Data
* Types&quot; section)</li>
* <li>the new attribute value, encoded according to its value type (see the
* &quot;Data Types&quot; section)</li>
* </ul>
......@@ -587,10 +593,10 @@ package org.netstream;
* <tt class="docutils literal">EVENT_DEL_EDGE_ATTR</tt> [0x1E]
* </p>
* <p>
* Remove an attribute from a given node. Followed by:
* Remove an attribute from a given edge. Followed by:
* </p>
* <ul class="simple">
* <li>the ID of the considered node (TYPE_STRING format)</li>
* <li>the ID of the considered edge (TYPE_STRING format)</li>
* <li>the attribute name (encoded with the TYPE_STRING format).</li>
* </ul>
* </li>
......
......@@ -38,6 +38,7 @@ import java.nio.charset.Charset;
import org.netstream.packing.NetStreamPacker;
/**
* <p>
* This class implements a sender according to specifications the NetStream
......@@ -64,7 +65,8 @@ import org.netstream.packing.NetStreamPacker;
* @author Yoann Pigné
*
*/
public class NetStreamSender {
public class NetStreamSender{
protected String stream;
byte[] streamIdArray;
protected String host;
......@@ -496,11 +498,12 @@ public class NetStreamSender {
sourceIdBuff = sourceId.getBytes(Charset.forName("UTF-8"));
}
byte[] attrArray = attribute.getBytes(Charset.forName("UTF-8"));
int valueType = getType(oldValue);
int oldValueType = getType(oldValue);
int newValueType = getType(newValue);
ByteBuffer bOldValue = encodeValue(oldValue, valueType);
ByteBuffer bOldValue = encodeValue(oldValue, oldValueType);
bOldValue.flip();
ByteBuffer bNewValue = encodeValue(newValue, valueType);
ByteBuffer bNewValue = encodeValue(newValue, newValueType);
bNewValue.flip();
ByteBuffer buff = ByteBuffer.allocate(4 + streamIdArray.length + // Stream
......@@ -509,13 +512,19 @@ public class NetStreamSender {
4 + sourceIdBuff.length + // source id
8 + // timeId
4 + attrArray.length + // attr name
1 + bOldValue.capacity() + bNewValue.capacity()); // values
1 + // value type
bOldValue.capacity() +
1 + // value type
bNewValue.capacity()); // values
buff.putInt(streamIdArray.length).put(streamIdArray)
.put((byte) NetStreamConstants.EVENT_CHG_GRAPH_ATTR)
.putInt(sourceIdBuff.length).put(sourceIdBuff).putLong(timeId)
.putInt(attrArray.length).put(attrArray).put((byte) valueType)
.put(bOldValue).put(bNewValue);
.putInt(attrArray.length).put(attrArray)
.put((byte) oldValueType)
.put(bOldValue)
.put((byte) newValueType)
.put(bNewValue);
doSend(buff);
......@@ -614,11 +623,12 @@ public class NetStreamSender {
}
byte[] attrArray = attribute.getBytes(Charset.forName("UTF-8"));
byte[] nodeIdArray = nodeId.getBytes(Charset.forName("UTF-8"));
int valueType = getType(oldValue);
int oldValueType = getType(oldValue);
int newValueType = getType(newValue);
ByteBuffer bOldValue = encodeValue(oldValue, valueType);
ByteBuffer bOldValue = encodeValue(oldValue, oldValueType);
bOldValue.flip();
ByteBuffer bNewValue = encodeValue(newValue, valueType);
ByteBuffer bNewValue = encodeValue(newValue, newValueType);
bNewValue.flip();
ByteBuffer buff = ByteBuffer.allocate(4 + streamIdArray.length + // stream
......@@ -629,6 +639,7 @@ public class NetStreamSender {
(4 + attrArray.length) + // attribute
1 + // value type
bOldValue.capacity() + // value
1 + // value type
bNewValue.capacity() // new value
);
......@@ -639,8 +650,9 @@ public class NetStreamSender {
.putInt(sourceIdBuff.length).put(sourceIdBuff).putLong(timeId)
.putInt(nodeIdArray.length).put(nodeIdArray) // nodeId
.putInt(attrArray.length).put(attrArray) // attribute
.put((byte) valueType) // value type
.put((byte) oldValueType) // value type
.put(bOldValue) // value
.put((byte) newValueType) // value type
.put(bNewValue); // value
doSend(buff);
}
......@@ -742,11 +754,12 @@ public class NetStreamSender {
}
byte[] edgeIdArray = edgeId.getBytes(Charset.forName("UTF-8"));
byte[] attrArray = attribute.getBytes(Charset.forName("UTF-8"));
int valueType = getType(oldValue);
int oldValueType = getType(oldValue);
int newValueType = getType(newValue);
ByteBuffer bOldValue = encodeValue(oldValue, valueType);
ByteBuffer bOldValue = encodeValue(oldValue, oldValueType);
bOldValue.flip();
ByteBuffer bNewValue = encodeValue(newValue, valueType);
ByteBuffer bNewValue = encodeValue(newValue, newValueType);
bNewValue.flip();
ByteBuffer buff = ByteBuffer.allocate(4 + streamIdArray.length + // stream
......@@ -758,6 +771,7 @@ public class NetStreamSender {
(4 + attrArray.length) + // attribute
1 + // value type
bOldValue.capacity() + // value
1 + // value type
bNewValue.capacity() // new value
);
......@@ -768,8 +782,9 @@ public class NetStreamSender {
.putInt(sourceIdBuff.length).put(sourceIdBuff).putLong(timeId)
.putInt(edgeIdArray.length).put(edgeIdArray) // nodeId
.putInt(attrArray.length).put(attrArray) // attribute
.put((byte) valueType) // value type
.put((byte) oldValueType) // value type
.put(bOldValue) // value
.put((byte) newValueType) // value type
.put(bNewValue); // value
doSend(buff);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment