2010-03-04 4 views
1

Ruby 공식 Ruby C 인터페이스를 사용 중이며 작동하지 않습니다. 그것은의 bzip 지원을 구축했다, ./configure를 말했다 : TokyoCabinet의 Ruby C 인터페이스는 bzip으로 만들 수 없습니다.

checking bzlib.h usability... yes 
checking bzlib.h presence... yes 
checking for bzlib.h... yes 

그래서 난 그냥 두 파일, 가정 bzip'd 하나는하지에 항목을 기록,이 예제 프로그램을 썼다. 둘 다 압축되지 않습니다. 마지막에 간단한 파일 크기 테스트를 제외하고 with_bzip.tcb 파일 을 편집하고 원시 문자열 텍스트를 볼 수 있습니다. 그것은 잘 압축 -이 악화 무엇

require 'tokyocabinet' 
include TokyoCabinet 

def write filename, options 
    File.unlink filename if File.exists? filename 
    bdb = BDB::new 
    bdb.tune(0, 0, 0, -1 -1, options) or raise "Couldn't tune" 
    bdb.open(filename, BDB::OWRITER | BDB::OCREAT | BDB::OLCKNB) or raise "Couldn't open" 
    bdb["test"] = "This string should be compressed and not appear raw.\n" * 10000 
    bdb.close 
end 

write 'without_bzip.tcb', 0 
write 'with_bzip.tcb', BDB::TBZIP 
puts "Not actually compressed" unless File.size('with_bzip.tcb') < File.size('without_bzip.tcb') 

내가 오클라호마 믹서 (내가 새 태그를 추가 할 수있는 명성을하지 않아도하지만 다음의 예)의 프리뷰 버전을 시도하는 경우이다. try() 호출로 일부 디버깅을 집어 넣을 때 tune (0, 0, 0, -1, -1, 4)에 동일한 호출을하는 것처럼 보입니다. 나는 완전히 완전히 엉망이되어 버렸습니다. 위의 코드가 잘못된 것을 누군가에게 말해 줄 수 있습니까?

require 'oklahoma_mixer' 
OklahomaMixer.open("minimal_om.tcb", :opts => 'lb') do |db| 
    db["test"] = "This string should be compressed and not appear raw.\n" * 10000 
end 

답변

1

이것은 사악하고 미묘한 버그입니다. 나는 tune() 호출에서 콤마를 생략하고 -1, -1 대신에 -1을 썼다. 모든 인수는 선택 사항이므로 조용히 bzipping하지 않았습니다. 아하.