changeset 555:2af387211a85 dispose

add zippedDataSize to ReceiveData
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Thu, 19 Nov 2015 02:25:33 +0900
parents 1dc473a637c6
children 65b615d3a30c 72ef96ba4195
files src/main/java/alice/daemon/CommandMessage.java src/main/java/alice/daemon/IncomingTcpConnection.java src/main/java/alice/datasegment/ReceiveData.java
diffstat 3 files changed, 22 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/alice/daemon/CommandMessage.java	Tue Nov 17 00:53:02 2015 +0900
+++ b/src/main/java/alice/daemon/CommandMessage.java	Thu Nov 19 02:25:33 2015 +0900
@@ -14,11 +14,11 @@
     public boolean quickFlag = false;//SEDAを挟まずに処理を行うかどうか
     public boolean serialized = false;//シリアライズされているかどうか
     public boolean compressed = false;//圧縮されているかどうか
-    public int dataSize = 0;
+    public int dataSize = 0;//
 
-    public boolean setTime = false;//?
-    public long time;//?
-    public int depth;//?
+    public boolean setTime = false;//計測用
+    public long time;//
+    public int depth;//
 
     public CommandMessage() {}
 
@@ -33,4 +33,5 @@
         this.compressed = cFlag;
         this.dataSize = datasize;
     }
+
 }
--- a/src/main/java/alice/daemon/IncomingTcpConnection.java	Tue Nov 17 00:53:02 2015 +0900
+++ b/src/main/java/alice/daemon/IncomingTcpConnection.java	Thu Nov 19 02:25:33 2015 +0900
@@ -59,14 +59,16 @@
                 switch (type) {
                 case UPDATE:
                 case PUT:
+                    int dataSize = unpacker.readInt();
                     if (msg.compressed) {
-                        rData = new ReceiveData(packer.read(unpacker.getSerializedByteArray(unpacker.readInt()), byte[].class), true, msg.dataSize);
+                        rData = new ReceiveData(packer.read(unpacker.getSerializedByteArray(dataSize), byte[].class), true, msg.dataSize);
                     } else {
-                        rData = new ReceiveData(unpacker.getSerializedByteArray(unpacker.readInt()), false, msg.dataSize);
+                        rData = new ReceiveData(unpacker.getSerializedByteArray(dataSize), false, msg.dataSize);
                     }
 
                     if (msg.setTime) {
                         rData.setTimes(msg.time, true, msg.depth);
+                        rData.setZippedDataSize(dataSize);
                     }
 
                     cmd = new Command(type, null, null, rData, 0, 0, null, null, reverseKey);
--- a/src/main/java/alice/datasegment/ReceiveData.java	Tue Nov 17 00:53:02 2015 +0900
+++ b/src/main/java/alice/datasegment/ReceiveData.java	Thu Nov 19 02:25:33 2015 +0900
@@ -16,12 +16,13 @@
     private Object val;//for Object DS
     private byte[] messagePack;//for byteArray(serialized) DS
     private byte[] zMessagePack;//for byteArray(compressed) DS
-    private int dataSize;
+    private int dataSize;//圧縮前(MessagePack)のデータサイズ
     private Class<?> clazz;
 
     private long time;//測定用
     private boolean setTime = false;
     private int depth = 1;
+    private int zippedDataSize;//圧縮後のデータサイズ
 
     private static final MessagePack packer = new MessagePack();
 
@@ -196,15 +197,15 @@
         }
     }
 
-    protected byte[] unzip(byte[] input, int zippedLength) {///read header & unzip
+    protected byte[] unzip(byte[] input, int dataSize) {///read header & unzip
         int length = input.length;
         Inflater inflater = new Inflater();
 
-        byte [] output = new byte [zippedLength];///byteArray for unziped data
+        byte [] output = new byte [dataSize];///byteArray for unziped data
         inflater.setInput(input, 0, length);///set unzip data without header
 
         try {
-            inflater.inflate(output, 0, zippedLength);///unzip
+            inflater.inflate(output, 0, dataSize);///unzip
         } catch (DataFormatException e) {
             e.printStackTrace();
         }
@@ -262,4 +263,12 @@
         return this.depth;
     }
 
+    public  void setZippedDataSize(int zippedDataSize){
+        this.zippedDataSize = zippedDataSize;
+    }
+
+    public  int getZippedDataSize(){
+        return this.zippedDataSize;
+    }
+
 }