20130328 dictionary-as-a-stirng or blocked storage@assignment 5

30 views
Skip to first unread message

Hongfei Yan

unread,
Mar 28, 2013, 3:53:17 AM3/28/13
to cs41...@googlegroups.com
在第五次作业中,其中要求
Implement dictionary compression with dictionary-as-a-stirng or blocked storage .

在C++中,如果用类似 map 容器,例如: map<string, Posting*> dic; 实际上不用关心具体是如何保存和查找的,因为map容器帮助完成了。
所以这个任务实际上已经完成,不必另行做了,只要提交作业中声明即可。

大家对这个问题是如何理解的?

-闫宏飞

Xiaosong Rong

unread,
Mar 28, 2013, 5:09:16 AM3/28/13
to cs41...@googlegroups.com
像是C++ 或 python 中 dict (key:value) 结构, 应该是很难做dictionary compression。
因为习惯上都是用 term 做 dict 的key, 没法再组织dictionary-as-a-string 的结构。

如果不采用dict, 自己写B+树来做索引, 才可以做吧。




--
You received this message because you are subscribed to the Google Groups "cs410pku" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cs410pku+u...@googlegroups.com.
To post to this group, send email to cs41...@googlegroups.com.
Visit this group at http://groups.google.com/group/cs410pku?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

过岩巍

unread,
Mar 28, 2013, 8:10:03 AM3/28/13
to cs41...@googlegroups.com
     我认为用map<string, Posting*>,还是vector<Posting*>,前者Posting中可以不含有string word变量,后者必须含有。无论使用map还是vector,都是用string这个变长字符串类型来存储word,一个string是由一个地址指针以及该指针指向的内容构成,这个地址指针可以看成书中图5-4的词项指针,内容可以看成图5-4中超长字符串的一小部分。所以相对于定长数组存储词典,已经进行了压缩。
     在32位系统中地址指针是4B,64位系统则是8B,若自己实现一种指针的话,按照书中计算只需3B。但是否节省空间跟具体实现相关,如果该指针本身还需要开辟空间来存储,比如char p[3],那么反而多了3B的开销。



Li Yechen

unread,
Mar 28, 2013, 8:50:26 PM3/28/13
to cs41...@googlegroups.com
这说了和没说一样,还是没压缩


2013/3/28 过岩巍 <pkug...@gmail.com>
     我认为用map<string, Posting*>,还是vector<Posting*>,前者Posting中可以不含有string word变量,后者必须含有。无论使用map还是vector,都是用string这个变长字符串类型来存储word,一个string是由一个地址指针以及该指针指向的内容构成,这个地址指针可以看成书中图5-4的词项指针,内容可以看成图5-4中超长字符串的一小部分。所以相对于定长数组存储词典,已经进行了压缩。
     在32位系统中地址指针是4B,64位系统则是8B,若自己实现一种指针的话,按照书中计算只需3B。但是否节省空间跟具体实现相关,如果该指针本身还需要开辟空间来存储,比如char p[3],那么反而多了3B的开销。



Reply all
Reply to author
Forward
0 new messages