From 3cab1178c51c6ff111794887c9b2a32f047174f9 Mon Sep 17 00:00:00 2001 From: jaysunxiao Date: Thu, 24 Jun 2021 12:10:57 +0800 Subject: [PATCH] =?UTF-8?q?perf[orm]:=20=E5=88=A0=E9=99=A4=E6=97=A0?= =?UTF-8?q?=E7=94=A8=E4=BB=A3=E7=A0=81=E5=92=8C=E8=B0=83=E6=95=B4=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zfoo/orm/{test => cache}/OrmTest.java | 2 +- .../zfoo/orm/{test => cache}/UserManager.java | 2 +- .../zfoo/orm/converter/MysqlToMongoDB.java | 85 ------------------- 3 files changed, 2 insertions(+), 87 deletions(-) rename orm/src/test/java/com/zfoo/orm/{test => cache}/OrmTest.java (98%) rename orm/src/test/java/com/zfoo/orm/{test => cache}/UserManager.java (97%) delete mode 100644 orm/src/test/java/com/zfoo/orm/converter/MysqlToMongoDB.java diff --git a/orm/src/test/java/com/zfoo/orm/test/OrmTest.java b/orm/src/test/java/com/zfoo/orm/cache/OrmTest.java similarity index 98% rename from orm/src/test/java/com/zfoo/orm/test/OrmTest.java rename to orm/src/test/java/com/zfoo/orm/cache/OrmTest.java index 72674246..14a967cf 100644 --- a/orm/src/test/java/com/zfoo/orm/test/OrmTest.java +++ b/orm/src/test/java/com/zfoo/orm/cache/OrmTest.java @@ -11,7 +11,7 @@ * See the License for the specific language governing permissions and limitations under the License. */ -package com.zfoo.orm.test; +package com.zfoo.orm.cache; import com.zfoo.orm.OrmContext; import com.zfoo.util.ThreadUtils; diff --git a/orm/src/test/java/com/zfoo/orm/test/UserManager.java b/orm/src/test/java/com/zfoo/orm/cache/UserManager.java similarity index 97% rename from orm/src/test/java/com/zfoo/orm/test/UserManager.java rename to orm/src/test/java/com/zfoo/orm/cache/UserManager.java index fdb0fa34..54123606 100644 --- a/orm/src/test/java/com/zfoo/orm/test/UserManager.java +++ b/orm/src/test/java/com/zfoo/orm/cache/UserManager.java @@ -11,7 +11,7 @@ * See the License for the specific language governing permissions and limitations under the License. */ -package com.zfoo.orm.test; +package com.zfoo.orm.cache; import com.zfoo.orm.entity.UserEntity; import com.zfoo.orm.model.anno.EntityCachesInjection; diff --git a/orm/src/test/java/com/zfoo/orm/converter/MysqlToMongoDB.java b/orm/src/test/java/com/zfoo/orm/converter/MysqlToMongoDB.java deleted file mode 100644 index 12a788f7..00000000 --- a/orm/src/test/java/com/zfoo/orm/converter/MysqlToMongoDB.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (C) 2020 The zfoo Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed - * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and limitations under the License. - */ - -package com.zfoo.orm.converter; - -import com.zfoo.orm.OrmContext; -import com.zfoo.orm.TestUnit; -import com.zfoo.orm.entity.UserEntity; -import com.zfoo.protocol.util.FileUtils; -import com.zfoo.protocol.util.IOUtils; -import com.zfoo.protocol.util.JsonUtils; -import com.zfoo.protocol.util.StringUtils; -import org.junit.Ignore; -import org.junit.Test; -import org.springframework.context.support.ClassPathXmlApplicationContext; - -import java.io.*; -import java.util.ArrayList; - -/** - * 将mysql导出的json数据导入到mongodb - * - * @author jaysunxiao - * @version 3.0 - */ -@Ignore -public class MysqlToMongoDB { - - @Test - public void converter() { - ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(TestUnit.CONFIG_LOCATION); - - var file = new File("E:\\user.json"); - - FileInputStream fileInputStream = null; - InputStreamReader inputStreamReader = null; - BufferedReader bufferedReader = null; - var result = new ArrayList(); - try { - fileInputStream = FileUtils.openInputStream(file); - inputStreamReader = new InputStreamReader(fileInputStream, StringUtils.DEFAULT_CHARSET_NAME); - bufferedReader = new BufferedReader(inputStreamReader); - - var builder = new StringBuilder(); - var line = ""; - - bufferedReader.readLine(); - bufferedReader.readLine(); - - builder = new StringBuilder(); - - var index = 1; - while ((line = bufferedReader.readLine()) != null) { - if (line.equals("},") || line.equals("]")) { - builder.append("}"); - var entity = JsonUtils.string2Object(builder.toString(), UserEntity.class); - entity.setId(index); - index++; - result.add(entity); - builder = new StringBuilder(); - continue; - } - - builder.append(line); - } - - OrmContext.getAccessor().batchInsert(result); - } catch (IOException e) { - e.printStackTrace(); - } finally { - IOUtils.closeIO(bufferedReader, inputStreamReader, fileInputStream); - } - } - -}