_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q22700
CalendarPickerView.unfixDialogDimens
train
public void unfixDialogDimens() { Logr.d("Reset the fixed dimensions to allow for re-measurement"); // Fix the layout height/width after the dialog has been shown. getLayoutParams().height = LayoutParams.MATCH_PARENT; getLayoutParams().width = LayoutParams.MATCH_PARENT; requestLayout(); }
java
{ "resource": "" }
q22701
IpcLogger.inflightRequests
train
AtomicInteger inflightRequests(Id id) { return Utils.computeIfAbsent(inflightRequests, id, i -> new AtomicInteger()); }
java
{ "resource": "" }
q22702
IpcLogger.limiterForKey
train
Function<String, String> limiterForKey(String key) { return Utils.computeIfAbsent(limiters, key, k -> CardinalityLimiters.rollup(25)); }
java
{ "resource": "" }
q22703
IpcLogger.log
train
void log(IpcLogEntry entry) { Level level = entry.getLevel(); Predicate<Marker> enabled; BiConsumer<Marker, String> log; switch (level) { case TRACE: enabled = logger::isTraceEnabled; log = logger::trace; break; case DEBUG: enabled = logger::isDebugEnabled; ...
java
{ "resource": "" }
q22704
SeqServerGroup.parse
train
public static SeqServerGroup parse(String asg) { int d1 = asg.indexOf('-'); int d2 = asg.indexOf('-', d1 + 1); int dN = asg.lastIndexOf('-'); if (dN < 0 || !isSequence(asg, dN)) { dN = asg.length(); } return new SeqServerGroup(asg, d1, d2, dN); }
java
{ "resource": "" }
q22705
SeqServerGroup.substr
train
private static CharSequence substr(CharSequence str, int s, int e) { return (s >= e) ? null : CharBuffer.wrap(str, s, e); }
java
{ "resource": "" }
q22706
PercentileDistributionSummary.builder
train
public static IdBuilder<Builder> builder(Registry registry) { return new IdBuilder<Builder>(registry) { @Override protected Builder createTypeBuilder(Id id) { return new Builder(registry, id); } }; }
java
{ "resource": "" }
q22707
PercentileDistributionSummary.counterFor
train
private Counter counterFor(int i) { Counter c = counters.get(i); if (c == null) { Id counterId = id.withTags(Statistic.percentile, new BasicTag("percentile", TAG_VALUES[i])); c = registry.counter(counterId); counters.set(i, c); } return c; }
java
{ "resource": "" }
q22708
PercentileDistributionSummary.percentile
train
public double percentile(double p) { long[] counts = new long[PercentileBuckets.length()]; for (int i = 0; i < counts.length; ++i) { counts[i] = counterFor(i).count(); } return PercentileBuckets.percentile(counts, p); }
java
{ "resource": "" }
q22709
AtomicDouble.max
train
public void max(double v) { if (Double.isFinite(v)) { double max = get(); while (isGreaterThan(v, max) && !compareAndSet(max, v)) { max = value.get(); } } }
java
{ "resource": "" }
q22710
JsonUtils.encode
train
static byte[] encode( Map<String, String> commonTags, List<Measurement> measurements) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); JsonGenerator gen = FACTORY.createGenerator(baos); gen.writeStartArray(); Map<String, Integer> strings = buildStringTable(gen,...
java
{ "resource": "" }
q22711
SparkValueFunction.fromConfig
train
public static SparkValueFunction fromConfig(Config config, String key) { return fromPatternList(config.getConfigList(key)); }
java
{ "resource": "" }
q22712
AbstractRegistry.getOrCreate
train
@SuppressWarnings("unchecked") protected <T extends Meter> T getOrCreate(Id id, Class<T> cls, T dflt, Function<Id, T> factory) { try { Preconditions.checkNotNull(id, "id"); Meter m = Utils.computeIfAbsent(meters, id, i -> compute(factory.apply(i), dflt)); if (!cls.isAssignableFrom(m.getClass()))...
java
{ "resource": "" }
q22713
AbstractRegistry.removeExpiredMeters
train
protected void removeExpiredMeters() { int total = 0; int expired = 0; Iterator<Map.Entry<Id, Meter>> it = meters.entrySet().iterator(); while (it.hasNext()) { ++total; Map.Entry<Id, Meter> entry = it.next(); Meter m = entry.getValue(); if (m.hasExpired()) { ++expired; ...
java
{ "resource": "" }
q22714
AbstractRegistry.cleanupCachedState
train
private void cleanupCachedState() { int total = 0; int expired = 0; Iterator<Map.Entry<Id, Object>> it = state.entrySet().iterator(); while (it.hasNext()) { ++total; Map.Entry<Id, Object> entry = it.next(); Object obj = entry.getValue(); if (obj instanceof Meter && ((Meter) obj)....
java
{ "resource": "" }
q22715
BucketDistributionSummary.get
train
public static BucketDistributionSummary get(Id id, BucketFunction f) { return get(Spectator.globalRegistry(), id, f); }
java
{ "resource": "" }
q22716
ServletPathHack.getServletPath
train
static String getServletPath(HttpServletRequest request) { String servletPath = request.getServletPath(); if (hackWorks && PACKAGE.equals(request.getClass().getPackage().getName())) { try { Object outer = get(request, "this$0"); Object servletPipeline = get(outer, "servletPipeline"); ...
java
{ "resource": "" }
q22717
TagsBuilder.withTag
train
public <E extends Enum<E>> T withTag(String k, Enum<E> v) { return withTag(k, v.name()); }
java
{ "resource": "" }
q22718
IpcLogEntry.withException
train
public IpcLogEntry withException(Throwable exception) { this.exception = exception; if (statusDetail == null) { statusDetail = exception.getClass().getSimpleName(); } if (status == null) { status = IpcStatus.forException(exception); } return this; }
java
{ "resource": "" }
q22719
IpcLogEntry.withUri
train
public IpcLogEntry withUri(String uri, String path) { this.uri = uri; this.path = path; return this; }
java
{ "resource": "" }
q22720
IpcLogEntry.log
train
public void log() { if (logger != null) { if (registry != null) { if (isClient()) { recordClientMetrics(); } else { recordServerMetrics(); } } if (inflightId != null) { logger.inflightRequests(inflightId).decrementAndGet(); } logger....
java
{ "resource": "" }
q22721
IpcLogEntry.reset
train
void reset() { logger = null; level = Level.DEBUG; marker = null; startTime = -1L; startNanos = -1L; latency = -1L; owner = null; result = null; protocol = null; status = null; statusDetail = null; exception = null; attempt = null; attemptFinal = null; vip = n...
java
{ "resource": "" }
q22722
IpcLogEntry.resetForRetry
train
void resetForRetry() { startTime = -1L; startNanos = -1L; latency = -1L; result = null; status = null; statusDetail = null; exception = null; attempt = null; attemptFinal = null; vip = null; serverRegion = null; serverZone = null; serverApp = null; serverCluster =...
java
{ "resource": "" }
q22723
PatternUtils.compile
train
public static PatternMatcher compile(String pattern) { String p = pattern; boolean ignoreCase = false; if (p.startsWith("(?i)")) { ignoreCase = true; p = pattern.substring(4); } if (p.length() > 0) { p = "^.*(" + p + ").*$"; } Parser parser = new Parser(PatternUtils.expandE...
java
{ "resource": "" }
q22724
PatternUtils.error
train
static IllegalArgumentException error(String message, String str, int pos) { return new IllegalArgumentException(message + "\n" + context(str, pos)); }
java
{ "resource": "" }
q22725
PatternUtils.unsupported
train
static UnsupportedOperationException unsupported(String message, String str, int pos) { return new UnsupportedOperationException(message + "\n" + context(str, pos)); }
java
{ "resource": "" }
q22726
PatternUtils.expandEscapedChars
train
@SuppressWarnings("PMD.NcssCount") static String expandEscapedChars(String str) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < str.length(); ++i) { char c = str.charAt(i); if (c == '\\') { ++i; if (i >= str.length()) { throw error("dangling escape", st...
java
{ "resource": "" }
q22727
PatternUtils.escape
train
@SuppressWarnings("PMD.NcssCount") static String escape(String str) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < str.length(); ++i) { char c = str.charAt(i); switch (c) { case '\t': builder.append("\\t"); break; case '\n': builder.append("\\n"); break; ...
java
{ "resource": "" }
q22728
PatternUtils.ignoreCase
train
static Matcher ignoreCase(Matcher matcher) { if (matcher instanceof CharClassMatcher) { CharClassMatcher m = matcher.as(); return new CharClassMatcher(m.set(), true); } else if (matcher instanceof CharSeqMatcher) { CharSeqMatcher m = matcher.as(); return new CharSeqMatcher(m.pattern(), t...
java
{ "resource": "" }
q22729
PatternUtils.head
train
static Matcher head(Matcher matcher) { if (matcher instanceof SeqMatcher) { List<Matcher> ms = matcher.<SeqMatcher>as().matchers(); return ms.get(0); } else { return matcher; } }
java
{ "resource": "" }
q22730
PatternUtils.tail
train
static Matcher tail(Matcher matcher) { if (matcher instanceof SeqMatcher) { List<Matcher> ms = matcher.<SeqMatcher>as().matchers(); return SeqMatcher.create(ms.subList(1, ms.size())); } else { return TrueMatcher.INSTANCE; } }
java
{ "resource": "" }
q22731
DefaultPlaceholderId.createWithFactories
train
static DefaultPlaceholderId createWithFactories(String name, Iterable<TagFactory> tagFactories, Registry registry) { if (tagFactories == null) { return new DefaultPlaceholderId(name, registry); } else { FactorySorterAndDeduplicator sorter = new FactorySorterAndDeduplicator(tagFactories); retu...
java
{ "resource": "" }
q22732
DefaultPlaceholderId.createNewId
train
private DefaultPlaceholderId createNewId(Consumer<FactorySorterAndDeduplicator> consumer) { FactorySorterAndDeduplicator sorter = new FactorySorterAndDeduplicator(tagFactories); consumer.accept(sorter); return new DefaultPlaceholderId(name, sorter.asCollection(), registry); }
java
{ "resource": "" }
q22733
Utils.getMethod
train
static Method getMethod(Class<?> cls, String name) throws NoSuchMethodException { NoSuchMethodException firstExc = null; for (Class<?> c = cls; c != null; c = c.getSuperclass()) { try { return c.getDeclaredMethod(name); } catch (NoSuchMethodException e) { if (firstExc == null) { ...
java
{ "resource": "" }
q22734
Utils.getGaugeMethod
train
static Method getGaugeMethod(Registry registry, Id id, Object obj, String method) { try { final Method m = Utils.getMethod(obj.getClass(), method); try { // Make sure we can cast the response to a Number final Number n = (Number) m.invoke(obj); REGISTRY_LOGGER.debug( ...
java
{ "resource": "" }
q22735
Utils.normalize
train
public static Id normalize(Id id) { return (new DefaultId(id.name())).withTags(id.tags()).normalize(); }
java
{ "resource": "" }
q22736
Utils.first
train
public static Measurement first(Iterable<Measurement> ms, Predicate<Measurement> p) { Iterator<Measurement> it = filter(ms, p).iterator(); return it.hasNext() ? it.next() : null; }
java
{ "resource": "" }
q22737
Utils.toList
train
public static <T> List<T> toList(Iterable<T> iter) { List<T> buf = new ArrayList<>(); for (T v : iter) { buf.add(v); } return buf; }
java
{ "resource": "" }
q22738
Utils.toList
train
public static <T> List<T> toList(Iterator<T> iter) { List<T> buf = new ArrayList<>(); while (iter.hasNext()) { buf.add(iter.next()); } return buf; }
java
{ "resource": "" }
q22739
Utils.size
train
@SuppressWarnings("PMD.UnusedLocalVariable") public static <T> int size(Iterable<T> iter) { if (iter instanceof ArrayTagSet) { return ((ArrayTagSet) iter).size(); } else if (iter instanceof Collection<?>) { return ((Collection<?>) iter).size(); } else { int size = 0; for (T v : ite...
java
{ "resource": "" }
q22740
Utils.toIterable
train
static Iterable<Tag> toIterable(String[] tags) { if (tags.length % 2 == 1) { throw new IllegalArgumentException("size must be even, it is a set of key=value pairs"); } ArrayList<Tag> ts = new ArrayList<>(tags.length / 2); for (int i = 0; i < tags.length; i += 2) { ts.add(new BasicTag(tags[i]...
java
{ "resource": "" }
q22741
Utils.propagateTypeError
train
public static void propagateTypeError( Registry registry, Id id, Class<?> desiredClass, Class<?> actualClass) { final String dType = desiredClass.getName(); final String aType = actualClass.getName(); final String msg = String.format("cannot access '%s' as a %s, it already exists as a %s", id,...
java
{ "resource": "" }
q22742
SpectatorAppender.addToRootLogger
train
public static void addToRootLogger( Registry registry, String name, boolean ignoreExceptions) { final Appender appender = new SpectatorAppender(registry, name, null, null, ignoreExceptions); appender.start(); LoggerContext context = (LoggerContext) LogManager.getContext(false); Config...
java
{ "resource": "" }
q22743
SpectatorAppender.createAppender
train
@PluginFactory public static SpectatorAppender createAppender( @PluginAttribute("name") String name, @PluginAttribute("ignoreExceptions") boolean ignoreExceptions, @PluginElement("Layout") Layout<? extends Serializable> layout, @PluginElement("Filters") Filter filter) { if (name == null) ...
java
{ "resource": "" }
q22744
LongTaskTimer.get
train
public static LongTaskTimer get(Registry registry, Id id) { ConcurrentMap<Id, Object> state = registry.state(); Object obj = Utils.computeIfAbsent(state, id, i -> { LongTaskTimer timer = new LongTaskTimer(registry, id); PolledMeter.using(registry) .withId(id) .withTag(Statistic.a...
java
{ "resource": "" }
q22745
SubscriptionManager.refresh
train
void refresh() { // Request latest expressions from the server try { HttpResponse res = client.get(uri) .withConnectTimeout(connectTimeout) .withReadTimeout(readTimeout) .addHeader("If-None-Match", etag) .send() .decompress(); if (res.status() == 304...
java
{ "resource": "" }
q22746
JmxData.mkString
train
@SuppressWarnings("PMD.AvoidCatchingThrowable") static String mkString(Object obj) { if (obj == null) { return "null"; } try { return obj.toString() + " (type is " + obj.getClass() + ")"; } catch (Throwable t) { return t.getClass().toString() + ": " + t.getMessage() + " (type is " + ...
java
{ "resource": "" }
q22747
HelperFunctions.getGcType
train
static GcType getGcType(String name) { GcType t = KNOWN_COLLECTOR_NAMES.get(name); return (t == null) ? GcType.UNKNOWN : t; }
java
{ "resource": "" }
q22748
HelperFunctions.getTotalUsage
train
static long getTotalUsage(Map<String, MemoryUsage> usages) { long sum = 0L; for (Map.Entry<String, MemoryUsage> e : usages.entrySet()) { sum += e.getValue().getUsed(); } return sum; }
java
{ "resource": "" }
q22749
HelperFunctions.getTotalMaxUsage
train
static long getTotalMaxUsage(Map<String, MemoryUsage> usages) { long sum = 0L; for (Map.Entry<String, MemoryUsage> e : usages.entrySet()) { long max = e.getValue().getMax(); if (max > 0) { sum += e.getValue().getMax(); } } return sum; }
java
{ "resource": "" }
q22750
HelperFunctions.getPromotionSize
train
static long getPromotionSize(GcInfo info) { long totalBefore = getTotalUsage(info.getMemoryUsageBeforeGc()); long totalAfter = getTotalUsage(info.getMemoryUsageAfterGc()); return totalAfter - totalBefore; }
java
{ "resource": "" }
q22751
StepLong.addAndGet
train
void addAndGet(long amount) { for (int i = 0; i < ServoPollers.NUM_POLLERS; ++i) { getCurrent(i).addAndGet(amount); } }
java
{ "resource": "" }
q22752
StepLong.getCurrent
train
AtomicLong getCurrent(int pollerIndex) { rollCount(pollerIndex, clock.now()); return data[2 * pollerIndex + CURRENT]; }
java
{ "resource": "" }
q22753
StepLong.poll
train
Long poll(int pollerIndex) { final long now = clock.now(); final long step = ServoPollers.POLLING_INTERVALS[pollerIndex]; rollCount(pollerIndex, now); final int prevPos = 2 * pollerIndex + PREVIOUS; final long value = data[prevPos].get(); final long last = lastPollTime[pollerIndex].getAndSet(n...
java
{ "resource": "" }
q22754
MappingExpr.substitute
train
static String substitute(String pattern, Map<String, String> vars) { String value = pattern; for (Map.Entry<String, String> entry : vars.entrySet()) { String raw = entry.getValue(); String v = Introspector.decapitalize(raw); value = value.replace("{raw:" + entry.getKey() + "}", raw); val...
java
{ "resource": "" }
q22755
MappingExpr.eval
train
@SuppressWarnings("PMD") static Double eval(String expr, Map<String, ? extends Number> vars) { Deque<Double> stack = new ArrayDeque<>(); String[] parts = expr.split("[,\\s]+"); for (String part : parts) { switch (part) { case ":add": binaryOp(stack, (a, b) -> a + b); break; ca...
java
{ "resource": "" }
q22756
StatelessRegistry.stop
train
public void stop() { if (scheduler != null) { scheduler.shutdown(); scheduler = null; logger.info("flushing metrics before stopping the registry"); collectData(); logger.info("stopped collecting metrics every {} reporting to {}", frequency, uri); } else { logger.warn("registr...
java
{ "resource": "" }
q22757
ServoRegistry.toMonitorConfig
train
MonitorConfig toMonitorConfig(Id id, Tag stat) { MonitorConfig.Builder builder = new MonitorConfig.Builder(id.name()); if (stat != null) { builder.withTag(stat.key(), stat.value()); } for (Tag t : id.tags()) { builder.withTag(t.key(), t.value()); } return builder.build(); }
java
{ "resource": "" }
q22758
HttpLogEntry.logClientRequest
train
@Deprecated public static void logClientRequest(Logger logger, HttpLogEntry entry) { log(logger, CLIENT, entry); }
java
{ "resource": "" }
q22759
HttpLogEntry.logServerRequest
train
@Deprecated public static void logServerRequest(Logger logger, HttpLogEntry entry) { log(logger, SERVER, entry); }
java
{ "resource": "" }
q22760
HttpLogEntry.withRequestUri
train
public HttpLogEntry withRequestUri(String uri, String path) { this.requestUri = uri; this.path = path; return this; }
java
{ "resource": "" }
q22761
HttpLogEntry.withRequestHeader
train
public HttpLogEntry withRequestHeader(String name, String value) { requestHeaders.add(new Header(name, value)); return this; }
java
{ "resource": "" }
q22762
HttpLogEntry.withResponseHeader
train
public HttpLogEntry withResponseHeader(String name, String value) { responseHeaders.add(new Header(name, value)); return this; }
java
{ "resource": "" }
q22763
HttpLogEntry.getLatency
train
public long getLatency() { if (latency >= 0L) { return latency; } else if (events.size() >= 2) { return events.get(events.size() - 1).timestamp() - events.get(0).timestamp(); } else { return -1; } }
java
{ "resource": "" }
q22764
HttpLogEntry.getOverallLatency
train
public long getOverallLatency() { if (maxAttempts <= 1 || originalStart < 0) { return getLatency(); } else if (events.isEmpty()) { return -1; } else { return events.get(events.size() - 1).timestamp() - originalStart; } }
java
{ "resource": "" }
q22765
HttpLogEntry.getStartTime
train
public String getStartTime() { return events.isEmpty() ? "unknown" : isoDate.format(new Date(events.get(0).timestamp())); }
java
{ "resource": "" }
q22766
HttpLogEntry.getTimeline
train
public String getTimeline() { StringBuilder builder = new StringBuilder(); for (Event event : events) { builder.append(event.name()).append(":").append(event.timestamp()).append(";"); } return builder.toString(); }
java
{ "resource": "" }
q22767
HttpRequestBuilder.addHeader
train
public HttpRequestBuilder addHeader(String name, String value) { reqHeaders.put(name, value); entry.withRequestHeader(name, value); return this; }
java
{ "resource": "" }
q22768
HttpRequestBuilder.withContent
train
public HttpRequestBuilder withContent(String type, String content) { return withContent(type, content.getBytes(StandardCharsets.UTF_8)); }
java
{ "resource": "" }
q22769
HttpRequestBuilder.compress
train
public HttpRequestBuilder compress(int level) throws IOException { addHeader("Content-Encoding", "gzip"); entity = HttpUtils.gzip(entity, level); return this; }
java
{ "resource": "" }
q22770
HttpRequestBuilder.withRetries
train
public HttpRequestBuilder withRetries(int n) { Preconditions.checkArg(n >= 0, "number of retries must be >= 0"); this.numAttempts = n + 1; entry.withMaxAttempts(numAttempts); return this; }
java
{ "resource": "" }
q22771
PercentileBuckets.asArray
train
public static long[] asArray() { long[] values = new long[BUCKET_VALUES.length]; System.arraycopy(BUCKET_VALUES, 0, values, 0, BUCKET_VALUES.length); return values; }
java
{ "resource": "" }
q22772
PercentileBuckets.map
train
public static <T> T[] map(Class<T> c, Function<Long, T> f) { @SuppressWarnings("unchecked") T[] values = (T[]) Array.newInstance(c, BUCKET_VALUES.length); for (int i = 0; i < BUCKET_VALUES.length; ++i) { values[i] = f.apply(BUCKET_VALUES[i]); } return values; }
java
{ "resource": "" }
q22773
PercentileBuckets.percentiles
train
public static void percentiles(long[] counts, double[] pcts, double[] results) { Preconditions.checkArg(counts.length == BUCKET_VALUES.length, "counts is not the same size as buckets array"); Preconditions.checkArg(pcts.length > 0, "pct array cannot be empty"); Preconditions.checkArg(pcts.length == ...
java
{ "resource": "" }
q22774
PercentileBuckets.percentile
train
public static double percentile(long[] counts, double p) { double[] pcts = new double[] {p}; double[] results = new double[1]; percentiles(counts, pcts, results); return results[0]; }
java
{ "resource": "" }
q22775
AtlasRegistry.getInitialDelay
train
long getInitialDelay(long stepSize) { long now = clock().wallTime(); long stepBoundary = now / stepSize * stepSize; // Buffer by 10% of the step interval on either side long offset = stepSize / 10; // Check if the current delay is within the acceptable range long delay = now - stepBoundary; ...
java
{ "resource": "" }
q22776
AtlasRegistry.stop
train
public void stop() { if (scheduler != null) { scheduler.shutdown(); scheduler = null; logger.info("stopped collecting metrics every {}ms reporting to {}", step, uri); } else { logger.warn("registry stopped, but was never started"); } }
java
{ "resource": "" }
q22777
AtlasRegistry.collectData
train
void collectData() { // Send data for any subscriptions if (config.lwcEnabled()) { try { handleSubscriptions(); } catch (Exception e) { logger.warn("failed to handle subscriptions", e); } } else { logger.debug("lwc is disabled, skipping subscriptions"); } // ...
java
{ "resource": "" }
q22778
AtlasRegistry.recordClockSkew
train
private void recordClockSkew(long responseTimestamp) { if (responseTimestamp == 0L) { logger.debug("no date timestamp on response, cannot record skew"); } else { final long delta = clock().wallTime() - responseTimestamp; if (delta >= 0L) { // Local clock is running fast compared to the...
java
{ "resource": "" }
q22779
AtlasRegistry.getBatches
train
List<List<Measurement>> getBatches() { List<List<Measurement>> batches = new ArrayList<>(); List<Measurement> ms = getMeasurements().collect(Collectors.toList()); for (int i = 0; i < ms.size(); i += batchSize) { List<Measurement> batch = ms.subList(i, Math.min(ms.size(), i + batchSize)); batches...
java
{ "resource": "" }
q22780
AsciiSet.control
train
public static AsciiSet control() { final boolean[] members = new boolean[128]; for (char c = 0; c < members.length; ++c) { members[c] = Character.isISOControl(c); } return new AsciiSet(members); }
java
{ "resource": "" }
q22781
AsciiSet.toPattern
train
private static String toPattern(boolean[] members) { StringBuilder buf = new StringBuilder(); if (members['-']) { buf.append('-'); } boolean previous = false; char s = 0; for (int i = 0; i < members.length; ++i) { if (members[i] && !previous) { s = (char) i; } else if (...
java
{ "resource": "" }
q22782
AsciiSet.containsAll
train
public boolean containsAll(CharSequence str) { final int n = str.length(); for (int i = 0; i < n; ++i) { if (!contains(str.charAt(i))) { return false; } } return true; }
java
{ "resource": "" }
q22783
AsciiSet.replaceNonMembers
train
public String replaceNonMembers(String input, char replacement) { if (!contains(replacement)) { throw new IllegalArgumentException(replacement + " is not a member of " + pattern); } return containsAll(input) ? input : replaceNonMembersImpl(input, replacement); }
java
{ "resource": "" }
q22784
AsciiSet.union
train
public AsciiSet union(AsciiSet set) { final boolean[] unionMembers = new boolean[128]; for (int i = 0; i < unionMembers.length; ++i) { unionMembers[i] = members[i] || set.members[i]; } return new AsciiSet(unionMembers); }
java
{ "resource": "" }
q22785
AsciiSet.intersection
train
public AsciiSet intersection(AsciiSet set) { final boolean[] intersectionMembers = new boolean[128]; for (int i = 0; i < intersectionMembers.length; ++i) { intersectionMembers[i] = members[i] && set.members[i]; } return new AsciiSet(intersectionMembers); }
java
{ "resource": "" }
q22786
AsciiSet.diff
train
public AsciiSet diff(AsciiSet set) { final boolean[] diffMembers = new boolean[128]; for (int i = 0; i < diffMembers.length; ++i) { diffMembers[i] = members[i] && !set.members[i]; } return new AsciiSet(diffMembers); }
java
{ "resource": "" }
q22787
AsciiSet.invert
train
public AsciiSet invert() { final boolean[] invertMembers = new boolean[128]; for (int i = 0; i < invertMembers.length; ++i) { invertMembers[i] = !members[i]; } return new AsciiSet(invertMembers); }
java
{ "resource": "" }
q22788
AsciiSet.character
train
public Optional<Character> character() { char c = 0; int count = 0; for (int i = 0; i < members.length; ++i) { if (members[i]) { c = (char) i; ++count; } } return (count == 1) ? Optional.of(c) : Optional.empty(); }
java
{ "resource": "" }
q22789
PrototypeMeasurementFilterSpecification.loadFromPath
train
public static PrototypeMeasurementFilterSpecification loadFromPath(String path) throws IOException { byte[] jsonData = Files.readAllBytes(Paths.get(path)); ObjectMapper objectMapper = new ObjectMapper(); return objectMapper.readValue( jsonData, PrototypeMeasurementFilterSpecification.class); ...
java
{ "resource": "" }
q22790
Main.run
train
public static Registry run(String type, String test) { Registry registry = createRegistry(type); TESTS.get(test).accept(registry); return registry; }
java
{ "resource": "" }
q22791
Main.main
train
@SuppressWarnings("PMD") public static void main(String[] args) { if (args.length < 2) { System.out.println("Usage: perf <registry> <test>"); System.exit(1); } Registry registry = run(args[0], args[1]); GraphLayout igraph = GraphLayout.parseInstance(registry); System.out.println(igra...
java
{ "resource": "" }
q22792
NetflixHeaders.extractFrom
train
public static Map<String, String> extractFrom(Function<String, String> env) { Map<String, String> headers = new LinkedHashMap<>(); addHeader(headers, env, NetflixHeader.ASG, NETFLIX_ASG); addHeader(headers, env, NetflixHeader.Node, NETFLIX_NODE); addHeader(headers, env, NetflixHeader.Zone, NETFLIX_ZONE)...
java
{ "resource": "" }
q22793
Evaluator.sync
train
public Evaluator sync(Map<String, List<Subscription>> subs) { Set<String> removed = subscriptions.keySet(); removed.removeAll(subs.keySet()); removed.forEach(this::removeGroupSubscriptions); subs.forEach(this::addGroupSubscriptions); return this; }
java
{ "resource": "" }
q22794
Evaluator.addGroupSubscriptions
train
public Evaluator addGroupSubscriptions(String group, List<Subscription> subs) { List<Subscription> oldSubs = subscriptions.put(group, subs); if (oldSubs == null) { LOGGER.debug("added group {} with {} subscriptions", group, subs.size()); } else { LOGGER.debug("updated group {}, {} subscriptions ...
java
{ "resource": "" }
q22795
Evaluator.removeGroupSubscriptions
train
public Evaluator removeGroupSubscriptions(String group) { List<Subscription> oldSubs = subscriptions.remove(group); if (oldSubs != null) { LOGGER.debug("removed group {} with {} subscriptions", group, oldSubs.size()); } return this; }
java
{ "resource": "" }
q22796
Evaluator.eval
train
public EvalPayload eval(String group, long timestamp, List<TagsValuePair> vs) { List<Subscription> subs = subscriptions.getOrDefault(group, Collections.emptyList()); List<EvalPayload.Metric> metrics = new ArrayList<>(); for (Subscription s : subs) { DataExpr expr = s.dataExpr(); for (TagsValuePa...
java
{ "resource": "" }
q22797
PolledMeter.update
train
public static void update(Registry registry) { Iterator<Map.Entry<Id, Object>> iter = registry.state().entrySet().iterator(); while (iter.hasNext()) { Map.Entry<Id, Object> entry = iter.next(); if (entry.getValue() instanceof AbstractMeterState) { AbstractMeterState tuple = (AbstractMeterSta...
java
{ "resource": "" }
q22798
PrototypeMeasurementFilter.metricToPatterns
train
public IncludeExcludePatterns metricToPatterns(String metric) { IncludeExcludePatterns foundPatterns = metricNameToPatterns.get(metric); if (foundPatterns != null) { return foundPatterns; } // Since the keys in the prototype can be regular expressions, // need to look at all of them and can...
java
{ "resource": "" }
q22799
PrototypeMeasurementFilter.loadFromPath
train
public static PrototypeMeasurementFilter loadFromPath(String path) throws IOException { PrototypeMeasurementFilterSpecification spec = PrototypeMeasurementFilterSpecification.loadFromPath(path); return new PrototypeMeasurementFilter(spec); }
java
{ "resource": "" }