Package org.apache.lucene.index

Examples of org.apache.lucene.index.RandomAccessOrds


        assertThat(topLevelReader.leaves().size(), equalTo(3));

        // First segment
        assertThat(globalOrdinals, instanceOf(GlobalOrdinalsIndexFieldData.class));
        AtomicOrdinalsFieldData afd = globalOrdinals.load(topLevelReader.leaves().get(0));
        RandomAccessOrds values = afd.getOrdinalsValues();
        values.setDocument(0);
        assertThat(values.cardinality(), equalTo(2));
        long ord = values.nextOrd();
        assertThat(ord, equalTo(3l));
        assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("02"));
        ord = values.nextOrd();
        assertThat(ord, equalTo(5l));
        assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("04"));
        values.setDocument(1);
        assertThat(values.cardinality(), equalTo(0));
        values.setDocument(2);
        assertThat(values.cardinality(), equalTo(1));
        ord = values.nextOrd();
        assertThat(ord, equalTo(4l));
        assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("03"));

        // Second segment
        afd = globalOrdinals.load(topLevelReader.leaves().get(1));
        values = afd.getOrdinalsValues();
        values.setDocument(0);
        assertThat(values.cardinality(), equalTo(3));
        ord = values.nextOrd();
        assertThat(ord, equalTo(5l));
        assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("04"));
        ord = values.nextOrd();
        assertThat(ord, equalTo(6l));
        assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("05"));
        ord = values.nextOrd();
        assertThat(ord, equalTo(7l));
        assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("06"));
        values.setDocument(1);
        assertThat(values.cardinality(), equalTo(3));
        ord = values.nextOrd();
        assertThat(ord, equalTo(7l));
        assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("06"));
        ord = values.nextOrd();
        assertThat(ord, equalTo(8l));
        assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("07"));
        ord = values.nextOrd();
        assertThat(ord, equalTo(9l));
        assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("08"));
        values.setDocument(2);
        assertThat(values.cardinality(), equalTo(0));
        values.setDocument(3);
        assertThat(values.cardinality(), equalTo(3));
        ord = values.nextOrd();
        assertThat(ord, equalTo(9l));
        assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("08"));
        ord = values.nextOrd();
        assertThat(ord, equalTo(10l));
        assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("09"));
        ord = values.nextOrd();
        assertThat(ord, equalTo(11l));
        assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("10"));

        // Third segment
        afd = globalOrdinals.load(topLevelReader.leaves().get(2));
        values = afd.getOrdinalsValues();
        values.setDocument(0);
        values.setDocument(0);
        assertThat(values.cardinality(), equalTo(3));
        ord = values.nextOrd();
        assertThat(ord, equalTo(0l));
        assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("!08"));
        ord = values.nextOrd();
        assertThat(ord, equalTo(1l));
        assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("!09"));
        ord = values.nextOrd();
        assertThat(ord, equalTo(2l));
        assertThat(values.lookupOrd(ord).utf8ToString(), equalTo("!10"));
    }
View Full Code Here

TOP

Related Classes of org.apache.lucene.index.RandomAccessOrds

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.