전체 글
-
elasticsearch 7 에서 total count 확인하기elasticsearch 2021. 6. 4. 00:25
GET my-index*/_search { "track_total_hits": true, "query": { "match": { "myfield": { "value": "some" } } } } elasticsearch 7 부터는 결과 개수가 10,000 개 이상일 때, 정확한 개수를 얻기 위해서는 위에서 처럼 "track_total_hits": true 를 넣어줘야 한다. (elasticsearch 6 에서는 track_total_hits 를 설정하지 않아도 잘 나왔었는데..) track_total_hits 을 설정하지 않았을 때 결과 "relation": "gte" 로 total 개수가 10000 보다 크거나 같음을 의미 "hits" : { "total" : { "value" : 10000, "rel..
-
docker image 만들기docker 2021. 6. 1. 22:59
1. Dockerfile, app.py 를 준비 https://github.com/mmumshad/simple-webapp-flask 을 참고해 Dockerfile FROM ubuntu:18.04 ENV TZ=Asia/Seoul ENV LANG=ko_KR.UTF-8 # ENV PATH="${PATH}:/home/windbird/.local/bin" # USER irteam # ADD --chown=irteam:irteam ./server/target/universal/stage /app/ RUN apt-get update && apt-get install -y python python-pip RUN pip install --upgrade pip && pip install flask COPY app.py ..
-
Dark Syntax Sugarscala/basic 2021. 5. 23. 15:30
Single Abstract Method trait Action { def act(x: Int): Unit } // 다음과 같이 사용해야 하지만 val action: Action = new Action { override def act(x: Int): Unit = println(x) } // 아래와 같이 표현하는 것도 가능 val action: Action = (x: Int) => println(x) // 비슷하게 아래와 같이 Thread 생성 가능 val thread: Thread = new Thread(() => println("run")) Methods with ':' are special class MyStream[T] { def -->:(value: T): MyStream[T] = ??? } v..
-
BroadcastState 예제flink 2021. 5. 20. 01:37
문제 입력으로 직원 Employee(id: Int, dept: String) 목록과 퇴직자 RetireId(id: Int) 목록이 있을 때, 직원 목록에서 퇴직자 목록을 제외 후 부서별(dept)로 남게되는 인원 정보 EmployeeLeft(dept: String, count: Int) 를 출력한다. RetireId 목록을 broadcast 해 구현한다. Input(in code) 직원 Employee Employee(1, "dept1") Employee(2, "dept2") Employee(3, "dept3") Employee(4, "dept1") Employee(5, "dept2") Employee(6, "dept3") Employee(7, "dept4") 퇴직자 RetireId RetireId(2..
-
CheckPoint 예제flink 2021. 5. 19. 22:42
문제 Stream WordCount 예제에 CheckPoint 를 적용해 본다. Code import org.apache.flink.api.common.restartstrategy.RestartStrategies import org.apache.flink.api.java.utils.ParameterTool import org.apache.flink.streaming.api.CheckpointingMode import org.apache.flink.streaming.api.environment.CheckpointConfig.ExternalizedCheckpointCleanup import org.apache.flink.streaming.api.scala._ object CheckPointExample { ..
-
ValueState 예제flink 2021. 5. 19. 21:53
문제 입력으로 MyInput(key, value) 가 들어올 때, 각각의 key 값으로 groupBy 해 각각의 id 에 대한 짝수번째 value 값을 출력한다. Input(in code) case class MyInput(key: String, value: Int) val data = env.fromElements( MyInput("a", 1), MyInput("b", 2), MyInput("a", 3), MyInput("a", 4), MyInput("b", 5), MyInput("a", 6), MyInput("b", 7) ) Expected Output 3 5 6 Code import org.apache.flink.api.common.functions.RichFlatMapFunction import ..
-
GlobalWindows 예제flink 2021. 5. 17. 20:38
문제 text file 을 라인 단위로 읽어 월별 신규 레코드가 2개씩 추가될 때 마다 전체 profit sum 을 계산해 출력한다. Input(/home/windbird123/product_info.txt) (month, product, profit) June,Bat,12 June,Perfume,10 July,Television,50 June,Shirt,38 June,Bat,41 Expected Output ProductInfo(June,?,22) ProductInfo(June,?,101) Code import org.apache.flink.api.scala._ import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnviron..
-
TumblingWindow 예제flink 2021. 5. 17. 14:28
문제 입력으로 1초마다 random TimeInput(timestamp: Long, value: Int) 이 들어올 때, 2초 단위로 나누어 value 값을 sum 해 출력한다. Input(in code) case class TimeInput(timestamp: Long, value: Int) val timeInput = TimeInput(System.currentTimeMillis(), Random.nextInt(100)) context.collect(timeInput) // 예시 (1621227515090, 96) ------------------- (1621227516114, 11) (1621227517128, 86) ------------------- (1621227518144, 54) (1621..