comparison src/main/java/alice/codesegment/OutputDataSegment.java @ 527:bfec2c3ff1b8 dispose

change unzip
author Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
date Thu, 30 Apr 2015 18:14:02 +0900
parents 928907206d21
children 4aeebea0c9b5
comparison
equal deleted inserted replaced
526:928907206d21 527:bfec2c3ff1b8
16 /** 16 /**
17 * input→ds変更→outputのときコピーを防ぐ 17 * input→ds変更→outputのときコピーを防ぐ
18 */ 18 */
19 public void flip(Receiver receiver) { 19 public void flip(Receiver receiver) {
20 if (receiver.isCompressed()){ 20 if (receiver.isCompressed()){
21 DataSegment.getCompressedLocal().put(receiver.key, receiver.getReceiveData(), false); 21 DataSegment.getCompressedLocal().put(receiver.key, receiver.getReceiveData(), null);
22 } else { 22 } else {
23 DataSegment.getLocal().put(receiver.key, receiver.getReceiveData(), false); 23 DataSegment.getLocal().put(receiver.key, receiver.getReceiveData(), null);
24 } 24 }
25 } 25 }
26 26
27 public void flip(Receiver receiver, CommandType type) { 27 public void flip(Receiver receiver, CommandType type) {
28 switch (type) { 28 switch (type) {
29 case PUT: 29 case PUT:
30 if (receiver.isCompressed()){ 30 if (receiver.isCompressed()){
31 DataSegment.getCompressedLocal().put(receiver.key, receiver.getReceiveData(), false);//localなら全部false。 31 DataSegment.getCompressedLocal().put(receiver.key, receiver.getReceiveData(), null);//localなら全部false。
32 } else { 32 } else {
33 DataSegment.getLocal().put(receiver.key, receiver.getReceiveData(), false); 33 DataSegment.getLocal().put(receiver.key, receiver.getReceiveData(), null);
34 } 34 }
35 break; 35 break;
36 case UPDATE: 36 case UPDATE:
37 if (receiver.isCompressed()){ 37 if (receiver.isCompressed()){
38 DataSegment.getCompressedLocal().update(receiver.key, receiver.getReceiveData(), false); 38 DataSegment.getCompressedLocal().update(receiver.key, receiver.getReceiveData(), null);
39 } else { 39 } else {
40 DataSegment.getLocal().update(receiver.key, receiver.getReceiveData(), false); 40 DataSegment.getLocal().update(receiver.key, receiver.getReceiveData(), null);
41 } 41 }
42 42
43 break; 43 break;
44 default: 44 default:
45 break; 45 break;
46 } 46 }
47 } 47 }
48 48
49 public void put(String key, ReceiveData rData) { 49 public void put(String key, ReceiveData rData) {
50 DataSegment.getLocal().put(key, rData, false); 50 DataSegment.getLocal().put(key, rData, null);
51 } 51 }
52 52
53 public void put(String key, Object val) { 53 public void put(String key, Object val) {
54 ReceiveData rData = new ReceiveData(val); 54 ReceiveData rData = new ReceiveData(val);
55 DataSegment.getLocal().put(key, rData, false); 55 DataSegment.getLocal().put(key, rData, new SendOption(false, false));
56 } 56 }
57 57
58 public void put(String key, Object val, boolean cFlag) {//追加 58 public void put(String key, Object val, boolean cFlag) {///追加
59 ReceiveData rData = new ReceiveData(val); 59 ReceiveData rData = new ReceiveData(val);
60 rData.setCompressFlag(cFlag); 60 DataSegment.getLocal().put(key, rData, new SendOption(false, cFlag));
61 DataSegment.getLocal().put(key, rData, false);
62 } 61 }
63 62
64 public void update(String key, Object val) { 63 public void update(String key, Object val) {
65 ReceiveData rData = new ReceiveData(val); 64 ReceiveData rData = new ReceiveData(val);
66 DataSegment.getLocal().update(key, rData, false); 65 DataSegment.getLocal().update(key, rData, new SendOption(false, false));
67 } 66 }
68 67
69 public void update(String key, Object val, boolean cFlag) {//追加 68 public void update(String key, Object val, boolean cFlag) {///追加
70 ReceiveData rData = new ReceiveData(val); 69 ReceiveData rData = new ReceiveData(val);
71 rData.setCompressFlag(cFlag); 70 DataSegment.getLocal().update(key, rData, new SendOption(false, cFlag));
72 DataSegment.getLocal().update(key, rData, false);
73 } 71 }
74 72
75 /** 73 /**
76 * for remote 74 * for remote
77 */ 75 */
78 public void put(String managerKey, String key, ReceiveData rData) { 76 public void put(String managerKey, String key, ReceiveData rData) {
79 if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ 77 if (!managerKey.equals("local") && DataSegment.contains(managerKey)){
80 if (rData.compressed()){ 78 SendOption option = new SendOption(false, rData.compressed());
81 DataSegment.get(managerKey + "!").put(key, rData, false); 79 //SendOption option = new SendOption(false, compressFlag);
82 } else { 80
83 DataSegment.get(managerKey).put(key, rData, false); 81 if (rData.compressed()){
84 } 82 DataSegment.get(managerKey + "!").put(key, rData, option);
85 83 } else {
84 DataSegment.get(managerKey).put(key, rData, option);
85 }
86 } else { 86 } else {
87 put(key, rData); 87 put(key, rData);
88 } 88 }
89 } 89 }
90 90
93 } 93 }
94 94
95 public void put(String managerKey, String key, Object val, boolean cFlag) {//追加 95 public void put(String managerKey, String key, Object val, boolean cFlag) {//追加
96 System.out.println("in PUT"); 96 System.out.println("in PUT");
97 ReceiveData rData = new ReceiveData(val); 97 ReceiveData rData = new ReceiveData(val);
98 rData.setCompressFlag(cFlag); 98 SendOption option = new SendOption(false, cFlag);
99 //rData.setCompressFlag(cFlag);
99 100
100 if (!managerKey.equals("local") && DataSegment.contains(managerKey)){///if remote 101 if (!managerKey.equals("local") && DataSegment.contains(managerKey)){///if remote
101 if (cFlag){ 102 if (cFlag){
102 DataSegment.get(managerKey + "!").put(key, rData, false); 103 DataSegment.get(managerKey + "!").put(key, rData, option);
103 } else { 104 } else {
104 DataSegment.get(managerKey).put(key, rData, false); 105 DataSegment.get(managerKey).put(key, rData, option);
105 } 106 }
106 } else {// if local 107 } else {// if local
107 if (cFlag){ 108 if (cFlag){
108 DataSegment.getCompressedLocal().put(key, rData, false); 109 DataSegment.getCompressedLocal().put(key, rData, option);
109 } else { 110 } else {
110 put(key, val); 111 put(key, val);
111 } 112 }
112 } 113 }
113
114
115
116 } 114 }
117 115
118 public void quickPut(String managerKey, String key, ReceiveData rData) { 116 public void quickPut(String managerKey, String key, ReceiveData rData) {
119 if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ 117 if (!managerKey.equals("local") && DataSegment.contains(managerKey)){
120 if (rData.compressed()){ 118 SendOption option = new SendOption(true, false);
121 DataSegment.get(managerKey + "!").put(key, rData, true); 119 if (rData.compressed()){
122 } else { 120 DataSegment.get(managerKey + "!").put(key, rData, option);
123 DataSegment.get(managerKey).put(key, rData, true); 121 } else {
122 DataSegment.get(managerKey).put(key, rData, option);
124 } 123 }
125 } else { 124 } else {
126 put(key, rData); 125 put(key, rData);
127 } 126 }
128 } 127 }
132 } 131 }
133 132
134 public void quickPut(String managerKey, String key, Object val, boolean cFlag) {//追加 133 public void quickPut(String managerKey, String key, Object val, boolean cFlag) {//追加
135 if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ 134 if (!managerKey.equals("local") && DataSegment.contains(managerKey)){
136 ReceiveData rData = new ReceiveData(val); 135 ReceiveData rData = new ReceiveData(val);
137 rData.setCompressFlag(cFlag); 136 SendOption option = new SendOption(true, cFlag);
138 if (cFlag){ 137 //rData.setCompressFlag(cFlag);
139 DataSegment.get(managerKey + "!").put(key, rData, true); 138
140 } else { 139 if (cFlag){
141 DataSegment.get(managerKey).put(key, rData, true); 140 DataSegment.get(managerKey + "!").put(key, rData, option);
141 } else {
142 DataSegment.get(managerKey).put(key, rData, option);
142 } 143 }
143 } else { 144 } else {
144 put(key, val); 145 put(key, val);
145 } 146 }
146 } 147 }
147 148
148 public void update(String managerKey, String key, ReceiveData rData) { 149 public void update(String managerKey, String key, ReceiveData rData) {
149 if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ 150 if (!managerKey.equals("local") && DataSegment.contains(managerKey)){
150 if (rData.compressed()){ 151 SendOption option = new SendOption(false, rData.compressed());
151 DataSegment.get(managerKey + "!").update(key, rData, false); 152 if (rData.compressed()){
152 } else { 153 DataSegment.get(managerKey + "!").update(key, rData, option);
153 DataSegment.get(managerKey).update(key, rData, false); 154 } else {
155 DataSegment.get(managerKey).update(key, rData, option);
154 } 156 }
155 } else { 157 } else {
156 update(key, rData); 158 update(key, rData);
157 } 159 }
158 } 160 }
160 public void update(String managerKey, String key, Object val) { 162 public void update(String managerKey, String key, Object val) {
161 update(managerKey, key, val, false); 163 update(managerKey, key, val, false);
162 } 164 }
163 165
164 public void update(String managerKey, String key, Object val, boolean cFlag) {//追加 166 public void update(String managerKey, String key, Object val, boolean cFlag) {//追加
165 if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ 167 ReceiveData rData = new ReceiveData(val);
166 ReceiveData rData = new ReceiveData(val); 168 SendOption option = new SendOption(false, cFlag);
167 rData.setCompressFlag(cFlag); 169 //rData.setCompressFlag(cFlag);
168 if(cFlag){ 170
169 DataSegment.get(managerKey + "!").update(key, rData, false); 171 if (!managerKey.equals("local") && DataSegment.contains(managerKey)){///if remote
170 } else { 172 if (cFlag){
171 DataSegment.get(managerKey).update(key, rData, false); 173 DataSegment.get(managerKey + "!").update(key, rData, option);
172 } 174 } else {
173 } else { 175 DataSegment.get(managerKey).update(key, rData, option);
174 update(key, val); 176 }
177 } else {// if local
178 if (cFlag){
179 DataSegment.getCompressedLocal().update(key, rData, option);
180 } else {
181 update(key, val);
182 }
175 } 183 }
176 } 184 }
177 185
178 public void quickUpdate(String managerKey, String key, ReceiveData rData) { 186 public void quickUpdate(String managerKey, String key, ReceiveData rData) {
179 if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ 187 if (!managerKey.equals("local") && DataSegment.contains(managerKey)){
180 if (rData.compressed()){ 188 SendOption option = new SendOption(true, rData.compressed());
181 DataSegment.get(managerKey + "!").update(key, rData, true); 189 if (rData.compressed()){
182 } else { 190 DataSegment.get(managerKey + "!").update(key, rData, option);
183 DataSegment.get(managerKey).update(key, rData, true); 191 } else {
192 DataSegment.get(managerKey).update(key, rData, option);
184 } 193 }
185 } else { 194 } else {
186 update(key, rData); 195 update(key, rData);
187 } 196 }
188 } 197 }
192 } 201 }
193 202
194 public void quickUpdate(String managerKey, String key, Object val, boolean cFlag) {//追加 203 public void quickUpdate(String managerKey, String key, Object val, boolean cFlag) {//追加
195 if (!managerKey.equals("local") && DataSegment.contains(managerKey)){ 204 if (!managerKey.equals("local") && DataSegment.contains(managerKey)){
196 ReceiveData rData = new ReceiveData(val); 205 ReceiveData rData = new ReceiveData(val);
197 rData.setCompressFlag(cFlag); 206 SendOption option = new SendOption(true, cFlag);
198 if (cFlag){ 207 //rData.setCompressFlag(cFlag);
199 DataSegment.get(managerKey + "!").update(key, rData, true); 208 if (cFlag){
200 } else { 209 DataSegment.get(managerKey + "!").update(key, rData, option);
201 DataSegment.get(managerKey).update(key, rData, true); 210 } else {
211 DataSegment.get(managerKey).update(key, rData, option);
202 } 212 }
203 } else { 213 } else {
204 update(key, val); 214 update(key, val);
205 } 215 }
206 } 216 }