set = new ArraySet(1); set.add(p);
set = new SingleNodeSet(p);
	public Value eval(DocumentSet docs, NodeSet context, NodeProxy node) {		long start = System.currentTimeMillis();		ArraySet result = new ArraySet(100);		Expression first = getExpression(0);		if (first == null)			return new ValueNodeSet(context);		switch (first.returnsType()) {			case Constants.TYPE_NODELIST :				{					setInPredicate(true);					NodeSet nodes = (NodeSet) super.eval(docs, context, null).getNodeList();					NodeProxy current, parent;					LongLinkedList contextNodes;					LongLinkedList.ListItem next;					for(Iterator i = nodes.iterator(); i.hasNext(); ) {						current = (NodeProxy)i.next();						contextNodes = current.getContext();						if(contextNodes == null) {							LOG.warn("context node is missing!");							break;						}						for(Iterator j = contextNodes.iterator(); j.hasNext(); ) {							next = (LongLinkedList.ListItem)j.next();							if((parent = context.get(current.doc, next.l)) != null) {								parent.addMatches(current.matches);								if(!result.contains(parent))									result.add(parent);							}						}					}					break;				}			case Constants.TYPE_BOOL :			case Constants.TYPE_STRING :				{					//string has no special meaning					NodeProxy p;					NodeSet set;					DocumentSet dset;					Value v;					for (Iterator i = context.iterator(); i.hasNext();) {						p = (NodeProxy) i.next();						set = new ArraySet(1);						set.add(p);						dset = new DocumentSet();						dset.add(p.doc);						v = first.eval(dset, set, p);						if (v.getBooleanValue())							result.add(p);					}					break;				}			case Constants.TYPE_NUM :				{					NodeProxy p;					NodeProxy n;					NodeSet set;					int level;					int count;					double pos;					long pid;					long last_pid = 0;					long f_gid;					long e_gid;					DocumentImpl doc;					DocumentImpl last_doc = null;					// evaluate predicate expression for each context node					for (Iterator i = context.iterator(); i.hasNext();) {						p = (NodeProxy) i.next();						set = new ArraySet(1);						set.add(p);						pos = first.eval(docs, context, p).getNumericValue();						doc = (DocumentImpl) p.getDoc();						level = doc.getTreeLevel(p.getGID());						pid =							(p.getGID() - doc.getLevelStartPoint(level))								/ doc.getTreeLevelOrder(level)								+ doc.getLevelStartPoint(level - 1);						if (pid == last_pid							&& last_doc != null							&& doc.getDocId() == last_doc.getDocId())							continue;						last_pid = pid;						last_doc = doc;						f_gid =							(pid - doc.getLevelStartPoint(level - 1))								* doc.getTreeLevelOrder(level)								+ doc.getLevelStartPoint(level);						e_gid = f_gid + doc.getTreeLevelOrder(level);						count = 1;						set = context.getRange(doc, f_gid, e_gid);						for (Iterator j = set.iterator(); j.hasNext(); count++) {							n = (NodeProxy) j.next();							if (count == pos) {								result.add(n);								break;							}						}					}				}		}		LOG.debug(			"predicate expression found "				+ result.getLength()				+ " in "				+ (System.currentTimeMillis() - start)				+ "ms.");		return new ValueNodeSet(result);	}