Mercurial > hg > Database > Alice
comparison src/alice/codesegment/InputDataSegment.java @ 202:7f47231ef509 working
add new flip API
author | sugi |
---|---|
date | Mon, 25 Mar 2013 17:46:07 +0900 |
parents | 15b68b65f8a4 |
children | 28469b1671e7 |
comparison
equal
deleted
inserted
replaced
201:7c3c59513fee | 202:7f47231ef509 |
---|---|
2 | 2 |
3 import java.util.concurrent.atomic.AtomicInteger; | 3 import java.util.concurrent.atomic.AtomicInteger; |
4 | 4 |
5 import org.msgpack.type.Value; | 5 import org.msgpack.type.Value; |
6 | 6 |
7 import alice.datasegment.Command; | |
7 import alice.datasegment.CommandType; | 8 import alice.datasegment.CommandType; |
8 import alice.datasegment.DataSegment; | 9 import alice.datasegment.DataSegment; |
9 import alice.datasegment.DataSegmentValue; | 10 import alice.datasegment.DataSegmentValue; |
10 import alice.datasegment.Receiver; | 11 import alice.datasegment.Receiver; |
11 | 12 |
19 | 20 |
20 public CodeSegment cs; | 21 public CodeSegment cs; |
21 private AtomicInteger count = new AtomicInteger(1); // 1 for no input data segments | 22 private AtomicInteger count = new AtomicInteger(1); // 1 for no input data segments |
22 private AtomicInteger keyCount = new AtomicInteger(0); // number of DataSegments | 23 private AtomicInteger keyCount = new AtomicInteger(0); // number of DataSegments |
23 | 24 |
24 private DataSegmentValue dsv; | 25 private Command cmd; |
25 | 26 |
26 public InputDataSegment(CodeSegment cs) { | 27 public InputDataSegment(CodeSegment cs) { |
27 this.cs = cs; | 28 this.cs = cs; |
28 } | 29 } |
29 | 30 |
57 | 58 |
58 public void take(Receiver receiver, String key, int index) { | 59 public void take(Receiver receiver, String key, int index) { |
59 DataSegment.getLocal().take(receiver, key, index, cs); | 60 DataSegment.getLocal().take(receiver, key, index, cs); |
60 } | 61 } |
61 | 62 |
62 public void flip(Receiver receiver, String key){ | 63 public void flip(CommandType type, String key, Value val,Object obj) { |
63 | 64 cmd.setElement(type, key, val, obj); |
64 } | 65 DataSegment.getLocal().flip(cmd); |
65 | |
66 public void flip(Receiver receiver, Value val, Object obj){ | |
67 DataSegment.getLocal().flip(receiver.key, val, obj, dsv); | |
68 } | 66 } |
69 | 67 |
70 public void reply(Receiver receiver, DataSegmentValue val) { | 68 public void reply(Receiver receiver, DataSegmentValue val) { |
71 receiver.index = val.index; | 69 receiver.index = val.index; |
72 receiver.val = val.val; | 70 receiver.val = val.val; |
73 receiver.from = val.from; | 71 receiver.from = val.from; |
74 receiver.obj = val.obj; | 72 receiver.obj = val.obj; |
75 setDataSegmentValue(val); | |
76 receive(); | 73 receive(); |
77 } | 74 } |
78 | 75 |
79 public void regist() { | 76 public void regist() { |
80 count.getAndIncrement(); | 77 count.getAndIncrement(); |
100 */ | 97 */ |
101 public Receiver create(CommandType type) { | 98 public Receiver create(CommandType type) { |
102 return new Receiver(this, type); | 99 return new Receiver(this, type); |
103 } | 100 } |
104 | 101 |
105 private void setDataSegmentValue(DataSegmentValue dsv){ | 102 public void setCommand(Command cmd) { |
106 this.dsv = dsv; | 103 this.cmd = cmd; |
104 } | |
105 | |
106 public void reply(Receiver receiver, int index, Value val, Object obj, | |
107 String reverseKey) { | |
108 // TODO Auto-generated method stub | |
109 | |
107 } | 110 } |
108 | 111 |
109 } | 112 } |