id
stringlengths
7
14
text
stringlengths
1
37.2k
106681970_1048
@Override public String toString() { return toString(true); }
106730885_1
public static void Before(Object... args) { addHook(args, true, false); }
106807349_26
public void readLog(String project, String logstore) { Client client = acqClient(); int shard_id = 0; long curTimeInSec = System.currentTimeMillis() / 1000; try { GetCursorResponse cursorRes = client.GetCursor(project, logstore, shard_id, curTimeInSec - 3600); String beginCursor = cursor...
106811067_44
@Override public String getHandledEvent() { return ProcessRuntimeEvent.ProcessEvents.PROCESS_CREATED.name(); }
106813148_35
public CompleteTaskCmdExecutor(TaskAdminRuntime taskAdminRuntime) { this.taskAdminRuntime = taskAdminRuntime; }
106816063_1
public static void main(String[] args) throws IOException { BenchmarkCollection bmcollection = null; String toolName = null, benchmark = null; IBenchmarkTask task = null; File toolDirectory = null; int runNumber = -1; int timeBudget = -1; String mode = null; if (BENCHMARK_CONFIG != null) { try { bmcollect...
106817657_51
public static Either<ValidationResult.Builder.ElementStep, FeelExpression> parse(final CharSequence charSequence) { try { return Eithers.right(PARSER.parse(charSequence)); } catch (final ParserException e) { return Eithers.left(ValidationResult.init.message("Could not parse '" + charSequence + "...
106841635_350
private Schema(Builder builder) { this.fieldNames = builder.fields.stream().map(Field::name).collect(toList()); this.fields = ImmutableList.copyOf(builder.fields); this.optionalFields = ImmutableSet.copyOf(builder.optionalFields); this.constraints = ImmutableList.copyOf(builder.constraints); this.ig...
106872676_7
@Override public void onStartup(ServletContext servletContext) throws ServletException { if (env.getActiveProfiles().length != 0) { log.info("Web application configuration, using profiles: {}", (Object[]) env.getActiveProfiles()); } EnumSet<DispatcherType> disps = EnumSet.of(DispatcherType.REQUEST, ...
106921925_3
@SuppressWarnings("unchecked") @Override @StreamListener(AuditConsumerChannels.AUDIT_CONSUMER) public void receiveCloudRuntimeEvent(@Headers Map<String, Object> headers, CloudRuntimeEvent<?, ?>... events) { if (events != null) { AtomicInteger counter = new AtomicInteger(0); for (CloudRuntimeEvent ev...
106984925_0
public void login() { if (InputHelper.isEmpty(userName) || InputHelper.isEmpty(password)) { AlertUtils.showToastShortMessage(App.getInstance(), "Please input username and password!"); return; } String auth = StringUtils.getBasicAuth(userName, password); execute(true, RestHelper.createRem...
107019647_6
public static String post(String requestUrl, Object data, ContentType contentType) { if (StringUtils.isBlank(requestUrl)) { throw new RuntimeException("requestUrl cann't be null"); } if (contentType == null) { throw new RuntimeException("contentType cann't be null"); } HttpPost post ...
107071531_0
public static @NotNull List<String> getArgsForMethod(@NotNull List<String> args, @NotNull Method method) { if (args.size() == 0 && method.getParameterCount() == 0) { return Collections.emptyList(); } List<String> argsOut = new ArrayList<>(); if (args.size() < method.getParameterCount()) { ...
107095945_3
@Override public void run() { Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); FileDownloadConnection connection = null; final long beginOffset = connectTask.getProfile().currentOffset; boolean isConnected = false; do { try { if (paused) { return; ...
107103226_93
@NonNull @Override public Map<String, Object> toMap() { Map<String, Object> map = new HashMap<>(); map.put(FIELD_NAME, name); map.put(FIELD_ADDRESS_CITY, addressCity); map.put(FIELD_ADDRESS_COUNTRY, addressCountry); map.put(FIELD_ADDRESS_LINE1, addressLine1); map.put(FIELD_ADDRESS_LINE1_CHECK, a...
107150826_3
public static Address from(byte[] address) { return new Address(new ByteArray(address)); }
107165228_4
static File resolveNextMigrationFile(File migrationDir) { Optional<Path> lastFile = resolveExistingMigrations(migrationDir, true, false) .stream() .findFirst(); Long fileIndex = lastFile.map((Path input) -> FILENAME_PATTERN.matcher(input.getFileName().toString())) .map(matcher -> { if (matcher.find()) ...
107220808_44
public static Path of(String... segments) { if (segments.length == 0) { return ImmutablePath.EMPTY; } PathBuilder pathBuilder = new PathBuilder(); for (String segment : segments) { pathBuilder.splitAndAdd(segment, false); } return ImmutablePath.create(pathBuilder); }
107254605_1
@Override public IBANValidationResult validate(String iban) { return getRestTemplate().getForObject(URL_TEMPLATE, IBANValidationResult.class, iban); }
107304223_8
@Override public String encode(final ByteBuffer unencodedData) { final int maxBytes = unencodedData.limit(); final StringBuilder sb = new StringBuilder(); int bitSource = nextByte(unencodedData); int unencodedBits = bitSource >> 2; // init unencodedBits with first 6 bits int bitIndex = 1; // initia...
107325380_12
@Override public MergeResult<SyncObject> resolveDiff(Class<? extends SyncObject> clazz, SyncObject local, SyncObject foreign) { return revolveConflict(local, foreign); }
107375180_161
public ElementDescriptor getDescriptor(Object pmo) { ElementDescriptor descriptor = findDescriptor(pmo); descriptor.addAspectDefinitions(additionalAspects); return descriptor; }
107386062_5
@Override public <T> TypedProperty<T> getProperty(String key, ValueParser<T> valueParser) { return new DefaultTypedProperty<T>(getProperty(key), valueParser); }
107436391_5
public static String getUserId(final Resource resource) { final String prefix = SlingshotConstants.APP_ROOT_PATH + "/"; String id = null; if ( resource.getPath().startsWith(prefix) ) { final int areaEnd = resource.getPath().indexOf('/', prefix.length()); if ( areaEnd != -1 ) { f...
107437722_133
@Override public final Object get(Object key) { if (key == null) { return null; } final ComputedPropertyParameter computedPropertyParameter = new ComputedPropertyParameter((String) key); log.trace("Getting value for key [ {} ] from CombinedProperties", computedPropertyParameter.getCacheId()); ...
107457897_1
@VisibleForTesting final int[] filterNonZeroIds(int[] allIds) { int nonZeroIdsCount = 0; for (int id : allIds) { if (id != 0) { nonZeroIdsCount++; } } if (nonZeroIdsCount == allIds.length) { return allIds; } int[] groupIds = new int[nonZeroIdsCount]; for (...
107465031_0
public boolean someLibraryMethod() { return true; }
107473189_9
public static @Nullable Method getMethod(@Nullable Class<?> clazz, String methodName) { if (clazz == null) { return null; } try { return clazz.getMethod(methodName); } catch (Exception e) { logger.debug(e.getMessage(), e); return null; } }
107511723_92
public Optional<byte[]> getBody() { if (bodyCache != null) { return bodyCache; } synchronized (this) { if (bodyCache != null) { return bodyCache; } return bodyCache = doGetBody(); } }
107515570_1
@Override public WechatMessage handle(JsonObject result) { // WechatMessage msg = new WechatMessage(); WechatMessage msg = gson.fromJson(result, WechatMessage.class); msg.setRaw(result.toString()); return msg; }
107536049_79
public void add(List<K> cascadingFactors, V value) { if (CollectionValues.isNullOrEmpty(cascadingFactors)) { this.value = value; return; } List<K> factors = Lists.newArrayList(cascadingFactors); K factor = factors.remove(0); ValueCheckers.notNull(factor, "factor"); SearchTree<K,...
107554429_150
@Override public int hashCode() { return streamConnectionId.hashCode(); }
107559907_4
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Interval other = (Interval) obj; if (endDate == null) { if (other.endDate != null) return false; ...
107591789_1
public static <T> T deserialize(String json, Class<T> type) { try { return new ObjectMapper().readValue(json,type); } catch (Exception ex) { log.error(ex.getMessage(),ex); } return null; }
107655600_15
public static List<MultiPartSpecification> convertToMultipart(List<Map<String, String>> parts) { return parts.stream() .map(part -> { final MultiPartSpecification specification; final String name = part.get(TestCaseUtils.JSON_FIELD_MULTIPART_NAME); Preconditions.checkNot...
107676801_25
@Deprecated @Restricted(DoNotUse.class) public static String resolve(ConfigurationContext context, String toInterpolate) { return context.getSecretSourceResolver().resolve(toInterpolate); }
107785408_7
public static ObjectMapper objectMapper() { return new ObjectMapper() // Property visibility .setDefaultPropertyInclusion(JsonInclude.Include.ALWAYS) .setDefaultVisibility(JsonAutoDetect.Value.construct(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.PROTECTED_AND_PUBLIC)) ...
107839447_17
public Matrix plusTo(@NonNull Matrix matrix) { checkNotNull(matrix); return Matrix.plusTo(this, matrix); }
107873649_2
List<FillOption> getOptions() { final List<FillOption> savedOptions = readConfigsFromStore(); final List<FillOption> result = new ArrayList<>(fillConfig.getOptions().size() + savedOptions.size()); result.addAll(savedOptions); result.addAll(fillConfig.getOptions()); return result; }
107914762_0
@Override public boolean shouldFilter(HttpRequestMessage msg) { for (String target: prefixPatterns) { if (msg.getPath().matches(target)) { return true; } } return false; }
107930307_0
public <SagaData> SagaInstance create(Saga<SagaData> saga, SagaData data) { SagaManager<SagaData> sagaManager = (SagaManager<SagaData>)sagaManagers.get(saga); if (sagaManager == null) throw new RuntimeException(("No SagaManager for " + saga)); return sagaManager.create(data); }
107932176_4
@RequestMapping(path = "/{orderId}", method = RequestMethod.GET) public ResponseEntity<GetOrderResponse> getOrder(@PathVariable String orderId) { return orderHistoryDao.findOrder(orderId) .map(order -> new ResponseEntity<>(makeGetOrderResponse(order), HttpStatus.OK)) .orElseGet(() -> new ResponseE...
108043571_0
public void uninstallAddon(AddonUninstallRequest request) throws IOException { addonSupport.uninstallAddon(request); }
108180205_0
public static List<Path> kShortestPaths(Graph g, Node origin, Node destination, Integer K) throws Exception{ List<Path> A = new LinkedList<Path>(); PriorityQueue<Path> B = new PriorityQueue<Path>(); A.add(SPAlgorithms.dijkstra(g, origin,destination)); if (A.get(0) == null) throw new Exception(); for (Integer k =...
108181481_18
public static boolean handle3DSecureResult(int requestCode, int resultCode, Intent data, Gateway3DSecureCallback callback) { if (callback == null) { return false; } if (requestCode == REQUEST_3D_SECURE) { if (resultCode == Activity.RESULT_OK) { String acsResultJson = data.getStr...
108452902_0
@GetMapping(path = "/users/{userId}/commands/recommendFriends") public Flux<RankedUser> recommendFriends(@PathVariable Long userId) { return Flux.fromIterable(friendRepository.recommendedFriends(userId)); }
108511089_7
public void startLogIngest() { DiscoveryEngineAbstract wd = new WeblogDiscoveryEngine(props, es, spark); wd.preprocess(); wd.process(); LOG.info("Logs have been ingested successfully"); }
108538904_1
public Query parse() throws SyntaxError { // // parse query string into terms -> use analyzer pipeline // final IndexSchema schema = req.getSchema(); String defaultField = QueryParsing.getDefaultField(schema, getParam(CommonParams.DF)); if(defaultField == null){ // todo ?? check if that is sen...
108542665_125
@Override public final B value(String value) { setValue(value); return builder; }
108649340_5
@Override public Category findCategoryById(Long id) { return categoryRepository.findOne(id); }
108706261_0
@Override public Object clone() { Set<TurtlePLSInLogo>[][] turtleSet = new Set[this.width][this.height]; Set<Mark>[][] markSet = new Set[this.width][this.height]; for(int x = 0; x < this.width; x++) { for(int y = 0; y < this.height; y++) { turtleSet[x][y] = new HashSet(); markSet[x][y] = new HashSet(); ...
108730056_24
@Override public void write(final LogContext log) { final LogLevel level = log.level(); final Throwable throwable = log.throwable(); final ArrayList<Throwable> suppressedThrowables = log.suppressedThrowables(); if (throwable != null && suppressedThrowables != null) { for (Throwable t : suppress...
108986590_1
;
108987781_0
@Transactional public List listAllFiles(){ return fileDao.listAllFiles(); }
109051447_21
RemoteRaftServer getCurrentLeader() { return getServer(vState.getCurrentLeader()); }
109141516_0
public synchronized static Telemetry getInstance() { // If sTelemetryInstance is not initialized, telemetry will be disabled. if (sTelemetryInstance == null) { new Builder().build(); } return sTelemetryInstance; }
109154869_141
@Override public boolean is_abstract() { return false; }
109219866_0
public static Services getDefault() { return INSTANCE; }
109246147_11
@NonNull static List<String> validatePromptParams(@NonNull Mode mode, @NonNull Goldfinger.PromptParams params) { List<String> errors = new ArrayList<>(); if (!(params.dialogOwner() instanceof Fragment) && !(params.dialogOwner() instanceof FragmentActivity)) { errors.add("DialogOwner must be of instance...
109259109_0
public Set<String> getKeys(String pattern) { Map<String, JedisPool> clusterNodes = jedisCluster.getClusterNodes(); TreeSet<String> keys = new TreeSet<String>(); for (String k : clusterNodes.keySet()) { logger.debug("Getting keys from: {}", k); JedisPool jp = clusterNodes.get(k); Jedis connection = jp.getResour...
109294216_4
@Override public void savePhoto(@NonNull Photo photo) { photoLocalDataSource.savePhoto(photo); cachedPhotos.put(photo.getPhotoId(), photo); }
109329697_14
public double getZawgyiProbability(String input, boolean verbose) { return model.predict(input, verbose); }
109339072_9
public Operand(OperandType type, int value) { this.type = type; this.value = value; }
109361137_91
@WXComponentProp(name = Constants.Name.RESIZE) public void setResize(String resize) { (getHostView()).setScaleType(getResizeMode(resize)); }
109377658_13
public static double string2Double(String str, double defaultValue) { try { if (!StringUtils.isBlank(str)) { return Double.parseDouble(str); } } catch (NumberFormatException ex) { if (logger.isWarnEnabled()) { logger.warn(String.format("Parse %s to double fail, de...
109394368_32
public void setUserId(int userId) { this.userId = userId; }
109401796_2
private FeatureExtension[] mergeExtensions(Feature f1, Feature f2, MergeContext ctx) { Map<String,FeatureExtension> extensions = new HashMap<>(f1.getExtensions()); Map<String,FeatureExtension> addExtensions = new HashMap<>(); for (Map.Entry<String,FeatureExtension> exEntry : f2.getExtensions().entrySet()) ...
109413088_0
static <T> T instantiate(Class<T> type, Object... args) { try { if (args.length == 0) { //return type.newInstance(); //deprecated return type.getDeclaredConstructor().newInstance(); } else { Class<?>[] classes = toClasses(args); return type.getDeclared...
109554170_6
public Statement createStatement(String sql) { return (Statement) invokeParser("statement", sql, PardSqlBaseParser::singleStatement); }
109644809_7
public Document getXML(String processName, @SuppressWarnings("UnusedParameters") int processVersion) { SAXReader reader = new SAXReader(); URL url = this.getClass().getResource("/" + processName.replaceAll("\\.", "/") + ".xml"); Document document; try { document = reader.read(url); } catch ...
109754092_3
@Override public AuditReplayCommand parse(Text inputLine, Function<Long, Long> relativeToAbsolute) throws IOException { Matcher m = MESSAGE_ONLY_PATTERN.matcher(inputLine.toString()); if (!m.find()) { throw new IOException("Unable to find valid message pattern from audit log line: " + inputLine); } long rel...
109754107_0
@Override public long skip(long count) { long skipped = 0; while (skipped < count) { try { if (!ensureBuffer()) { return skipped; // end of results } } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new UncheckedInterruptedException(e); } ...
109774858_2
public LRUCache(int capacity) { this.capacity = capacity; map = new HashMap<>(); head = new Node(-1, -1); tail = new Node(-1, -1); head.next = tail; tail.prev = head; }
109902579_117
public ServiceHost setPublicUri(URI publicUri) { this.state.publicUri = publicUri; clearUriAndLogPrefix(); return this; }
109917787_31
@Override public void execute(final CommandLine commandLine, final Options options, RPCHook rpcHook) throws SubCommandException { DefaultMQAdminExt defaultMQAdminExt = new DefaultMQAdminExt(rpcHook); defaultMQAdminExt.setInstanceName(Long.toString(System.currentTimeMillis())); String topic = commandLine.get...
109999895_30
public static <T> Guard<Chain<T>, T> call(@NonNull Callable<T> callable) { return new Guard<>(new Chain<T>(null, InternalConfiguration.getInstance(null)).access(), callable); }
110054572_6
public State getState() { return state; }
110099034_2
public CharacterComposite sentenceByChinese() { List<ChineseWord> words = new ArrayList<>(); words.add(new ChineseWord(Arrays.asList(new Character('我')))); words.add(new ChineseWord(Arrays.asList(new Character('是')))); words.add(new ChineseWord(Arrays.asList(new Character('来'), new Character('自')))); words.a...
110117973_41
protected static List<String> queriesForBounds( long min, long max, int parallelism, String splitColumn, QueryBuilder queryBuilder) { List<QueryRange> ranges = generateRanges(min, max, parallelism); return ranges.stream() .map( x -> queryBuilder .withParallelizationCondition( ...
110121462_2
public static void removeRecursive(final Path path) throws IOException { Files.walkFileTree( path, new SimpleFileVisitor<Path>() { @Override public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException { Files.deleteIfExists(fi...
110129066_0
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doWithAuthentication(request, response, this::updateConfiguration); }
110164590_0
@Override public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { User user = repository.findOne(username); if (user == null) { throw new UsernameNotFoundException(username); } log.debug(" User from username ", user.toString()); return user; }
110211147_1
public PageResult<String> findKeysForPage(String patternKey, int currentPage, int pageSize) { ScanOptions options = ScanOptions.scanOptions() .match(patternKey) .build(); RedisConnectionFactory factory = stringRedisTemplate.getConnectionFactory(); RedisConnection rc = factory.getConn...
110344150_1
public static int randomizedSelect(int[] a, int p, int r, int i) { if (p == r) { return a[p];//这种情况就是数组内只有一个元素 } // 查找p r中间点 q int q = randomizedPartition(a, p, r); // 这里都是基于游标的,因为k是第几个,所以要加 1 int k = q - p + 1;//拿到上一句中作为枢纽的数是第几小的数 if (i == k) { //找到 return a[q]; ...
110449600_0
@Override public void addNewDog(DogFirebase dogFirebase) { firebaseRepository.addNew(dogFirebase); }
110454850_13
public static EditMessageMediaBuilder forMessage(AudioMessage message) { Objects.requireNonNull(message, "audio message cannot be null"); return builder() .chatId(message.getChat().getChatId()) .messageId(message.getMessageId()); }
110526820_8
@Override public void override(UserTask userTask) { String oldFormKey = userTask.getFormKey(); String newFormKey = modelIdentifiers.get(oldFormKey); if (newFormKey != null) { userTask.setFormKey(newFormKey); } }
110547066_3
@Override public void accept(Swagger swagger) { int initial = swagger.getDefinitions().size(); Pruner pruner = new Pruner(buildHierarchy(swagger)); while(pruner.hasPruneable()) { Stream<String> prune = pruner.prune(); Map<String, Model> defs = swagger.getDefinitions(); prune.forEach(...
110686293_62
public static List<Location> getLocationsBetween(List<Location> locationList, long minimumTimestamp, long maximumTimestamp) { List<Location> matchingLocations = new ArrayList<>(); for (Location location : locationList) { if (location.getTimestamp() < minimumTimestamp || location.getTimestamp() >= maximu...
110719900_2
public static boolean isEmailValid(String email) { Pattern pattern; Matcher matcher; final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@" + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; pattern = Pattern.compile(EMAIL_PATTERN); matcher = pat...
110826170_26
@Override public void setText(CharSequence text, BufferType type) { originalText = new SpannableStringBuilder(text); final SpannableStringBuilder spacedOutString = getSpacedOutString(text); super.setText(spacedOutString, BufferType.SPANNABLE); }
110837893_0
@Override public List<Task> loadTasks() { List<Task> tasks = new ArrayList<>(); // 1. 获取task配置文件 File[] taskFiles = FileAccessSupport.getTaskFiles(DEFAULT_TASK_PATH); // 2. 解析task配置文件 for (File taskFile : taskFiles) { Task task = FileParser.parseTask(taskFile, false); tasks.add(task...
110937663_4
public FieldDescriptors and(FieldDescriptor... additionalDescriptors) { return andWithPrefix("", additionalDescriptors); }
110988186_211
@Override public void generateGraph( Graph<V, E> target, VertexFactory<V> vertexFactory, Map<String, V> resultMap) { /* * Special cases */ if (n == 0) { return; } else if (n == 1) { target.addVertex(vertexFactory.createVertex()); return; } /* * Ensure dire...
110995785_4
public static ValueSets getEmpty(SparkSession spark) { Dataset<ValueSet> emptyValueSets = spark.emptyDataset(VALUE_SET_ENCODER) .withColumn("timestamp", lit(null).cast("timestamp")) .as(VALUE_SET_ENCODER); return new ValueSets(spark, spark.emptyDataset(URL_AND_VERSION_ENCODER), emptyValueS...
111026852_397
@Override public Response apply(Sc2Api.Response sc2ApiResponse) { require("sc2api response", sc2ApiResponse); if (sc2ApiResponse.getErrorCount() > 0) { return ResponseError.from(sc2ApiResponse); } if (sc2ApiResponse.hasPing()) { return ResponsePing.from(sc2ApiResponse); } if (sc2...
111042175_0
static String parseContainerIdFromHostname(String hostname) { return hostname.replaceAll("recommendation-v\\d+-", ""); }
111090962_7
public List<Integer> match(String toMatch) { // For now, we do case-insensitive search... toMatch = toMatch.toLowerCase(); ArrayList<Integer> result= new ArrayList<>(); if (toMatch.length() == 0) return result; int found = 0; while ((found = content.indexOf(toMatch, found)) != -...
111096014_345
@Override public void onNewPartition(String partitionName, Partition partition) { addPartition(partition); }
111107245_954
public static ConjunctFuture<Void> waitForAll(Collection<? extends CompletableFuture<?>> futures) { checkNotNull(futures, "futures"); return new WaitingConjunctFuture(futures); }