Hi,
I am quite new in the community. While I am porting an app from VO to X# and accessing the files at first through DBFCDX and VO and later with X# and finally with AXDBFCDX, I've noticed that I need to rebuild the indexes at some points. What might be the best routine to rebuild all indexes? Right now I am removing all CDX files from the disk and rebuilding it from scratch. Would DbReindex be just as good? How would a decent routine look like?
Maybe someone wants to share his/her routine or experience?
And last but not least, I am trying to figure out how reindexing could look like with ADS. I don't have access to the CDX files through the API. So there is probably another way.
Thank you very much.
Best Reindexing Routine
Best Reindexing Routine
Moritz,
What the DbReindex code does exactly depends entirely on what the developer has chosen.
For the X# driver for example we are saving the index expressions and conditions, then we erase the file and recreate it.
It is very well possible that ADS does the same. But you can't be sure.
If you want to delete the CDX with ADS (especially when the file is on a remote machine), then the best approach is to delete each of the tags in the Cdx (with OrdDestroy). I know from experience that ADS will delete the CDX file when the last tag in it is deleted. After that you can recreate the tags one by one.
Robert
What the DbReindex code does exactly depends entirely on what the developer has chosen.
For the X# driver for example we are saving the index expressions and conditions, then we erase the file and recreate it.
It is very well possible that ADS does the same. But you can't be sure.
If you want to delete the CDX with ADS (especially when the file is on a remote machine), then the best approach is to delete each of the tags in the Cdx (with OrdDestroy). I know from experience that ADS will delete the CDX file when the last tag in it is deleted. After that you can recreate the tags one by one.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
The Netherlands
robert@xsharp.eu
-
- Posts: 75
- Joined: Sun Sep 20, 2020 7:25 am
- Location: Germany
Best Reindexing Routine
Hi,
I am trying my DBFCDX code on AXDBFCDX and having a hard time on reindexing and (re)creating DBF files. Right now my code to recreate the index files looks something like this:
It throws an Unknown Error on AXDBFCDX. Also my routine to recreate DBF files checks if a file is existing. This will also not work on a remote server connection.
Is anyone from the community willing to share some pieces of code, on how to achieve reindexing, recreation of files on remote ADS? (If reindexing is possible through Advantage Data architect that would be also fine for now.)
Already a big thank you to you!
I am trying my DBFCDX code on AXDBFCDX and having a hard time on reindexing and (re)creating DBF files. Right now my code to recreate the index files looks something like this:
Code: Select all
oServer:createOrder(cTagName, cFile, cKey, bKey, lUnique)
Is anyone from the community willing to share some pieces of code, on how to achieve reindexing, recreation of files on remote ADS? (If reindexing is possible through Advantage Data architect that would be also fine for now.)
Already a big thank you to you!
Best Reindexing Routine
Hi Moritz,
I'm using dictionary based file and order creating routines in both VO and X#.
I never use a packing routine as a problem there could damage the data, but I recreate the dbf table, copy all data and then do a rename.
For the reindexing routine I delete the CDX file and recreate all orders:
HTH
Wolfgang
P.S. this code is at least 20 years old, but it works in many different applications
I'm using dictionary based file and order creating routines in both VO and X#.
I never use a packing routine as a problem there could damage the data, but I recreate the dbf table, copy all data and then do a rename.
For the reindexing routine I delete the CDX file and recreate all orders:
Code: Select all
FOR nCounter := 1 UPTO ALen( _aOrders )
oOrder := _aOrders[nCounter]
if Empty( oOrder:ForCondition )
oServer:SetOrderCondition( ,,,,{||ReIndexAppExec()},500,,,,,oOrder:Descending )
ELSE
cbCondition := &("{||" + oOrder:ForCondition + "}")
oServer:SetOrderCondition( oOrder:ForCondition, cbCondition,,,{||ReindexAppExec()},500,,,,,oOrder:Descending )
endif
cbExpression := &("{||" + oOrder:IndexExpr + "}")
if oServer:CreateOrder( oOrder:TagName,cFileName,oOrder:IndexExpr,cbExpression,false ) == false
ErrBox( oWindow, "Fehler beim Erstellen des Orders " + oOrder:TagName + "/" + self:Name )
lSuccess := false
endif
NEXT
Wolfgang
P.S. this code is at least 20 years old, but it works in many different applications
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
-
- Posts: 75
- Joined: Sun Sep 20, 2020 7:25 am
- Location: Germany
Best Reindexing Routine
Thanks Wolfgang! Appreciate it.
Does this routine even work on a remote ADS Server? Because my call to 'CreateOrder' always returns false on the remote server, but seems to work on the local server. Is the call to 'ReIndexAppExec' something custom from your side or from VO/X#? And finally how would you delete CDX files on remote server? I could not find OrdDestroy call that Robert mentioned.
Thanks
Does this routine even work on a remote ADS Server? Because my call to 'CreateOrder' always returns false on the remote server, but seems to work on the local server. Is the call to 'ReIndexAppExec' something custom from your side or from VO/X#? And finally how would you delete CDX files on remote server? I could not find OrdDestroy call that Robert mentioned.
Thanks
Best Reindexing Routine
Hi Moritz,
this code works on both local and remote ADS server and on both local and remote DBFCDX.
I'm using it regularly in VO, and the few times I've used it in X# it worked too, but I would have to recheck (had it working using the old SAP RDD).
Wolfgang
this code works on both local and remote ADS server and on both local and remote DBFCDX.
I'm using it regularly in VO, and the few times I've used it in X# it worked too, but I would have to recheck (had it working using the old SAP RDD).
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Best Reindexing Routine
Hi Moritz,
I should read the entire message <g>.
And to delete the index I use the FErase() function (I have write access to the DBF folder, otherwise it would not work).
Wolfgang
I should read the entire message <g>.
Code: Select all
function ReindexAppExec()
ApplicationExec( EXECWHILEEVENT )
return true
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
-
- Posts: 97
- Joined: Tue Mar 01, 2016 11:50 am
- Location: Germany
Best Reindexing Routine
...one note from me:
With a small extension, you can show a progress bar during creating that index:
IF Empty( oOrder:ForCondition )
oServer:SetOrderCondition( ,,,,{||ReIndexAppExec( oServer:OrderInfo(1805) )},500,,,,,oOrder:Descending )
ELSE
...
Function ReindexAppExec(nIndexbar)
// nIndexbar = 0-100 %
ApplicationExec( EXECWHILEEVENT )
RETURN TRUE
I use this eval-block to show a progress bar:
cbEval := { || oDlg:UpdateIndex (oServer:OrderInfo(1805)) }
From the ADS helpfile:
The cbEval code block passed to the DBServer:SetOrderCondition method will not be evaluated for every record the server processes. Instead, it will be evaluated about every two seconds while the index order is created.
HTH
Gerhard Bunzel
With a small extension, you can show a progress bar during creating that index:
IF Empty( oOrder:ForCondition )
oServer:SetOrderCondition( ,,,,{||ReIndexAppExec( oServer:OrderInfo(1805) )},500,,,,,oOrder:Descending )
ELSE
...
Function ReindexAppExec(nIndexbar)
// nIndexbar = 0-100 %
ApplicationExec( EXECWHILEEVENT )
RETURN TRUE
I use this eval-block to show a progress bar:
cbEval := { || oDlg:UpdateIndex (oServer:OrderInfo(1805)) }
From the ADS helpfile:
The cbEval code block passed to the DBServer:SetOrderCondition method will not be evaluated for every record the server processes. Instead, it will be evaluated about every two seconds while the index order is created.
HTH
Gerhard Bunzel
-
- Posts: 75
- Joined: Sun Sep 20, 2020 7:25 am
- Location: Germany
Best Reindexing Routine
Thanks for your input!
-
- Posts: 75
- Joined: Sun Sep 20, 2020 7:25 am
- Location: Germany
Best Reindexing Routine
Out of curiosity: If I reindex my files with VO or X# using DBFCDX RDD it takes about 15 min for all files. But if I reindex wit X# and AXDBFCDX RDD it is done after 1-2 min!! It seems to work though. Now I am curios why there is such a big difference in time. Does anyone know why? Thanks!