List of usage examples for org.apache.lucene.index SortedSetDocValues SortedSetDocValues
protected SortedSetDocValues()
From source file:lucene.security.index.SecureAtomicReader.java
License:Apache License
@Override public SortedSetDocValues getSortedSetDocValues(String field) throws IOException { final SortedSetDocValues sortedSetDocValues = in.getSortedSetDocValues(field); if (sortedSetDocValues == null) { return null; }//from w w w .ja v a 2s . co m return new SortedSetDocValues() { private boolean _access; @Override public void setDocument(int docID) { try { if (_access = _accessControl.hasAccess(ReadType.SORTED_SET_DOC_VALUE, docID)) { sortedSetDocValues.setDocument(docID); } } catch (IOException e) { throw new RuntimeException(e); } } @Override public long nextOrd() { if (_access) { return sortedSetDocValues.nextOrd(); } return NO_MORE_ORDS; } @Override public void lookupOrd(long ord, BytesRef result) { if (_access) { sortedSetDocValues.lookupOrd(ord, result); } else { result.bytes = BinaryDocValues.MISSING; result.length = 0; result.offset = 0; } } @Override public long getValueCount() { return sortedSetDocValues.getValueCount(); } }; }
From source file:org.apache.blur.lucene.codec.DiskDocValuesProducer.java
License:Apache License
@Override public SortedSetDocValues getSortedSet(FieldInfo field) throws IOException { final long valueCount = binaries.get(field.number).count; // we keep the byte[]s and list of ords on disk, these could be large final LongBinaryDocValues binary = (LongBinaryDocValues) getBinary(field); final LongNumericDocValues ordinals = getNumeric(ords.get(field.number)); Tracer trace = Trace.trace("getSortedSet - MonotonicBlockPackedReader - create"); final MonotonicBlockPackedReader ordIndex; try {/* w ww . j av a 2s. com*/ NumericEntry entry = ordIndexes.get(field.number); IndexInput data = this.data.clone(); data.seek(entry.offset); ordIndex = new MonotonicBlockPackedReader(data, entry.packedIntsVersion, entry.blockSize, entry.count, true); } finally { trace.done(); } return new SortedSetDocValues() { long offset; long endOffset; @Override public long nextOrd() { if (offset == endOffset) { return NO_MORE_ORDS; } else { long ord = ordinals.get(offset); offset++; return ord; } } @Override public void setDocument(int docID) { offset = (docID == 0 ? 0 : ordIndex.get(docID - 1)); endOffset = ordIndex.get(docID); } @Override public void lookupOrd(long ord, BytesRef result) { binary.get(ord, result); } @Override public long getValueCount() { return valueCount; } }; }