Sample acceleration
Posted: Sun Jul 15, 2012 9:10 pm
I have 3 databases, one main (Obi_Zag) and 2 connected with main the relation "one to many" (Obi_Kcl, Obi_Kpr). Key field: Kod_Obj. I choose the Abs databases given for formation from the connected databases:
However a sample of data in an example with the given code goes extremely slowly. Whether it is impossible to accelerate this process essentially? There can be this result the relation organization "can give one to many"? But I couldn't organize it, though looked examples from xdemo.exe. But there examples for the dialogue organization are given. It at me turned out. And for calculations I couldn't make it. Can be eat any filter based not on LOOK, and on DBSEEK on an index, or even on DBGOTO ()?
Code: Select all
SELECT Obi_Zag
DBGOTOP()
DO WHILE .NOT. EOF() // Начало цикла по анкетам обучающей выборки
Mess = "Расчет абс. частот - ABS - Обработка #/$ объекта обуч.выборки"
Mess = STRTRAN(Mess,"#", ALLTRIM(STR(++Time_progress,15)))
Mess = STRTRAN(Mess,"$", ALLTRIM(STR(N_Obj,15)))
oSay1:SetCaption(Mess)
M_KodObj = Kod_Obj // Код объекта обучающей выборки
// Формирование массива кодов классов текущего объекта обучающей выборки
Ar_Kcl := {}
SELECT Obi_Kcl
SET FILTER TO M_KodObj = Kod_Obj
DBGOTOP();DBGOBOTTOM();DBGOTOP()
DO WHILE .NOT. EOF() // Начало цикла по записям БД кодов классов текущего объекта
FOR j=2 TO 5
M_Kcl = FIELDGET(j)
IF VALTYPE(M_Kcl) = "N"
IF 0 < M_Kcl .AND. M_Kcl <= N_Cls
AADD(Ar_Kcl, M_Kcl)
ENDIF
ENDIF
NEXT
DBSKIP(1)
ENDDO
// Формирование массива кодов признаков текущего объекта обучающей выборки
Ar_Kpr := {}
SELECT Obi_Kpr
SET FILTER TO M_KodObj = Kod_Obj
DBGOTOP();DBGOBOTTOM();DBGOTOP()
DO WHILE .NOT. EOF() // Начало цикла по записям БД кодов признаков текущего объекта
FOR j=2 TO 8
M_Kpr = FIELDGET(j)
IF VALTYPE(M_Kpr) = "N"
IF 0 < M_Kpr .AND. M_Kpr <= N_Gos
AADD(Ar_Kpr, M_Kpr)
ENDIF
ENDIF
NEXT
DBSKIP(1)
ENDDO
// Суммирование 1 в ячейки БД Abs.dbf, соотвествующие строкам и столбцам,
// а также в строку и столбец "Сумма" и строку: Кол-во объектов по классам"
SELECT Abs
FOR i=1 TO LEN(Ar_Kpr)
DBGOTO(Ar_Kpr[i])
For j=1 TO LEN(Ar_Kcl)
FIELDPUT(2+Ar_Kcl[j], FIELDGET(2+Ar_Kcl[j])+1) // Ячейка [i,j]++
Ar_SummaNj[2+Ar_Kcl[j]] = Ar_SummaNj[2+Ar_Kcl[j]] + 1 // Строка "Сумма абс.частот"
Ar_SummaNi[Ar_Kpr[i]] = Ar_SummaNi[Ar_Kpr[i]] + 1 // Столбец "Сумма абс.частот" по строкам
Summa_Nij++ // Сумма Nij по всей БД Abs.dbf
NEXT
NEXT
For j=1 TO LEN(Ar_Kcl)
Ar_SummaObj[2+Ar_Kcl[j]] = Ar_SummaObj[2+Ar_Kcl[j]] + 1 // Строка "Сумма числа объектов по классам"
Summa_Obj++ // Сумма Obj по всей БД Abs.dbf
NEXT
lOk = Time_Progress (Time_progress, Wsego, oProgress, lOk )
SELECT Obi_Zag
DBSKIP(1)
ENDDO