Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best QM handling for arrays
#1
Hello Gintaras,

for a project i'll code later, i need to know how in QM handle array of 3 or four elements, to be able to search
a record from one of it's properties and retreive the others from one of them.

Say i have a record like those:

"fruit" "pear" "yellow"
"fruit" apple" "green"
"vegetable" "patato" "brown" "soup"

Must I implement a custom variable, a CSV, stringmap, xml file???

I want to be able to search, delete, add or modify each item of 3 or four properties.
The numbers of items will be around 100. I look for the most efficient way in terms of speed, memory handling and easy to use.

Thanks.
#2
Will need to save in a file?
Will need to convert to/from string?

If both true, use CSV. Function ICsv.Find is quite fast for 100 items.
If not, maybe easier to use ARRAY of user-defined type or 2 dimensions. Will need to search with for(i 0 a.len)... It's maybe slower but quite fast for 100 items.

For large number of items faster would be IStringMap. But difficult if need >2 columns; need to somehow store several strings in single string.
Sqlite may be better if need to store large number of items in a file or in a memory table. But for 100 items probably will be slower, even with indexing.

XML - slower. It is better for trees than tables.
#3
Ok. Yes, datas will be saved/loaded from file.

my former code was using homemade type

TYPE Mytype
str'data1
str'data2

mytype d
d.data1="jjj"
d.data2"kkkk"

ARRAY(mytype) j

if(strcmp(_s d.data1)=0)
do something...



you get the picture, hard to maintain and long coding. Will try IStringMap or cvs first.

But I need to store all in a file for later use, and need to write/save the file.

Are there possibilty to search records/items in a file or must I load it in memory then do thing, and save it later?
or are there function as for file type (rset, read, append, etc)?
#4
If only 100 items, better load all into memory. I would use CSV.
If file can be >3-10 MB, I would use Sqlite, it can load only part of file into memory for searching.
#5
ok, did not dig into sqlite yet. Does it handle all the needed features in QM implementation?
#6
Yes, but it is not so easy as ICsv. More learning (unless you are familiar with SQL), more code.
#7
no, i have no knowledge at all in SQL, and the use of it, even is the best, will depend on the learning curve.

Will find some doc on the web, then decide if it worth the time spent to learn. Some milliseconds
lost in datas management don't justify days of learning and coding.

I'll investigate.
#8
For a 100-item table CSV is easier and faster than Sqlite.
#9
Ok, will use this, thanks.
No experience with cvs too, but maybe easier and hope QM implementation is sweet (sure it is )....
#10
Macro Macro2123
Code:
Copy      Help
str CSV=
;"fruit", "pear", "yellow"
;"fruit", apple, "green"
;"vegetable", "patato", "brown", "soup"

ICsv x._create
x.FromString(CSV)
int i=x.Find("vegetable")
if(i<0) out "not found"
else x.Cell(i 2)="yellow"

x.ToString(_s)
out _s
#11
tx for example.
will read the QM help and google a bit...


Forum Jump:


Users browsing this thread: 1 Guest(s)