# HG changeset patch # User Nozomi Teruya # Date 1447867533 -32400 # Node ID 2af387211a8504cb3d5f04a9cc7e1456218420ea # Parent 1dc473a637c6422bd20fc3856b3379c44805dce2 add zippedDataSize to ReceiveData diff -r 1dc473a637c6 -r 2af387211a85 src/main/java/alice/daemon/CommandMessage.java --- 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; } + } diff -r 1dc473a637c6 -r 2af387211a85 src/main/java/alice/daemon/IncomingTcpConnection.java --- 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); diff -r 1dc473a637c6 -r 2af387211a85 src/main/java/alice/datasegment/ReceiveData.java --- 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; + } + }