Search for string Advice?

Just starting out? Need help? Post your questions and find answers here.
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Search for string Advice?

Post by collectordave »

Hi All

I have a large series of strings, 750,000 of them and I need to search these for a single string.

They are downloaded from the internet.

What is the quickest method to carry out a search? Either put them all in a database then search or use lists or maps.

Regards

CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
User avatar
falsam
Enthusiast
Enthusiast
Posts: 630
Joined: Wed Sep 21, 2011 9:11 am
Location: France
Contact:

Re: Search for string Advice?

Post by falsam »

They are downloaded from the internet.
How are your data stored on the server ?
The data received is formatted? JSON ?
Do you have a loop to receive data in your code?

➽ Windows 11 64-bit - PB 6.0 x64 - AMD Ryzen 7 - NVIDIA GeForce GTX 1650 Ti

Sorry for my bad english and the Dunning–Kruger effect.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Search for string Advice?

Post by wilbert »

What kind of search ?
An exact match of the entire string, a substring search, case (in)sensitive ?
Do you always need to search for the same string ?
Windows (x64)
Raspberry Pi OS (Arm64)
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Search for string Advice?

Post by collectordave »

Hi

The strings come from several different places with no defined format they may also contain unicode characters.

I have a loop that reads all the strings from the various locations working no bother. My problem is that when a new string is entered or downloaded I have to check all the strings for an exact match, whitespace can be thrown away.

CD
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Search for string Advice?

Post by wilbert »

If your only goal is to built a list of strings without adding duplicates, the easiest way is to use AddMapElement. The default behaviour is already to avoid duplicate keys so you wouldn’t need a search. This should also be pretty fast.
Windows (x64)
Raspberry Pi OS (Arm64)
Post Reply