The qDecoder Projects - Tue, 14 May 2013 05:11:16 +0000 The qDecoder Projects - qLibc: Recently closed tasks http://www.qdecoder.org/bugs/ FS#50: tt22 Seungyoung Kim Tue, 14 May 2013 04:09:17 +0000 http://www.qdecoder.org/bugs/index.php?do=details&task_id=50 http://www.qdecoder.org/bugs/index.php?do=details&task_id=50 FS#49: tt Seungyoung Kim Tue, 14 May 2013 04:06:06 +0000 http://www.qdecoder.org/bugs/index.php?do=details&task_id=49 http://www.qdecoder.org/bugs/index.php?do=details&task_id=49 FS#7: Bug in the Q_HASHARR container. Seungyoung Kim Mon, 11 Jul 2011 21:49:06 +0000 -----------------------

1. __putData 함수 부분

사용중 프로그램이 먹통이 되는 현상과 저장된 카운트 오류를 찾다가 발견했습니다.
memset()의 세 번째 인자가 잘못 지정되어 있는 것으로 보입니다.

2. __getIdx 함수 부분
첨부 파일에 테스트한 파일입니다. 파일에서 23번째 컬럼부터 12바이트를 키로 사용했습니다. 이 파일을 tbl->put() 함수를 이용해서 입력하면 tbl->num가 885가 나옵니다. 그러나 테스트한 파일을 uniq 프로그램으로 확인해보면 884줄이 나와야 맞습니다.

디버깅을 해보니, 같은 해쉬 값을 갖는 데이터 A, B, C가 이미 입력되어 있을 경우 B가 다시 들어올 경우 A가 입력된 슬롯의 count 값이 잘못 되어 있는 것을 발견 있길래 좀 더 확인해 보니 B가 다시 입력되어을 경우 put() 함수에서 B를 삭제하고 다시 put() 함수를 호출했을때, B가 입력되어 있던 원래 slot의 count 값은 0이 되어 있는데, _getIdx() 함수에서 이 슬롯을 발견하지 못해서 생긴 것으로 보입니다.

첨부한 패치 파일로 테스트해서 원하는 결과 값을 얻긴 얻었습니다.

좋은 라이브러리를 만들어 공개해 주신 덕분에 많은 시간과 노력을 들이지 않고 원하는 결과물을 얻게 되었습니다.
감사드립니다.

테스트 환경
$ uname -a
Linux blue 2.6.38-10-generic #46-Ubuntu SMP Tue Jun 28 15:07:17 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

uniq 프로그램은 이렇게 사용했습니다.
$ cut -c23-34 158454 | sort | uniq -c | wc -l
884

qHasharr.c.diff
--- ../../../qlibc-1.0.6.org/src/containers/qHasharr.c 2011-01-22 16:49:48.000000000 +0900
+++ qHasharr.c 2011-07-11 20:57:16.021512781 +0900
@@ -715,7 +715,10 @@
while(true) {
if (idx >= tbl->maxslots) idx = 0;

- if (tbl->slots[idx].count != -2 && tbl->slots[idx].hash == hash) {
+ /* if (tbl->slots[idx].count != -2 && tbl->slots[idx].hash == hash) */
+ if (tbl->slots[idx].count != -2 && tbl->slots[idx].hash == hash
+ && tbl->slots[idx].count) // -2, Positive value.
+ {
// found same hash
count++;
break;
@@ -827,7 +830,7 @@
}

// clear & set
- memset((void *)(&tbl->slots[tmpidx]), 0, sizeof(Q_HASHARR));
+ memset((void *)(&tbl->slots[tmpidx]), 0, sizeof(struct _Q_HASHARR_SLOT));

tbl->slots[tmpidx].count = -2; // extended data block
tbl->slots[tmpidx].hash = newidx; // prev link
]]>
http://www.qdecoder.org/bugs/index.php?do=details&task_id=7 http://www.qdecoder.org/bugs/index.php?do=details&task_id=7
FS#1: Code freeze and release 1.0.0. Seungyoung Kim Tue, 30 Nov 2010 10:17:17 +0000 http://www.qdecoder.org/bugs/index.php?do=details&task_id=1 http://www.qdecoder.org/bugs/index.php?do=details&task_id=1