Mercurial > hg > Members > tatsuki > Alice
changeset 195:b4ca7f75e6b2 working
add put , Update API (no convert to value)
author | e095732 |
---|---|
date | Tue, 12 Mar 2013 00:49:19 +0900 |
parents | fc4dbf4e1978 |
children | caee170e6cfa |
files | src/alice/codesegment/OutputDataSegment.java src/alice/datasegment/Command.java src/alice/datasegment/DataSegmentKey.java src/alice/datasegment/DataSegmentValue.java src/alice/datasegment/Receiver.java |
diffstat | 5 files changed, 35 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/codesegment/OutputDataSegment.java Fri Mar 08 15:56:48 2013 +0900 +++ b/src/alice/codesegment/OutputDataSegment.java Tue Mar 12 00:49:19 2013 +0900 @@ -13,6 +13,21 @@ /** * for local */ + public <T> void put(String key, T val,Boolean flag) { + if (flag){ + put(key, val); + } else { + DataSegment.getLocal().put(key, val); + } + } + + public <T> void update(String key, T val,Boolean flag) { + if (flag){ + update(key, val); + } else { + DataSegment.getLocal().update(key, val); + } + } public void put(String key, Value val) { DataSegment.getLocal().put(key, val); @@ -31,7 +46,11 @@ } public <T> void put(String key, T val) { - DataSegment.getLocal().put(key, val); + try { + DataSegment.getLocal().put(key, SingletonMessage.getInstance().unconvert(val)); + } catch (IOException e) { + e.printStackTrace(); + } } public void update(String key, Value val) { @@ -51,7 +70,11 @@ } public <T> void update(String key, T val) { - DataSegment.getLocal().update(key, val); + try { + DataSegment.getLocal().update(key, SingletonMessage.getInstance().unconvert(val)); + } catch (IOException e) { + e.printStackTrace(); + } }
--- a/src/alice/datasegment/Command.java Fri Mar 08 15:56:48 2013 +0900 +++ b/src/alice/datasegment/Command.java Tue Mar 12 00:49:19 2013 +0900 @@ -17,6 +17,13 @@ public CodeSegment cs; public String reverseKey; public Object obj; + public DataSegmentValue dsv; + + public Command(CommandType cmdType, int seq, DataSegmentValue dsv){ + this.type = cmdType; + this.seq = seq; + this.dsv = dsv; + } public Command(CommandType cmdType, Receiver receiver, String key, Value val, int index, int seq, BlockingQueue<Command> replyQueue, CodeSegment cs, String reverseKey) { this.type = cmdType;
--- a/src/alice/datasegment/DataSegmentKey.java Fri Mar 08 15:56:48 2013 +0900 +++ b/src/alice/datasegment/DataSegmentKey.java Tue Mar 12 00:49:19 2013 +0900 @@ -96,7 +96,7 @@ break; case FLIP: index = tailIndex.getAndIncrement(); - dataList.get(0).setDataSegmentValue(index, cmd.val, cmd.obj, cmd.reverseKey); + dataList.set(0, new DataSegmentValue(index, cmd.val, cmd.obj, cmd.reverseKey)); // need to check waitList break; case REMOVE:
--- a/src/alice/datasegment/DataSegmentValue.java Fri Mar 08 15:56:48 2013 +0900 +++ b/src/alice/datasegment/DataSegmentValue.java Tue Mar 12 00:49:19 2013 +0900 @@ -22,7 +22,7 @@ this.from = reverseKey; } - public void setDataSegmentValue(int index, Value val, Object obj,String reverseKey){ + public void setDataSegmentValue(int index, Value val, Object obj, String reverseKey){ this.index = index; this.val = val; this.obj = obj;
--- a/src/alice/datasegment/Receiver.java Fri Mar 08 15:56:48 2013 +0900 +++ b/src/alice/datasegment/Receiver.java Tue Mar 12 00:49:19 2013 +0900 @@ -51,11 +51,7 @@ } public <T> void flip(T val) { - try { - DataSegment.getLocal().flip(this.key, SingletonMessage.getInstance().unconvert(val)); - } catch (IOException e) { - e.printStackTrace(); - } + DataSegment.getLocal().flip(key, val); } public void setKey(String managerKey, String key) {