Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 10 of 12 total |
The dreaded custom filters |
Tue, Feb 21 2006 4:22 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Can anyone suggest why the following custom filter causes re-entrancy to the custom filter "master" function (ie the oone assigned to the engine)?
end else if (CompareText(FunctionName, 'ScanAttachments') = 0) then begin Result := not FunctionParams[0].IsNull; if FunctionParams[1].Asinteger = 30169 then showmessage('here'); if Result then begin Result := False; AttTbl := MakeDBISAMTable('AF' + IntToStr(GetTickCount), 'Memory', tfrSession); AttTbl.TableName := MakeImgAttMemTable('AF' + IntToStr(GetTickCount), 'A', tfrSession); fileBumph := TMemoryStream.Create; TMemoField(FunctionParams[0]).SaveToStream(fileBumph);<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< RE-ENTRANCY fileBumph.Free; AttTbl.LoadFromStream(fileBumph); while (not Result) and (not AttTbl.Eof) do begin //roy if 0<>pos('vincent',lowerCase(AttTbl.FieldByName('_Name').AsString)) then showmessage('xx'); //roy tmpStr := AttTbl.FieldByName('_Item').AsString; Result := CheckTextMatch(nil, FunctionParams[2].AsString, tmpstr); AttTbl.Next; end; ZapInMemoryTable(AttTbl); end; The function is designed to check documents stored in a table which is turn stored in a memo field in a table. Roy Lambert |
Tue, Feb 21 2006 4:39 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | I thought I'd found it - freeing the memory stream before I used it. But I've fixed that and still have the problem.
Roy Lambert |
Tue, Feb 21 2006 9:10 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | I think I'm finally understanding things. The ftMemo type applied to functionparams simply means STRING. No wonder I can't get it to stream.
I've come up with a solution since all I want to do is simple string matching I can just do it on the whole of the memo field. I'm lucky I had no compression set for it. Now a question for Tim. In ElevateDB will the default compression still be zero. So that as in this case I store documents in a memo field in a memory table and then store that in a memo field in a disk table when I pass the disk memo field through as a parameter to a custom function I can test the string OR is compression going to be a default in which case I've had it. Roy Lambert |
Tue, Feb 21 2006 10:07 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Final (I hope) question. The onprogress doesn't seem to fire. Any idea?
The current form of the filter is Result := not FunctionParams[0].IsNull; if Result then begin Result := False; tmpStr := LowerCase(FunctionParams[0].AsMemo); Result := CheckTextMatch(nil, FunctionParams[1].AsString, tmpstr); end; Roy Lambert function Tdm.CheckTextMatch(const strm: TMemoryStream; const Checklist: string; WorkStr: string): boolean; var fileData: TStringStream; fileString: string; const MustContain = 1; MightContain = 2; MustNotContain = 3; function MatchedText(WhichBlock: integer; const Blank: boolean): boolean; var TestStrings: string; Fld: integer; CompStr: string; iResult: boolean; begin Result := Blank; TestStrings := SubFld(CheckList, RecSep, WhichBlock); if TestStrings = '' then Exit; Result := WhichBlock = 1; Fld := 1; CompStr := SubFld(TestStrings, StrSep, Fld); while CompStr <> '' do begin iResult := 0 <> Pos(CompStr, WorkStr); case WhichBlock of MustContain: if not iResult then begin Result := False; Exit; end; MightContain, MustNotContain: if iResult then begin Result := True; Exit; end; end; inc(Fld); CompStr := SubFld(TestStrings, StrSep, Fld); end; end; begin if strm <> nil then begin fileData := TStringStream.Create(fileString); strm.Position := 0; strm.SaveToStream(fileData); WorkStr := LowerCase(fileData.DataString); fileData.Free; end; Result := MatchedText(MustContain, True) and MatchedText(MightContain, True) and (not MatchedText(MustNotContain, False)); end; |
Tue, Feb 21 2006 12:55 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Roy,
<< In ElevateDB will the default compression still be zero. >> Yes. But it doesn't really matter since the compression is only "on disk" and never affects BLOBs that are opened and in memory. -- Tim Young Elevate Software www.elevatesoft.com |
Tue, Feb 21 2006 12:56 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Roy,
<< Final (I hope) question. The onprogress doesn't seem to fire. Any idea? >> Which OnProgress - the OnQueryProgress ? -- Tim Young Elevate Software www.elevatesoft.com |
Tue, Feb 21 2006 1:12 PM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Tim
>Which OnProgress - the OnQueryProgress ? Yup. But strangely enough with the same custom filter but just using a single table (same one actually) rather than a joined wadge it does work. So Select * FROM MandN WHERE ScanAttachments(_Attachments,'vincent..') the OnProgress event works OK Select _ID FROM Contacts JOIN MandN ON MandN._fkContacts = _ID ... ... ... WHERE ScanAttachments(_Attachments,'vincent..') the OnProgress event seems to do nothing until the end then it goes from 0% - 100% FAST. BTW is there a way of getting a table stored in a memo field back into a table in a custom function using FunctionParams? Roy Lambert |
Wed, Feb 22 2006 5:58 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Roy,
<< the OnProgress event seems to do nothing until the end then it goes from 0% - 100% FAST. >> That's the way it works when there is a brute-force filter that can be applied directly to the source table. Basically the query engine evaluates it like this: Select _ID FROM Contacts JOIN (SELECT * FROM MandN WHERE ScanAttachments(_Attachments,'vincent..')) N MandN._fkContacts = _ID so it doesn't get included in the "main" progress calculations. It's something that has needed to be addressed, but hasn't been yet. It's semi-difficult to pre-calculate the total progress when dealing with various sub-queries, etc. -- Tim Young Elevate Software www.elevatesoft.com |
Thu, Feb 23 2006 3:24 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Tim
Fair enough. On another topic any chance of OnFilterProgress in ElevateDB? Roy Lambert |
Thu, Feb 23 2006 12:30 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Roy,
<< On another topic any chance of OnFilterProgress in ElevateDB? >> Yes, there certainly is a chance. -- Tim Young Elevate Software www.elevatesoft.com |
Page 1 of 2 | Next Page » | |
Jump to Page: 1 2 |
This web page was last updated on Thursday, May 23, 2024 at 07:54 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |