(empty log message)
@@ -532,7 +532,8 @@ | ||
532 | 532 | resultMap.put(oneRet[0], oneRet[1]); |
533 | 533 | } |
534 | 534 | |
535 | - for (int i = 0; i < requestKeyList.size(); i++) { | |
535 | + int requestKeyListSize = requestKeyList.size(); | |
536 | + for (int i = 0; i < requestKeyListSize; i++) { | |
536 | 537 | |
537 | 538 | String retVal = (String)resultMap.get((String)requestKeyList.get(i)); |
538 | 539 |
@@ -2264,7 +2265,8 @@ | ||
2264 | 2265 | } else { |
2265 | 2266 | |
2266 | 2267 | // OR検索の場合は全てのWordで検索出来たものをマージしてそれをベースに検索を行う |
2267 | - for (int idx = 0; idx < allSearchWordList.size(); idx++) { | |
2268 | + int allSearchWordListSize = allSearchWordList.size(); | |
2269 | + for (int idx = 0; idx < allSearchWordListSize; idx++) { | |
2268 | 2270 | |
2269 | 2271 | String[] singleWordList = (String[])allSearchWordList.get(idx); |
2270 | 2272 | boolean fullMatchFlg = ((Boolean)fullMatchList.get(idx)).booleanValue(); |
@@ -207,8 +207,9 @@ | ||
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
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++) { | |
212 | 213 | retObjs[idx] = dataList.get(idx); |
213 | 214 | } |
214 | 215 | return retObjs; |
@@ -34,6 +34,10 @@ | ||
34 | 34 | private RandomAccessFile raf = null; |
35 | 35 | private ArrayBlockingQueue freeCacheSpaceQueue = null; |
36 | 36 | |
37 | + private ArrayBlockingQueue readOnlyFpQueue = null; | |
38 | + private int readOnlyFpQueueSize = 4; | |
39 | + | |
40 | + | |
37 | 41 | private String cacheStoreFilePath = null; |
38 | 42 | private File cacheStoreFile = null; |
39 | 43 |
@@ -58,6 +62,13 @@ | ||
58 | 62 | freeSpacePoint = freeSpacePoint + ImdstDefine.dataFileWriteMaxSize; |
59 | 63 | } |
60 | 64 | 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) {} | |
61 | 72 | } |
62 | 73 | |
63 | 74 |
@@ -116,16 +127,22 @@ | ||
116 | 127 | * @return Object |
117 | 128 | */ |
118 | 129 | public Object get(Object key) { |
119 | - w.lock(); | |
130 | + | |
120 | 131 | byte[] retData = null; |
132 | + RandomAccessFile useRaf = null; | |
133 | + | |
134 | + r.lock(); | |
121 | 135 | try { |
122 | 136 | Long cacheSeekPoint = (Long)super.get(key); |
123 | 137 | |
124 | 138 | if (cacheSeekPoint != null) { |
125 | 139 | |
140 | + useRaf = (RandomAccessFile)this.readOnlyFpQueue.poll(100L, TimeUnit.MILLISECONDS); | |
141 | + if (useRaf == null) return null; | |
142 | + | |
126 | 143 | if (ImdstDefine.dataFileWriteMaxSize > 4096) { |
127 | 144 | |
128 | - this.raf.seek(cacheSeekPoint.longValue()); | |
145 | + useRaf.seek(cacheSeekPoint.longValue()); | |
129 | 146 | int readCount = ImdstDefine.dataFileWriteMaxSize / 4096; |
130 | 147 | int assist = ImdstDefine.dataFileWriteMaxSize % 4096; |
131 | 148 | if (assist > 0) { |
@@ -132,14 +149,14 @@ | ||
132 | 149 | readCount = readCount + 1; |
133 | 150 | } |
134 | 151 | |
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; | |
138 | 155 | } else { |
139 | 156 | |
140 | 157 | 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); | |
143 | 160 | } |
144 | 161 | } |
145 | 162 | } catch(Exception e) { |
@@ -147,7 +164,17 @@ | ||
147 | 164 | retData = null; |
148 | 165 | e.printStackTrace(); |
149 | 166 | } 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(); | |
151 | 178 | } |
152 | 179 | return retData; |
153 | 180 | } |
@@ -316,6 +316,14 @@ | ||
316 | 316 | ret = this.readOverSizeData(key, buf); |
317 | 317 | } else { |
318 | 318 | |
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 | + } | |
319 | 327 | for (; i < buf.length; i++) { |
320 | 328 | if (buf[i] == 38) break; |
321 | 329 | } |
@@ -371,9 +379,18 @@ | ||
371 | 379 | ret = this.readOverSizeData(key, buf); |
372 | 380 | } else { |
373 | 381 | |
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 | + } | |
374 | 390 | for (; i < buf.length; i++) { |
375 | 391 | if (buf[i] == 38) break; |
376 | 392 | } |
393 | + | |
377 | 394 | ret = new String(buf, 0, i, ImdstDefine.keyWorkFileEncoding); |
378 | 395 | } |
379 | 396 |
@@ -445,12 +462,11 @@ | ||
445 | 462 | |
446 | 463 | // 渡されたデータが固定の長さ分ない場合は足りない部分を補う |
447 | 464 | // 足りない文字列は固定の"&"で補う(38) |
448 | - | |
449 | - byte[] appendDatas = new byte[this.oneDataLength - valueSize + 1]; | |
465 | + byte[] appendDatas = new byte[this.oneDataLength - valueSize]; | |
450 | 466 | Arrays.fill(appendDatas, (byte)38); |
451 | - appendDatas[appendDatas.length - 2] = 10; | |
452 | 467 | |
453 | 468 | writeBuf.append(new String(appendDatas)); |
469 | + writeBuf.append("\n"); | |
454 | 470 | |
455 | 471 | if ((this.fullDiskMode == true && ImdstDefine.reuseDataFileValuePositionFlg == false) || (seekPoint = this.calcSeekDataPoint(key, false)) == -1) { |
456 | 472 |
@@ -1301,7 +1301,8 @@ | ||
1301 | 1301 | |
1302 | 1302 | ArrayList tmpNodeList = (ArrayList)allNodeMap.get("main"); |
1303 | 1303 | |
1304 | - for (int i = 0; i < tmpNodeList.size(); i++) { | |
1304 | + int tmpNodeListSize = tmpNodeList.size(); | |
1305 | + for (int i = 0; i < tmpNodeListSize; i++) { | |
1305 | 1306 | mainNodeList.add(tmpNodeList.get(i)); |
1306 | 1307 | } |
1307 | 1308 | retMap.put("main", mainNodeList); |
@@ -1310,7 +1311,8 @@ | ||
1310 | 1311 | if (allNodeMap.containsKey("sub")) { |
1311 | 1312 | tmpNodeList = (ArrayList)allNodeMap.get("sub"); |
1312 | 1313 | |
1313 | - for (int i = 0; i < tmpNodeList.size(); i++) { | |
1314 | + tmpNodeListSize = tmpNodeList.size(); | |
1315 | + for (int i = 0; i < tmpNodeListSize; i++) { | |
1314 | 1316 | subNodeList.add(tmpNodeList.get(i)); |
1315 | 1317 | } |
1316 | 1318 | retMap.put("sub", subNodeList); |
@@ -1320,7 +1322,8 @@ | ||
1320 | 1322 | if (allNodeMap.containsKey("third")) { |
1321 | 1323 | tmpNodeList = (ArrayList)allNodeMap.get("third"); |
1322 | 1324 | |
1323 | - for (int i = 0; i < tmpNodeList.size(); i++) { | |
1325 | + tmpNodeListSize = tmpNodeList.size(); | |
1326 | + for (int i = 0; i < tmpNodeListSize; i++) { | |
1324 | 1327 | thirdNodeList.add(tmpNodeList.get(i)); |
1325 | 1328 | } |
1326 | 1329 | retMap.put("third", thirdNodeList); |
@@ -2462,8 +2462,9 @@ | ||
2462 | 2462 | counter++; |
2463 | 2463 | if (counter > (maxLineCount - 1)) { |
2464 | 2464 | |
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++) { | |
2467 | 2468 | keyListInt[idx] = ((Long)keyList.get(idx)).longValue(); |
2468 | 2469 | } |
2469 | 2470 | Arrays.sort(keyListInt); |
@@ -2493,7 +2494,9 @@ | ||
2493 | 2494 | } |
2494 | 2495 | |
2495 | 2496 | if (keyList.size() > 0) { |
2496 | - long[] keyListInt = new long[keyList.size()]; | |
2497 | + | |
2498 | + int keyListSize = keyList.size(); | |
2499 | + long[] keyListInt = new long[keyListSize]; | |
2497 | 2500 | for (int idx = 0; idx < keyListInt.length; idx++) { |
2498 | 2501 | keyListInt[idx] = ((Long)keyList.get(idx)).longValue(); |
2499 | 2502 | } |
@@ -348,11 +348,13 @@ | ||
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
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]; | |
353 | 354 | |
354 | - for (int idx = 0; idx < requestWorkList.size(); idx++) { | |
355 | 355 | |
356 | + for (int idx = 0; idx < requestWorkListSize; idx++) { | |
357 | + | |
356 | 358 | retStrs[idx] = (String)requestWorkList.get(idx); |
357 | 359 | requestSplit[idx] = (String)replaceRequestWorkList.get(idx); |
358 | 360 | } |
@@ -18,6 +18,10 @@ | ||
18 | 18 | |
19 | 19 | private BufferedInputStream bis = null; |
20 | 20 | |
21 | + private ByteArrayOutputStream bos = new ByteArrayOutputStream(4096); | |
22 | + private byte[] b = new byte[1]; | |
23 | + | |
24 | + | |
21 | 25 | public CustomReader(InputStream is) { |
22 | 26 | |
23 | 27 | this.is = is; |
@@ -26,20 +30,21 @@ | ||
26 | 30 | |
27 | 31 | |
28 | 32 | public String readLine() throws Exception { |
33 | + this.b[0] = (byte)0; | |
29 | 34 | |
30 | - byte[] b = new byte[1]; | |
31 | - ByteArrayOutputStream bos = new ByteArrayOutputStream(); | |
32 | - | |
33 | 35 | int i = 0; |
34 | - while (bis.read(b, 0, 1) != -1) { | |
36 | + while (bis.read(this.b, 0, 1) != -1) { | |
35 | 37 | |
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) { | |
39 | 41 | break; |
40 | 42 | } |
41 | 43 | } |
42 | - return bos.toString(); | |
44 | + | |
45 | + String ret = this.bos.toString(); | |
46 | + this.bos.reset(); | |
47 | + return ret; | |
43 | 48 | } |
44 | 49 | |
45 | 50 |