cleanups, remove unused code
This commit is contained in:
parent
f190ec4396
commit
9781d8675d
|
@ -24,7 +24,6 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.compress.CompressedString;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
|
@ -36,7 +35,6 @@ import java.util.Map;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@Immutable
|
||||
public class AliasMetaData {
|
||||
|
||||
private final String alias;
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import org.elasticsearch.common.regex.Regex;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||
|
@ -47,7 +46,6 @@ import static org.elasticsearch.common.settings.ImmutableSettings.*;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@Immutable
|
||||
public class IndexMetaData {
|
||||
|
||||
private static ImmutableSet<String> dynamicSettings = ImmutableSet.<String>builder()
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
|||
import org.elasticsearch.common.regex.Regex;
|
||||
import org.elasticsearch.common.settings.ImmutableSettings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
import org.elasticsearch.common.xcontent.*;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.indices.IndexMissingException;
|
||||
|
@ -47,7 +46,6 @@ import static org.elasticsearch.common.settings.ImmutableSettings.*;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@Immutable
|
||||
public class MetaData implements Iterable<IndexMetaData> {
|
||||
|
||||
private static ImmutableSet<String> dynamicSettings = ImmutableSet.<String>builder()
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.elasticsearch.cluster.metadata.IndexMetaData;
|
|||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
@ -38,7 +37,6 @@ import static com.google.common.collect.Lists.newArrayList;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@Immutable
|
||||
public class IndexRoutingTable implements Iterable<IndexShardRoutingTable> {
|
||||
|
||||
private final String index;
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.block.ClusterBlocks;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.common.util.concurrent.NotThreadSafe;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
@ -37,7 +36,6 @@ import static com.google.common.collect.Maps.newHashMap;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@NotThreadSafe
|
||||
public class RoutingNodes implements Iterable<RoutingNode> {
|
||||
|
||||
private final MetaData metaData;
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.elasticsearch.cluster.ClusterState;
|
|||
import org.elasticsearch.cluster.metadata.MetaData;
|
||||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
import org.elasticsearch.index.Index;
|
||||
import org.elasticsearch.indices.IndexMissingException;
|
||||
|
||||
|
@ -39,7 +38,6 @@ import static com.google.common.collect.Maps.newHashMap;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@Immutable
|
||||
public class RoutingTable implements Iterable<IndexRoutingTable> {
|
||||
|
||||
public static final RoutingTable EMPTY_ROUTING_TABLE = builder().build();
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package org.elasticsearch.common.component;
|
||||
|
||||
import org.elasticsearch.ElasticSearchIllegalStateException;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
|
||||
/**
|
||||
* Lifecycle state. Allows the following transitions:
|
||||
|
@ -57,10 +56,7 @@ import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
|||
* // perofrm close logic here
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public class Lifecycle {
|
||||
|
||||
public static enum State {
|
||||
|
|
|
@ -19,18 +19,13 @@
|
|||
|
||||
package org.elasticsearch.common.io;
|
||||
|
||||
import org.elasticsearch.common.util.concurrent.NotThreadSafe;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* A similar class to {@link java.io.CharArrayWriter} allowing to get the underlying <tt>char[]</tt> buffer.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@NotThreadSafe
|
||||
public class FastCharArrayWriter extends Writer {
|
||||
|
||||
/**
|
||||
|
|
|
@ -19,18 +19,15 @@
|
|||
|
||||
package org.elasticsearch.common.io;
|
||||
|
||||
import org.elasticsearch.common.util.concurrent.NotThreadSafe;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
* A character stream whose source is a string that is <b>not thread safe</b>
|
||||
*
|
||||
* <p/>
|
||||
* (shay.banon
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
@NotThreadSafe
|
||||
public class FastStringReader extends CharSequenceReader {
|
||||
|
||||
private String str;
|
||||
|
|
|
@ -19,16 +19,12 @@
|
|||
|
||||
package org.elasticsearch.common.joda;
|
||||
|
||||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* A simple wrapper around {@link DateTimeFormatter} that retains the
|
||||
* format that was used to create it.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Immutable
|
||||
public class FormatDateTimeFormatter {
|
||||
|
||||
private final String format;
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.lucene.versioned;
|
||||
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* An implementation of {@link VersionedMap} based on {@link ConcurrentHashMap}.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public class ConcurrentVersionedMap implements VersionedMap {
|
||||
|
||||
private final ConcurrentHashMap<Integer, Integer> map = new ConcurrentHashMap<Integer, Integer>();
|
||||
|
||||
@Override
|
||||
public boolean beforeVersion(int key, int versionToCheck) {
|
||||
Integer result = map.get(key);
|
||||
return result == null || versionToCheck < result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putVersion(int key, int version) {
|
||||
map.put(key, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putVersionIfAbsent(int key, int version) {
|
||||
map.putIfAbsent(key, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
map.clear();
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.lucene.versioned;
|
||||
|
||||
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
|
||||
import org.elasticsearch.common.util.concurrent.ConcurrentMapLong;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
|
||||
/**
|
||||
* An implementation of {@link VersionedMap} based on {@link org.elasticsearch.common.util.concurrent.ConcurrentMapLong}.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public class ConcurrentVersionedMapLong implements VersionedMap {
|
||||
|
||||
private final ConcurrentMapLong<Integer> map = ConcurrentCollections.newConcurrentMapLong();
|
||||
|
||||
@Override
|
||||
public boolean beforeVersion(int key, int versionToCheck) {
|
||||
Integer result = map.get(key);
|
||||
return result == null || versionToCheck < result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putVersion(int key, int version) {
|
||||
map.put(key, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putVersionIfAbsent(int key, int version) {
|
||||
map.putIfAbsent(key, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
map.clear();
|
||||
}
|
||||
}
|
|
@ -1,154 +0,0 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.lucene.versioned;
|
||||
|
||||
import gnu.trove.impl.Constants;
|
||||
import gnu.trove.map.hash.TIntIntHashMap;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
|
||||
/**
|
||||
* An implementation of {@link VersionedMap} based on trove.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public class NativeVersionedMap implements VersionedMap {
|
||||
|
||||
/**
|
||||
* Mask value for indexing into segments. The upper bits of a
|
||||
* key's hash code are used to choose the segment.
|
||||
*/
|
||||
private final int segmentMask;
|
||||
|
||||
/**
|
||||
* Shift value for indexing within segments.
|
||||
*/
|
||||
private final int segmentShift;
|
||||
|
||||
private final Segment[] segments;
|
||||
|
||||
public NativeVersionedMap() {
|
||||
this(16);
|
||||
}
|
||||
|
||||
public NativeVersionedMap(int concurrencyLevel) {
|
||||
// Find power-of-two sizes best matching arguments
|
||||
int sshift = 0;
|
||||
int ssize = 1;
|
||||
while (ssize < concurrencyLevel) {
|
||||
++sshift;
|
||||
ssize <<= 1;
|
||||
}
|
||||
segmentShift = 32 - sshift;
|
||||
segmentMask = ssize - 1;
|
||||
this.segments = new Segment[ssize];
|
||||
for (int i = 0; i < segments.length; i++) {
|
||||
segments[i] = new Segment();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean beforeVersion(int key, int versionToCheck) {
|
||||
Segment segment = segmentFor(hash(key));
|
||||
segment.rwl.readLock().lock();
|
||||
try {
|
||||
int result = segment.map.get(key);
|
||||
return result == -1 || versionToCheck < result;
|
||||
} finally {
|
||||
segment.rwl.readLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putVersion(int key, int version) {
|
||||
Segment segment = segmentFor(hash(key));
|
||||
segment.rwl.writeLock().lock();
|
||||
try {
|
||||
segment.map.put(key, version);
|
||||
} finally {
|
||||
segment.rwl.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void putVersionIfAbsent(int key, int version) {
|
||||
Segment segment = segmentFor(hash(key));
|
||||
segment.rwl.writeLock().lock();
|
||||
try {
|
||||
if (!segment.map.containsKey(key)) {
|
||||
segment.map.put(key, version);
|
||||
}
|
||||
} finally {
|
||||
segment.rwl.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
for (Segment segment : segments) {
|
||||
segment.rwl.writeLock().lock();
|
||||
try {
|
||||
segment.map.clear();
|
||||
} finally {
|
||||
segment.rwl.writeLock().unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a supplemental hash function to a given hashCode, which
|
||||
* defends against poor quality hash functions. This is critical
|
||||
* because ConcurrentHashMap uses power-of-two length hash tables,
|
||||
* that otherwise encounter collisions for hashCodes that do not
|
||||
* differ in lower or upper bits.
|
||||
*/
|
||||
private static int hash(int h) {
|
||||
// Spread bits to regularize both segment and index locations,
|
||||
// using variant of single-word Wang/Jenkins hash.
|
||||
h += (h << 15) ^ 0xffffcd7d;
|
||||
h ^= (h >>> 10);
|
||||
h += (h << 3);
|
||||
h ^= (h >>> 6);
|
||||
h += (h << 2) + (h << 14);
|
||||
return h ^ (h >>> 16);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the segment that should be used for key with given hash
|
||||
*
|
||||
* @param hash the hash code for the key
|
||||
* @return the segment
|
||||
*/
|
||||
final Segment segmentFor(int hash) {
|
||||
return segments[(hash >>> segmentShift) & segmentMask];
|
||||
}
|
||||
|
||||
private static class Segment {
|
||||
final ReadWriteLock rwl = new ReentrantReadWriteLock();
|
||||
final TIntIntHashMap map = new TIntIntHashMap(Constants.DEFAULT_CAPACITY, Constants.DEFAULT_LOAD_FACTOR, 0, -1);
|
||||
|
||||
private Segment() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.lucene.versioned;
|
||||
|
||||
import org.apache.lucene.index.*;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public class VersionedIndexReader extends FilterIndexReader {
|
||||
|
||||
protected final int version;
|
||||
|
||||
protected final VersionedMap versionedMap;
|
||||
|
||||
public VersionedIndexReader(IndexReader in, int version, VersionedMap versionedMap) {
|
||||
super(in);
|
||||
this.version = version;
|
||||
this.versionedMap = versionedMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TermDocs termDocs() throws IOException {
|
||||
return new VersionedTermDocs(in.termDocs());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TermDocs termDocs(Term term) throws IOException {
|
||||
return new VersionedTermDocs(in.termDocs(term));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TermPositions termPositions() throws IOException {
|
||||
return new VersionedTermPositions(in.termPositions());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TermPositions termPositions(Term term) throws IOException {
|
||||
return new VersionedTermPositions(in.termPositions(term));
|
||||
}
|
||||
|
||||
|
||||
private class VersionedTermDocs extends FilterTermDocs {
|
||||
|
||||
public VersionedTermDocs(TermDocs in) {
|
||||
super(in);
|
||||
}
|
||||
|
||||
public boolean next() throws IOException {
|
||||
while (in.next()) {
|
||||
if (versionedMap.beforeVersion(in.doc(), version)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int read(final int[] docs, final int[] freqs) throws IOException {
|
||||
int i = 0;
|
||||
while (i < docs.length) {
|
||||
if (!in.next()) return i;
|
||||
|
||||
int doc = in.doc();
|
||||
if (versionedMap.beforeVersion(doc, version)) {
|
||||
docs[i] = doc;
|
||||
freqs[i] = in.freq();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public boolean skipTo(int i) throws IOException {
|
||||
if (!in.skipTo(i)) return false;
|
||||
if (versionedMap.beforeVersion(in.doc(), version)) return true;
|
||||
|
||||
return next();
|
||||
}
|
||||
}
|
||||
|
||||
private class VersionedTermPositions extends VersionedTermDocs implements TermPositions {
|
||||
final TermPositions _tp;
|
||||
|
||||
public VersionedTermPositions(TermPositions in) {
|
||||
super(in);
|
||||
_tp = in;
|
||||
}
|
||||
|
||||
public int nextPosition() throws IOException {
|
||||
return _tp.nextPosition();
|
||||
}
|
||||
|
||||
public int getPayloadLength() {
|
||||
return _tp.getPayloadLength();
|
||||
}
|
||||
|
||||
public byte[] getPayload(byte[] data, int offset) throws IOException {
|
||||
return _tp.getPayload(data, offset);
|
||||
}
|
||||
|
||||
public boolean isPayloadAvailable() {
|
||||
return _tp.isPayloadAvailable();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.lucene.versioned;
|
||||
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
|
||||
/**
|
||||
* A versioned map, allowing to put version numbers associated with specific
|
||||
* keys.
|
||||
* <p/>
|
||||
* <p>Note. versions can be assumed to be >= 0.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public interface VersionedMap {
|
||||
|
||||
/**
|
||||
* Returns <tt>true</tt> if the versionToCheck is smaller than the current version
|
||||
* associated with the key. If there is no version associated with the key, then
|
||||
* it should return <tt>true</tt> as well.
|
||||
*/
|
||||
boolean beforeVersion(int key, int versionToCheck);
|
||||
|
||||
/**
|
||||
* Puts (and replaces if it exists) the current key with the provided version.
|
||||
*/
|
||||
void putVersion(int key, int version);
|
||||
|
||||
/**
|
||||
* Puts the version with the key only if it is absent.
|
||||
*/
|
||||
void putVersionIfAbsent(int key, int version);
|
||||
|
||||
/**
|
||||
* Clears the map.
|
||||
*/
|
||||
void clear();
|
||||
}
|
|
@ -34,8 +34,6 @@ import org.elasticsearch.common.unit.ByteSizeUnit;
|
|||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.unit.SizeValue;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -51,11 +49,7 @@ import static org.elasticsearch.common.unit.TimeValue.parseTimeValue;
|
|||
|
||||
/**
|
||||
* An immutable implementation of {@link Settings}.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
@Immutable
|
||||
public class ImmutableSettings implements Settings {
|
||||
|
||||
private ImmutableMap<String, String> settings;
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.google.common.collect.ImmutableMap;
|
|||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.unit.SizeValue;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -33,10 +32,8 @@ import java.util.Map;
|
|||
* <p>Using {@link ImmutableSettings#settingsBuilder()} in order to create a builder
|
||||
* which in turn can create an immutable implementation of settings.
|
||||
*
|
||||
*
|
||||
* @see ImmutableSettings
|
||||
*/
|
||||
@ThreadSafe
|
||||
public interface Settings {
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,142 +0,0 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.util.concurrent;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
/**
|
||||
* Provides the semantics of a thread safe copy on write map.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public class CopyOnWriteMap<K, V> implements ConcurrentMap<K, V> {
|
||||
|
||||
private volatile Map<K, V> map = new HashMap<K, V>();
|
||||
|
||||
public void clear() {
|
||||
map = new HashMap<K, V>();
|
||||
}
|
||||
|
||||
public boolean containsKey(Object key) {
|
||||
return map.containsKey(key);
|
||||
}
|
||||
|
||||
public boolean containsValue(Object value) {
|
||||
return map.containsValue(value);
|
||||
}
|
||||
|
||||
public Set<Entry<K, V>> entrySet() {
|
||||
return map.entrySet();
|
||||
}
|
||||
|
||||
public V get(Object key) {
|
||||
return map.get(key);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return map.isEmpty();
|
||||
}
|
||||
|
||||
public Set<K> keySet() {
|
||||
return map.keySet();
|
||||
}
|
||||
|
||||
public V put(K key, V value) {
|
||||
synchronized (this) {
|
||||
Map<K, V> copyMap = copyMap();
|
||||
V put = copyMap.put(key, value);
|
||||
map = copyMap;
|
||||
return put;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void putAll(Map<? extends K, ? extends V> t) {
|
||||
Map<K, V> copyMap = copyMap();
|
||||
copyMap.putAll(t);
|
||||
map = copyMap;
|
||||
}
|
||||
|
||||
public synchronized V remove(Object key) {
|
||||
Map<K, V> copyMap = copyMap();
|
||||
V remove = copyMap.remove(key);
|
||||
map = copyMap;
|
||||
return remove;
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return map.size();
|
||||
}
|
||||
|
||||
public Collection<V> values() {
|
||||
return map.values();
|
||||
}
|
||||
|
||||
private Map<K, V> copyMap() {
|
||||
return new HashMap<K, V>(map);
|
||||
}
|
||||
|
||||
public synchronized V putIfAbsent(K key, V value) {
|
||||
V v = map.get(key);
|
||||
if (v == null) {
|
||||
Map<K, V> copyMap = copyMap();
|
||||
copyMap.put(key, value);
|
||||
map = copyMap;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
public synchronized boolean remove(Object key, Object value) {
|
||||
V v = map.get(key);
|
||||
if (v != null && v.equals(value)) {
|
||||
Map<K, V> copyMap = copyMap();
|
||||
copyMap.remove(key);
|
||||
map = copyMap;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public synchronized V replace(K key, V value) {
|
||||
V v = map.get(key);
|
||||
if (v != null) {
|
||||
Map<K, V> copyMap = copyMap();
|
||||
copyMap.put(key, value);
|
||||
map = copyMap;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
public synchronized boolean replace(K key, V oldValue, V newValue) {
|
||||
V v = map.get(key);
|
||||
if (v != null && v.equals(oldValue)) {
|
||||
Map<K, V> copyMap = copyMap();
|
||||
copyMap.put(key, newValue);
|
||||
map = copyMap;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.util.concurrent;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Immutable
|
||||
* <p/>
|
||||
* The class to which this annotation is applied is immutable. This means that
|
||||
* its state cannot be seen to change by callers. Of necessity this means that
|
||||
* all public fields are final, and that all public final reference fields refer
|
||||
* to other immutable objects, and that methods do not publish references to any
|
||||
* internal state which is mutable by implementation even if not by design.
|
||||
* Immutable objects may still have internal mutable state for purposes of
|
||||
* performance optimization; some state variables may be lazily computed, so
|
||||
* long as they are computed from immutable state and that callers cannot tell
|
||||
* the difference.
|
||||
* <p/>
|
||||
* Immutable objects are inherently thread-safe; they may be passed between
|
||||
* threads or published without synchronization.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Documented
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
public @interface Immutable {
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.util.concurrent;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* NotThreadSafe
|
||||
* <p/>
|
||||
* The class to which this annotation is applied is not thread-safe. This
|
||||
* annotation primarily exists for clarifying the non-thread-safety of a class
|
||||
* that might otherwise be assumed to be thread-safe, despite the fact that it
|
||||
* is a bad idea to assume a class is thread-safe without good reason.
|
||||
*
|
||||
*
|
||||
* @see ThreadSafe
|
||||
*/
|
||||
@Documented
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
public @interface NotThreadSafe {
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.common.util.concurrent;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* ThreadSafe
|
||||
* <p/>
|
||||
* The class to which this annotation is applied is thread-safe. This means that
|
||||
* no sequences of accesses (reads and writes to public fields, calls to public
|
||||
* methods) may put the object into an invalid state, regardless of the
|
||||
* interleaving of those actions by the runtime, and without requiring any
|
||||
* additional synchronization or coordination on the part of the caller.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Documented
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
public @interface ThreadSafe {
|
||||
}
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.index;
|
|||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
@ -30,7 +29,6 @@ import java.io.Serializable;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@Immutable
|
||||
public class Index implements Serializable, Streamable {
|
||||
|
||||
private String name;
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.index.analysis;
|
|||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.TokenStream;
|
||||
import org.apache.lucene.document.Fieldable;
|
||||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
@ -30,10 +29,7 @@ import java.io.Reader;
|
|||
/**
|
||||
* Named analyzer is an analyzer wrapper around an actual analyzer ({@link #analyzer} that is associated
|
||||
* with a name ({@link #name()}.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Immutable
|
||||
public final class NamedAnalyzer extends Analyzer {
|
||||
|
||||
private final String name;
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.elasticsearch.common.lease.Releasable;
|
|||
import org.elasticsearch.common.lucene.uid.UidField;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
import org.elasticsearch.index.VersionType;
|
||||
import org.elasticsearch.index.deletionpolicy.SnapshotIndexCommit;
|
||||
import org.elasticsearch.index.mapper.DocumentMapper;
|
||||
|
@ -48,7 +47,6 @@ import java.util.List;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public interface Engine extends IndexShardComponent, CloseableComponent {
|
||||
|
||||
static ByteSizeValue INACTIVE_SHARD_INDEXING_BUFFER = ByteSizeValue.parseBytesSizeValue("500kb");
|
||||
|
|
|
@ -19,12 +19,9 @@
|
|||
|
||||
package org.elasticsearch.index.mapper;
|
||||
|
||||
import org.elasticsearch.common.util.concurrent.NotThreadSafe;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@NotThreadSafe
|
||||
public class ContentPath {
|
||||
|
||||
public static enum Type {
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.index.mapper;
|
|||
import com.google.common.collect.*;
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.elasticsearch.common.regex.Regex;
|
||||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
import org.elasticsearch.index.analysis.FieldNameAnalyzer;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -34,7 +33,6 @@ import static com.google.common.collect.Maps.newHashMap;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@Immutable
|
||||
public class DocumentFieldMappers implements Iterable<FieldMapper> {
|
||||
|
||||
private final ImmutableList<FieldMapper> fieldMappers;
|
||||
|
|
|
@ -26,18 +26,14 @@ import org.apache.lucene.index.Term;
|
|||
import org.apache.lucene.search.Filter;
|
||||
import org.apache.lucene.search.Query;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
import org.elasticsearch.index.field.data.FieldDataType;
|
||||
import org.elasticsearch.index.query.QueryParseContext;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public interface FieldMapper<T> {
|
||||
|
||||
@Immutable
|
||||
public static class Names {
|
||||
|
||||
private final String name;
|
||||
|
|
|
@ -22,16 +22,12 @@ package org.elasticsearch.index.mapper;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.UnmodifiableIterator;
|
||||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A holder for several {@link FieldMapper}.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Immutable
|
||||
public class FieldMappers implements Iterable<FieldMapper> {
|
||||
|
||||
private final ImmutableList<FieldMapper> fieldMappers;
|
||||
|
|
|
@ -23,8 +23,6 @@ import com.google.common.collect.ImmutableMap;
|
|||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.Strings;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.NotThreadSafe;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
|
||||
|
@ -34,12 +32,10 @@ import java.util.Map;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public interface Mapper extends ToXContent {
|
||||
|
||||
public static final Mapper[] EMPTY_ARRAY = new Mapper[0];
|
||||
|
||||
@NotThreadSafe
|
||||
public static class BuilderContext {
|
||||
private final Settings indexSettings;
|
||||
private final ContentPath contentPath;
|
||||
|
@ -59,7 +55,6 @@ public interface Mapper extends ToXContent {
|
|||
}
|
||||
}
|
||||
|
||||
@NotThreadSafe
|
||||
public static abstract class Builder<T extends Builder, Y extends Mapper> {
|
||||
|
||||
public String name;
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.elasticsearch.common.lucene.search.TermFilter;
|
|||
import org.elasticsearch.common.lucene.search.XBooleanFilter;
|
||||
import org.elasticsearch.common.regex.Regex;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
import org.elasticsearch.env.Environment;
|
||||
import org.elasticsearch.env.FailedToResolveConfigException;
|
||||
import org.elasticsearch.index.AbstractIndexComponent;
|
||||
|
@ -65,7 +64,6 @@ import static org.elasticsearch.common.collect.MapBuilder.newMapBuilder;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public class MapperService extends AbstractIndexComponent implements Iterable<DocumentMapper> {
|
||||
|
||||
public static final String DEFAULT_MAPPING = "_default_";
|
||||
|
|
|
@ -22,15 +22,11 @@ package org.elasticsearch.index.mapper;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.UnmodifiableIterator;
|
||||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
import org.elasticsearch.index.mapper.object.ObjectMapper;
|
||||
|
||||
/**
|
||||
* A holder for several {@link org.elasticsearch.index.mapper.object.ObjectMapper}.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Immutable
|
||||
public class ObjectMappers implements Iterable<ObjectMapper> {
|
||||
|
||||
private final ImmutableList<ObjectMapper> objectMappers;
|
||||
|
|
|
@ -25,7 +25,6 @@ import org.apache.lucene.document.Field;
|
|||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.lucene.all.AllEntries;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.NotThreadSafe;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
import org.elasticsearch.index.analysis.AnalysisService;
|
||||
import org.elasticsearch.index.mapper.object.RootObjectMapper;
|
||||
|
@ -38,7 +37,6 @@ import java.util.Map;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@NotThreadSafe
|
||||
public class ParseContext {
|
||||
|
||||
private final DocumentMapper docMapper;
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.elasticsearch.common.Strings;
|
|||
import org.elasticsearch.common.joda.FormatDateTimeFormatter;
|
||||
import org.elasticsearch.common.lucene.search.TermFilter;
|
||||
import org.elasticsearch.common.lucene.uid.UidField;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
import org.elasticsearch.common.xcontent.ToXContent;
|
||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
@ -52,7 +51,6 @@ import static org.elasticsearch.index.mapper.core.TypeParsers.parsePathType;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll {
|
||||
|
||||
public static final String CONTENT_TYPE = "object";
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.index.shard;
|
|||
import org.elasticsearch.common.io.stream.StreamInput;
|
||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
import org.elasticsearch.common.util.concurrent.Immutable;
|
||||
import org.elasticsearch.index.Index;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -30,10 +29,7 @@ import java.io.Serializable;
|
|||
|
||||
/**
|
||||
* Allows for shard level components to be injected with the shard id.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Immutable
|
||||
public class ShardId implements Serializable, Streamable {
|
||||
|
||||
private Index index;
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.index.shard.service;
|
|||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.cluster.routing.ShardRouting;
|
||||
import org.elasticsearch.common.Nullable;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
import org.elasticsearch.index.engine.Engine;
|
||||
import org.elasticsearch.index.engine.EngineException;
|
||||
import org.elasticsearch.index.flush.FlushStats;
|
||||
|
@ -44,7 +43,6 @@ import org.elasticsearch.index.store.StoreStats;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public interface IndexShard extends IndexShardComponent {
|
||||
|
||||
ShardIndexingService indexingService();
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.elasticsearch.common.lucene.search.Queries;
|
|||
import org.elasticsearch.common.metrics.MeanMetric;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.unit.TimeValue;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
import org.elasticsearch.index.aliases.IndexAliasesService;
|
||||
import org.elasticsearch.index.cache.IndexCache;
|
||||
import org.elasticsearch.index.engine.*;
|
||||
|
@ -77,7 +76,6 @@ import static org.elasticsearch.index.mapper.SourceToParse.source;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public class InternalIndexShard extends AbstractIndexShardComponent implements IndexShard {
|
||||
|
||||
private final ThreadPool threadPool;
|
||||
|
|
|
@ -29,8 +29,6 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
|||
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||
import org.elasticsearch.common.io.stream.Streamable;
|
||||
import org.elasticsearch.common.lease.Releasable;
|
||||
import org.elasticsearch.common.util.concurrent.NotThreadSafe;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
import org.elasticsearch.index.engine.Engine;
|
||||
import org.elasticsearch.index.shard.IndexShardComponent;
|
||||
|
||||
|
@ -40,7 +38,6 @@ import java.io.InputStream;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public interface Translog extends IndexShardComponent {
|
||||
|
||||
public static final String TRANSLOG_ID_KEY = "translog_id";
|
||||
|
@ -145,7 +142,6 @@ public interface Translog extends IndexShardComponent {
|
|||
/**
|
||||
* A snapshot of the transaction log, allows to iterate over all the transaction log operations.
|
||||
*/
|
||||
@NotThreadSafe
|
||||
static interface Snapshot extends Releasable {
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.elasticsearch.indices;
|
|||
import org.elasticsearch.ElasticSearchException;
|
||||
import org.elasticsearch.common.component.LifecycleComponent;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
import org.elasticsearch.index.service.IndexService;
|
||||
|
||||
import java.util.Set;
|
||||
|
@ -30,7 +29,6 @@ import java.util.Set;
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public interface IndicesService extends Iterable<IndexService>, LifecycleComponent<IndicesService> {
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,7 +30,6 @@ import org.elasticsearch.common.inject.*;
|
|||
import org.elasticsearch.common.io.FileSystemUtils;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.util.concurrent.EsExecutors;
|
||||
import org.elasticsearch.common.util.concurrent.ThreadSafe;
|
||||
import org.elasticsearch.env.NodeEnvironment;
|
||||
import org.elasticsearch.gateway.Gateway;
|
||||
import org.elasticsearch.index.*;
|
||||
|
@ -90,7 +89,6 @@ import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilde
|
|||
/**
|
||||
*
|
||||
*/
|
||||
@ThreadSafe
|
||||
public class InternalIndicesService extends AbstractLifecycleComponent<IndicesService> implements IndicesService {
|
||||
|
||||
private final NodeEnvironment nodeEnv;
|
||||
|
|
|
@ -19,14 +19,9 @@
|
|||
|
||||
package org.elasticsearch.script;
|
||||
|
||||
import org.elasticsearch.common.util.concurrent.NotThreadSafe;
|
||||
|
||||
/**
|
||||
* An executable script, can't be used concurrently.
|
||||
*
|
||||
*
|
||||
*/
|
||||
@NotThreadSafe
|
||||
public interface ExecutableScript {
|
||||
|
||||
void setNextVar(String name, Object value);
|
||||
|
|
|
@ -1,207 +0,0 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.benchmark.common.lucene.versioned;
|
||||
|
||||
import org.elasticsearch.common.StopWatch;
|
||||
import org.elasticsearch.common.lucene.versioned.ConcurrentVersionedMap;
|
||||
import org.elasticsearch.common.lucene.versioned.ConcurrentVersionedMapLong;
|
||||
import org.elasticsearch.common.lucene.versioned.NativeVersionedMap;
|
||||
import org.elasticsearch.common.lucene.versioned.VersionedMap;
|
||||
import org.elasticsearch.common.unit.ByteSizeValue;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.CyclicBarrier;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class VersionedMapBenchmark {
|
||||
|
||||
private final VersionedMap versionedMap;
|
||||
|
||||
private final int readerIterations;
|
||||
|
||||
private final int writerIterations;
|
||||
|
||||
private final CountDownLatch latch;
|
||||
|
||||
private final Thread[] readerThreads;
|
||||
|
||||
private final Thread[] writerThreads;
|
||||
|
||||
private final CyclicBarrier barrier1;
|
||||
private final CyclicBarrier barrier2;
|
||||
|
||||
public VersionedMapBenchmark(VersionedMap versionedMap,
|
||||
int numberOfReaders, int readerIterations,
|
||||
int numberOfWriters, int writerIterations) {
|
||||
this.versionedMap = versionedMap;
|
||||
this.readerIterations = readerIterations;
|
||||
this.writerIterations = writerIterations;
|
||||
|
||||
readerThreads = new Thread[numberOfReaders];
|
||||
for (int i = 0; i < numberOfReaders; i++) {
|
||||
readerThreads[i] = new Thread(new ReaderThread(), "reader[" + i + "]");
|
||||
}
|
||||
|
||||
writerThreads = new Thread[numberOfWriters];
|
||||
for (int i = 0; i < numberOfWriters; i++) {
|
||||
writerThreads[i] = new Thread(new WriterThread(), "writer[" + i + "]");
|
||||
}
|
||||
|
||||
latch = new CountDownLatch(numberOfReaders + numberOfWriters);
|
||||
barrier1 = new CyclicBarrier(numberOfReaders + numberOfWriters + 1);
|
||||
barrier2 = new CyclicBarrier(numberOfReaders + numberOfWriters + 1);
|
||||
|
||||
// now, warm up a bit
|
||||
StopWatch stopWatch = new StopWatch("warmup");
|
||||
stopWatch.start();
|
||||
int warmupSize = 1000000;
|
||||
for (int i = 0; i < warmupSize; i++) {
|
||||
versionedMap.putVersion(i, i);
|
||||
versionedMap.beforeVersion(i, i);
|
||||
}
|
||||
stopWatch.stop();
|
||||
System.out.println("Warmup up of [" + warmupSize + "]: " + stopWatch.totalTime());
|
||||
versionedMap.clear();
|
||||
}
|
||||
|
||||
public void run() throws Exception {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
System.gc();
|
||||
MILLISECONDS.sleep(100);
|
||||
}
|
||||
|
||||
long emptyUsed = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed();
|
||||
|
||||
for (Thread t : readerThreads) {
|
||||
t.start();
|
||||
}
|
||||
for (Thread t : writerThreads) {
|
||||
t.start();
|
||||
}
|
||||
barrier1.await();
|
||||
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
barrier2.await();
|
||||
|
||||
latch.await();
|
||||
stopWatch.stop();
|
||||
|
||||
// verify that the writers wrote...
|
||||
for (int i = 0; i < writerIterations; i++) {
|
||||
if (versionedMap.beforeVersion(i, Integer.MAX_VALUE)) {
|
||||
System.out.println("Wrong value for [" + i + ']');
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("Total:");
|
||||
System.out.println(" - [" + readerThreads.length + "] readers with [" + readerIterations + "] iterations");
|
||||
System.out.println(" - [" + writerThreads.length + "] writers with [" + writerIterations + "] iterations");
|
||||
System.out.println(" - Took: " + stopWatch.totalTime());
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
System.gc();
|
||||
MILLISECONDS.sleep(100);
|
||||
}
|
||||
|
||||
long bytesTaken = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() - emptyUsed;
|
||||
System.out.println("Size of [" + writerIterations + "] entries is " + new ByteSizeValue(bytesTaken));
|
||||
}
|
||||
|
||||
private class ReaderThread implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
barrier1.await();
|
||||
barrier2.await();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
for (int i = 0; i < readerIterations; i++) {
|
||||
versionedMap.beforeVersion(i, i);
|
||||
}
|
||||
latch.countDown();
|
||||
}
|
||||
}
|
||||
|
||||
private class WriterThread implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
barrier1.await();
|
||||
barrier2.await();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
for (int i = 0; i < writerIterations; i++) {
|
||||
versionedMap.putVersionIfAbsent(i, i);
|
||||
}
|
||||
latch.countDown();
|
||||
}
|
||||
}
|
||||
|
||||
// Some results: Two cores machine, general average across 5 runs
|
||||
|
||||
// VersionedMapBenchmark benchmark = new VersionedMapBenchmark(
|
||||
// versionedMap, 30, 2000000, 10, 2000000
|
||||
// );
|
||||
|
||||
// Running [native] type
|
||||
// Took StopWatch '': running time = 11.9s
|
||||
// -----------------------------------------
|
||||
// ms % Task name
|
||||
// -----------------------------------------
|
||||
// 11909 100%
|
||||
//
|
||||
// Size of [2000000] entries is 17.9mb
|
||||
|
||||
// Running [nb] type
|
||||
// Took StopWatch '': running time = 6.1s
|
||||
// -----------------------------------------
|
||||
// ms % Task name
|
||||
// -----------------------------------------
|
||||
// 06134 100%
|
||||
//
|
||||
// Size of [2000000] entries is 77.6mb
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String type = args.length > 0 ? args[0] : "nb";
|
||||
VersionedMap versionedMap;
|
||||
if ("nb".equalsIgnoreCase(type)) {
|
||||
versionedMap = new ConcurrentVersionedMapLong();
|
||||
} else if ("native".equalsIgnoreCase(type)) {
|
||||
versionedMap = new NativeVersionedMap();
|
||||
} else if ("concurrent".equalsIgnoreCase(type)) {
|
||||
versionedMap = new ConcurrentVersionedMap();
|
||||
} else {
|
||||
throw new IllegalArgumentException("Type [" + type + "] unknown");
|
||||
}
|
||||
System.out.println("Running [" + type + "] type");
|
||||
VersionedMapBenchmark benchmark = new VersionedMapBenchmark(
|
||||
versionedMap, 30, 2000000, 10, 2000000
|
||||
);
|
||||
benchmark.run();
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.test.unit.common.lucene.versioned;
|
||||
|
||||
import org.elasticsearch.common.lucene.versioned.VersionedMap;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractVersionedMapTests {
|
||||
|
||||
protected abstract VersionedMap create();
|
||||
|
||||
@Test
|
||||
public void testSimple() {
|
||||
VersionedMap versionedMap = create();
|
||||
|
||||
assertThat(true, equalTo(versionedMap.beforeVersion(1, 1)));
|
||||
assertThat(true, equalTo(versionedMap.beforeVersion(2, 2)));
|
||||
|
||||
versionedMap.putVersion(1, 2);
|
||||
assertThat(true, equalTo(versionedMap.beforeVersion(1, 1)));
|
||||
assertThat(false, equalTo(versionedMap.beforeVersion(1, 2)));
|
||||
assertThat(true, equalTo(versionedMap.beforeVersion(2, 2)));
|
||||
|
||||
versionedMap.putVersionIfAbsent(1, 0);
|
||||
assertThat(true, equalTo(versionedMap.beforeVersion(1, 1)));
|
||||
assertThat(true, equalTo(versionedMap.beforeVersion(2, 2)));
|
||||
|
||||
versionedMap.putVersion(2, 1);
|
||||
assertThat(true, equalTo(versionedMap.beforeVersion(2, 0)));
|
||||
assertThat(false, equalTo(versionedMap.beforeVersion(2, 1)));
|
||||
assertThat(false, equalTo(versionedMap.beforeVersion(2, 2)));
|
||||
assertThat(false, equalTo(versionedMap.beforeVersion(2, 3)));
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.test.unit.common.lucene.versioned;
|
||||
|
||||
import org.elasticsearch.common.lucene.versioned.NativeVersionedMap;
|
||||
import org.elasticsearch.common.lucene.versioned.VersionedMap;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class NativeVersionedMapTests extends AbstractVersionedMapTests {
|
||||
|
||||
@Override
|
||||
protected VersionedMap create() {
|
||||
return new NativeVersionedMap();
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.test.unit.common.lucene.versioned;
|
||||
|
||||
import org.elasticsearch.common.lucene.versioned.ConcurrentVersionedMapLong;
|
||||
import org.elasticsearch.common.lucene.versioned.VersionedMap;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class NonBlockingVersionedMapTests extends AbstractVersionedMapTests {
|
||||
|
||||
@Override
|
||||
protected VersionedMap create() {
|
||||
return new ConcurrentVersionedMapLong();
|
||||
}
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
/*
|
||||
* Licensed to ElasticSearch and Shay Banon under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. ElasticSearch licenses this
|
||||
* file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.elasticsearch.test.unit.common.lucene.versioned;
|
||||
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.index.*;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.elasticsearch.common.lucene.Lucene;
|
||||
import org.elasticsearch.common.lucene.versioned.ConcurrentVersionedMapLong;
|
||||
import org.elasticsearch.common.lucene.versioned.VersionedIndexReader;
|
||||
import org.elasticsearch.common.lucene.versioned.VersionedMap;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.elasticsearch.common.lucene.DocumentBuilder.doc;
|
||||
import static org.elasticsearch.common.lucene.DocumentBuilder.field;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class VersionedIndexReaderTests {
|
||||
|
||||
private RAMDirectory dir;
|
||||
private IndexReader indexReader;
|
||||
private IndexWriter indexWriter;
|
||||
private VersionedMap versionedMap;
|
||||
|
||||
@BeforeClass
|
||||
public void setUp() throws Exception {
|
||||
versionedMap = new ConcurrentVersionedMapLong();
|
||||
dir = new RAMDirectory();
|
||||
indexWriter = new IndexWriter(dir, new IndexWriterConfig(Lucene.VERSION, Lucene.STANDARD_ANALYZER));
|
||||
indexWriter.addDocument(doc().add(field("value", "0")).build());
|
||||
indexWriter.addDocument(doc().add(field("value", "1")).build());
|
||||
indexWriter.addDocument(doc().add(field("value", "2")).build());
|
||||
indexWriter.addDocument(doc().add(field("value", "3")).build());
|
||||
indexWriter.commit();
|
||||
indexReader = IndexReader.open(dir, true);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public void tearDown() throws Exception {
|
||||
indexWriter.close();
|
||||
indexReader.close();
|
||||
dir.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verifyExpected() throws Exception {
|
||||
TermDocs termDocs;
|
||||
Document doc = indexReader.document(0);
|
||||
|
||||
assertThat(doc.getFieldable("value").stringValue(), equalTo("0"));
|
||||
termDocs = indexReader.termDocs(new Term("value", "0"));
|
||||
assertThat(termDocs.next(), equalTo(true));
|
||||
assertThat(termDocs.next(), equalTo(false));
|
||||
|
||||
doc = indexReader.document(1);
|
||||
assertThat(doc.getFieldable("value").stringValue(), equalTo("1"));
|
||||
termDocs = indexReader.termDocs(new Term("value", "1"));
|
||||
assertThat(termDocs.next(), equalTo(true));
|
||||
assertThat(termDocs.next(), equalTo(false));
|
||||
|
||||
doc = indexReader.document(2);
|
||||
assertThat(doc.getFieldable("value").stringValue(), equalTo("2"));
|
||||
termDocs = indexReader.termDocs(new Term("value", "2"));
|
||||
assertThat(termDocs.next(), equalTo(true));
|
||||
assertThat(termDocs.next(), equalTo(false));
|
||||
|
||||
doc = indexReader.document(3);
|
||||
assertThat(doc.getFieldable("value").stringValue(), equalTo("3"));
|
||||
termDocs = indexReader.termDocs(new Term("value", "3"));
|
||||
assertThat(termDocs.next(), equalTo(true));
|
||||
assertThat(termDocs.next(), equalTo(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimple() throws Exception {
|
||||
TermDocs termDocs;
|
||||
// open a versioned index reader in version 0
|
||||
VersionedIndexReader versionedIndexReader = new VersionedIndexReader(indexReader, 0, versionedMap);
|
||||
// delete doc 0 in version 1
|
||||
versionedMap.putVersion(0, 1);
|
||||
|
||||
// we can see doc 0 still (versioned reader is on version 0)
|
||||
termDocs = versionedIndexReader.termDocs(new Term("value", "0"));
|
||||
assertThat(termDocs.next(), equalTo(true));
|
||||
assertThat(termDocs.next(), equalTo(false));
|
||||
// make sure we see doc 1, it was never deleted
|
||||
termDocs = versionedIndexReader.termDocs(new Term("value", "1"));
|
||||
assertThat(termDocs.next(), equalTo(true));
|
||||
assertThat(termDocs.next(), equalTo(false));
|
||||
|
||||
// delete doc 1 in version 2, we still
|
||||
versionedMap.putVersion(1, 2);
|
||||
// we can see doc 0 still (versioned reader is on version 0)
|
||||
termDocs = versionedIndexReader.termDocs(new Term("value", "0"));
|
||||
assertThat(termDocs.next(), equalTo(true));
|
||||
// we can see doc 1 still (versioned reader is on version 0)
|
||||
termDocs = versionedIndexReader.termDocs(new Term("value", "1"));
|
||||
assertThat(termDocs.next(), equalTo(true));
|
||||
|
||||
// move the versioned reader to 1
|
||||
versionedIndexReader = new VersionedIndexReader(indexReader, 1, versionedMap);
|
||||
// we now can't see the deleted version 0
|
||||
termDocs = versionedIndexReader.termDocs(new Term("value", "0"));
|
||||
assertThat(termDocs.next(), equalTo(false));
|
||||
// we can still see deleted version 1
|
||||
termDocs = versionedIndexReader.termDocs(new Term("value", "1"));
|
||||
assertThat(termDocs.next(), equalTo(true));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue