• R/O
  • SSH
  • HTTPS

okuyama: 提交


Commit MetaInfo

修訂962 (tree)
時間2012-08-23 21:25:45
作者okuyamaoo

Log Message

(empty log message)

Change Summary

差異

--- trunk/src/okuyama/imdst/helper/MasterManagerHelper.java (revision 961)
+++ trunk/src/okuyama/imdst/helper/MasterManagerHelper.java (revision 962)
@@ -532,7 +532,8 @@
532532 resultMap.put(oneRet[0], oneRet[1]);
533533 }
534534
535- for (int i = 0; i < requestKeyList.size(); i++) {
535+ int requestKeyListSize = requestKeyList.size();
536+ for (int i = 0; i < requestKeyListSize; i++) {
536537
537538 String retVal = (String)resultMap.get((String)requestKeyList.get(i));
538539
@@ -2264,7 +2265,8 @@
22642265 } else {
22652266
22662267 // OR検索の場合は全てのWordで検索出来たものをマージしてそれをベースに検索を行う
2267- for (int idx = 0; idx < allSearchWordList.size(); idx++) {
2268+ int allSearchWordListSize = allSearchWordList.size();
2269+ for (int idx = 0; idx < allSearchWordListSize; idx++) {
22682270
22692271 String[] singleWordList = (String[])allSearchWordList.get(idx);
22702272 boolean fullMatchFlg = ((Boolean)fullMatchList.get(idx)).booleanValue();
--- trunk/src/okuyama/imdst/util/FileBaseDataList.java (revision 961)
+++ trunk/src/okuyama/imdst/util/FileBaseDataList.java (revision 962)
@@ -207,8 +207,9 @@
207207 }
208208 }
209209
210- Object[] retObjs = new Object[dataList.size()];
211- for (int idx = 0; idx < dataList.size(); idx++) {
210+ int dataListSize = dataList.size();
211+ Object[] retObjs = new Object[dataListSize];
212+ for (int idx = 0; idx < dataListSize; idx++) {
212213 retObjs[idx] = dataList.get(idx);
213214 }
214215 return retObjs;
--- trunk/src/okuyama/imdst/util/DiskBaseCacheMap.java (revision 961)
+++ trunk/src/okuyama/imdst/util/DiskBaseCacheMap.java (revision 962)
@@ -34,6 +34,10 @@
3434 private RandomAccessFile raf = null;
3535 private ArrayBlockingQueue freeCacheSpaceQueue = null;
3636
37+ private ArrayBlockingQueue readOnlyFpQueue = null;
38+ private int readOnlyFpQueueSize = 4;
39+
40+
3741 private String cacheStoreFilePath = null;
3842 private File cacheStoreFile = null;
3943
@@ -58,6 +62,13 @@
5862 freeSpacePoint = freeSpacePoint + ImdstDefine.dataFileWriteMaxSize;
5963 }
6064 this.cacheStoreFilePath = this.cacheStoreFile.getAbsolutePath();
65+
66+ this.readOnlyFpQueue = new ArrayBlockingQueue(this.readOnlyFpQueueSize);
67+ try {
68+ for (int i = 0; i < this.readOnlyFpQueueSize; i++) {
69+ this.readOnlyFpQueue.put(new RandomAccessFile(this.cacheStoreFile, "r"));
70+ }
71+ } catch (Exception ee) {}
6172 }
6273
6374
@@ -116,16 +127,22 @@
116127 * @return Object
117128 */
118129 public Object get(Object key) {
119- w.lock();
130+
120131 byte[] retData = null;
132+ RandomAccessFile useRaf = null;
133+
134+ r.lock();
121135 try {
122136 Long cacheSeekPoint = (Long)super.get(key);
123137
124138 if (cacheSeekPoint != null) {
125139
140+ useRaf = (RandomAccessFile)this.readOnlyFpQueue.poll(100L, TimeUnit.MILLISECONDS);
141+ if (useRaf == null) return null;
142+
126143 if (ImdstDefine.dataFileWriteMaxSize > 4096) {
127144
128- this.raf.seek(cacheSeekPoint.longValue());
145+ useRaf.seek(cacheSeekPoint.longValue());
129146 int readCount = ImdstDefine.dataFileWriteMaxSize / 4096;
130147 int assist = ImdstDefine.dataFileWriteMaxSize % 4096;
131148 if (assist > 0) {
@@ -132,14 +149,14 @@
132149 readCount = readCount + 1;
133150 }
134151
135- byte[] baos2 = new byte[((readCount - 1) * 4096) + assist];
136- this.raf.read(baos2);
137- retData = baos2;
152+ byte[] baos = new byte[((readCount - 1) * 4096) + assist];
153+ useRaf.read(baos);
154+ retData = baos;
138155 } else {
139156
140157 retData = new byte[ImdstDefine.dataFileWriteMaxSize];
141- this.raf.seek(cacheSeekPoint.longValue());
142- this.raf.read(retData);
158+ useRaf.seek(cacheSeekPoint.longValue());
159+ useRaf.read(retData);
143160 }
144161 }
145162 } catch(Exception e) {
@@ -147,7 +164,17 @@
147164 retData = null;
148165 e.printStackTrace();
149166 } finally {
150- w.unlock();
167+ try {
168+ if (this.errorFlg) {
169+ useRaf.close();
170+ useRaf = null;
171+ }
172+
173+ if (useRaf != null) this.readOnlyFpQueue.offer(useRaf);
174+ } catch(Exception ee) {
175+
176+ }
177+ r.unlock();
151178 }
152179 return retData;
153180 }
--- trunk/src/okuyama/imdst/util/KeyManagerValueMap.java (revision 961)
+++ trunk/src/okuyama/imdst/util/KeyManagerValueMap.java (revision 962)
@@ -316,6 +316,14 @@
316316 ret = this.readOverSizeData(key, buf);
317317 } else {
318318
319+ if (buf[buf.length / 2] != 38) i = buf.length / 2;
320+ for (; i < buf.length; i=i+1024) {
321+ if (buf[i] == 38) break;
322+ }
323+
324+ if (i != 0) {
325+ i = i - 1024;
326+ }
319327 for (; i < buf.length; i++) {
320328 if (buf[i] == 38) break;
321329 }
@@ -371,9 +379,18 @@
371379 ret = this.readOverSizeData(key, buf);
372380 } else {
373381
382+ if (buf[buf.length / 2] != 38) i = buf.length / 2;
383+ for (; i < buf.length; i=i+1024) {
384+ if (buf[i] == 38) break;
385+ }
386+
387+ if (i != 0) {
388+ i = i - 1024;
389+ }
374390 for (; i < buf.length; i++) {
375391 if (buf[i] == 38) break;
376392 }
393+
377394 ret = new String(buf, 0, i, ImdstDefine.keyWorkFileEncoding);
378395 }
379396
@@ -445,12 +462,11 @@
445462
446463 // 渡されたデータが固定の長さ分ない場合は足りない部分を補う
447464 // 足りない文字列は固定の"&"で補う(38)
448-
449- byte[] appendDatas = new byte[this.oneDataLength - valueSize + 1];
465+ byte[] appendDatas = new byte[this.oneDataLength - valueSize];
450466 Arrays.fill(appendDatas, (byte)38);
451- appendDatas[appendDatas.length - 2] = 10;
452467
453468 writeBuf.append(new String(appendDatas));
469+ writeBuf.append("\n");
454470
455471 if ((this.fullDiskMode == true && ImdstDefine.reuseDataFileValuePositionFlg == false) || (seekPoint = this.calcSeekDataPoint(key, false)) == -1) {
456472
--- trunk/src/okuyama/imdst/util/DataDispatcher.java (revision 961)
+++ trunk/src/okuyama/imdst/util/DataDispatcher.java (revision 962)
@@ -1301,7 +1301,8 @@
13011301
13021302 ArrayList tmpNodeList = (ArrayList)allNodeMap.get("main");
13031303
1304- for (int i = 0; i < tmpNodeList.size(); i++) {
1304+ int tmpNodeListSize = tmpNodeList.size();
1305+ for (int i = 0; i < tmpNodeListSize; i++) {
13051306 mainNodeList.add(tmpNodeList.get(i));
13061307 }
13071308 retMap.put("main", mainNodeList);
@@ -1310,7 +1311,8 @@
13101311 if (allNodeMap.containsKey("sub")) {
13111312 tmpNodeList = (ArrayList)allNodeMap.get("sub");
13121313
1313- for (int i = 0; i < tmpNodeList.size(); i++) {
1314+ tmpNodeListSize = tmpNodeList.size();
1315+ for (int i = 0; i < tmpNodeListSize; i++) {
13141316 subNodeList.add(tmpNodeList.get(i));
13151317 }
13161318 retMap.put("sub", subNodeList);
@@ -1320,7 +1322,8 @@
13201322 if (allNodeMap.containsKey("third")) {
13211323 tmpNodeList = (ArrayList)allNodeMap.get("third");
13221324
1323- for (int i = 0; i < tmpNodeList.size(); i++) {
1325+ tmpNodeListSize = tmpNodeList.size();
1326+ for (int i = 0; i < tmpNodeListSize; i++) {
13241327 thirdNodeList.add(tmpNodeList.get(i));
13251328 }
13261329 retMap.put("third", thirdNodeList);
--- trunk/src/okuyama/imdst/util/KeyMapManager.java (revision 961)
+++ trunk/src/okuyama/imdst/util/KeyMapManager.java (revision 962)
@@ -2462,8 +2462,9 @@
24622462 counter++;
24632463 if (counter > (maxLineCount - 1)) {
24642464
2465- long[] keyListInt = new long[keyList.size()];
2466- for (int idx = 0; idx < keyList.size(); idx++) {
2465+ int keyListSize = keyList.size();
2466+ long[] keyListInt = new long[keyListSize];
2467+ for (int idx = 0; idx < keyListSize; idx++) {
24672468 keyListInt[idx] = ((Long)keyList.get(idx)).longValue();
24682469 }
24692470 Arrays.sort(keyListInt);
@@ -2493,7 +2494,9 @@
24932494 }
24942495
24952496 if (keyList.size() > 0) {
2496- long[] keyListInt = new long[keyList.size()];
2497+
2498+ int keyListSize = keyList.size();
2499+ long[] keyListInt = new long[keyListSize];
24972500 for (int idx = 0; idx < keyListInt.length; idx++) {
24982501 keyListInt[idx] = ((Long)keyList.get(idx)).longValue();
24992502 }
--- trunk/src/okuyama/imdst/util/protocol/MemcachedProtocolTaker.java (revision 961)
+++ trunk/src/okuyama/imdst/util/protocol/MemcachedProtocolTaker.java (revision 962)
@@ -348,11 +348,13 @@
348348 }
349349 }
350350
351- retStrs = new String[requestWorkList.size()];
352- this.requestSplit = new String[requestWorkList.size()];
351+ int requestWorkListSize = requestWorkList.size();
352+ retStrs = new String[requestWorkListSize];
353+ this.requestSplit = new String[requestWorkListSize];
353354
354- for (int idx = 0; idx < requestWorkList.size(); idx++) {
355355
356+ for (int idx = 0; idx < requestWorkListSize; idx++) {
357+
356358 retStrs[idx] = (String)requestWorkList.get(idx);
357359 requestSplit[idx] = (String)replaceRequestWorkList.get(idx);
358360 }
--- trunk/src/okuyama/imdst/util/io/CustomReader.java (revision 961)
+++ trunk/src/okuyama/imdst/util/io/CustomReader.java (revision 962)
@@ -18,6 +18,10 @@
1818
1919 private BufferedInputStream bis = null;
2020
21+ private ByteArrayOutputStream bos = new ByteArrayOutputStream(4096);
22+ private byte[] b = new byte[1];
23+
24+
2125 public CustomReader(InputStream is) {
2226
2327 this.is = is;
@@ -26,20 +30,21 @@
2630
2731
2832 public String readLine() throws Exception {
33+ this.b[0] = (byte)0;
2934
30- byte[] b = new byte[1];
31- ByteArrayOutputStream bos = new ByteArrayOutputStream();
32-
3335 int i = 0;
34- while (bis.read(b, 0, 1) != -1) {
36+ while (bis.read(this.b, 0, 1) != -1) {
3537
36- if (b[0] != 13 && b[0] != 10) {
37- bos.write(b, 0, 1);
38- } else if (b[0] == 10) {
38+ if (this.b[0] != 13 && this.b[0] != 10) {
39+ this.bos.write(this.b, 0, 1);
40+ } else if (this.b[0] == 10) {
3941 break;
4042 }
4143 }
42- return bos.toString();
44+
45+ String ret = this.bos.toString();
46+ this.bos.reset();
47+ return ret;
4348 }
4449
4550
Show on old repository browser