method2testcases stringlengths 118 6.63k |
|---|
### Question:
CorpusDb { public CorpusDocument loadDocumentByKey(int key) { String sql = "SELECT ID, DOC_ID, SOURCE_ID, SOURCE_DATE, PROCESS_DATE, CONTENT FROM DOCUMENT_TABLE " + "WHERE ID = " + key; return getDocument(sql); } CorpusDb(Path dbRoot); private CorpusDb(JdbcConnectionPool connectionPool); void addAll(List... |
### Question:
CorpusDb { public List<SentenceSearchResult> search(String text) { try (Connection connection = connectionPool.getConnection()) { String sql = "SELECT T.* FROM FT_SEARCH_DATA('" + text + "', 0, 0) FT, SENTENCE_TABLE T " + "WHERE FT.TABLE='SENTENCE_TABLE' AND T.ID=FT.KEYS[0];"; Statement stat = connection.... |
### Question:
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter write(String s) throws IOException { try { if (s == null || s.length() == 0) { return this; } writer.write(s); return this; } finally { if (!keepOpen) { close(); } } } private SimpleTextWriter(
BufferedWriter writer,
OutputSt... |
### Question:
SimpleTextWriter implements AutoCloseable { public SimpleTextWriter writeLines(Collection<String> lines) throws IOException { try { IOs.writeLines(lines, writer); return this; } finally { if (!keepOpen) { close(); } } } private SimpleTextWriter(
BufferedWriter writer,
OutputStream os,
S... |
### Question:
KeyValueReader { public Map<String, String> loadFromFile(File file) throws IOException { return loadFromFile(new SimpleTextReader. Builder(file) .trim() .ignoreIfStartsWith(ignorePrefix) .ignoreWhiteSpaceLines() .build()); } KeyValueReader(String seperator); KeyValueReader(String seperator, String ignore... |
### Question:
Strings { public static boolean isNullOrEmpty(String str) { return str == null || str.length() == 0; } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... strings); static boolean allNullOrEmpty(String... strings); static Stri... |
### Question:
Strings { public static boolean hasText(String s) { return s != null && s.length() > 0 && s.trim().length() > 0; } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... strings); static boolean allNullOrEmpty(String... strings);... |
### Question:
Strings { public static boolean allHasText(String... strings) { checkVarargString(strings); for (String s : strings) { if (!hasText(s)) { return false; } } return true; } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... str... |
### Question:
Strings { public static boolean allNullOrEmpty(String... strings) { checkVarargString(strings); for (String s : strings) { if (!isNullOrEmpty(s)) { return false; } } return true; } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(Str... |
### Question:
Strings { public static String leftTrim(String s) { if (s == null) { return null; } if (s.length() == 0) { return EMPTY_STRING; } int j = 0; for (int i = 0; i < s.length(); i++) { if (Character.isWhitespace(s.charAt(i))) { j++; } else { break; } } return s.substring(j); } private Strings(); static boolea... |
### Question:
Strings { public static String rightTrim(String str) { if (str == null) { return null; } if (str.length() == 0) { return EMPTY_STRING; } int j = str.length(); for (int i = str.length() - 1; i >= 0; --i) { if (Character.isWhitespace(str.charAt(i))) { j--; } else { break; } } return str.substring(0, j); } p... |
### Question:
Strings { public static String repeat(char c, int count) { if (count < 1) { return EMPTY_STRING; } char[] chars = new char[count]; Arrays.fill(chars, c); return new String(chars); } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(St... |
### Question:
Strings { public static String reverse(String str) { if (str == null) { return null; } if (str.length() == 0) { return EMPTY_STRING; } return new StringBuilder(str).reverse().toString(); } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHas... |
### Question:
CharacterGraphDecoder { public List<String> getSuggestions(String input) { return new Decoder().decode(input).getKeyList(); } CharacterGraphDecoder(float maxPenalty); CharacterGraphDecoder(); CharacterGraphDecoder(CharacterGraph graph); CharacterGraphDecoder(float maxPenalty, Map<Character, String> nea... |
### Question:
Strings { public static String insertFromLeft(String str, int interval, String stringToInsert) { if (interval < 0) { throw new IllegalArgumentException("interval value cannot be negative."); } if (str == null || interval == 0 || interval >= str.length() || isNullOrEmpty(stringToInsert)) { return str; } St... |
### Question:
Strings { public static String insertFromRight(String str, int interval, String stringToInsert) { if (interval < 0) { throw new IllegalArgumentException("interval value cannot be negative."); } if (str == null || interval == 0 || interval >= str.length() || isNullOrEmpty(stringToInsert)) { return str; } S... |
### Question:
Strings { public static String rightPad(String str, int size) { return rightPad(str, size, ' '); } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... strings); static boolean allNullOrEmpty(String... strings); static String l... |
### Question:
Strings { public static String leftPad(String str, int size) { return leftPad(str, size, " "); } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText(String... strings); static boolean allNullOrEmpty(String... strings); static String lef... |
### Question:
CharacterGraphDecoder { public List<ScoredItem<String>> getSuggestionsWithScores(String input) { Decoder decoder = new Decoder(); return getMatches(input, decoder); } CharacterGraphDecoder(float maxPenalty); CharacterGraphDecoder(); CharacterGraphDecoder(CharacterGraph graph); CharacterGraphDecoder(flo... |
### Question:
Strings { public static String whiteSpacesToSingleSpace(String str) { if (str == null) { return null; } if (str.isEmpty()) { return str; } return MULTI_SPACE.matcher(WHITE_SPACE_EXCEPT_SPACE.matcher(str).replaceAll(" ")) .replaceAll(" "); } private Strings(); static boolean isNullOrEmpty(String str); sta... |
### Question:
Strings { public static String eliminateWhiteSpaces(String str) { if (str == null) { return null; } if (str.isEmpty()) { return str; } return WHITE_SPACE.matcher(str).replaceAll(""); } private Strings(); static boolean isNullOrEmpty(String str); static boolean hasText(String s); static boolean allHasText... |
### Question:
Strings { public static String subStringAfterFirst(String str, String s) { if (isNullOrEmpty(str) || isNullOrEmpty(s)) { return str; } final int pos = str.indexOf(s); if (pos < 0) { return str; } else { return str.substring(pos + s.length()); } } private Strings(); static boolean isNullOrEmpty(String str... |
### Question:
Strings { public static String subStringAfterLast(String str, String s) { if (isNullOrEmpty(str) || isNullOrEmpty(s)) { return str; } final int pos = str.lastIndexOf(s); if (pos < 0) { return str; } else { return str.substring(pos + s.length()); } } private Strings(); static boolean isNullOrEmpty(String ... |
### Question:
Strings { public static String subStringUntilFirst(String str, String s) { if (isNullOrEmpty(str) || isNullOrEmpty(s)) { return str; } final int pos = str.indexOf(s); if (pos < 0) { return str; } else { return str.substring(0, pos); } } private Strings(); static boolean isNullOrEmpty(String str); static ... |
### Question:
Strings { public static String subStringUntilLast(String str, String s) { if (isNullOrEmpty(str) || isNullOrEmpty(s)) { return str; } final int pos = str.lastIndexOf(s); if (pos < 0) { return str; } return str.substring(0, pos); } private Strings(); static boolean isNullOrEmpty(String str); static boolea... |
### Question:
Strings { public static String[] separateGrams(String word, int gramSize) { if (gramSize < 1) { throw new IllegalArgumentException("Gram size cannot be smaller than 1"); } if (gramSize > word.length()) { return EMPTY_STRING_ARRAY; } String[] grams = new String[word.length() - gramSize + 1]; for (int i = 0... |
### Question:
Bytes { public static int normalize(int i, int bitCount) { int max = 0xffffffff >>> (32 - bitCount); if (i > max) { throw new IllegalArgumentException("The integer cannot fit to bit boundaries."); } if (i > (max >>> 1)) { return i - (max + 1); } else { return i; } } static byte[] toByteArray(int... uints... |
### Question:
Bytes { public static short[] toShortArray(byte[] ba, int amount, boolean bigEndian) { final int size = determineSize(amount, ba.length, 2); short[] result = new short[size / 2]; int i = 0; for (int j = 0; j < size; j += 2) { if (bigEndian) { result[i++] = (short) (ba[j] << 8 & 0xff00 | ba[j + 1] & 0xff);... |
### Question:
Bytes { public static String toHex(byte b) { return String.format("%x", b); } static byte[] toByteArray(int... uints); static int toInt(byte[] pb, boolean bigEndian); static int normalize(int i, int bitCount); static void normalize(int iarr[], int bitCount); static byte[] toByteArray(int i, int size, boo... |
### Question:
Bytes { public static String toHexWithZeros(byte b) { if (b == 0) { return "00"; } String s = toHex(b); if (s.length() == 1) { return "0" + s; } else { return s; } } static byte[] toByteArray(int... uints); static int toInt(byte[] pb, boolean bigEndian); static int normalize(int i, int bitCount); static ... |
### Question:
Bytes { public static void hexDump(OutputStream os, byte[] bytes, int columns) throws IOException { Dumper.hexDump(new ByteArrayInputStream(bytes, 0, bytes.length), os, columns, bytes.length); } static byte[] toByteArray(int... uints); static int toInt(byte[] pb, boolean bigEndian); static int normalize(... |
### Question:
SimpleTextReader implements AutoCloseable { public String asString() throws IOException { String res = IOs.readAsString(getReader()); if (trim) { return res.trim(); } else { return res; } } SimpleTextReader(InputStream is, Template template); SimpleTextReader(File file); SimpleTextReader(File file, Stri... |
### Question:
SimpleTextReader implements AutoCloseable { public List<String> asStringList() throws IOException { return IOs.readAsStringList(getReader(), trim, filters.toArray(new Filter[0])); } SimpleTextReader(InputStream is, Template template); SimpleTextReader(File file); SimpleTextReader(File file, String encod... |
### Question:
SimpleTextReader implements AutoCloseable { public IterableLineReader getIterableReader() throws IOException { return new IterableLineReader(getReader(), trim, filters); } SimpleTextReader(InputStream is, Template template); SimpleTextReader(File file); SimpleTextReader(File file, String encoding); Sim... |
### Question:
Hash implements Comparable<Hash> { @Override public int compareTo(Hash o) { if (bytes.length != o.bytes.length) { return bytes.length - o.bytes.length; } BigInteger a = new BigInteger(1, bytes); BigInteger b = new BigInteger(1, o.bytes); return a.compareTo(b); } Hash(byte[] bytes); byte[] getBytes(); Stri... |
### Question:
ECKeyStore { public void changePassword(char[] password) throws KeyStoreException { try { for (String alias : Collections.list(ks.aliases())) { Entry entry = ks.getEntry(alias, new PasswordProtection(this.password)); ks.setEntry(alias, entry, new PasswordProtection(password)); } Arrays.fill(this.password,... |
### Question:
MemoryMetricsCollector extends SystemMetricsCollector<MemoryMetrics> { @Override @ThreadSafe(enableChecks = false) public synchronized boolean getSnapshot(MemoryMetrics snapshot) { checkNotNull(snapshot, "Null value passed to getSnapshot!"); if (!mIsEnabled) { return false; } snapshot.sequenceNumber = mCo... |
### Question:
WakeLockMetrics extends SystemMetrics<WakeLockMetrics> { @Override public WakeLockMetrics set(WakeLockMetrics b) { heldTimeMs = b.heldTimeMs; acquiredCount = b.acquiredCount; if (b.isAttributionEnabled && isAttributionEnabled) { tagTimeMs.clear(); tagTimeMs.putAll(b.tagTimeMs); } return this; } WakeLockMe... |
### Question:
WakeLockMetrics extends SystemMetrics<WakeLockMetrics> { @Override public WakeLockMetrics sum(@Nullable WakeLockMetrics b, @Nullable WakeLockMetrics output) { if (output == null) { output = new WakeLockMetrics(isAttributionEnabled); } if (b == null) { output.set(this); } else { output.heldTimeMs = heldTim... |
### Question:
WakeLockMetrics extends SystemMetrics<WakeLockMetrics> { @Override public WakeLockMetrics diff(@Nullable WakeLockMetrics b, @Nullable WakeLockMetrics output) { if (output == null) { output = new WakeLockMetrics(isAttributionEnabled); } if (b == null) { output.set(this); } else { output.heldTimeMs = heldTi... |
### Question:
WakeLockMetrics extends SystemMetrics<WakeLockMetrics> { public @Nullable JSONObject attributionToJSONObject() throws JSONException { if (!isAttributionEnabled) { return null; } JSONObject attribution = new JSONObject(); for (int i = 0, size = tagTimeMs.size(); i < size; i++) { long currentTagTimeMs = tag... |
### Question:
CompositeMetricsSerializer extends SystemMetricsSerializer<CompositeMetrics> { public <T extends SystemMetrics<T>> CompositeMetricsSerializer addMetricsSerializer( Class<T> metricsClass, SystemMetricsSerializer<T> serializer) { Class<? extends SystemMetrics<?>> existingClass = mDeserializerClasses.get(ser... |
### Question:
SystemMetricsSerializer { public abstract void serializeContents(T metrics, DataOutput output) throws IOException; final void serialize(T metrics, DataOutput output); final boolean deserialize(T metrics, DataInput input); abstract long getTag(); abstract void serializeContents(T metrics, DataOutput outpu... |
### Question:
SystemMetricsSerializer { public final boolean deserialize(T metrics, DataInput input) throws IOException { if (input.readShort() != MAGIC || input.readShort() != VERSION || input.readLong() != getTag()) { return false; } return deserializeContents(metrics, input); } final void serialize(T metrics, DataO... |
### Question:
CompositeMetricsReporter implements SystemMetricsReporter<CompositeMetrics> { public void reportTo(CompositeMetrics metrics, SystemMetricsReporter.Event event) { for (int i = 0; i < mMetricsReporterMap.size(); i++) { Class<? extends SystemMetrics> metricsClass = mMetricsReporterMap.keyAt(i); if (metrics.i... |
### Question:
SensorMetricsCollector extends SystemMetricsCollector<SensorMetrics> { @Override public synchronized boolean getSnapshot(SensorMetrics snapshot) { Utilities.checkNotNull(snapshot, "Null value passed to getSnapshot!"); if (!mEnabled) { return false; } long currentTimeMs = SystemClock.elapsedRealtime(); sna... |
### Question:
CameraMetricsReporter implements SystemMetricsReporter<CameraMetrics> { @Override public void reportTo(CameraMetrics metrics, SystemMetricsReporter.Event event) { if (metrics.cameraOpenTimeMs != 0) { event.add(CAMERA_OPEN_TIME_MS, metrics.cameraOpenTimeMs); } if (metrics.cameraPreviewTimeMs != 0) { event.... |
### Question:
CpuFrequencyMetricsReporter implements SystemMetricsReporter<CpuFrequencyMetrics> { @Override public void reportTo(CpuFrequencyMetrics metrics, SystemMetricsReporter.Event event) { JSONObject output = metrics.toJSONObject(); if (output != null && output.length() != 0) { event.add(CPU_TIME_IN_STATE_S, outp... |
### Question:
TrafficStatsNetworkBytesCollector extends NetworkBytesCollector { @Override public synchronized boolean getTotalBytes(long[] bytes) { if (!mIsValid) { return false; } updateTotalBytes(); System.arraycopy(mTotalBytes, 0, bytes, 0, bytes.length); return true; } TrafficStatsNetworkBytesCollector(Context cont... |
### Question:
CompositeMetricsCollector extends SystemMetricsCollector<CompositeMetrics> { @Override @ThreadSafe(enableChecks = false) public boolean getSnapshot(CompositeMetrics snapshot) { checkNotNull(snapshot, "Null value passed to getSnapshot!"); boolean result = false; SimpleArrayMap<Class<? extends SystemMetrics... |
### Question:
MemoryMetrics extends SystemMetrics<MemoryMetrics> { public MemoryMetrics sum(@Nullable MemoryMetrics b, @Nullable MemoryMetrics output) { if (output == null) { output = new MemoryMetrics(); } if (b == null) { output.set(this); } else { MemoryMetrics latest = sequenceNumber > b.sequenceNumber ? this : b; ... |
### Question:
AppWakeupMetrics extends SystemMetrics<AppWakeupMetrics> { @Override public AppWakeupMetrics sum(@Nullable AppWakeupMetrics b, @Nullable AppWakeupMetrics output) { if (output == null) { output = new AppWakeupMetrics(); } if (b == null) { output.set(this); } else { output.appWakeups.clear(); for (int i = 0... |
### Question:
AppWakeupMetrics extends SystemMetrics<AppWakeupMetrics> { @Override public AppWakeupMetrics diff(@Nullable AppWakeupMetrics b, @Nullable AppWakeupMetrics output) { if (output == null) { output = new AppWakeupMetrics(); } if (b == null) { output.set(this); } else { output.appWakeups.clear(); for (int i = ... |
### Question:
AppWakeupMetrics extends SystemMetrics<AppWakeupMetrics> { public JSONArray toJSON() throws JSONException { JSONArray jsonArray = new JSONArray(); for (int i = 0; i < appWakeups.size(); i++) { JSONObject obj = new JSONObject(); AppWakeupMetrics.WakeupDetails details = appWakeups.valueAt(i); obj.put("key",... |
### Question:
SystemMetricsCollector { public abstract boolean getSnapshot(T snapshot); abstract boolean getSnapshot(T snapshot); abstract T createMetrics(); }### Answer:
@Test public void testNullSnapshot() throws Exception { mExpectedException.expect(IllegalArgumentException.class); T instance = getClazz().newInsta... |
### Question:
MemoryMetrics extends SystemMetrics<MemoryMetrics> { @Override public MemoryMetrics diff(@Nullable MemoryMetrics b, @Nullable MemoryMetrics output) { if (output == null) { output = new MemoryMetrics(); } if (b == null) { output.set(this); } else { MemoryMetrics latest = sequenceNumber >= b.sequenceNumber ... |
### Question:
SystemMetrics implements Serializable { public abstract T set(T b); abstract T sum(@Nullable T b, @Nullable T output); abstract T diff(@Nullable T b, @Nullable T output); abstract T set(T b); T sum(@Nullable T b); T diff(@Nullable T b); }### Answer:
@Test public void testSet() throws Exception { T a = c... |
### Question:
SystemMetrics implements Serializable { public abstract T sum(@Nullable T b, @Nullable T output); abstract T sum(@Nullable T b, @Nullable T output); abstract T diff(@Nullable T b, @Nullable T output); abstract T set(T b); T sum(@Nullable T b); T diff(@Nullable T b); }### Answer:
@Test public void testSu... |
### Question:
SystemMetrics implements Serializable { public abstract T diff(@Nullable T b, @Nullable T output); abstract T sum(@Nullable T b, @Nullable T output); abstract T diff(@Nullable T b, @Nullable T output); abstract T set(T b); T sum(@Nullable T b); T diff(@Nullable T b); }### Answer:
@Test public void testD... |
### Question:
ProcFileReader { public ProcFileReader reset() { mIsValid = true; if (mFile != null) { try { mFile.seek(0); } catch (IOException ioe) { close(); } } if (mFile == null) { try { mFile = new RandomAccessFile(mPath, "r"); } catch (IOException ioe) { mIsValid = false; close(); } } if (mIsValid) { mPosition = -... |
### Question:
StatefulSystemMetricsCollector { @Nullable public R getLatestDiffAndReset() { if (getLatestDiff() == null) { return null; } R temp = mPrev; mPrev = mCurr; mCurr = temp; return mDiff; } StatefulSystemMetricsCollector(S collector); StatefulSystemMetricsCollector(S collector, R curr, R prev, R diff); S getC... |
### Question:
StatefulSystemMetricsCollector { @Nullable public R getLatestDiff() { mIsValid &= mCollector.getSnapshot(this.mCurr); if (!mIsValid) { return null; } mCurr.diff(mPrev, mDiff); return mDiff; } StatefulSystemMetricsCollector(S collector); StatefulSystemMetricsCollector(S collector, R curr, R prev, R diff);... |
### Question:
HealthStatsMetrics extends SystemMetrics<HealthStatsMetrics> { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; HealthStatsMetrics that = (HealthStatsMetrics) o; if (dataType != null ? !dataType.equals(that.dataType) : that.... |
### Question:
SensorMetrics extends SystemMetrics<SensorMetrics> { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } SensorMetrics that = (SensorMetrics) o; return isAttributionEnabled == that.isAttributionEnabled && total.equals(t... |
### Question:
HealthStatsMetrics extends SystemMetrics<HealthStatsMetrics> { @Override public HealthStatsMetrics set(HealthStatsMetrics b) { dataType = b.dataType; measurement.clear(); for (int i = 0; i < b.measurement.size(); i++) { measurement.append(b.measurement.keyAt(i), b.measurement.valueAt(i)); } timer.clear();... |
### Question:
HealthStatsMetrics extends SystemMetrics<HealthStatsMetrics> { @VisibleForTesting static <K, V> ArrayMap<K, V> opArrayMaps(int op, ArrayMap<K, V> a, @Nullable ArrayMap<K, V> b) { int aSize = a.size(); ArrayMap<K, V> output = new ArrayMap<>(); for (int i = 0; i < aSize; i++) { K key = a.keyAt(i); V bValue ... |
### Question:
HealthStatsMetrics extends SystemMetrics<HealthStatsMetrics> { @VisibleForTesting static <K> SparseArray<K> op(int op, SparseArray<K> a, SparseArray<K> b, SparseArray<K> output) { output.clear(); for (int i = 0; i < a.size(); i++) { int aKey = a.keyAt(i); output.put(aKey, (K) opValues(op, a.valueAt(i), b.... |
### Question:
HealthStatsMetrics extends SystemMetrics<HealthStatsMetrics> { @Override public HealthStatsMetrics sum( @Nullable HealthStatsMetrics b, @Nullable HealthStatsMetrics output) { if (output == null) { output = new HealthStatsMetrics(); } output.dataType = dataType; if (b == null) { output.set(this); } else if... |
### Question:
HealthStatsMetrics extends SystemMetrics<HealthStatsMetrics> { @Override public HealthStatsMetrics diff( @Nullable HealthStatsMetrics b, @Nullable HealthStatsMetrics output) { if (output == null) { output = new HealthStatsMetrics(); } output.dataType = dataType; if (b == null || compareSnapshotAge(this, b... |
### Question:
SensorMetrics extends SystemMetrics<SensorMetrics> { @Override public SensorMetrics set(SensorMetrics b) { total.set(b.total); if (isAttributionEnabled && b.isAttributionEnabled) { sensorConsumption.clear(); for (int i = 0, l = b.sensorConsumption.size(); i < l; i++) { sensorConsumption.put(b.sensorConsum... |
### Question:
TimeMetricsCollector extends SystemMetricsCollector<TimeMetrics> { @Override @ThreadSafe(enableChecks = false) public boolean getSnapshot(TimeMetrics snapshot) { checkNotNull(snapshot, "Null value passed to getSnapshot!"); snapshot.realtimeMs = SystemClock.elapsedRealtime(); snapshot.uptimeMs = SystemCloc... |
### Question:
BluetoothMetrics extends SystemMetrics<BluetoothMetrics> { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } BluetoothMetrics that = (BluetoothMetrics) o; if (bleScanCount != that.bleScanCount || bleScanDurationMs != ... |
### Question:
BluetoothMetrics extends SystemMetrics<BluetoothMetrics> { @Override public BluetoothMetrics set(BluetoothMetrics b) { bleScanCount = b.bleScanCount; bleScanDurationMs = b.bleScanDurationMs; bleOpportunisticScanCount = b.bleOpportunisticScanCount; bleOpportunisticScanDurationMs = b.bleOpportunisticScanDur... |
### Question:
BluetoothMetrics extends SystemMetrics<BluetoothMetrics> { @Override public BluetoothMetrics diff(@Nullable BluetoothMetrics b, @Nullable BluetoothMetrics output) { if (output == null) { output = new BluetoothMetrics(); } if (b == null) { output.set(this); } else { output.bleScanCount = bleScanCount - b.b... |
### Question:
BluetoothMetrics extends SystemMetrics<BluetoothMetrics> { @Override public BluetoothMetrics sum(@Nullable BluetoothMetrics b, @Nullable BluetoothMetrics output) { if (output == null) { output = new BluetoothMetrics(); } if (b == null) { output.set(this); } else { output.bleScanCount = bleScanCount + b.bl... |
### Question:
CpuFrequencyMetrics extends SystemMetrics<CpuFrequencyMetrics> { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } CpuFrequencyMetrics that = (CpuFrequencyMetrics) o; if (timeInStateS.length != that.timeInStateS.lengt... |
### Question:
CpuFrequencyMetrics extends SystemMetrics<CpuFrequencyMetrics> { @Override public CpuFrequencyMetrics sum( @Nullable CpuFrequencyMetrics b, @Nullable CpuFrequencyMetrics output) { if (output == null) { output = new CpuFrequencyMetrics(); } if (b == null) { output.set(this); } else { for (int i = 0; i < ti... |
### Question:
SensorMetrics extends SystemMetrics<SensorMetrics> { @Override public SensorMetrics sum(@Nullable SensorMetrics b, @Nullable SensorMetrics output) { if (output == null) { output = new SensorMetrics(isAttributionEnabled); } if (b == null) { output.set(this); } else { total.sum(b.total, output.total); if (o... |
### Question:
WakeLockMetrics extends SystemMetrics<WakeLockMetrics> { @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } WakeLockMetrics that = (WakeLockMetrics) o; if (isAttributionEnabled != that.isAttributionEnabled || heldTimeM... |
### Question:
SensorMetrics extends SystemMetrics<SensorMetrics> { @Override public SensorMetrics diff(@Nullable SensorMetrics b, @Nullable SensorMetrics output) { if (output == null) { output = new SensorMetrics(isAttributionEnabled); } if (b == null) { output.set(this); } else { total.diff(b.total, output.total); if ... |
### Question:
UndertowEndpointManager implements WebSocketConnectionCallback, XEndpointManager<UndertowEndpoint> { UndertowEndpoint createEndpoint(WebSocketChannel channel) { final UndertowEndpoint endpoint = new UndertowEndpoint(this, channel); try { channel.setOption(Options.TCP_NODELAY, NODELAY); } catch (IOExceptio... |
### Question:
UndertowEndpoint extends AbstractReceiveListener implements XEndpoint { WebSocketCallback<Void> wrapCallback(XSendCallback callback) { return new WebSocketCallback<Void>() { private final AtomicBoolean onceOnly = new AtomicBoolean(); @Override public void complete(WebSocketChannel channel, Void context) {... |
### Question:
PomHelper { public static boolean updatePomVersions(List<PomUpdateStatus> pomsToChange, List<DependencyVersionChange> changes) throws IOException { Map<String, String> propertyChanges = new TreeMap<>(); for (PomUpdateStatus status : pomsToChange) { status.updateVersions(changes, propertyChanges); } if (!p... |
### Question:
BorderingDistanceMetric implements SpatialDistanceMetric { @Override public double distance(Geometry g1, Geometry g2) { if (adjacencyList.isEmpty()) { throw new UnsupportedOperationException(); } int srcId = getContainingGeometry(g1); int destId = getContainingGeometry(g2); if (srcId < 0) { throw new Ille... |
### Question:
Configurator implements Cloneable { public <T> T get(Class<T> klass, String name) throws ConfigurationException { return get(klass, name, null); } Configurator(Configuration conf); Configuration getConf(); T get(Class<T> klass, String name); T get(Class<T> klass, String name, String runtimeKey, String run... |
### Question:
SparseMatrix implements Matrix<SparseMatrixRow> { @Override public Iterator<SparseMatrixRow> iterator() { return new SparseMatrixIterator(); } SparseMatrix(File path); long lastModified(); @Override SparseMatrixRow getRow(int rowId); @Override int[] getRowIds(); @Override int getNumRows(); ValueConf getVa... |
### Question:
DenseMatrix implements Matrix<DenseMatrixRow> { @Override public Iterator<DenseMatrixRow> iterator() { return new DenseMatrixIterator(); } DenseMatrix(File path); @Override DenseMatrixRow getRow(int rowId); @Override int[] getRowIds(); int[] getColIds(); @Override int getNumRows(); ValueConf getValueConf(... |
### Question:
PageViewUtils { public static SortedSet<DateTime> timestampsInInterval(DateTime start, DateTime end) { if (start.isAfter(end)) { throw new IllegalArgumentException(); } DateTime current = new DateTime( start.year().get(), start.monthOfYear().get(), start.dayOfMonth().get(), start.hourOfDay().get(), 0); if... |
### Question:
BorderingDistanceMetric implements SpatialDistanceMetric { @Override public List<Neighbor> getNeighbors(Geometry g, int maxNeighbors) { return getNeighbors(g, maxNeighbors, Double.MAX_VALUE); } BorderingDistanceMetric(SpatialDataDao dao, String layer); @Override void setValidConcepts(TIntSet concepts); @O... |
### Question:
Title implements Externalizable { public Title(String text, LanguageInfo language) { this(text, false, language); } Title(String text, LanguageInfo language); Title(String text, boolean isCanonical, LanguageInfo lang); Title(String title, Language language); String getCanonicalTitle(); LanguageInfo getL... |
### Question:
WikidataParser { public WikidataEntity parse(String json) throws WpParseException { JacksonTermedStatementDocument mwDoc; try { mwDoc = mapper.readValue(json, JacksonTermedStatementDocument.class); } catch (IOException e) { LOG.info("Error parsing: " + json); throw new WpParseException(e); } WikidataEntit... |
### Question:
GoogleSimilarity implements VectorSimilarity { public GoogleSimilarity(int numPages) { this.numPages = numPages; } GoogleSimilarity(int numPages); @Override synchronized void setMatrices(SparseMatrix features, SparseMatrix transpose, File dataDir); @Override double similarity(TIntFloatMap vector1, TIntFlo... |
### Question:
CosineSimilarity implements VectorSimilarity { @Override public double similarity(MatrixRow a, MatrixRow b) { return SimUtils.cosineSimilarity(a, b); } @Override synchronized void setMatrices(SparseMatrix features, SparseMatrix transpose, File dataDir); @Override double similarity(MatrixRow a, MatrixRow ... |
### Question:
SimUtils { public static double cosineSimilarity(TIntDoubleMap X, TIntDoubleMap Y) { double xDotX = 0.0; double yDotY = 0.0; double xDotY = 0.0; for (int id : X.keys()) { double x = X.get(id); xDotX += x * x; if (Y.containsKey(id)) { xDotY += x * Y.get(id); } } for (double y : Y.values()) { yDotY += y * y... |
### Question:
SimUtils { public static TIntDoubleMap normalizeVector(TIntDoubleMap X) { TIntDoubleHashMap Y = new TIntDoubleHashMap(); double sumSquares = 0.0; for (double x : X.values()) { sumSquares += x * x; } if (sumSquares != 0.0) { double norm = Math.sqrt(sumSquares); for (int id : X.keys()) { Y.put(id, X.get(id)... |
### Question:
GraphDistanceMetric implements SpatialDistanceMetric { @Override public double distance(Geometry g1, Geometry g2) { if (adjacencyList.isEmpty()) { throw new UnsupportedOperationException(); } List<ClosestPointIndex.Result> closest = index.query(g2, 1); int maxSteps = maxDistance; if (maxSteps == 0 || clos... |
### Question:
SimUtils { public static Map sortByValue(TIntDoubleHashMap unsortMap) { if (unsortMap.isEmpty()) { return new HashMap(); } HashMap<Integer, Double> tempMap = new HashMap<Integer, Double>(); TIntDoubleIterator iterator = unsortMap.iterator(); for ( int i = unsortMap.size(); i-- > 0; ) { iterator.advance();... |
### Question:
DatasetDao { public static Collection<Info> readInfos() throws DaoException { try { return readInfos(WpIOUtils.openResource(RESOURCE_DATASET_INFO)); } catch (IOException e) { throw new DaoException(e); } } DatasetDao(); DatasetDao(Collection<Info> info); void setNormalize(boolean normalize); List<Dataset... |
### Question:
DatasetDao { public Dataset get(Language language, String name) throws DaoException { if (groups.containsKey(name)) { List<Dataset> members = new ArrayList<Dataset>(); for (String n : groups.get(name)) { members.add(get(language, n)); } return new Dataset(name, members); } if (name.contains("/") || name.c... |
### Question:
MostSimilarGuess { public double getNDGC() { if (observations.isEmpty()) { return 0.0; } TIntDoubleMap actual = new TIntDoubleHashMap(); for (KnownSim ks : known.getMostSimilar()) { actual.put(ks.wpId2, ks.similarity); } int ranks[] = new int[observations.size()]; double scores[] = new double[observations... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.