解决拉取历史消息问题
This commit is contained in:
@@ -761,7 +761,7 @@ public class DatabaseStore {
|
|||||||
|
|
||||||
int month = 0;
|
int month = 0;
|
||||||
while (messages.size() < count && !DBUtil.IsEmbedDB && month++ < 24) {
|
while (messages.size() < count && !DBUtil.IsEmbedDB && month++ < 24) {
|
||||||
String nexTable = MessageShardingUtil.getPreviousMessageTable(before[0]);
|
String nexTable = MessageShardingUtil.getMessageTable(beforeUid, -month);
|
||||||
|
|
||||||
int size = messages.size();
|
int size = messages.size();
|
||||||
hasMore = true;
|
hasMore = true;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class MessageShardingUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
if (mid != Long.MAX_VALUE) {
|
if (mid != Long.MAX_VALUE && mid != 0) {
|
||||||
mid >>= (nodeIdWidth + rotateIdWidth);
|
mid >>= (nodeIdWidth + rotateIdWidth);
|
||||||
Date date = new Date(mid + T201801010000);
|
Date date = new Date(mid + T201801010000);
|
||||||
calendar.setTime(date);
|
calendar.setTime(date);
|
||||||
@@ -99,6 +99,10 @@ public class MessageShardingUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getPreviousMessageTable(long mid) {
|
public static String getPreviousMessageTable(long mid) {
|
||||||
|
return getMessageTable(mid, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getMessageTable(long mid, int offset) {
|
||||||
if (DBUtil.IsEmbedDB) {
|
if (DBUtil.IsEmbedDB) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -110,11 +114,17 @@ public class MessageShardingUtil {
|
|||||||
int month = calendar.get(Calendar.MONTH);
|
int month = calendar.get(Calendar.MONTH);
|
||||||
int year = calendar.get(Calendar.YEAR);
|
int year = calendar.get(Calendar.YEAR);
|
||||||
year %= 3;
|
year %= 3;
|
||||||
month = month - 1;
|
|
||||||
if (month == -1) {
|
month = month + offset;
|
||||||
month = 11;
|
while (month < 0) {
|
||||||
|
month += 12;
|
||||||
year = (year + 3 - 1)%3;
|
year = (year + 3 - 1)%3;
|
||||||
}
|
}
|
||||||
|
while (month >= 12) {
|
||||||
|
month -= 12;
|
||||||
|
year = (year + 1)%3;
|
||||||
|
}
|
||||||
|
|
||||||
return "t_messages_" + (year * 12 + month);
|
return "t_messages_" + (year * 12 + month);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user