如何使用spring数据模拟hdfs操作

64jmpszr  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(442)

我是SpringDataHadoop的新手,想问一个一般性的问题。我有不同格式的文件,并希望提取有用的内容与apachetika和存储为文本文件在hdfs。我已经阅读了spring数据hadoop的参考文档(http://docs.spring.io/spring-hadoop/docs/2.0.0.release/reference/html/store.html)但不知道怎么做。我没有找到其他有用的资源。
有没有使用springdatahadoop将数据写入hdfs的示例项目或源代码?

q35jwt9p

q35jwt9p1#

从risberg的评论中有一个有用的例子:-
https://github.com/trisberg/springone-2015/tree/master/boot-ingest
datawriter接口的textfilewriter实现的另一个代码段:-

  1. //build naming strategy
  2. ChainedFileNamingStrategy namingStrategy =
  3. new ChainedFileNamingStrategy(
  4. Arrays.asList(new FileNamingStrategy[] {
  5. new StaticFileNamingStrategy("document"),
  6. new UuidFileNamingStrategy(someUUID),
  7. new StaticFileNamingStrategy("txt", ".") }));
  8. //set the naming strategy
  9. textFileWriter.setFileNamingStrategy(namingStrategy);
  10. textFileWriter.write("this is a test content");
  11. //flush and close the writer
  12. textFileWriter.flush();
  13. textFileWriter.close();

相关问题