|
|
@@ -23,60 +23,66 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
public class AggApplication {
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
-// String dataDirPath = "D:\\Documents\\ChenYL\\CodeRepository\\money-mining-python\\data";
|
|
|
- String dataDirPath = "D:\\Documents\\ChenYL\\CodeRepository\\money-mining-python\\data\\test";
|
|
|
+// public static void main(String[] args) {
|
|
|
+//// String dataDirPath = "D:\\Documents\\ChenYL\\CodeRepository\\money-mining-python\\data";
|
|
|
+// String dataDirPath = "D:\\Documents\\ChenYL\\CodeRepository\\money-mining-python\\data\\test";
|
|
|
+//
|
|
|
+// // 判断传入路径是否有效
|
|
|
+// File dataDir = new File(dataDirPath);
|
|
|
+// if (!dataDir.exists() || !dataDir.isDirectory()) {
|
|
|
+// System.out.println(String.format("数据目录路径不存在,%s", dataDirPath));
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 判断关键资源文件是否存在
|
|
|
+// List<String> fileNameList = Arrays.asList("长尾词_合并_分词.txt", "长尾词_合并_聚合.txt", "长尾词_合并.txt", "长尾词_合并_倒排索引.txt");
|
|
|
+// for (String fileName : fileNameList) {
|
|
|
+// String resFilePath = String.join(File.separator, dataDirPath, fileName);
|
|
|
+// File resfile = new File(resFilePath);
|
|
|
+// if (!resfile.exists() || !resfile.isFile()) {
|
|
|
+// System.out.println(String.format("文件不存在!文件路径:%s", resFilePath));
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 归档历史数据文件
|
|
|
+// File[] files = dataDir.listFiles();
|
|
|
+// Pattern aggFilePattern = Pattern.compile("长尾词_合并_聚合_\\d+_\\d+.txt");
|
|
|
+// List<File> historyAggFile = Arrays.stream(files).filter(file -> {
|
|
|
+// Matcher matcher = aggFilePattern.matcher(file.getName());
|
|
|
+// return matcher.find();
|
|
|
+// }).collect(Collectors.toList());
|
|
|
+// if (Objects.nonNull(historyAggFile) || historyAggFile.size() > 0) {
|
|
|
+// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
+// String archivePath = String.join(File.separator, dataDirPath, String.format("长尾词_聚合_归档_%s", sdf.format(new Date())));
|
|
|
+// File archiveDir = new File(archivePath);
|
|
|
+// archiveDir.mkdirs();
|
|
|
+// for (File historyFile : historyAggFile) {
|
|
|
+// String destPath = String.join(File.separator, archivePath, historyFile.getName());
|
|
|
+// System.out.println(destPath);
|
|
|
+// historyFile.renameTo(new File(destPath));
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// JedisPool pool = new JedisPool("127.0.0.1", 6379);
|
|
|
+// try (Jedis jedis = pool.getResource()) {
|
|
|
+// try (FileReader reader = new FileReader(String.join(File.separator, dataDirPath, "长尾词_合并_分词.txt"));
|
|
|
+// BufferedReader br = new BufferedReader(reader)) {
|
|
|
+// String line = null;
|
|
|
+// while ((line = br.readLine()) != null) {
|
|
|
+// System.out.println(line);
|
|
|
+// System.out.println("暂停");
|
|
|
+// }
|
|
|
+//
|
|
|
+// } catch (IOException e) {
|
|
|
+// throw new RuntimeException(e);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
- // 判断传入路径是否有效
|
|
|
- File dataDir = new File(dataDirPath);
|
|
|
- if (!dataDir.exists() || !dataDir.isDirectory()) {
|
|
|
- System.out.println(String.format("数据目录路径不存在,%s", dataDirPath));
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- // 判断关键资源文件是否存在
|
|
|
- List<String> fileNameList = Arrays.asList("长尾词_合并_分词.txt", "长尾词_合并_聚合.txt", "长尾词_合并.txt", "长尾词_合并_倒排索引.txt");
|
|
|
- for (String fileName : fileNameList) {
|
|
|
- String resFilePath = String.join(File.separator, dataDirPath, fileName);
|
|
|
- File resfile = new File(resFilePath);
|
|
|
- if (!resfile.exists() || !resfile.isFile()) {
|
|
|
- System.out.println(String.format("文件不存在!文件路径:%s", resFilePath));
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 归档历史数据文件
|
|
|
- File[] files = dataDir.listFiles();
|
|
|
- Pattern aggFilePattern = Pattern.compile("长尾词_合并_聚合_\\d+_\\d+.txt");
|
|
|
- List<File> historyAggFile = Arrays.stream(files).filter(file -> {
|
|
|
- Matcher matcher = aggFilePattern.matcher(file.getName());
|
|
|
- return matcher.find();
|
|
|
- }).collect(Collectors.toList());
|
|
|
- if (Objects.nonNull(historyAggFile) || historyAggFile.size() > 0) {
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
|
|
- String archivePath = String.join(File.separator, dataDirPath, String.format("长尾词_聚合_归档_%s", sdf.format(new Date())));
|
|
|
- File archiveDir = new File(archivePath);
|
|
|
- archiveDir.mkdirs();
|
|
|
- for (File historyFile : historyAggFile) {
|
|
|
- String destPath = String.join(File.separator, archivePath, historyFile.getName());
|
|
|
- System.out.println(destPath);
|
|
|
- historyFile.renameTo(new File(destPath));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- JedisPool pool = new JedisPool("127.0.0.1", 6379);
|
|
|
- try (Jedis jedis = pool.getResource()) {
|
|
|
- try (FileReader reader = new FileReader(String.join(File.separator, dataDirPath, "长尾词_合并_分词.txt"));
|
|
|
- BufferedReader br = new BufferedReader(reader)) {
|
|
|
- String line = null;
|
|
|
- while ((line = br.readLine()) != null) {
|
|
|
- System.out.println(line);
|
|
|
- System.out.println("暂停");
|
|
|
- }
|
|
|
-
|
|
|
- } catch (IOException e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
- }
|
|
|
+ public static void main(String[] args) throws InterruptedException {
|
|
|
+ System.out.println("hello python start");
|
|
|
+ Thread.sleep(5000);
|
|
|
+ System.out.println("hello python end");
|
|
|
}
|
|
|
}
|