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