Mercurial > hg > Database > Alice
annotate src/main/java/alice/datasegment/Receiver.java @ 650:4289b232b3fd
nulValue
author | suruga |
---|---|
date | Fri, 02 Feb 2018 18:26:49 +0900 |
parents | 33f300d0720a |
children | 058bff2123c8 |
rev | line source |
---|---|
345 | 1 package alice.datasegment; |
2 | |
3 | |
4 import alice.codesegment.InputDataSegment; | |
636
33f300d0720a
running CodeSegment by Annotation without create Receiver :D
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
525
diff
changeset
|
5 import javassist.compiler.ast.ASTree; |
345 | 6 |
7 /** | |
523
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
8 * idsコマンド(create, setKey)の処理をする。コマンドの定義はids/LDSM内にある。 |
345 | 9 * MessagePack implementation and DataSegment Receiver |
10 * @author kazz | |
11 * | |
12 */ | |
13 public class Receiver { | |
452 | 14 private ReceiveData data; |
417 | 15 public InputDataSegment ids; |
16 public int index; | |
17 public String from; | |
18 public CommandType type; | |
525
30a74eee59c7
working TestRemoteAlice
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
523
diff
changeset
|
19 public String managerKey;//DSMを一意に特定。localかremoteか、どのremoteからか。 |
417 | 20 public String key; |
523
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
21 public boolean compressedFlag = false; |
417 | 22 |
23 public Receiver(InputDataSegment ids, CommandType type) { | |
24 this.ids = ids; | |
25 this.type = type; | |
26 ids.register(); | |
523
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
27 } |
417 | 28 |
523
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
29 public Receiver(InputDataSegment ids, CommandType type, boolean compressedFlag) { |
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
30 this.ids = ids; |
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
31 this.type = type; |
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
32 ids.register(); |
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
33 this.compressedFlag = compressedFlag; |
417 | 34 } |
35 | |
36 public void setQuickKey(String managerKey, String key){ | |
37 setQuickKey(managerKey, key, 0); | |
523
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
38 }//? |
345 | 39 |
417 | 40 public void setQuickKey(String managerKey, String key, int index) { |
41 this.managerKey = managerKey; | |
42 this.key = key; | |
43 switch (type) { | |
44 case PEEK: | |
45 ids.quickPeek(this); | |
46 break; | |
47 case TAKE: | |
48 ids.quickTake(this); | |
49 break; | |
50 default: | |
51 break; | |
52 } | |
53 ids.setKey(); | |
54 } | |
55 | |
56 public void setKey(String managerKey, String key) { | |
57 setKey(managerKey, key, 0); | |
58 } | |
345 | 59 |
417 | 60 public void setKey(String managerKey, String key, int index) { |
61 this.managerKey = managerKey; | |
62 this.key = key; | |
63 this.index = index; | |
64 switch (type) { | |
65 case PEEK: | |
66 ids.peek(this); | |
67 break; | |
68 case TAKE: | |
69 ids.take(this); | |
70 break; | |
71 default: | |
72 break; | |
73 } | |
74 ids.setKey(); | |
75 } | |
76 | |
77 public void setKey(String key) { | |
78 setKey(key, 0); | |
79 } | |
345 | 80 |
417 | 81 public void setKey(String key, int index) { |
82 this.key = key; | |
83 this.index = index; | |
84 switch (type) { | |
85 case PEEK: | |
86 ids.peek(this); | |
87 break; | |
88 case TAKE: | |
89 ids.take(this); | |
90 break; | |
91 default: | |
92 break; | |
93 } | |
94 ids.setKey(); | |
95 } | |
345 | 96 |
523
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
458
diff
changeset
|
97 //以下各型でDS本体を受け取る |
452 | 98 public void setData(ReceiveData r) { |
417 | 99 data = r; |
100 } | |
345 | 101 |
417 | 102 public int asInteger() { |
103 return data.asInteger(); | |
104 } | |
105 | |
106 public String asString() { | |
107 return data.asString(); | |
108 } | |
345 | 109 |
417 | 110 public <T> T asClass(Class<T> clazz) { |
111 return data.asClass(clazz); | |
112 } | |
345 | 113 |
417 | 114 public Object getObj() { |
115 return data.getObj(); | |
116 } | |
117 | |
118 public Object getVal() { | |
119 return data.getVal(); | |
120 } | |
121 | |
458 | 122 public ReceiveData getReceiveData() { |
123 return data; | |
124 } | |
525
30a74eee59c7
working TestRemoteAlice
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
523
diff
changeset
|
125 |
30a74eee59c7
working TestRemoteAlice
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
523
diff
changeset
|
126 public boolean isCompressed(){ |
30a74eee59c7
working TestRemoteAlice
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
523
diff
changeset
|
127 return data.compressed(); |
30a74eee59c7
working TestRemoteAlice
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
523
diff
changeset
|
128 } |
345 | 129 } |