티스토리 뷰
object AvroUtils {
private const val PATH = "/avsc"
private val parser = Schema.Parser()
fun define(name: String): Schema {
return parser.parse(
AvroUtils.javaClass
.getResourceAsStream("${PATH}/${name}.avsc")
)
}
fun convert(schema: Schema, json: String): GenericRecord {
val reader: DatumReader<GenericData.Record> = GenericDatumReader(schema)
val decoder: Decoder = DecoderFactory().jsonDecoder(schema, json)
return reader.read(null, decoder)
}
fun convert(record: GenericRecord): ByteArray? {
return toBytes(record)
}
@Throws(IOException::class)
private fun toBytes(genericRecord: GenericRecord): ByteArray? {
ByteArrayOutputStream().use { outputStream ->
val writer: DatumWriter<GenericContainer> = GenericDatumWriter(genericRecord.schema)
writer.setSchema(genericRecord.schema)
val encoder: BinaryEncoder = EncoderFactory.get().binaryEncoder(outputStream, null)
writer.write(genericRecord, encoder)
encoder.flush()
return outputStream.toByteArray()
}
}
}
resources/avsc/data-api.avsc
https://seongtak-yoon.tistory.com/27
[Gradle] 파일 복사, Jar에 파일 포함하기 (task copy)
// << 는 바로 수행시키않는 역할을 함 task copySample() << { println file("src/main/resources/sample.properties") println file("build/classes/") copy { from "src/main/resources/sample.properties"..
seongtak-yoon.tistory.com
https://stackoverflow.com/questions/20389255/reading-a-resource-file-from-within-jar
Reading a resource file from within jar
I would like to read a resource from within my jar like so: File file; file = new File(getClass().getResource("/file.txt").toURI()); BufferedReader reader = new BufferedReader(new FileRea...
stackoverflow.com
https://toolslick.com/generation/metadata/avro-schema-from-json
Avro Schema From JSON Generator - Tool Slick
JavaScript Object Notation (JSON), pronounced as Jason, is the most common data interchange format on the web. Douglas Crockford first released the JSON specification in the early 2000s. It is a simple format that is easier to comprehend than XML. It is al
toolslick.com
'공부' 카테고리의 다른 글
[Shell] concat string arrays (0) | 2022.06.20 |
---|---|
[java] org.apache.commons.lang3.CharEncoding.UTF_8 (0) | 2022.06.20 |
[kotlin] merge json (0) | 2022.06.20 |
[Shell]join string array (0) | 2022.06.20 |
[Kotlin] add list + list (0) | 2022.06.19 |
- Total
- Today
- Yesterday
- 테슬라 리퍼럴 코드 혜택
- 테슬라 레퍼럴 적용 확인
- wlw
- follower
- 모델y
- 할인
- 어떻게 능력을 보여줄 것인가?
- 메디파크 내과 전문의 의학박사 김영수
- 테슬라 리퍼럴 코드 생성
- 테슬라 크레딧 사용
- 개리마커스
- 테슬라 리퍼럴 코드
- COUNT
- 테슬라
- 연애학개론
- Kluge
- 테슬라 추천
- 책그림
- 모델 Y 레퍼럴
- 클루지
- 인스타그램
- 김달
- 팔로워 수 세기
- 테슬라 레퍼럴
- Bot
- 레퍼럴
- 유투브
- 테슬라 레퍼럴 코드 확인
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |