티스토리 뷰
728x90
public static <T> Writer makeOrcWriter(String path, Class<T> clazz) throws IOException {
FileUtils.delete(path);
Configuration conf = new Configuration(false);
FileSystem fs = FileSystem.get(conf);
return OrcFile.createWriter(new Path(path),
OrcFile.writerOptions(conf)
.inspector(ObjectInspectorFactory.getReflectionObjectInspector(clazz,
ObjectInspectorFactory.ObjectInspectorOptions.JAVA))
.fileSystem(fs)
);
}
public static void delete(String path) {
new File(path).delete();
}
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.util.List;
import org.apache.hadoop.hive.ql.io.orc.Writer;
import lombok.Getter;
@Getter
public class OrcFileWriter <T> implements Closeable {
private String path;
private Class<T> clazz;
private Writer writer;
private File file;
public OrcFileWriter(String path, Class<T> clazz) throws IOException {
this.path = path;
this.clazz = clazz;
writer = FileUtils.makeOrcWriter(path, clazz);
file = new File(path);
}
@Override
public void close() throws IOException {
writer.close();
}
public <T> void addRow(T o) throws IOException {
writer.addRow(o);
}
public <T> void addRow(List<T> list) throws IOException {
for (T o : list) {
writer.addRow(o);
}
}
public void delete() throws IOException {
file.delete();
close();
}
}
import java.io.File;
import java.io.IOException;
import org.apache.hadoop.hive.ql.io.orc.Reader;
import org.apache.hadoop.hive.ql.io.orc.RecordReader;
import lombok.Getter;
@Getter
public class OrcFileReader {
private String path;
private File file;
private Reader reader;
public OrcFileReader(String path) throws IOException {
this.path = path;
file = new File(path);
reader = FileUtils.makeOrcReader(path);
}
public long count() {
return reader.getNumberOfRows();
}
public void print() throws IOException {
RecordReader rows = reader.rows();
while (rows.hasNext()) {
Object row = rows.next(null);
System.out.println(row);
}
rows.close();
}
}
https://orc.apache.org/docs/core-java.html
Using Core Java
Navigate the docs… Background ORC Adopters Types Indexes ACID support Building ORC Releases Spark DDL Spark Configuration Hive DDL Hive Configuration Using in MapRed Using in MapReduce Using Core Java Using Core C++ C++ Tools Java Tools Using Core Java T
orc.apache.org
https://www.javahelps.com/2020/08/read-and-write-orc-files-in-core-java.html
Read and Write ORC Files in Core Java
In this article, we will create a simple ORC writer and reader to write ORC files and to read from ORC files in core Java.
www.javahelps.com
728x90
'공부' 카테고리의 다른 글
[Java] SHA256 (0) | 2022.01.10 |
---|---|
[Java] resource (0) | 2022.01.10 |
[Java] files (0) | 2022.01.10 |
[JUnit] Assert API (0) | 2022.01.10 |
[Java] type: a.getClass().getName() (0) | 2022.01.10 |
댓글
250x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 클루지
- wlw
- 책그림
- 모델y
- 개리마커스
- 테슬라 레퍼럴 코드 확인
- 테슬라 리퍼럴 코드 생성
- 팔로워 수 세기
- 어떻게 능력을 보여줄 것인가?
- 테슬라 레퍼럴 적용 확인
- 모델 Y 레퍼럴
- 테슬라 크레딧 사용
- 테슬라 레퍼럴
- Bot
- 테슬라 리퍼럴 코드 혜택
- 테슬라 추천
- 테슬라 리퍼럴 코드
- 레퍼럴
- 유투브
- 인스타그램
- COUNT
- 연애학개론
- 메디파크 내과 전문의 의학박사 김영수
- Kluge
- 할인
- 김달
- follower
- 테슬라
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
글 보관함