天天看點

ARTS Week 1AlgorithmReviewTipShare

ARTS Week 1

  • Algorithm
    • [Two Sum](https://leetcode.com/problems/two-sum/)
  • Review
    • [Why We’re Switching to gRPC](https://eng.fromatob.com/post/2019/05/why-were-switching-to-grpc/)
  • Tip
    • [Spring Cloud/Boot 微服務 優雅停止(非kill -9)](https://blog.csdn.net/gpstnt/article/details/86690025)
  • Share
    • [Best Performance Practices for Hibernate 5 and Spring Boot 2 (Part 1)](https://dzone.com/articles/50-best-performance-practices-for-hibernate-5-amp)

Algorithm

Two Sum

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class TwoSum_1_Self {

	public static void main(String[] args) {
		int[] nums = {1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 15, 20};
		int[] ints = twoSum(nums, 7);
		List<Integer> result = Arrays.stream(ints).boxed().collect(Collectors.toList());
		result.stream().forEach(System.out::println);
	}

	public static int[] twoSum(int[] nums, int target) {
		int[] result = new int[2];
		for (int i = 0; i < nums.length; i++) {
			int secondNum = target - nums[i];
			for (int j = i + 1; j < nums.length; j++) {
				if (secondNum == nums[j]) {
					result = new int[]{i, j};
					return result;
				}
			}
		}
		return result;
	}
}
           

Review

Why We’re Switching to gRPC

Summary:

  1. gRPC faster than JSON/HTTP.
  2. Two outstanding advantages of gRPC.One is clear interface specifications,the other is support for streaming.
  3. There are a couple of downsides of gRPC.Both of them have to do with tooling, rather than the protocol itself.
  4. For us, gRPC is going to be the default option for any new internal service we build.

Tip

Spring Cloud/Boot 微服務 優雅停止(非kill -9)

Share

Best Performance Practices for Hibernate 5 and Spring Boot 2 (Part 1)