Revision 1761
Added by Jing Tao over 21 years ago
src/edu/ucsb/nceas/metacat/DBSAXHandler.java | ||
---|---|---|
81 | 81 |
protected Stack textBufferStack = new Stack(); |
82 | 82 |
|
83 | 83 |
protected static final int MAXDATACHARS = 4000; |
84 |
//protected static final int MAXDATACHARS = 50; |
|
84 | 85 |
protected static final long INDEXDELAY = 10000; |
85 | 86 |
// methods writeChildNodeToDB, setAttribute, setNamespace, |
86 | 87 |
// writeTextForDBSAXNode will increase endNodeId. |
... | ... | |
247 | 248 |
if (hitTextNode && parentNode != null) |
248 | 249 |
{ |
249 | 250 |
// write the textbuffer into db for parent node. |
250 |
endNodeId = writeTextForDBSAXNode(textBuffer, parentNode); |
|
251 |
endNodeId = writeTextForDBSAXNode(endNodeId, textBuffer, parentNode);
|
|
251 | 252 |
// rest hitTextNode |
252 | 253 |
hitTextNode =false; |
253 | 254 |
// reset textbuffer |
... | ... | |
487 | 488 |
textBuffer.append(new String(cbuf, start,len)); |
488 | 489 |
// set hittextnode true |
489 | 490 |
hitTextNode = true; |
491 |
// if text buffer .size is greater than max, write it to db. |
|
492 |
// so we can save memory |
|
493 |
if (textBuffer.length() > MAXDATACHARS) |
|
494 |
{ |
|
495 |
MetaCatUtil.debugMessage("Write text into DB in charaters" + |
|
496 |
" when text buffer size is greater than maxmum number", 50); |
|
497 |
DBSAXNode currentNode = (DBSAXNode)nodeStack.peek(); |
|
498 |
endNodeId = writeTextForDBSAXNode(endNodeId, textBuffer, currentNode); |
|
499 |
textBuffer = null; |
|
500 |
textBuffer = new StringBuffer(); |
|
501 |
} |
|
490 | 502 |
} |
491 | 503 |
|
492 | 504 |
/** |
... | ... | |
552 | 564 |
if (hitTextNode) |
553 | 565 |
{ |
554 | 566 |
MetaCatUtil.debugMessage("Write text into DB in End Element", 50); |
555 |
endNodeId = writeTextForDBSAXNode(textBuffer, currentNode); |
|
567 |
endNodeId = writeTextForDBSAXNode(endNodeId, textBuffer, currentNode);
|
|
556 | 568 |
|
557 | 569 |
//if it is triple parsing process |
558 | 570 |
if (startParseTriple) |
... | ... | |
768 | 780 |
} |
769 | 781 |
|
770 | 782 |
/* Method to write a text buffer for DBSAXNode*/ |
771 |
protected long writeTextForDBSAXNode(StringBuffer strBuffer, DBSAXNode node) |
|
772 |
throws SAXException |
|
783 |
protected long writeTextForDBSAXNode(long previousEndNodeId, |
|
784 |
StringBuffer strBuffer, DBSAXNode node) |
|
785 |
throws SAXException |
|
773 | 786 |
{ |
774 |
long nodeId = -1;
|
|
787 |
long nodeId = previousEndNodeId;
|
|
775 | 788 |
// Check parameter |
776 | 789 |
if ( strBuffer == null || node == null) |
777 | 790 |
{ |
Also available in: Unified diff
When character size is greater than 4000, it will write to db.