Mercurial > hg > Database > Alice
view src/main/java/alice/codesegment/OutputDataSegment.java @ 523:145c425db88d dispose
add CompressedLDSM
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 09 Apr 2015 18:36:26 +0900 (2015-04-09) |
parents | b6e663a9a372 |
children | 30a74eee59c7 |
line wrap: on
line source
package alice.codesegment; import alice.datasegment.CommandType; import alice.datasegment.DataSegment; import alice.datasegment.ReceiveData; import alice.datasegment.Receiver; import alice.datasegment.SendOption; public class OutputDataSegment { private boolean compressFlag = false;//圧縮するかどうか /** * for local */ /** * input→ds変更→outputのときコピーを防ぐ */ public void flip(Receiver receiver) { DataSegment.getLocal().put(receiver.key, receiver.getReceiveData(), false); } public void flip(Receiver receiver, CommandType type) { switch (type) { case PUT: DataSegment.getLocal().put(receiver.key, receiver.getReceiveData(), false);//localなら全部false。 break; case UPDATE: DataSegment.getLocal().update(receiver.key, receiver.getReceiveData(), false); break; default: break; } } public void put(String key, ReceiveData rData) { DataSegment.getLocal().put(key, rData, false); } public void put(String key, Object val) { ReceiveData rData = new ReceiveData(val, false, false); DataSegment.getLocal().put(key, rData, false); } public void update(String key, Object val) { ReceiveData rData = new ReceiveData(val, false, false); DataSegment.getLocal().update(key, rData, false); } /** * for remote */ public void put(String managerKey, String key, ReceiveData rData) { if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ DataSegment.get(managerKey).put(key, rData, false); } else { put(key, rData); } } public void put(String managerKey, String key, Object val) { if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ ReceiveData rData = new ReceiveData(val, true, false);///false false DataSegment.get(managerKey).put(key, rData, false); } else { put(key, val); } } public void quickPut(String managerKey, String key, ReceiveData rData) { if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ DataSegment.get(managerKey).put(key, rData, true); } else { put(key, rData); } } public void quickPut(String managerKey, String key, Object val) { if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ ReceiveData rData = new ReceiveData(val, false, false); DataSegment.get(managerKey).put(key, rData, true); } else { put(key, val); } } public void update(String managerKey, String key, ReceiveData rData) { if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ DataSegment.get(managerKey).update(key, rData, false); } else { update(key, rData); } } public void update(String managerKey, String key, Object val) { if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ ReceiveData rData = new ReceiveData(val, true, false);///false, false DataSegment.get(managerKey).update(key, rData, false); } else { update(key, val); } } public void quickUpdate(String managerKey, String key, ReceiveData rData) { if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ DataSegment.get(managerKey).update(key, rData, true); } else { update(key, rData); } } public void quickUpdate(String managerKey, String key, Object val) { if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ ReceiveData rData = new ReceiveData(val, false, false); DataSegment.get(managerKey).update(key, rData, true); } else { update(key, val); } } /** * kill the Alice process after send other messages. * * @param managerKey */ public void finish(String managerKey) { if (DataSegment.contains(managerKey)) DataSegment.get(managerKey).finish(); } /** * close socket for RemoteDataSegment after send other messages. * * @param managerKey */ public void close(String managerKey) { if (DataSegment.contains(managerKey)) DataSegment.get(managerKey).close(); } /** * "key" is not remote DataSegment's key. * "Ping Response" return in this "key" * * @param managerKey * @param returnKey */ public void ping(String managerKey, String returnKey) { if (DataSegment.contains(managerKey)) DataSegment.get(managerKey).ping(returnKey); } public boolean compressFlag() { return compressFlag; } public void setCompressFlag(boolean cFlag) { compressFlag = cFlag; } }