RangeIndexSpec qnIdx = idxSpec.getIndexByQName(node.getQName()); if (qnIdx != null && qnameValueIndexation) { indexType |= RangeIndexSpec.QNAME_INDEX; }
	public void store(final NodeImpl node, NodePath currentPath, boolean index) {		// first, check available memory		if (nodesCount > MEM_LIMIT_CHECK) {			final int percent = (int) (run.freeMemory() / (run.totalMemory() / 100));			if (percent < memMinFree) {				//LOG.info(				//	"total memory: " + run.totalMemory() + "; free: " + run.freeMemory());				flush();				System.gc();				LOG.info(					"total memory: " + run.totalMemory() + "; free: " + run.freeMemory());			}		}		final DocumentImpl doc = (DocumentImpl) node.getOwnerDocument();		final boolean isTemp = TEMP_COLLECTION.equals(doc.getCollection().getName());		final IndexSpec idxSpec = 		    doc.getCollection().getIdxConf(this);		final FulltextIndexSpec ftIdx = idxSpec != null ? idxSpec.getFulltextIndexSpec() : null;		final long gid = node.getGID();		if (gid < 0) {			LOG.debug("illegal node: " + gid + "; " + node.getNodeName());			Thread.dumpStack();			return;		}		final short nodeType = node.getNodeType();		final String nodeName = node.getNodeName();		final int depth = idxSpec == null ? defaultIndexDepth : idxSpec.getIndexDepth();		new DOMTransaction(this, domDb, Lock.WRITE_LOCK, doc) {			public Object start() throws ReadOnlyException {				long address = -1;				final byte data[] = node.serialize();				if (nodeType == Node.TEXT_NODE					|| nodeType == Node.ATTRIBUTE_NODE					|| doc.getTreeLevel(gid) > depth)					address = domDb.add(data);				else {					address = domDb.put(new NodeRef(doc.getDocId(), gid), data);				}				if (address < 0)					LOG.warn("address is missing");				node.setInternalAddress(address);				ByteArrayPool.releaseByteArray(data);				return null;			}		}		.run();		++nodesCount;		NodeProxy tempProxy = null;		QName qname;		int indexType = RangeIndexSpec.NO_INDEX;		switch (nodeType) {			case Node.ELEMENT_NODE :				if (idxSpec != null) {				    RangeIndexSpec spec = idxSpec.getIndexByPath(currentPath);				    if(spec != null)				        indexType = spec.getIndexType();				}				if(ftIdx == null || currentPath == null || ftIdx.match(currentPath))				    indexType |= RangeIndexSpec.TEXT;				if(node.getChildCount() - node.getAttributesCount() > 1) {				    indexType |= RangeIndexSpec.MIXED_CONTENT;				}				((ElementImpl) node).setIndexType(indexType);				break;			case Node.ATTRIBUTE_NODE :				tempProxy = new NodeProxy(doc, gid, node.getInternalAddress());				QName idxQName = new QName('@' + node.getLocalName(), node.getNamespaceURI());                if (currentPath != null)                    currentPath.addComponent(idxQName);				GeneralRangeIndexSpec valSpec = null;				if (idxSpec != null) {				    valSpec = idxSpec.getIndexByPath(currentPath);				    if(valSpec != null) {				        indexType = valSpec.getIndexType();				    }				}				boolean indexAttribs = false;				if(index && (ftIdx == null || currentPath == null || ftIdx.matchAttribute(currentPath))) {				    indexType |= RangeIndexSpec.TEXT;					indexAttribs = true;				}				tempProxy.setIndexType(indexType);								qname = node.getQName();				qname.setNameType(ElementValue.ATTRIBUTE);				elementIndex.setDocument(doc);				elementIndex.addRow(qname, tempProxy);				if (valSpec != null) {			        valueIndex.setDocument(doc);			        valueIndex.storeAttribute(valSpec, (AttrImpl) node);				}								if (idxSpec != null && qnameValueIndexation) {					RangeIndexSpec qnIdx = idxSpec.getIndexByQName(idxQName);					if (qnIdx != null) {						qnameValueIndex.setDocument(doc);						qnameValueIndex.storeAttribute(qnIdx, (AttrImpl) node);					}				}								if(indexAttribs && !isTemp)					textEngine.storeAttribute(ftIdx, (AttrImpl) node);				// if the attribute has type ID, store the ID-value				// to the element index as well				if (((AttrImpl) node).getType() == AttrImpl.ID) {					qname = new QName(((AttrImpl) node).getValue(), "", null);					//LOG.debug("found ID: " + qname.getLocalName());					qname.setNameType(ElementValue.ATTRIBUTE_ID);					elementIndex.addRow(qname, tempProxy);				}                if (currentPath != null)                    currentPath.removeLastComponent();				break;			case Node.TEXT_NODE :				// check if this textual content should be fulltext-indexed				// by calling IndexPaths.match(path)				if (!isTemp && index) {					if (ftIdx == null || ftIdx.match(currentPath)) {     		                boolean valore = (ftIdx == null ? false : ftIdx.preserveContent(currentPath));						textEngine.storeText(ftIdx, (TextImpl) node, valore);					}				}				break;		}	}