|
@@ -23,19 +23,19 @@ import java.util.*;
|
|
public class RepairTable {
|
|
public class RepairTable {
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
- args = new String[]{"-b", "physical_world_v3_226", "-p", "1101080001"};
|
|
|
|
|
|
+ //args = new String[]{"-b", "physical_world_v3_226", "-p", "1101080001"};
|
|
HBaseTable tableInfo = new HBaseTable();
|
|
HBaseTable tableInfo = new HBaseTable();
|
|
boolean complete = HBaseTable.getInfo(args, tableInfo);
|
|
boolean complete = HBaseTable.getInfo(args, tableInfo);
|
|
if(!complete){
|
|
if(!complete){
|
|
System.out.println("参数错误, -b 数据库名, -p 项目号(不带Pj)");
|
|
System.out.println("参数错误, -b 数据库名, -p 项目号(不带Pj)");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ System.out.println(tableInfo.getDatabase() + " + " + tableInfo.getDatatable() + " + " + tableInfo.getProjectId());
|
|
ZillionAgent agent = ZillionAgentProvider.GetAgent();
|
|
ZillionAgent agent = ZillionAgentProvider.GetAgent();
|
|
ResultScanner scanner = null;
|
|
ResultScanner scanner = null;
|
|
JSONObject criteria = new JSONObject();
|
|
JSONObject criteria = new JSONObject();
|
|
- if(tableInfo.getProjectId() != null && tableInfo.getProjectId().length() > 0){
|
|
|
|
- criteria.put("project_id", tableInfo.getProjectId());
|
|
|
|
- }
|
|
|
|
|
|
+ generateCriteria(criteria, tableInfo);
|
|
|
|
+
|
|
ZillionTableSchema schema = agent.container.repositoryMap.get(tableInfo.getDatabase()).GetTable(tableInfo.getDatatable());
|
|
ZillionTableSchema schema = agent.container.repositoryMap.get(tableInfo.getDatabase()).GetTable(tableInfo.getDatatable());
|
|
ZillionTableIndex index = HbaseScanIndex.zillionTableIndex(schema, criteria, null);
|
|
ZillionTableIndex index = HbaseScanIndex.zillionTableIndex(schema, criteria, null);
|
|
try {
|
|
try {
|
|
@@ -47,6 +47,15 @@ public class RepairTable {
|
|
agent.Stop();
|
|
agent.Stop();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private static void generateCriteria(JSONObject criteria, HBaseTable tableInfo) {
|
|
|
|
+ if(tableInfo.isVotn()){
|
|
|
|
+ criteria.put("obj_type", "VOTn");
|
|
|
|
+ }
|
|
|
|
+ if(tableInfo.getProjectId() != null && tableInfo.getProjectId().length() > 0){
|
|
|
|
+ criteria.put("project_id", tableInfo.getProjectId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
private static void fixData(ResultScanner scanner, ZillionTableIndex index, ZillionTableSchema schema, HBaseTable tableInfo) {
|
|
private static void fixData(ResultScanner scanner, ZillionTableIndex index, ZillionTableSchema schema, HBaseTable tableInfo) {
|
|
if(scanner == null)
|
|
if(scanner == null)
|
|
return;
|
|
return;
|
|
@@ -78,7 +87,7 @@ public class RepairTable {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- putToDeleteArr(fixMap, deleteArr);
|
|
|
|
|
|
+ putToDeleteArr(fixMap, deleteArr, tableInfo);
|
|
if(deleteArr.size() > 2000){
|
|
if(deleteArr.size() > 2000){
|
|
ZillionOpUtil.delete(deleteArr, tableInfo);
|
|
ZillionOpUtil.delete(deleteArr, tableInfo);
|
|
System.out.println("正在修复 " + curProjectId);
|
|
System.out.println("正在修复 " + curProjectId);
|
|
@@ -94,7 +103,7 @@ public class RepairTable {
|
|
System.out.println("已完成");
|
|
System.out.println("已完成");
|
|
}
|
|
}
|
|
|
|
|
|
- private static void putToDeleteArr(Map<String, ArrayList<InfosObj>> fixMap, ArrayList<InfosObj> deleteArr) {
|
|
|
|
|
|
+ private static void putToDeleteArr(Map<String, ArrayList<InfosObj>> fixMap, ArrayList<InfosObj> deleteArr, HBaseTable tableInfo) {
|
|
String lastKey = null;
|
|
String lastKey = null;
|
|
for(String idKey : fixMap.keySet()){
|
|
for(String idKey : fixMap.keySet()){
|
|
lastKey = idKey;
|
|
lastKey = idKey;
|
|
@@ -127,7 +136,12 @@ public class RepairTable {
|
|
}else{
|
|
}else{
|
|
lastValue = single.getObjInfoValue();
|
|
lastValue = single.getObjInfoValue();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ }
|
|
|
|
+ if(tableInfo.isVotn()){
|
|
|
|
+ for(; arr.size() > 1; ){
|
|
|
|
+ deleteArr.add(arr.get(0));
|
|
|
|
+ arr.remove(0);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(lastKey == null ){
|
|
if(lastKey == null ){
|