Package org.elasticsearch.common

Examples of org.elasticsearch.common.BytesWrap


    @Override public void setScorer(Scorer scorer) throws IOException {

    }

    @Override public void collect(int doc) throws IOException {
        BytesWrap parentId = typeCache.parentIdByDoc(doc);
        if (parentId == null) {
            return;
        }
        for (Tuple<IndexReader, IdReaderTypeCache> tuple : readers) {
            IndexReader indexReader = tuple.v1();
View Full Code Here


            int readerIndex = context.searcher().readerIndex(scoreDoc.doc);
            IndexReader subReader = context.searcher().subReaders()[readerIndex];
            int subDoc = scoreDoc.doc - context.searcher().docStarts()[readerIndex];

            // find the parent id
            BytesWrap parentId = context.idCache().reader(subReader).parentIdByDoc(parentType, subDoc);
            if (parentId == null) {
                // no parent found
                continue;
            }
            // now go over and find the parent doc Id and reader tuple
View Full Code Here

                            if (typeBuilder == null) {
                                typeBuilder = new TypeBuilder(reader);
                                readerBuilder.put(StringHelper.intern(uid.type()), typeBuilder);
                            }

                            BytesWrap idAsBytes = checkIfCanReuse(builders, new BytesWrap(uid.id()));
                            termDocs.seek(termEnum);
                            while (termDocs.next()) {
                                // when traversing, make sure to ignore deleted docs, so the key->docId will be correct
                                if (!reader.isDeleted(termDocs.doc())) {
                                    typeBuilder.idToDoc.put(idAsBytes, termDocs.doc());
                                }
                            }
                        } while (termEnum.next());
                    } finally {
                        termDocs.close();
                        termEnum.close();
                    }
                }

                // now, go and load the docId->parentId map

                for (IndexReader reader : readers) {
                    if (idReaders.containsKey(reader.getCoreCacheKey())) {
                        // no need, continue
                        continue;
                    }

                    Map<String, TypeBuilder> readerBuilder = builders.get(reader.getCoreCacheKey());

                    String field = StringHelper.intern(ParentFieldMapper.NAME);
                    TermDocs termDocs = reader.termDocs();
                    TermEnum termEnum = reader.terms(new Term(field));
                    try {
                        do {
                            Term term = termEnum.term();
                            if (term == null || term.field() != field) break;
                            // TODO we can optimize this, since type is the prefix, and we get terms ordered
                            // so, only need to move to the next type once its different
                            Uid uid = Uid.createUid(term.text());

                            TypeBuilder typeBuilder = readerBuilder.get(uid.type());
                            if (typeBuilder == null) {
                                typeBuilder = new TypeBuilder(reader);
                                readerBuilder.put(StringHelper.intern(uid.type()), typeBuilder);
                            }

                            BytesWrap idAsBytes = checkIfCanReuse(builders, new BytesWrap(uid.id()));
                            boolean added = false; // optimize for when all the docs are deleted for this id

                            termDocs.seek(termEnum);
                            while (termDocs.next()) {
                                // ignore deleted docs while we are at it
View Full Code Here

            }
        }
    }

    private BytesWrap checkIfCanReuse(Map<Object, Map<String, TypeBuilder>> builders, BytesWrap idAsBytes) {
        BytesWrap finalIdAsBytes;
        // go over and see if we can reuse this id
        for (SimpleIdReaderCache idReaderCache : idReaders.values()) {
            finalIdAsBytes = idReaderCache.canReuse(idAsBytes);
            if (finalIdAsBytes != null) {
                return finalIdAsBytes;
View Full Code Here

    /**
     * Returns an already stored instance if exists, if not, returns null;
     */
    public BytesWrap canReuse(BytesWrap id) {
        for (SimpleIdReaderTypeCache typeCache : types.values()) {
            BytesWrap wrap = typeCache.canReuse(id);
            if (wrap != null) {
                return wrap;
            }
        }
        return null;
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.BytesWrap

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.