proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
crate_crate | crate/server/src/main/java/org/elasticsearch/common/settings/Settings.java | FilteredMap | entrySet | class FilteredMap extends AbstractMap<String, Object> {
private final Map<String, Object> delegate;
private final Predicate<String> filter;
private final String prefix;
// we cache that size since we have to iterate the entire set
// this is safe to do since this map is only used... |
Set<Entry<String, Object>> delegateSet = delegate.entrySet();
return new AbstractSet<>() {
@Override
public Iterator<Entry<String, Object>> iterator() {
Iterator<Entry<String, Object>> iter = delegateSet.iterator();
retur... | 396 | 516 | 912 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/common/time/JavaDateFormatter.java | JavaDateFormatter | equals | class JavaDateFormatter implements DateFormatter {
private final String format;
private final DateTimeFormatter printer;
private final DateTimeFormatter[] parsers;
JavaDateFormatter(String format, DateTimeFormatter printer, DateTimeFormatter... parsers) {
if (printer == null) {
thr... |
if (obj.getClass().equals(this.getClass()) == false) {
return false;
}
JavaDateFormatter other = (JavaDateFormatter) obj;
return Objects.equals(format, other.format) &&
Objects.equals(getLocale(), other.getLocale()) &&
Objects.equals(this.print... | 1,239 | 104 | 1,343 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/common/transport/PortsRange.java | PortsRange | iterate | class PortsRange {
private final String portRange;
public PortsRange(String portRange) {
this.portRange = portRange;
}
public String getPortRangeString() {
return portRange;
}
public int[] ports() throws NumberFormatException {
final IntArrayList ports = new IntArrayL... |
StringTokenizer st = new StringTokenizer(portRange, ",");
boolean success = false;
while (st.hasMoreTokens() && !success) {
String portToken = st.nextToken().trim();
int index = portToken.indexOf('-');
if (index == -1) {
int portNumber = Integ... | 240 | 276 | 516 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/common/unit/Fuzziness.java | Fuzziness | parseCustomAuto | class Fuzziness {
public static final Fuzziness ZERO = new Fuzziness(0);
public static final Fuzziness ONE = new Fuzziness(1);
public static final Fuzziness TWO = new Fuzziness(2);
public static final Fuzziness AUTO = new Fuzziness("AUTO");
private static final int DEFAULT_LOW_DISTANCE = 3;
pri... |
assert string.toUpperCase(Locale.ROOT).startsWith(AUTO.asString() + ":");
String[] fuzzinessLimit = string.substring(AUTO.asString().length() + 1).split(",");
if (fuzzinessLimit.length == 2) {
try {
int lowerLimit = Integer.parseInt(fuzzinessLimit[0]);
... | 1,337 | 206 | 1,543 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/common/unit/SizeValue.java | SizeValue | toString | class SizeValue implements Writeable, Comparable<SizeValue> {
private final long size;
private final SizeUnit sizeUnit;
public SizeValue(long singles) {
this(singles, SizeUnit.SINGLE);
}
public SizeValue(long size, SizeUnit sizeUnit) {
if (size < 0) {
throw new Illegal... |
long singles = singles();
double value = singles;
String suffix = "";
if (singles >= SizeUnit.C5) {
value = petaFrac();
suffix = "p";
} else if (singles >= SizeUnit.C4) {
value = teraFrac();
suffix = "t";
} else if (singles... | 1,395 | 201 | 1,596 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/common/util/BigByteArray.java | BigByteArray | set | class BigByteArray extends AbstractBigArray implements ByteArray {
private static final BigByteArray ESTIMATOR = new BigByteArray(0, BigArrays.NON_RECYCLING_INSTANCE, false);
private byte[][] pages;
/** Constructor. */
BigByteArray(long size, BigArrays bigArrays, boolean clearOnResize) {
supe... |
assert index + len <= size();
int pageIndex = pageIndex(index);
final int indexInPage = indexInPage(index);
if (indexInPage + len <= pageSize()) {
System.arraycopy(buf, offset, pages[pageIndex], indexInPage, len);
} else {
int copyLen = pageSize() - index... | 1,195 | 189 | 1,384 | <methods>public final long ramBytesEstimated(long) ,public final long ramBytesUsed() ,public abstract void resize(long) ,public final long size() <variables>private V<?>[] cache,private final non-sealed int pageMask,private final non-sealed int pageShift,private final non-sealed org.elasticsearch.common.util.PageCacheR... |
crate_crate | crate/server/src/main/java/org/elasticsearch/common/util/BigObjectArray.java | BigObjectArray | resize | class BigObjectArray<T> extends AbstractBigArray implements ObjectArray<T> {
@SuppressWarnings("rawtypes")
private static final BigObjectArray ESTIMATOR = new BigObjectArray(0, BigArrays.NON_RECYCLING_INSTANCE);
private Object[][] pages;
/** Constructor. */
BigObjectArray(long size, BigArrays big... |
final int numPages = numPages(newSize);
if (numPages > pages.length) {
pages = Arrays.copyOf(pages, ArrayUtil.oversize(numPages, RamUsageEstimator.NUM_BYTES_OBJECT_REF));
}
for (int i = numPages - 1; i >= 0 && pages[i] == null; --i) {
pages[i] = newObjectPage(i);... | 509 | 169 | 678 | <methods>public final long ramBytesEstimated(long) ,public final long ramBytesUsed() ,public abstract void resize(long) ,public final long size() <variables>private V<?>[] cache,private final non-sealed int pageMask,private final non-sealed int pageShift,private final non-sealed org.elasticsearch.common.util.PageCacheR... |
crate_crate | crate/server/src/main/java/org/elasticsearch/common/util/CancellableThreads.java | CancellableThreads | add | class CancellableThreads {
private final Set<Thread> threads = new HashSet<>();
// needs to be volatile as it is also read outside of synchronized blocks.
private volatile boolean cancelled = false;
private final SetOnce<OnCancel> onCancel = new SetOnce<>();
private String reason;
public synch... |
checkForCancel();
threads.add(Thread.currentThread());
// capture and clean the interrupted thread before we start, so we can identify
// our own interrupt. we do so under lock so we know we don't clear our own.
return Thread.interrupted();
| 1,328 | 68 | 1,396 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/common/util/concurrent/AbstractAsyncTask.java | AbstractAsyncTask | run | class AbstractAsyncTask implements Runnable, Closeable {
private final Logger logger;
private final ThreadPool threadPool;
private final AtomicBoolean closed = new AtomicBoolean(false);
private final boolean autoReschedule;
private volatile Scheduler.Cancellable cancellable;
private volatile bo... |
synchronized (this) {
cancellable = null;
isScheduledOrRunning = autoReschedule;
}
try {
runInternal();
} catch (Exception ex) {
if (lastThrownException == null || sameException(lastThrownException, ex) == false) {
// preve... | 1,070 | 198 | 1,268 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/common/util/concurrent/AbstractLifecycleRunnable.java | AbstractLifecycleRunnable | doRun | class AbstractLifecycleRunnable extends AbstractRunnable {
/**
* The monitored lifecycle for the associated service.
*/
private final Lifecycle lifecycle;
/**
* The service's logger (note: this is passed in!).
*/
private final Logger logger;
/**
* {@link AbstractLifecycleRu... |
// prevent execution if the service is stopped
if (lifecycle.stoppedOrClosed()) {
logger.trace("lifecycle is stopping. exiting");
return;
}
doRunInLifecycle();
| 750 | 63 | 813 | <methods>public non-sealed void <init>() ,public boolean isForceExecution() ,public void onAfter() ,public abstract void onFailure(java.lang.Exception) ,public void onRejection(java.lang.Exception) ,public final void run() <variables> |
crate_crate | crate/server/src/main/java/org/elasticsearch/common/util/concurrent/AbstractRefCounted.java | AbstractRefCounted | tryIncRef | class AbstractRefCounted implements RefCounted {
private final AtomicInteger refCount = new AtomicInteger(1);
private final String name;
public AbstractRefCounted(String name) {
this.name = name;
}
@Override
public final void incRef() {
if (tryIncRef() == false) {
a... |
do {
int i = refCount.get();
if (i > 0) {
if (refCount.compareAndSet(i, i + 1)) {
return true;
}
} else {
return false;
}
} while (true);
| 306 | 72 | 378 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/common/util/concurrent/EsAbortPolicy.java | EsAbortPolicy | rejectedExecution | class EsAbortPolicy implements XRejectedExecutionHandler {
private final CounterMetric rejected = new CounterMetric();
@Override
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {<FILL_FUNCTION_BODY>}
@Override
public long rejected() {
return rejected.count();
}
} |
if (r instanceof AbstractRunnable) {
if (((AbstractRunnable) r).isForceExecution()) {
BlockingQueue<Runnable> queue = executor.getQueue();
if (!(queue instanceof SizeBlockingQueue)) {
throw new IllegalStateException("forced execution, but expected... | 89 | 191 | 280 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/common/util/concurrent/FutureUtils.java | FutureUtils | cancel | class FutureUtils {
/**
* Cancel execution of this future without interrupting a running thread. See {@link Future#cancel(boolean)} for details.
*
* @param toCancel the future to cancel
* @return false if the future could not be cancelled, otherwise true
*/
@SuppressForbidden(reason = ... |
if (toCancel != null) {
return toCancel.cancel(false); // this method is a forbidden API since it interrupts threads
}
return false;
| 578 | 46 | 624 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/common/util/concurrent/ReleasableLock.java | ReleasableLock | removeCurrentThread | class ReleasableLock implements Releasable {
private final Lock lock;
// a per-thread count indicating how many times the thread has entered the lock; only works if assertions are enabled
private final ThreadLocal<Integer> holdingThreads;
public ReleasableLock(Lock lock) {
this.lock = lock;
... |
final Integer count = holdingThreads.get();
assert count != null && count > 0;
if (count == 1) {
holdingThreads.remove();
} else {
holdingThreads.set(count - 1);
}
return true;
| 411 | 70 | 481 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/common/util/concurrent/SizeBlockingQueue.java | SizeBlockingQueue | poll | class SizeBlockingQueue<E> extends AbstractQueue<E> implements BlockingQueue<E> {
private final BlockingQueue<E> queue;
private final int capacity;
private final AtomicInteger size = new AtomicInteger();
public SizeBlockingQueue(BlockingQueue<E> queue, int capacity) {
assert capacity >= 0;
... |
E e = queue.poll(timeout, unit);
if (e != null) {
size.decrementAndGet();
}
return e;
| 1,140 | 45 | 1,185 | <methods>public boolean add(E) ,public boolean addAll(Collection<? extends E>) ,public void clear() ,public E element() ,public E remove() <variables> |
crate_crate | crate/server/src/main/java/org/elasticsearch/discovery/DiscoveryStats.java | DiscoveryStats | toXContent | class DiscoveryStats implements Writeable, ToXContentFragment {
private final PendingClusterStateStats queueStats;
private final PublishClusterStateStats publishStats;
public DiscoveryStats(PendingClusterStateStats queueStats, PublishClusterStateStats publishStats) {
this.queueStats = queueStats;
... |
builder.startObject(Fields.DISCOVERY);
if (queueStats != null) {
queueStats.toXContent(builder, params);
}
if (publishStats != null) {
publishStats.toXContent(builder, params);
}
builder.endObject();
return builder;
| 307 | 84 | 391 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/discovery/HandshakingTransportAddressConnector.java | HandshakingTransportAddressConnector | onResponse | class HandshakingTransportAddressConnector implements TransportAddressConnector {
private static final Logger LOGGER = LogManager.getLogger(HandshakingTransportAddressConnector.class);
// connection timeout for probes
public static final Setting<TimeValue> PROBE_CONNECT_TIMEOUT_SETTING =
Setting.t... |
LOGGER.trace("[{}] opened probe connection", thisConnectionAttempt);
// use NotifyOnceListener to make sure the following line does not result in onFailure being called when
// the connection is closed in the onResponse handler
... | 747 | 734 | 1,481 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/env/ESFileStore.java | ESFileStore | getTotalSpace | class ESFileStore extends FileStore {
/** Underlying filestore */
final FileStore in;
private int majorDeviceNumber;
private int minorDeviceNumber;
@SuppressForbidden(reason = "tries to determine if disk is spinning")
// TODO: move PathUtils to be package-private here instead of
// public+f... |
long result = in.getTotalSpace();
if (result < 0) {
// see https://bugs.openjdk.java.net/browse/JDK-8162520:
result = Long.MAX_VALUE;
}
return result;
| 958 | 71 | 1,029 | <methods>public abstract java.lang.Object getAttribute(java.lang.String) throws java.io.IOException,public long getBlockSize() throws java.io.IOException,public abstract V getFileStoreAttributeView(Class<V>) ,public abstract long getTotalSpace() throws java.io.IOException,public abstract long getUnallocatedSpace() thro... |
crate_crate | crate/server/src/main/java/org/elasticsearch/gateway/GatewayAllocator.java | InternalPrimaryShardAllocator | fetchData | class InternalPrimaryShardAllocator extends PrimaryShardAllocator {
private final NodeClient client;
InternalPrimaryShardAllocator(NodeClient client) {
this.client = client;
}
@Override
protected AsyncShardFetch.FetchResult<NodeGatewayStartedShards> fetchData(Shard... |
// explicitely type lister, some IDEs (Eclipse) are not able to correctly infer the function type
Lister<BaseNodesResponse<NodeGatewayStartedShards>, NodeGatewayStartedShards> lister = this::listStartedShards;
AsyncShardFetch<NodeGatewayStartedShards> fetch = asyncFetchStarted.compu... | 219 | 265 | 484 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/gateway/TransportNodesListGatewayMetaState.java | NodeGatewayMetaState | writeTo | class NodeGatewayMetaState extends BaseNodeResponse {
@Nullable
private final Metadata metadata;
public NodeGatewayMetaState(DiscoveryNode node, Metadata metadata) {
super(node);
this.metadata = metadata;
}
public NodeGatewayMetaState(StreamInput in) th... |
super.writeTo(out);
if (metadata == null) {
out.writeBoolean(false);
} else {
out.writeBoolean(true);
metadata.writeTo(out);
}
| 182 | 56 | 238 | <methods><variables>protected final non-sealed org.elasticsearch.cluster.service.ClusterService clusterService,protected final non-sealed Class<org.elasticsearch.gateway.TransportNodesListGatewayMetaState.NodeGatewayMetaState> nodeResponseClass,protected final non-sealed org.elasticsearch.threadpool.ThreadPool threadPo... |
crate_crate | crate/server/src/main/java/org/elasticsearch/gateway/WriteStateException.java | WriteStateException | rethrowAsErrorOrUncheckedException | class WriteStateException extends IOException {
private final boolean dirty;
WriteStateException(boolean dirty, String message, Exception cause) {
super(message, cause);
this.dirty = dirty;
}
/**
* If this method returns false, state is guaranteed to be not written to disk.
*... |
if (isDirty()) {
throw new IOError(this);
} else {
throw new UncheckedIOException(this);
}
| 207 | 40 | 247 | <methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.Throwable) ,public void <init>(java.lang.String, java.lang.Throwable) <variables>static final long serialVersionUID |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/analysis/CustomNormalizerProvider.java | CustomNormalizerProvider | build | class CustomNormalizerProvider extends AbstractIndexAnalyzerProvider<CustomAnalyzer> {
private final Settings analyzerSettings;
private CustomAnalyzer customAnalyzer;
public CustomNormalizerProvider(IndexSettings indexSettings,
String name, Settings settings) {
... |
if (analyzerSettings.get("tokenizer") != null) {
throw new IllegalArgumentException("Custom normalizer [" + name() + "] cannot configure a tokenizer");
}
List<String> charFilterNames = analyzerSettings.getAsList("char_filter");
List<CharFilterFactory> charFiltersList = new ... | 178 | 552 | 730 | <methods>public void <init>(org.elasticsearch.index.IndexSettings, java.lang.String, org.elasticsearch.common.settings.Settings) ,public final java.lang.String name() ,public final org.elasticsearch.index.analysis.AnalyzerScope scope() <variables>private final non-sealed java.lang.String name,protected final non-sealed... |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/analysis/IndexAnalyzers.java | IndexAnalyzers | close | class IndexAnalyzers extends AbstractIndexComponent implements Closeable {
private final NamedAnalyzer defaultIndexAnalyzer;
private final NamedAnalyzer defaultSearchAnalyzer;
private final NamedAnalyzer defaultSearchQuoteAnalyzer;
private final Map<String, NamedAnalyzer> analyzers;
private final Ma... |
IOUtils.close(() -> Stream.concat(analyzers.values().stream(), normalizers.values().stream())
.filter(a -> a.scope() == AnalyzerScope.INDEX).iterator());
| 654 | 52 | 706 | <methods>public org.elasticsearch.index.IndexSettings getIndexSettings() ,public org.elasticsearch.index.Index index() <variables>protected final non-sealed org.elasticsearch.common.logging.DeprecationLogger deprecationLogger,protected final non-sealed org.elasticsearch.index.IndexSettings indexSettings,protected final... |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/analysis/PreConfiguredAnalysisComponent.java | PreConfiguredAnalysisComponent | get | class PreConfiguredAnalysisComponent<T> implements AnalysisModule.AnalysisProvider<T> {
private final String name;
protected final PreBuiltCacheFactory.PreBuiltCache<T> cache;
protected PreConfiguredAnalysisComponent(String name, PreBuiltCacheFactory.CachingStrategy cache) {
this.name = name;
... |
Version versionCreated = Version.indexCreated(settings);
synchronized (this) {
T factory = cache.get(versionCreated);
if (factory == null) {
factory = create(versionCreated);
cache.put(versionCreated, factory);
}
return fac... | 239 | 76 | 315 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/analysis/PreConfiguredCharFilter.java | PreConfiguredCharFilter | create | class PreConfiguredCharFilter extends PreConfiguredAnalysisComponent<CharFilterFactory> {
/**
* Create a pre-configured char filter that may not vary at all.
*/
public static PreConfiguredCharFilter singleton(String name, boolean useFilterForMultitermQueries, UnaryOperator<Reader> create) {
r... |
if (useFilterForMultitermQueries) {
return new MultiTermAwareCharFilterFactory() {
@Override
public String name() {
return getName();
}
@Override
public Reader create(Reader reader) {
... | 757 | 169 | 926 | <methods>public org.elasticsearch.index.analysis.CharFilterFactory get(org.elasticsearch.index.IndexSettings, org.elasticsearch.env.Environment, java.lang.String, org.elasticsearch.common.settings.Settings) throws java.io.IOException,public java.lang.String getName() <variables>protected final non-sealed PreBuiltCache<... |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java | Factory | create | class Factory implements TokenFilterFactory {
private final int maxShingleSize;
private final boolean outputUnigrams;
private final boolean outputUnigramsIfNoShingles;
private final String tokenSeparator;
private final String fillerToken;
private int minShingleSize;
... |
ShingleFilter filter = new ShingleFilter(tokenStream, minShingleSize, maxShingleSize);
filter.setOutputUnigrams(outputUnigrams);
filter.setOutputUnigramsIfNoShingles(outputUnigramsIfNoShingles);
filter.setTokenSeparator(tokenSeparator);
filter.setFillerToken(... | 483 | 213 | 696 | <methods>public void <init>(org.elasticsearch.index.IndexSettings, java.lang.String, org.elasticsearch.common.settings.Settings) ,public java.lang.String name() ,public final Version version() <variables>private final non-sealed java.lang.String name,protected final non-sealed Version version |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/engine/CombinedDocValues.java | CombinedDocValues | docVersion | class CombinedDocValues {
private final NumericDocValues versionDV;
private final NumericDocValues seqNoDV;
private final NumericDocValues primaryTermDV;
private final NumericDocValues tombstoneDV;
private final NumericDocValues recoverySource;
CombinedDocValues(LeafReader leafReader) throws IO... |
assert versionDV.docID() < segmentDocId;
if (versionDV.advanceExact(segmentDocId) == false) {
assert false : "DocValues for field [" + DocSysColumns.VERSION.name() + "] is not found";
throw new IllegalStateException("DocValues for field [" + DocSysColumns.VERSION.name() + "] is ... | 773 | 111 | 884 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/engine/CommitStats.java | CommitStats | writeTo | class CommitStats implements Writeable {
private final Map<String, String> userData;
private final long generation;
private final String id; // lucene commit id in base 64;
private final int numDocs;
public CommitStats(SegmentInfos segmentInfos) {
// clone the map to protect against concur... |
out.writeVInt(userData.size());
for (Map.Entry<String, String> entry : userData.entrySet()) {
out.writeString(entry.getKey());
out.writeString(entry.getValue());
}
out.writeLong(generation);
out.writeOptionalString(id);
out.writeInt(numDocs);
| 564 | 94 | 658 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/engine/DeleteVersionValue.java | DeleteVersionValue | equals | class DeleteVersionValue extends VersionValue {
private static final long BASE_RAM_BYTES_USED = RamUsageEstimator.shallowSizeOfInstance(DeleteVersionValue.class);
final long time;
DeleteVersionValue(long version,long seqNo, long term, long time) {
super(version, seqNo, term);
this.time = ... |
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
DeleteVersionValue that = (DeleteVersionValue) o;
return time == that.time;
| 306 | 73 | 379 | <methods>public boolean equals(java.lang.Object) ,public Collection<Accountable> getChildResources() ,public org.elasticsearch.index.translog.Translog.Location getLocation() ,public int hashCode() ,public boolean isDelete() ,public long ramBytesUsed() ,public java.lang.String toString() <variables>private static final ... |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/engine/IndexVersionValue.java | IndexVersionValue | equals | class IndexVersionValue extends VersionValue {
private static final long RAM_BYTES_USED = RamUsageEstimator.shallowSizeOfInstance(IndexVersionValue.class);
private final Translog.Location translogLocation;
IndexVersionValue(Translog.Location translogLocation, long version, long seqNo, long term) {
... |
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
IndexVersionValue that = (IndexVersionValue) o;
return Objects.equals(translogLocation, that.translogLocation);
| 314 | 80 | 394 | <methods>public boolean equals(java.lang.Object) ,public Collection<Accountable> getChildResources() ,public org.elasticsearch.index.translog.Translog.Location getLocation() ,public int hashCode() ,public boolean isDelete() ,public long ramBytesUsed() ,public java.lang.String toString() <variables>private static final ... |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/engine/TranslogLeafReader.java | TranslogLeafReader | docFromOperation | class TranslogLeafReader extends LeafReader {
private final Translog.Index operation;
private static final FieldInfo FAKE_SOURCE_FIELD
= new FieldInfo(SourceFieldMapper.NAME, 1, false, false, false, IndexOptions.NONE, DocValuesType.NONE, -1, Collections.emptyMap(),
0, 0, 0, 0, VectorEncoding.BY... |
if (docID != 0) {
throw new IllegalArgumentException("no such doc ID " + docID);
}
if (visitor.needsField(FAKE_SOURCE_FIELD) == StoredFieldVisitor.Status.YES) {
assert operation.getSource().toBytesRef().offset == 0;
assert operation.getSource().toBytesRef().l... | 1,133 | 189 | 1,322 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/engine/VersionValue.java | VersionValue | toString | class VersionValue implements Accountable {
private static final long BASE_RAM_BYTES_USED = RamUsageEstimator.shallowSizeOfInstance(VersionValue.class);
/** the version of the document. used for versioned indexed operations and as a BWC layer, where no seq# are set yet */
final long version;
/** the ... |
return "VersionValue{" +
"version=" + version +
", seqNo=" + seqNo +
", term=" + term +
'}';
| 538 | 47 | 585 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/mapper/ArrayTypeParser.java | ArrayTypeParser | parse | class ArrayTypeParser implements Mapper.TypeParser {
@Override
public Mapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {<FILL_FUNCTION_BODY>}
} |
Object inner = node.remove(ArrayMapper.INNER_TYPE);
if (inner == null) {
throw new MapperParsingException("property [inner] missing");
}
if (!(inner instanceof Map)) {
throw new MapperParsingException("property [inner] must be a map");
}
@Suppress... | 65 | 260 | 325 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/mapper/FieldNamesFieldMapper.java | FieldNamesFieldType | parseCreateField | class FieldNamesFieldType extends MappedFieldType {
private boolean enabled = Defaults.ENABLED;
public FieldNamesFieldType() {
super(Defaults.NAME, true, false);
}
@Override
public String typeName() {
return CONTENT_TYPE;
}
public void ... |
if (fieldType().isEnabled() == false) {
return;
}
Document document = context.doc();
final List<String> paths = new ArrayList<>(document.getFields().size());
String previousPath = ""; // used as a sentinel - field names can't be empty
for (IndexableField fiel... | 557 | 285 | 842 | <methods>public void postParse(org.elasticsearch.index.mapper.ParseContext) throws java.io.IOException,public abstract void preParse(org.elasticsearch.index.mapper.ParseContext) throws java.io.IOException<variables> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/mapper/Mapping.java | Mapping | toXContent | class Mapping implements ToXContentFragment {
final Version indexCreated;
final RootObjectMapper root;
final MetadataFieldMapper[] metadataMappers;
final Map<Class<? extends MetadataFieldMapper>, MetadataFieldMapper> metadataMappersMap;
final Map<String, Object> meta;
public Mapping(Version in... |
root.toXContent(builder, params, new ToXContent() {
@Override
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
if (meta != null) {
builder.field("_meta", meta);
}
for (Mappe... | 967 | 117 | 1,084 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/mapper/ParseContext.java | InternalParseContext | createCopyToContext | class InternalParseContext extends ParseContext {
private final DocumentMapper docMapper;
private final DocumentMapperParser docMapperParser;
private final ContentPath path;
private final XContentParser parser;
private final Document document;
private final IndexSet... |
return new FilterParseContext(this) {
@Override
public boolean isWithinCopyTo() {
return true;
}
};
| 582 | 40 | 622 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/mapper/ParsedDocument.java | ParsedDocument | toString | class ParsedDocument {
private final Field version;
private final String id;
private final SequenceIDFields seqID;
private final Document document;
private final BytesReference source;
private final Mapping dynamicMappingsUpdate;
public ParsedDocument(Field version,
... |
return "Document id[" + id + "] doc [" + document + ']';
| 503 | 23 | 526 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/recovery/RecoveryStats.java | RecoveryStats | toString | class RecoveryStats {
private final AtomicInteger currentAsSource = new AtomicInteger();
private final AtomicInteger currentAsTarget = new AtomicInteger();
private final AtomicLong throttleTimeInNanos = new AtomicLong();
public RecoveryStats() {
}
public void add(RecoveryStats recoveryStats) ... |
return "recoveryStats, currentAsSource [" + currentAsSource() + "],currentAsTarget ["
+ currentAsTarget() + "], throttle [" + throttleTime() + "]";
| 532 | 51 | 583 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/search/MultiMatchQuery.java | CrossFieldsQueryBuilder | blendTerms | class CrossFieldsQueryBuilder extends QueryBuilder {
private FieldAndFieldType[] blendedFields;
CrossFieldsQueryBuilder(float tiebreaker) {
super(tiebreaker);
}
@Override
public List<Query> buildGroupedQueries(MultiMatchQueryType type, Map<String, Float> fieldNames,... |
List<Query> queries = new ArrayList<>();
Term[] terms = new Term[blendedFields.length * values.length];
float[] blendedBoost = new float[blendedFields.length * values.length];
int i = 0;
for (FieldAndFieldType ft : blendedFields) {
for (BytesRef term : values) {
... | 1,168 | 635 | 1,803 | <methods>public void <init>(org.elasticsearch.index.query.QueryShardContext) ,public Query parse(org.elasticsearch.index.search.MatchQuery.Type, java.lang.String, java.lang.Object) ,public void setAnalyzer(java.lang.String) ,public void setAnalyzer(Analyzer) ,public void setAutoGenerateSynonymsPhraseQuery(boolean) ,pub... |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/seqno/SequenceNumbers.java | SequenceNumbers | loadSeqNoInfoFromLuceneCommit | class SequenceNumbers {
public static final String LOCAL_CHECKPOINT_KEY = "local_checkpoint";
public static final String MAX_SEQ_NO = "max_seq_no";
/**
* Represents an unassigned sequence number (e.g., can be used on primary operations before they are executed).
*/
public static final long UN... |
long maxSeqNo = NO_OPS_PERFORMED;
long localCheckpoint = NO_OPS_PERFORMED;
for (final Map.Entry<String, String> entry : commitData) {
final String key = entry.getKey();
if (key.equals(SequenceNumbers.LOCAL_CHECKPOINT_KEY)) {
assert localCheckpoint == NO_... | 1,117 | 207 | 1,324 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/shard/PrimaryReplicaSyncer.java | SnapshotSender | doRun | class SnapshotSender extends AbstractRunnable implements ActionListener<ReplicationResponse> {
private final SyncAction syncAction;
private final ResyncTask task; // to track progress
private final String primaryAllocationId;
private final long primaryTerm;
private final ShardId ... |
long size = 0;
final List<Translog.Operation> operations = new ArrayList<>();
task.setPhase("collecting_ops");
task.setResyncedOperations(totalSentOps.get());
task.setSkippedOperations(totalSkippedOps.get());
Translog.Operation operation;
... | 578 | 594 | 1,172 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/shard/ReplicationGroup.java | ReplicationGroup | hashCode | class ReplicationGroup {
private final IndexShardRoutingTable routingTable;
private final Set<String> inSyncAllocationIds;
private final Set<String> trackedAllocationIds;
private final long version;
private final Set<String> unavailableInSyncShards; // derived from the other fields
private fina... |
int result = routingTable.hashCode();
result = 31 * result + inSyncAllocationIds.hashCode();
result = 31 * result + trackedAllocationIds.hashCode();
return result;
| 1,120 | 55 | 1,175 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/shard/ShardId.java | ShardId | computeHashCode | class ShardId implements Writeable, Comparable<ShardId> {
private final Index index;
private final int shardId;
private final int hashCode;
public ShardId(Index index, int shardId) {
this.index = index;
this.shardId = shardId;
this.hashCode = computeHashCode();
}
publi... |
int result = index != null ? index.hashCode() : 0;
result = 31 * result + shardId;
return result;
| 569 | 40 | 609 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/shard/ShardUtils.java | ShardUtils | extractShardId | class ShardUtils {
private ShardUtils() {
}
/**
* Tries to extract the shard id from a reader if possible, when its not possible,
* will return null.
*/
@Nullable
public static ShardId extractShardId(LeafReader reader) {
final ElasticsearchLeafReader esReader = Elasticsearch... |
final ElasticsearchDirectoryReader esReader = ElasticsearchDirectoryReader.getElasticsearchDirectoryReader(reader);
if (esReader != null) {
return esReader.shardId();
}
throw new IllegalArgumentException("can't extract shard ID, can't unwrap ElasticsearchDirectoryReader");
... | 234 | 79 | 313 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/RateLimitingInputStream.java | RateLimitingInputStream | read | class RateLimitingInputStream extends FilterInputStream {
private final Supplier<RateLimiter> rateLimiterSupplier;
private final Listener listener;
private long bytesSinceLastRateLimit;
public interface Listener {
void onPause(long nanos);
}
public RateLimitingInputStream(InputStrea... |
int n = super.read(b, off, len);
if (n > 0) {
maybePause(n);
}
return n;
| 365 | 43 | 408 | <methods>public int available() throws java.io.IOException,public void close() throws java.io.IOException,public synchronized void mark(int) ,public boolean markSupported() ,public int read() throws java.io.IOException,public int read(byte[]) throws java.io.IOException,public int read(byte[], int, int) throws java.io.I... |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/snapshots/blobstore/SnapshotFiles.java | SnapshotFiles | findPhysicalIndexFile | class SnapshotFiles {
private final String snapshot;
private final List<FileInfo> indexFiles;
@Nullable
private final String shardStateIdentifier;
private Map<String, FileInfo> physicalFiles = null;
/**
* Returns snapshot name
*
* @return snapshot name
*/
public Stri... |
if (physicalFiles == null) {
Map<String, FileInfo> files = new HashMap<>();
for (FileInfo fileInfo : indexFiles) {
files.put(fileInfo.physicalName(), fileInfo);
}
this.physicalFiles = files;
}
return physicalFiles.get(physicalName)... | 467 | 83 | 550 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/store/ByteSizeCachingDirectory.java | SizeAndModCount | wrapIndexOutput | class SizeAndModCount {
final long size;
final long modCount;
final boolean pendingWrite;
SizeAndModCount(long length, long modCount, boolean pendingWrite) {
this.size = length;
this.modCount = modCount;
this.pendingWrite = pendingWrite;
}
... |
synchronized (this) {
numOpenOutputs++;
}
return new FilterIndexOutput(out.toString(), out) {
@Override
public void writeBytes(byte[] b, int length) throws IOException {
// Don't write to atomicXXX here since it might be called in
... | 974 | 256 | 1,230 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/store/StoreStats.java | StoreStats | add | class StoreStats implements Writeable, ToXContentFragment {
/**
* Sentinel value for cases where the shard does not yet know its reserved size so we must fall back to an estimate, for instance
* prior to receiving the list of files in a peer recovery.
*/
public static final long UNKNOWN_RESERVED... |
if (stats == null) {
return;
}
sizeInBytes += stats.sizeInBytes;
reservedSize = ignoreIfUnknown(reservedSize) + ignoreIfUnknown(stats.reservedSize);
| 913 | 55 | 968 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/translog/BufferedChecksumStreamInput.java | BufferedChecksumStreamInput | readShort | class BufferedChecksumStreamInput extends FilterStreamInput {
private static final int SKIP_BUFFER_SIZE = 1024;
private static final ThreadLocal<byte[]> BUFFER = ThreadLocal.withInitial(() -> new byte[8]);
private byte[] skipBuffer;
private final Checksum digest;
private final String source;
... |
final byte[] buf = BUFFER.get();
readBytes(buf, 0, 2);
return (short) (((buf[0] & 0xFF) << 8) | (buf[1] & 0xFF));
| 1,011 | 61 | 1,072 | <methods>public int available() throws java.io.IOException,public void close() throws java.io.IOException,public org.elasticsearch.Version getVersion() ,public int read() throws java.io.IOException,public byte readByte() throws java.io.IOException,public void readBytes(byte[], int, int) throws java.io.IOException,publi... |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/translog/MultiSnapshot.java | SeqNoSet | getAndSet | class SeqNoSet {
static final short BIT_SET_SIZE = 1024;
private final LongObjectHashMap<CountedBitSet> bitSets = new LongObjectHashMap<>();
/**
* Marks this sequence number and returns {@code true} if it is seen before.
*/
boolean getAndSet(long value) {<FILL_FUNCTION... |
assert value >= 0;
final long key = value / BIT_SET_SIZE;
CountedBitSet bitset = bitSets.get(key);
if (bitset == null) {
bitset = new CountedBitSet(BIT_SET_SIZE);
bitSets.put(key, bitset);
}
final int index = Math.t... | 102 | 136 | 238 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/translog/TranslogCorruptedException.java | TranslogCorruptedException | corruptedMessage | class TranslogCorruptedException extends ElasticsearchException {
public TranslogCorruptedException(String source, String details) {
super(corruptedMessage(source, details));
}
public TranslogCorruptedException(String source, Throwable cause) {
this(source, null, cause);
}
public T... |
String msg = "translog from source [" + source + "] is corrupted";
if (details != null) {
msg += ", " + details;
}
return msg;
| 172 | 50 | 222 | <methods>public void <init>(java.lang.Throwable) ,public transient void <init>(java.lang.String, java.lang.Object[]) ,public transient void <init>(java.lang.String, java.lang.Throwable, java.lang.Object[]) ,public void <init>(org.elasticsearch.common.io.stream.StreamInput) throws java.io.IOException,public void addHead... |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/translog/TranslogReader.java | TranslogReader | open | class TranslogReader extends BaseTranslogReader implements Closeable {
protected final long length;
private final int totalOperations;
private final Checkpoint checkpoint;
protected final AtomicBoolean closed = new AtomicBoolean(false);
/**
* Create a translog writer against the specified tran... |
final TranslogHeader header = TranslogHeader.read(translogUUID, path, channel);
return new TranslogReader(checkpoint, channel, path, header);
| 1,131 | 42 | 1,173 | <methods>public void <init>(long, java.nio.channels.FileChannel, java.nio.file.Path, org.elasticsearch.index.translog.TranslogHeader) ,public int compareTo(org.elasticsearch.index.translog.BaseTranslogReader) ,public final long getFirstOperationOffset() ,public long getGeneration() ,public long getLastModifiedTime() th... |
crate_crate | crate/server/src/main/java/org/elasticsearch/index/translog/TranslogStats.java | TranslogStats | toString | class TranslogStats {
private final long translogSizeInBytes;
private final int numberOfOperations;
private final long uncommittedSizeInBytes;
private final int uncommittedOperations;
public TranslogStats(int numberOfOperations,
long translogSizeInBytes,
... |
return "TranslogStats{" +
"translogSizeInBytes=" + translogSizeInBytes +
", numberOfOperations=" + numberOfOperations +
", uncommittedSizeInBytes=" + uncommittedSizeInBytes +
", uncommittedOperations=" + uncommittedOperations +
'}';
... | 467 | 85 | 552 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/indices/IndicesModule.java | IndicesModule | getEngineFactories | class IndicesModule extends AbstractModule {
private final MapperRegistry mapperRegistry;
public IndicesModule(List<MapperPlugin> mapperPlugins) {
this.mapperRegistry = new MapperRegistry(getMappers(mapperPlugins), getMetadataMappers(mapperPlugins));
}
public static List<NamedWriteableRegistry... |
return List.of(
indexSettings -> {
if (indexSettings.getSettings().get(LogicalReplicationSettings.REPLICATION_SUBSCRIPTION_NAME.getKey()) != null) {
return Optional.of(SubscriberEngine::new);
}
return Optional.empty();
... | 1,679 | 83 | 1,762 | <methods>public non-sealed void <init>() ,public final synchronized void configure(org.elasticsearch.common.inject.Binder) <variables>org.elasticsearch.common.inject.Binder binder |
crate_crate | crate/server/src/main/java/org/elasticsearch/indices/ShardLimitValidator.java | ShardLimitValidator | checkShardLimit | class ShardLimitValidator {
public static final Setting<Integer> SETTING_CLUSTER_MAX_SHARDS_PER_NODE =
Setting.intSetting("cluster.max_shards_per_node", 1000, 1, Property.Dynamic, Property.NodeScope, Property.Exposed);
protected final AtomicInteger shardLimitPerNode = new AtomicInteger();
public Sh... |
int nodeCount = state.nodes().getDataNodes().size();
// Only enforce the shard limit if we have at least one data node, so that we don't block
// index creation during cluster setup
if (nodeCount == 0 || newShards < 0) {
return Optional.empty();
}
int maxSha... | 787 | 229 | 1,016 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/indices/breaker/BreakerSettings.java | BreakerSettings | toString | class BreakerSettings {
private final String name;
private final long limitBytes;
private final CircuitBreaker.Type type;
public BreakerSettings(String name, long limitBytes, CircuitBreaker.Type type) {
this.name = name;
this.limitBytes = limitBytes;
this.type = type;
}
... |
return "[" + this.name +
",type=" + this.type.toString() +
",limit=" + this.limitBytes + "/" + new ByteSizeValue(this.limitBytes) + "]";
| 174 | 56 | 230 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/indices/breaker/CircuitBreakerStats.java | CircuitBreakerStats | toString | class CircuitBreakerStats {
private final String name;
private final long limit;
private final long used;
private final long trippedCount;
private final double overhead;
@ConstructorProperties({"name", "limit", "used", "trippedCount", "overhead"})
public CircuitBreakerStats(String name,
... |
return "[" + this.name +
",limit=" + this.limit + "/" + new ByteSizeValue(this.limit) +
",estimated=" + this.used + "/" + new ByteSizeValue(this.used) +
",overhead=" + this.overhead + ",tripped=" + this.trippedCount + "]";
| 335 | 92 | 427 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/indices/recovery/BlobRecoveryTarget.java | StartTransferRequestHandler | messageReceived | class StartTransferRequestHandler implements TransportRequestHandler<BlobRecoveryStartTransferRequest> {
@Override
public void messageReceived(BlobRecoveryStartTransferRequest request, TransportChannel channel) throws Exception {<FILL_FUNCTION_BODY>}
} |
BlobRecoveryStatus status = onGoingBlobRecoveries.get(request.recoveryId());
LOGGER.debug("received BlobRecoveryStartTransferRequest for file {} with size {}",
request.path(), request.size());
if (status == null) {
throw new IllegalBlobRecove... | 66 | 395 | 461 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/indices/recovery/MultiChunkTransfer.java | MultiChunkTransfer | handleItems | class MultiChunkTransfer<Source, Request extends MultiChunkTransfer.ChunkRequest> implements Closeable {
private Status status = Status.PROCESSING;
private final Logger logger;
private final ActionListener<Void> listener;
private final LocalCheckpointTracker requestSeqIdTracker = new LocalCheckpointTrac... |
if (status != Status.PROCESSING) {
assert status == Status.FAILED : "must not receive any response after the transfer was completed";
// These exceptions will be ignored as we record only the first failure, log them for debugging purpose.
items.stream().filter(item -> item.v... | 1,087 | 598 | 1,685 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/indices/recovery/RecoveryFilesInfoRequest.java | RecoveryFilesInfoRequest | writeTo | class RecoveryFilesInfoRequest extends RecoveryTransportRequest {
private final long recoveryId;
private final ShardId shardId;
final List<String> phase1FileNames;
final List<Long> phase1FileSizes;
final List<String> phase1ExistingFileNames;
final List<Long> phase1ExistingFileSizes;
int t... |
super.writeTo(out);
out.writeLong(recoveryId);
shardId.writeTo(out);
out.writeVInt(phase1FileNames.size());
for (String phase1FileName : phase1FileNames) {
out.writeString(phase1FileName);
}
out.writeVInt(phase1FileSizes.size());
for (Long p... | 688 | 254 | 942 | <methods>public long requestSeqNo() ,public void writeTo(org.elasticsearch.common.io.stream.StreamOutput) throws java.io.IOException<variables>private final non-sealed long requestSeqNo |
crate_crate | crate/server/src/main/java/org/elasticsearch/indices/recovery/RecoverySourceHandler.java | FileChunk | sendFiles | class FileChunk implements MultiChunkTransfer.ChunkRequest, Releasable {
final StoreFileMetadata md;
final BytesReference content;
final long position;
final boolean lastChunk;
final Releasable onClose;
FileChunk(StoreFileMetadata md, BytesReference content, long positio... |
ArrayUtil.timSort(files, Comparator.comparingLong(StoreFileMetadata::length)); // send smallest first
final MultiChunkTransfer<StoreFileMetadata, FileChunk> multiFileSender = new MultiChunkTransfer<StoreFileMetadata, FileChunk>(
logger, listener, maxConcurrentFileChunks, Arrays.asList(file... | 236 | 728 | 964 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/indices/recovery/StartRecoveryRequest.java | StartRecoveryRequest | writeTo | class StartRecoveryRequest extends TransportRequest {
private final long recoveryId;
private final ShardId shardId;
private final String targetAllocationId;
private final DiscoveryNode sourceNode;
private final DiscoveryNode targetNode;
private final Store.MetadataSnapshot metadataSnapshot;
... |
super.writeTo(out);
out.writeLong(recoveryId);
shardId.writeTo(out);
out.writeString(targetAllocationId);
sourceNode.writeTo(out);
targetNode.writeTo(out);
metadataSnapshot.writeTo(out);
out.writeBoolean(primaryRelocation);
out.writeLong(startingS... | 777 | 100 | 877 | <methods>public void <init>() ,public void <init>(org.elasticsearch.common.io.stream.StreamInput) throws java.io.IOException,public org.elasticsearch.tasks.TaskId getParentTask() ,public void setParentTask(org.elasticsearch.tasks.TaskId) ,public void writeTo(org.elasticsearch.common.io.stream.StreamOutput) throws java.... |
crate_crate | crate/server/src/main/java/org/elasticsearch/monitor/fs/FsHealthService.java | FsHealthMonitor | monitorFSHealth | class FsHealthMonitor implements Runnable {
static final String TEMP_FILE_NAME = ".es_temp_file";
private byte[] byteToWrite;
FsHealthMonitor() {
this.byteToWrite = UUIDs.randomBase64UUID().getBytes(StandardCharsets.UTF_8);
}
@Override
public void run() {
... |
Set<Path> currentUnhealthyPaths = null;
for (Path path : nodeEnv.nodeDataPaths()) {
long executionStartTime = currentTimeMillisSupplier.getAsLong();
try {
if (Files.exists(path)) {
Path tempDataPath = path.resolve(TEMP_... | 176 | 353 | 529 | <methods>public void addLifecycleListener(org.elasticsearch.common.component.LifecycleListener) ,public void close() ,public org.elasticsearch.common.component.Lifecycle.State lifecycleState() ,public void removeLifecycleListener(org.elasticsearch.common.component.LifecycleListener) ,public void start() ,public void st... |
crate_crate | crate/server/src/main/java/org/elasticsearch/monitor/jvm/JvmGcMonitorService.java | GcThreshold | doStart | class GcThreshold {
public final String name;
public final long warnThreshold;
public final long infoThreshold;
public final long debugThreshold;
GcThreshold(String name, long warnThreshold, long infoThreshold, long debugThreshold) {
this.name = name;
thi... |
if (!enabled) {
return;
}
scheduledFuture = threadPool.scheduleWithFixedDelay(new JvmMonitor(gcThresholds, gcOverheadThreshold) {
@Override
void onMonitorFailure(Exception e) {
LOGGER.debug("failed to monitor", e);
}
@... | 1,377 | 220 | 1,597 | <methods>public void addLifecycleListener(org.elasticsearch.common.component.LifecycleListener) ,public void close() ,public org.elasticsearch.common.component.Lifecycle.State lifecycleState() ,public void removeLifecycleListener(org.elasticsearch.common.component.LifecycleListener) ,public void start() ,public void st... |
crate_crate | crate/server/src/main/java/org/elasticsearch/monitor/jvm/JvmService.java | JvmService | stats | class JvmService {
private static final Logger LOGGER = LogManager.getLogger(JvmService.class);
private final JvmInfo jvmInfo;
private final TimeValue refreshInterval;
private JvmStats jvmStats;
public static final Setting<TimeValue> REFRESH_INTERVAL_SETTING =
Setting.timeSetting("monit... |
if ((System.currentTimeMillis() - jvmStats.getTimestamp()) > refreshInterval.millis()) {
jvmStats = JvmStats.jvmStats();
}
return jvmStats;
| 268 | 54 | 322 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/monitor/os/OsStats.java | Cpu | writeTo | class Cpu implements Writeable {
private final short percent;
private final double[] loadAverage;
public Cpu(short systemCpuPercent, double[] systemLoadAverage) {
this.percent = systemCpuPercent;
this.loadAverage = systemLoadAverage;
}
public Cpu(Stream... |
out.writeShort(percent);
if (loadAverage == null) {
out.writeBoolean(false);
} else {
out.writeBoolean(true);
out.writeDoubleArray(loadAverage);
}
| 220 | 61 | 281 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/monitor/process/ProcessProbe.java | ProcessProbeHolder | getUnixMethod | class ProcessProbeHolder {
private static final ProcessProbe INSTANCE = new ProcessProbe();
}
public static ProcessProbe getInstance() {
return ProcessProbeHolder.INSTANCE;
}
private ProcessProbe() {
}
/**
* Returns the maximum number of file descriptors allowed on the sy... |
try {
return Class.forName("com.sun.management.UnixOperatingSystemMXBean").getMethod(methodName);
} catch (Exception t) {
// not available
return null;
}
| 1,007 | 58 | 1,065 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/node/InternalSettingsPreparer.java | InternalSettingsPreparer | prepareEnvironment | class InternalSettingsPreparer {
private InternalSettingsPreparer() {}
/**
* Prepares the settings by gathering all elasticsearch system properties, optionally loading the configuration settings.
*
* @param input the custom settings to use; these are not overwritten by settings in the conf... |
// just create enough settings to build the environment, to get the config dir
Settings.Builder output = Settings.builder();
initializeSettings(output, input, properties);
Environment environment = new Environment(output.build(), configPath);
output = Settings.builder(); // sta... | 676 | 276 | 952 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/node/NodeNames.java | NodeNames | nodeNames | class NodeNames {
public static String randomNodeName() {
List<String> names = nodeNames();
int index = ThreadLocalRandom.current().nextInt(names.size());
return names.get(index);
}
static List<String> nodeNames() {<FILL_FUNCTION_BODY>}
} |
InputStream input = NodeNames.class.getResourceAsStream("/config/names.txt");
try {
List<String> names = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(input, StandardCharsets.UTF_8))) {
String line = reader.readLine();
... | 83 | 216 | 299 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/plugins/PluginInfo.java | PluginInfo | readFromProperties | class PluginInfo {
public static final String ES_PLUGIN_PROPERTIES = "plugin-descriptor.properties";
private final String name;
private final String description;
private final String classname;
/**
* Construct plugin info.
*
* @param name the name of the plugin
... |
final Path descriptor = path.resolve(ES_PLUGIN_PROPERTIES);
final Map<String, String> propsMap;
{
final Properties props = new Properties();
try (InputStream stream = Files.newInputStream(descriptor)) {
props.load(stream);
}
props... | 650 | 427 | 1,077 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/repositories/IndexId.java | IndexId | equals | class IndexId implements Writeable, ToXContentObject {
protected static final String NAME = "name";
protected static final String ID = "id";
private final String name;
private final String id;
private final int hashCode;
public IndexId(final String name, final String id) {
this.name = ... |
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
IndexId that = (IndexId) o;
return Objects.equals(name, that.name) && Objects.equals(id, that.id);
| 603 | 85 | 688 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/repositories/RepositoriesModule.java | RepositoriesModule | create | class RepositoriesModule extends AbstractModule {
private final RepositoriesService repositoriesService;
public RepositoriesModule(Environment env,
List<RepositoryPlugin> repoPlugins,
TransportService transportService,
C... |
return new LogicalReplicationRepository(
clusterService,
logicalReplicationService,
remoteClusters,
metadata,
threadPool,
replicationSettings);
... | 771 | 46 | 817 | <methods>public non-sealed void <init>() ,public final synchronized void configure(org.elasticsearch.common.inject.Binder) <variables>org.elasticsearch.common.inject.Binder binder |
crate_crate | crate/server/src/main/java/org/elasticsearch/search/profile/AbstractInternalProfileTree.java | AbstractInternalProfileTree | getProfileBreakdown | class AbstractInternalProfileTree<PB extends AbstractProfileBreakdown<?>, E> {
protected ArrayList<PB> timings;
/** Maps the Query to it's list of children. This is basically the dependency tree */
protected ArrayList<ArrayList<Integer>> tree;
/** A list of the original queries, keyed by index positio... |
int token = currentToken;
boolean stackEmpty = stack.isEmpty();
// If the stack is empty, we are a new root query
if (stackEmpty) {
// We couldn't find a rewritten query to attach to, so just add it as a
// top-level root. This is just a precaution: it really ... | 1,217 | 238 | 1,455 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/search/profile/query/ProfileWeight.java | ProfileWeight | scorerSupplier | class ProfileWeight extends Weight {
private final Weight subQueryWeight;
private final QueryProfileBreakdown profile;
public ProfileWeight(Query query, Weight subQueryWeight, QueryProfileBreakdown profile) throws IOException {
super(query);
this.subQueryWeight = subQueryWeight;
th... |
Timer timer = profile.getTimer(QueryTimingType.BUILD_SCORER);
timer.start();
final ScorerSupplier subQueryScorerSupplier;
try {
subQueryScorerSupplier = subQueryWeight.scorerSupplier(context);
} finally {
timer.stop();
}
if (subQueryScorer... | 434 | 250 | 684 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/snapshots/InFlightShardSnapshotStates.java | InFlightShardSnapshotStates | generationForShard | class InFlightShardSnapshotStates {
/**
* Compute information about all shard ids that currently have in-flight state for the given repository.
*
* @param repoName repository name
* @param snapshots snapshots in progress
* @return in flight shard states for all snapshot operation running ... |
final String inFlightBest = generations.getOrDefault(indexId.getName(), Collections.emptyMap()).get(shardId);
if (inFlightBest != null) {
return inFlightBest;
}
return shardGenerations.getShardGen(indexId, shardId);
| 1,120 | 79 | 1,199 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/snapshots/InternalSnapshotsInfoService.java | FetchingSnapshotShardSizeRunnable | invariant | class FetchingSnapshotShardSizeRunnable extends AbstractRunnable {
private final SnapshotShard snapshotShard;
private boolean removed;
FetchingSnapshotShardSizeRunnable(SnapshotShard snapshotShard) {
super();
this.snapshotShard = snapshotShard;
this.removed ... |
assert Thread.holdsLock(mutex);
assert activeFetches >= 0 : "active fetches should be greater than or equal to zero but got: " + activeFetches;
assert activeFetches <= maxConcurrentFetches : activeFetches + " <= " + maxConcurrentFetches;
for (ObjectCursor<SnapshotShard> cursor : knownSn... | 974 | 338 | 1,312 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/snapshots/RestoreInfo.java | Fields | equals | class Fields {
static final String SNAPSHOT = "snapshot";
static final String INDICES = "indices";
static final String SHARDS = "shards";
static final String TOTAL = "total";
static final String FAILED = "failed";
static final String SUCCESSFUL = "successful";
}
... |
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RestoreInfo that = (RestoreInfo) o;
return totalShards == that.totalShards &&
successfulShards == that.successfulShards &&
Objects.equals(name, that.name) &&
Object... | 675 | 104 | 779 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/snapshots/Snapshot.java | Snapshot | equals | class Snapshot implements Writeable {
private final String repository;
private final SnapshotId snapshotId;
private final int hashCode;
/**
* Constructs a snapshot.
*/
public Snapshot(final String repository, final SnapshotId snapshotId) {
this.repository = Objects.requireNonNull... |
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Snapshot that = (Snapshot) o;
return repository.equals(that.repository) && snapshotId.equals(that.snapshotId);
| 402 | 81 | 483 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/snapshots/SnapshotId.java | SnapshotId | equals | class SnapshotId implements Comparable<SnapshotId>, Writeable, ToXContentObject {
private static final String NAME = "name";
private static final String UUID = "uuid";
private final String name;
private final String uuid;
// Caching hash code
private final int hashCode;
/**
* Constr... |
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final SnapshotId that = (SnapshotId) o;
return name.equals(that.name) && uuid.equals(that.uuid);
| 584 | 82 | 666 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/snapshots/SnapshotShardSizeInfo.java | SnapshotShardSizeInfo | getShardSize | class SnapshotShardSizeInfo {
public static final SnapshotShardSizeInfo EMPTY = new SnapshotShardSizeInfo(ImmutableOpenMap.of());
private final ImmutableOpenMap<InternalSnapshotsInfoService.SnapshotShard, Long> snapshotShardSizes;
public SnapshotShardSizeInfo(ImmutableOpenMap<InternalSnapshotsInfoService... |
if (shardRouting.primary()
&& shardRouting.active() == false
&& shardRouting.recoverySource().getType() == RecoverySource.Type.SNAPSHOT) {
final RecoverySource.SnapshotRecoverySource snapshotRecoverySource =
(RecoverySource.SnapshotRecoverySource) shardRoutin... | 253 | 167 | 420 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/snapshots/SnapshotUtils.java | SnapshotUtils | filterIndices | class SnapshotUtils {
/**
* Filters out list of available indices based on the list of selected indices.
*
* @param availableIndices list of available indices
* @param selectedIndices list of selected indices
* @param indicesOptions ignore indices flag
* @return filtered out indic... |
if (IndexNameExpressionResolver.isAllIndices(selectedIndices)) {
return availableIndices;
}
Set<String> result = null;
for (int i = 0; i < selectedIndices.size(); i++) {
String indexOrPattern = selectedIndices.get(i);
boolean add = true;
i... | 127 | 686 | 813 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/threadpool/FixedExecutorBuilder.java | FixedExecutorBuilder | formatInfo | class FixedExecutorBuilder extends ExecutorBuilder<FixedExecutorBuilder.FixedExecutorSettings> {
private final Setting<Integer> sizeSetting;
private final Setting<Integer> queueSizeSetting;
/**
* Construct a fixed executor builder; the settings will have the key prefix "thread_pool." followed by the ... |
return String.format(
Locale.ROOT,
"name [%s], size [%d], queue size [%s]",
info.getName(),
info.getMax(),
info.getQueueSize() == null ? "unbounded" : info.getQueueSize());
| 872 | 73 | 945 | <methods>public void <init>(java.lang.String) ,public abstract List<Setting<?>> getRegisteredSettings() <variables>private final non-sealed java.lang.String name |
crate_crate | crate/server/src/main/java/org/elasticsearch/threadpool/ScalingExecutorBuilder.java | ScalingExecutorBuilder | build | class ScalingExecutorBuilder extends ExecutorBuilder<ScalingExecutorBuilder.ScalingExecutorSettings> {
private final Setting<Integer> coreSetting;
private final Setting<Integer> maxSetting;
private final Setting<TimeValue> keepAliveSetting;
/**
* Construct a scaling executor builder; the settings... |
TimeValue keepAlive = settings.keepAlive;
int core = settings.core;
int max = settings.max;
final ThreadPool.Info info = new ThreadPool.Info(name(), ThreadPool.ThreadPoolType.SCALING, core, max, keepAlive, null);
final ThreadFactory threadFactory = EsExecutors.daemonThreadFactor... | 874 | 180 | 1,054 | <methods>public void <init>(java.lang.String) ,public abstract List<Setting<?>> getRegisteredSettings() <variables>private final non-sealed java.lang.String name |
crate_crate | crate/server/src/main/java/org/elasticsearch/threadpool/ScheduledCancellableAdapter.java | ScheduledCancellableAdapter | compareTo | class ScheduledCancellableAdapter implements Scheduler.ScheduledCancellable {
private final ScheduledFuture<?> scheduledFuture;
ScheduledCancellableAdapter(ScheduledFuture<?> scheduledFuture) {
assert scheduledFuture != null;
this.scheduledFuture = scheduledFuture;
}
@Override
publ... |
// unwrap other by calling on it.
return -other.compareTo(scheduledFuture);
| 196 | 27 | 223 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/transport/CloseableConnection.java | CloseableConnection | close | class CloseableConnection implements Transport.Connection {
private final CompletableFuture<Void> closeContext = new CompletableFuture<>();
@Override
public void addCloseListener(ActionListener<Void> listener) {
closeContext.whenComplete(listener);
}
@Override
public boolean isClosed(... |
// This method is safe to call multiple times as the close context will provide concurrency
// protection and only be completed once. The attached listeners will only be notified once.
closeContext.complete(null);
| 119 | 51 | 170 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/transport/InboundAggregator.java | InboundAggregator | finishAggregation | class InboundAggregator implements Releasable {
private final Supplier<CircuitBreaker> circuitBreaker;
private final Predicate<String> requestCanTripBreaker;
private ReleasableBytesReference firstContent;
private ArrayList<ReleasableBytesReference> contentAggregation;
private Header currentHeader;... |
ensureOpen();
final ReleasableBytesReference releasableContent;
if (isFirstContent()) {
releasableContent = ReleasableBytesReference.wrap(BytesArray.EMPTY);
} else if (contentAggregation == null) {
releasableContent = firstContent;
} else {
fi... | 1,425 | 429 | 1,854 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/transport/InboundMessage.java | InboundMessage | takeBreakerReleaseControl | class InboundMessage implements Releasable {
private final Header header;
private final ReleasableBytesReference content;
private final Exception exception;
private final boolean isPing;
private Releasable breakerRelease;
private StreamInput streamInput;
public InboundMessage(Header header... |
final Releasable toReturn = breakerRelease;
breakerRelease = null;
if (toReturn != null) {
return toReturn;
} else {
return () -> {};
}
| 563 | 57 | 620 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/transport/OutboundHandler.java | OutboundHandler | sendRequest | class OutboundHandler {
private static final Logger LOGGER = LogManager.getLogger(OutboundHandler.class);
private final String nodeName;
private final Version version;
private final StatsTracker statsTracker;
private final ThreadPool threadPool;
private final BigArrays bigArrays;
private ... |
Version version = Version.min(this.version, channelVersion);
OutboundMessage.Request message = new OutboundMessage.Request(
request,
version,
action,
requestId,
isHandshake,
compressRequest
);
ChannelFuture future =... | 1,173 | 107 | 1,280 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/transport/OutboundMessage.java | OutboundMessage | writeMessage | class OutboundMessage {
private final Writeable message;
protected final Version version;
protected final long requestId;
protected final byte status;
OutboundMessage(Version version, byte status, long requestId, Writeable message) {
this.version = version;
this.status = status;
... |
final BytesReference zeroCopyBuffer;
if (message instanceof BytesTransportRequest) {
BytesTransportRequest bRequest = (BytesTransportRequest) message;
bRequest.writeThin(stream);
zeroCopyBuffer = bRequest.bytes;
} else if (message instanceof RemoteTransportEx... | 982 | 295 | 1,277 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/transport/RemoteTransportException.java | RemoteTransportException | fillInStackTrace | class RemoteTransportException extends ActionTransportException implements ElasticsearchWrapperException {
public RemoteTransportException(String msg, Throwable cause) {
super(msg, null, null, cause);
}
public RemoteTransportException(String name, TransportAddress address, String action, Throwable... |
// no need for stack trace here, we always have cause
return this;
| 156 | 22 | 178 | <methods>public void <init>(org.elasticsearch.common.io.stream.StreamInput) throws java.io.IOException,public void <init>(java.lang.String, org.elasticsearch.common.transport.TransportAddress, java.lang.String, java.lang.Throwable) ,public void <init>(java.lang.String, org.elasticsearch.common.transport.TransportAddres... |
crate_crate | crate/server/src/main/java/org/elasticsearch/transport/TcpHeader.java | TcpHeader | headerSize | class TcpHeader {
public static final Version VERSION_WITH_HEADER_SIZE = Version.V_4_5_0;
public static final int MARKER_BYTES_SIZE = 2;
public static final int MESSAGE_LENGTH_SIZE = 4;
public static final int REQUEST_ID_SIZE = 8;
public static final int STATUS_SIZE = 1;
public static fina... |
if (version.onOrAfter(VERSION_WITH_HEADER_SIZE)) {
return HEADER_SIZE;
} else {
return PRE_76_HEADER_SIZE;
}
| 656 | 54 | 710 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/transport/TransportActionProxy.java | ProxyResponseHandler | handleException | class ProxyResponseHandler<T extends TransportResponse> implements TransportResponseHandler<T> {
private final Writeable.Reader<T> reader;
private final TransportChannel channel;
ProxyResponseHandler(TransportChannel channel, Writeable.Reader<T> reader) {
this.reader = reader;
... |
try {
channel.sendResponse(exp);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
| 227 | 39 | 266 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/transport/TransportDecompressor.java | TransportDecompressor | pollDecompressedPage | class TransportDecompressor implements Closeable {
private final Inflater inflater;
private final PageCacheRecycler recycler;
private final ArrayDeque<Recycler.V<byte[]>> pages;
private int pageOffset = PageCacheRecycler.BYTE_PAGE_SIZE;
private boolean hasReadHeader = false;
public TransportDe... |
if (pages.isEmpty()) {
return null;
} else if (pages.size() == 1) {
if (isEOS()) {
Recycler.V<byte[]> page = pages.pollFirst();
ReleasableBytesReference reference = new ReleasableBytesReference(new BytesArray(page.v(), 0, pageOffset), page);
... | 991 | 168 | 1,159 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/transport/TransportHandshaker.java | TransportHandshaker | sendHandshake | class TransportHandshaker {
static final String HANDSHAKE_ACTION_NAME = "internal:tcp/handshake";
private final ConcurrentMap<Long, HandshakeResponseHandler> pendingHandshakes = new ConcurrentHashMap<>();
private final CounterMetric numHandshakes = new CounterMetric();
private final Version version;
... |
numHandshakes.inc();
final HandshakeResponseHandler handler = new HandshakeResponseHandler(requestId, version, listener);
pendingHandshakes.put(requestId, handler);
channel.addCloseListener(ActionListener.wrap(
() -> handler.handleLocalException(new TransportException("hands... | 1,385 | 365 | 1,750 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/transport/TransportLogger.java | TransportLogger | format | class TransportLogger {
private static final Logger LOGGER = LogManager.getLogger(TransportLogger.class);
private static final int HEADER_SIZE = TcpHeader.MARKER_BYTES_SIZE + TcpHeader.MESSAGE_LENGTH_SIZE;
static void logInboundMessage(CloseableChannel channel, InboundMessage message) {
if (LOGGER... |
final StringBuilder sb = new StringBuilder();
sb.append(channel);
if (message.isPing()) {
sb.append(" [ping]").append(' ').append(event).append(": ").append(6).append('B');
} else {
boolean success = false;
Header header = message.getHeader();
... | 203 | 410 | 613 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/transport/TransportRequestDeduplicator.java | CompositeListener | addListener | class CompositeListener implements ActionListener<Void> {
private final List<ActionListener<Void>> listeners = new ArrayList<>();
private final T request;
private boolean isNotified;
private Exception failure;
CompositeListener(T request) {
this.request = request;... |
synchronized (this) {
if (this.isNotified == false) {
listeners.add(listener);
return listeners.size() == 1 ? this : null;
}
}
if (failure != null) {
listener.onFailure(failure);
} el... | 279 | 96 | 375 | <no_super_class> |
crate_crate | crate/server/src/main/java/org/elasticsearch/transport/netty4/Netty4InboundStatsHandler.java | Netty4InboundStatsHandler | channelActive | class Netty4InboundStatsHandler extends ChannelInboundHandlerAdapter implements Releasable {
final Set<Channel> openChannels = Collections.newSetFromMap(new ConcurrentHashMap<>());
final StatsTracker statsTracker;
final Logger logger;
public Netty4InboundStatsHandler(StatsTracker statsTracker, Logge... |
if (logger.isTraceEnabled()) {
logger.trace("channel opened: {}", ctx.channel());
}
final boolean added = openChannels.add(ctx.channel());
if (added) {
statsTracker.incrementOpenChannels();
ctx.channel().closeFuture().addListener(remover);
}
... | 448 | 95 | 543 | <no_super_class> |
citerus_dddsample-core | dddsample-core/src/main/java/com/pathfinder/internal/GraphDAOStub.java | GraphDAOStub | getTransitEdge | class GraphDAOStub implements GraphDAO{
private static final Random random = new Random();
public List<String> listAllNodes() {
return new ArrayList<String>(List.of(
"CNHKG", "AUMEL", "SESTO", "FIHEL", "USCHI", "JNTKO", "DEHAM", "CNSHA", "NLRTM", "SEGOT", "CNHGH", "USNYC", "USDAL"
));
}
public ... |
final int i = random.nextInt(5);
if (i == 0) return "0100S";
if (i == 1) return "0200T";
if (i == 2) return "0300A";
if (i == 3) return "0301S";
return "0400S";
| 159 | 90 | 249 | <no_super_class> |
citerus_dddsample-core | dddsample-core/src/main/java/com/pathfinder/internal/GraphTraversalServiceImpl.java | GraphTraversalServiceImpl | findShortestPath | class GraphTraversalServiceImpl implements GraphTraversalService {
private GraphDAO dao;
private Random random;
private static final long ONE_MIN_MS = 1000 * 60;
private static final long ONE_DAY_MS = ONE_MIN_MS * 60 * 24;
public GraphTraversalServiceImpl(GraphDAO dao) {
this.dao = dao;
this.random ... |
List<String> allVertices = dao.listAllNodes();
allVertices.remove(originNode);
allVertices.remove(destinationNode);
int candidateCount = getRandomNumberOfCandidates();
List<TransitPath> candidates = new ArrayList<>(candidateCount);
for (int i = 0; i < candidateCount; i++) {
allVertices ... | 341 | 320 | 661 | <no_super_class> |
citerus_dddsample-core | dddsample-core/src/main/java/se/citerus/dddsample/application/impl/BookingServiceImpl.java | BookingServiceImpl | changeDestination | class BookingServiceImpl implements BookingService {
private final CargoRepository cargoRepository;
private final LocationRepository locationRepository;
private final RoutingService routingService;
private final CargoFactory cargoFactory;
private static final Logger logger = LoggerFactory.getLogger(MethodHan... |
final Cargo cargo = cargoRepository.find(trackingId);
final Location newDestination = locationRepository.find(unLocode);
final RouteSpecification routeSpecification = new RouteSpecification(
cargo.origin(), newDestination, cargo.routeSpecification().arrivalDeadline()
);
cargo.specifyNewRoute... | 579 | 126 | 705 | <no_super_class> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.