On 07/11/2013 09:59 AM, Ankit Murarka wrote:
> Say, suppose I send a Message X. The contents of the message X is
> stored. Now, for each incoming message I will compare the contents
> with the message X. If the content is equal I will increment the
> counter and when it reaches say 100, I will not allow more processing
> of messages.
>
> For each message, I will compare it with X. If the content is
> different, then it would be stored as Y. Hence the next incoming
> message will be compared with both X and Y and accordingly the
> counters will be incremented.
>
> Now, I think to parse each message say about 500 bytes containing all
> the possible characters I might have to use Lucene. Please guide if it
> will be helpful. Because the entire comparison mechanism is expected
> to be completed in milliseconds.

This is not job for Lucene. Also, it's not a difficult problem.

Simple, naive solution: store X & Y in HashMap (key: String, value:
Integer (count)). It's fast (you compare by hash, and use nice
properties of hashtable).

If HashMap doesn't suit you well (if number of messages is too large),
simply use distributed hashtable (some are also know as
Key-Value-Stores). Notable products: Apache Voldemort, Redis (extremly
simple with lots of bindings), Riak, ...


  Regards,
    Ivan Krišto

> On 7/11/2013 11:59 AM, Ivan Krišto wrote:
>> On 07/11/2013 08:04 AM, Ankit Murarka wrote:
>>   
>>> a. I have a string of 190 characters.
>>> b. I need to store this string or the content of the string.
>>> c. For every request, I will compare the string with this stored
>>> string.
>>> d. If match, found I will increment the counter and once counter
>>> reaches 100 I need to block all request.
>>>
>>> I want to know will this searching the provided string with the input
>>> string can be achieved by Lucene. If yes, can anyone provide me some
>>> input on how to go ahead with this. I mean the type of analyzer to use
>>> etc.
>>>      
>> I'm not sure if I have understood you well.
>>
>> How do you compare string you got from request and stored string? Do you
>> do "storedString.equals(requestString)"?
>> If comparison is simple, than you don't need Lucene even if you have
>> thousands of stored strings. Just do it from scratch (simple hashtable
>> will do just fine).
>>
>> Use lucene only if: comparison method is complicated (searching over
>> tokens which involves tokenization and normalization) and you have lots
>> of strings (documents).
>> Otherwise, it's an overkill.
>>
>>
>>    Regards,
>>      Ivan Krišto
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
>> For additional commands, e-mail: java-user-h...@lucene.apache.org
>>
>>
>>    
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to