From: Grant on
On Mon, 26 Oct 2009 17:09:04 +0800, Hongyi Zhao <hongyi.zhao(a)gmail.com> wrote:

>On Mon, 26 Oct 2009 18:58:11 +1100, Grant
><g_r_a_n_t_(a)bugsplatter.id.au> wrote:
>
>>Not under cygwin :)
>
>Thanks for your suggestion.
>
>Another issue: in the private mail I've sent to you, I told you that
>the ip lookup table used here is extracted from the following binary
>file:
>
>http://update.cz88.net/soft/qqwry.rar
>
>In the bottom of the following url, there is a demo code to read IP
>informations from the above binary file (this webpage is in Chinese,
>but of course the demo code itself is in English):
>
>http://lumaqq.linuxsir.org/article/qqwry_format_detail.html
>
>So I want to konw is it possible to read the above binary file
>directly to note the specific IP addresses.

Google translate does a fairly good job with Chinese :) Unfortunately
the diagrams have Chinese text embedded in the images -- so I cannot
follow the data layout :(

Grant.
--
http://bugsplatter.id.au
From: Ed Morton on
Hongyi Zhao wrote:
> On Mon, 26 Oct 2009 15:08:37 +1100, Grant
> <g_r_a_n_t_(a)bugsplatter.id.au> wrote:
>
>> I forgot about sorting IPs :(
>>
>> sort -t. -n -k1,1 -k2,2 -k3,3 -k4,4 file2 > file2-sorted
>
> In my case, whether I do the above sorting process or not, your scipt
> will take the same time approximately,

But it won't produce the same output. The binary search algorithm relies
on the input data being sorted.

Ed.
From: Hongyi Zhao on
On Mon, 26 Oct 2009 22:20:27 +1100, Grant
<g_r_a_n_t_(a)bugsplatter.id.au> wrote:

>Google translate does a fairly good job with Chinese :) Unfortunately
>the diagrams have Chinese text embedded in the images -- so I cannot
>follow the data layout :(

A quick search in google give me the following codes related to the
format of qqwry.dat, you can checkout it by the following command:

svn checkout http://qqwry.googlecode.com/svn/trunk/ qqwry-read-only

Then you can obtain the following subdirectory:
qqwry-read-only\libqqwry

I hope the source files on the above folder can give you some hints.
If not, I'll translate the webpage for you on which the format of
qqwry.dat is given.

Best regards.
--
..: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.
From: Hongyi Zhao on
On Mon, 26 Oct 2009 07:36:13 -0500, Ed Morton <mortonspam(a)gmail.com>
wrote:

>>> I forgot about sorting IPs :(
>>>
>>> sort -t. -n -k1,1 -k2,2 -k3,3 -k4,4 file2 > file2-sorted
>>
>> In my case, whether I do the above sorting process or not, your scipt
>> will take the same time approximately,
>
>But it won't produce the same output. The binary search algorithm relies
>on the input data being sorted.

Do you mean that I should always do the sorting process like the above
firstly?
--
..: Hongyi Zhao [ hongyi.zhao AT gmail.com ] Free as in Freedom :.
From: Ed Morton on
Hongyi Zhao wrote:
> On Mon, 26 Oct 2009 07:36:13 -0500, Ed Morton <mortonspam(a)gmail.com>
> wrote:
>
>>>> I forgot about sorting IPs :(
>>>>
>>>> sort -t. -n -k1,1 -k2,2 -k3,3 -k4,4 file2 > file2-sorted
>>> In my case, whether I do the above sorting process or not, your scipt
>>> will take the same time approximately,
>> But it won't produce the same output. The binary search algorithm relies
>> on the input data being sorted.
>
> Do you mean that I should always do the sorting process like the above
> firstly?

If you want to do a binary search, then yes you need to sort the input
data first. The alternative is to not sort the data and do a linear (or
other uninformed) search, so you can test to see which takes longer
(sort+binary vs linear) and make your choice.

Ed.