SearchDomino.com
August 13, 2001
Developer Tip
================================================= 
------------------------------------------------- 
Sponsored By: The Learning Continuum Company
------------------------------------------------- 
Don't become extinct! 
Get certified or learn advanced topics like LotusScript, Java and XML
to stay ahead in today's very competitive job market!  TLCC's highly
acclaimed Notes/Domino training lets you download the courses to your
office or home computer and learn at your convenience ANY PLACE and
ANY TIME.  Instructor support is a click away.  Hurry, TLCC's Hot
Summer Sale end on 8/31! Try a FREE course now at
http://www.tlcc.com/searchdom. 
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
Feature Tip
================================================= 
Title: Writing more than 64k data to a single document

This tip was submitted by Lothar Mueller, a senior IT consultant and
senior developer in Muenchen, Germany, and a searchDomino.com Dog
Pound member.

While it is possible to write unlimited amounts of data to RichText
fields, it is not possible to retrieve more than 64k from a RichText
field programmatically. The reading procedure simply will stop at
64k. Writing to multiple standard fields probably will stop you with
a "32k limit" error message when you are trying to save the target
document. The standard solution as it is used in log.nsf is writing
to multiple documents instead of just a single doc. 

But assume you need to write big amounts of data to a single document
programmatically, with the option to retrieve that data later on
(again programmatically). The solution is to write arrays of data to
multiple standard fields. These fields are created on the fly through
your script code with the ISSUMMARY flag set to FALSE; if a field's
size passes a given threshold value, the next field is created (for
an example see 1. example code below). 

You also need a second field recording the amount of dynamically
created fields. The value stored here is used when retrieving the
data at a later time (for an example see 2. example code below). When
I tested this solution, I also tried various threshold sizes for the
target fields. I observed big differences in the time my script
needed to write the data depending on the threshold size. The result
was that it takes less time to write many small fields than writing
few big fields. In fact, the time needed seems to rise exponentially,
while the total size of the resulting document is hardly growing at
all. See example measurements block below. 

The goal for this in my case is a data analysis performed on a very
"lively" application on a regular basis. Of course it take minutes
just to open the resulting analysis document because currently there
are some 10,000 documents analyzed and logged to a single log
document. Since data are structured the way they are, I can compare
the log documents created at various times (such as for finding out
document movement within a workflow application, tracking document
failures etc.).

CODE: 
1. example code: writing

Set logdoc = targetdb.CreateDocument
logdoc.Form = "log"
Set logitm = New NotesItem (logdoc, "LogField" & Cstr (j), "")  '-->
j is initialized as 0
     For i = 0 To 3000
          If logitm.ValueLength >= 5000 Then
               j = j + 1
               Set logitm = New NotesItem (logdoc, "LogField" & Cstr
(j), "")  '--> IsSummary is set to FALSE by default
          End If
          Call logitm.AppendToTextList (strText)
     Next
     logdoc.NumLogFields = j  ' --> record number of fields created

2. example code: retrieving

for i = 0 to logdoc.NumLogFields (0)
  set logitm = logdoc.GetFirstItem ("LogField" & Cstr (i))
    Forall entry in logitm
      'entry represents a line that previously was written to the
item; do whatever you need to do with it
    End Forall
  Next

3. Here are some example measurements for 3000 lines of text (150
characters each) written to text fields:

threshold size 5000 bytes:
number of fields = 94
time needed / write = 2 s
time needed / retrieve < 1 s
doc size = 476.298 bytes

threshold size 15000 bytes:
number of fields = 32
time needed / write = 8 s
time needed / retrieve < 1 s
doc size = 476.174 bytes

threshold size 35000 bytes:
number of fields = 14
time needed / write = 36 s
time needed / retrieve < 1 s
doc size = 476.138 bytes

threshold size 65000 bytes:
number of fields = 8
time needed / write = 113 s
time needed / retrieve < 1 s
doc size = 476.126 bytes

END CODE

http://searchdomino.techtarget.com/tip/1,289483,sid4_gci754367,00.html

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
DID THIS TIP WORK FOR YOU? Send us your feedback, and we'll add it to
the tip posted on searchDomino.com. Send you comments and feedback to
[EMAIL PROTECTED] 

OR SEND US YOUR FEEDBACK TO BE POSTED ON THIS TIP TO:
[EMAIL PROTECTED]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
NEWLY POSTED DEVELOPER TIPS: 
================================================= 
We posted 8 new tips last week. Thanks for all your tips and keep
them coming!

Agent Category:
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283834_alpD_idx0,00.html
[1] Insert various file attachments on the Web

Domino Category:
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283837_alpD_idx0,00.html
[1] Dynamic name/value pairs for HTML select fields

Formula Category:
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283836_alpD_idx0,00.html
[1] Handling errors in @DbColumn/@DbLookup
[2] Finding the Last Date of a Month
[3] Separate the "STG" graphics from the real attachments in
@AttachmentNames

HTML Category
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283838_alpD_idx0,00.html
[1] End-user customizable CSS on the Web

Script Category:
http://searchdomino.techtarget.com/tipsIndex/0,289482,sid4_tax283841_alpD_idx0,00.html
[1] Don't use GetNthDocument
[2] RichText objects appearing in UIDoc

================================================= 
FEATURED BOOK:
================================================= 
WebSphere V3.5 Handbook: Using Websphere Application Server Standard 
By: Ken Ueno

This book walks you through every key task and procedure associated
with deploying, executing, administering, and troubleshooting
WebSphere applications.  The authors also include in-depth
discussions or architectural alternatives, deployment topologies, and
workload management.  Get clear explanations of every key WebSphere
concept and technology, including the Servlet, JSP, EJB, APIs,
WebSphere security, and transaction support.  The included CD-ROM
contains invaluable source codes, Java Class files, HTTP sessions,
and more.

http://www.digitalguru.com/dgstore/product.asp?isbn=0130416568&ac_id=60

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
Disclaimer: These tips are submitted by your Domino peers. Our tips
services and online tips exchange are a way for you to learn from
other IT professionals and share technical advice and expertise with
your peers. Techtarget.com provides the infrastructure to facilitate
this sharing of information. However, we can't guarantee the accuracy
and validity of the material submitted. You agree that your use of
the searchDomino.com tips services and your reliance on any
questions, answers, information or other materials received through
searchDomino.com will be at your own risk.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
================================================= 
If you would like to sponsor this or any TechTarget newsletter,
please contact Gabrielle DeRussy at [EMAIL PROTECTED]

================================================= 



If you no longer wish to receive this newsletter simply reply to 
this message with "REMOVE" in the subject line.  Or, visit 
http://searchDomino.techtarget.com/register 
and adjust your subscriptions accordingly. 

If you choose to unsubscribe using our automated processing, you 
must send the "REMOVE" request from the email account to which 
this newsletter was delivered.  Please allow 24 hours for your 
"REMOVE" request to be processed.

Reply via email to