Package xbird.util.collections

Examples of xbird.util.collections.LongQueue


    public long[] listNotContained(LongRange range) {
        return listNotContained(range.getStart(), range.getEnd());
    }

    public long[] listNotContained(long start, long end) {
        final LongQueue list = new LongQueue();
        for(long i = start; i <= end; i++) {
            if(!contains(i)) {
                list.add(i);
            }
        }
        return list.toArray();
    }
View Full Code Here


        public final boolean next(IFocus<XQNode> focus) throws XQueryException {
            if(focus.reachedEnd()) {
                return false;
            }
            IndexMatchFocus ffcous = (IndexMatchFocus) focus;
            LongQueue pendings = ffcous.getPtrsQueue();
            outer: if(pendings != null && !pendings.isEmpty()) {
                long ptr = pendings.dequeue();
                while(ptr == -1L) {
                    if(pendings.isEmpty()) {
                        break outer;
                    }
                    ptr = pendings.dequeue();
                }
                DocumentTableModel dtm = ffcous.getDocumentTableModel();
                XQNode node = dtm.createNode(ptr);
                ffcous.setContextItem(node);
                return true;
            }
            final Profiler profiler = _dynEnv.getProfiler();
            final Iterator<Pair<DbCollection, String>> itor = ffcous.eachDocument();
            while(itor.hasNext()) {
                final Pair<DbCollection, String> pair = itor.next();
                final DbCollection col = pair.getFirst();
                final String docName = pair.getSecond();
                final File idxFile = getIndexFile(col, docName);
                BTreeIndexer indexer = new BTreeIndexer(idxFile);
                final IndexMatch matched;
                try {
                    matched = indexer.find(idxCond);
                } catch (DbException e) {
                    throw new XQRTException("failed to query index: " + idxFile.getAbsolutePath(), e);
                }
                // TODO REVIEWME sort really required?
                final long[] ptrs = filter(matched.getMatchedUnsorted(), docName, idxFile);
                final int matchCounts = ptrs.length;
                if(LOG.isInfoEnabled()) {
                    LOG.info("Index scan done. matched: " + matched.countMatched() + ", filtered: "
                            + matchCounts);
                }
                if(matchCounts > 0) {
                    final IDocumentTable doctbl;
                    try {
                        doctbl = DocumentTableLoader.load(col, docName, _dynEnv);
                    } catch (IOException e) {
                        throw new XQRTException("failed to load document '" + docName
                                + "' is the collection '" + col.getAbsolutePath() + '\'', e);
                    }
                    final PagingProfile profile = doctbl.getPagingProfile();
                    Strategy origStrategy = null;
                    if(profile != null) {
                        profile.setProfiler(profiler);
                        origStrategy = profile.getStrategy();
                        profile.setStrategy(Strategy.index);
                    }
                    DocumentTableModel dtm = new DocumentTableModel(doctbl, true);
                    final int last = matchCounts - 1;
                    for(int i = 0; i <= last; i++) {
                        long ptr = ptrs[i];
                        if(ptr != -1) {
                            XQNode node = dtm.createNode(ptr);
                            ffcous.setContextItem(node);
                            if(i != last) {
                                LongQueue ptrsQueue = new LongQueue(ptrs, i + 1, last);
                                ffcous.enqueue(dtm, ptrsQueue);
                            }
                            if(profile != null) {
                                profile.setStrategy(origStrategy);
                            }
View Full Code Here

        remoteMMFile.writeExternal(out);
        out.writeBoolean(_nativeByteOrder);
    }

    public long[] referredTextBlocks(final long curr, final long last, final SerializationContext serContext) {
        final LongQueue textBlocks = new LongQueue();
        final Set<Long> textBufferAddrs = serContext.textBufferAddresses();
        for(long i = curr; i <= last; i += BLOCKS_PER_NODE) {
            final byte kind = getNodeKindAt(i);
            if(kind == NodeKind.TEXT || kind == NodeKind.ATTRIBUTE || kind == NodeKind.NAMESPACE
                    || kind == NodeKind.COMMENT) {
                long cid = dataAt(i + CONTENT_OFFSET);
                long addr = _strChunk.getBufferAddress(cid);
                if(textBufferAddrs.add(addr)) {
                    textBlocks.add(addr);
                }
            }
        }
        return textBlocks.toArray();
    }
View Full Code Here

TOP

Related Classes of xbird.util.collections.LongQueue

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.