refactor(messagestore): extract ReadMessageRow as shared deserialiser
Pure deserialisation helper that pulls one row from the current reader position into a Message. The MessageEnumerator load path delegates to it, and the upcoming FTS-join LoadByGuids (Task 4.3) will share the same code so both stay in lockstep when the column layout shifts. Pre-step for v1.4.8 H2 FTS5 full-text search.
This commit is contained in:
+40
-28
@@ -136,6 +136,43 @@ internal class MessageStore : IDisposable
|
||||
)
|
||||
);
|
||||
|
||||
// Pure deserialisation of one messages-row at the reader's current position.
|
||||
// Shared between the MessageEnumerator load path and the upcoming v1.4.8
|
||||
// LoadByGuids FTS-join path so both stay in lockstep when the column layout
|
||||
// moves. Throws on row-level errors; the caller decides whether to skip+log
|
||||
// (enumerator) or fail-fast (bulk lookup).
|
||||
internal static Message ReadMessageRow(DbDataReader reader)
|
||||
{
|
||||
return new Message(
|
||||
reader.GetGuid(0),
|
||||
(ulong)reader.GetInt64(1),
|
||||
(ulong)reader.GetInt64(2),
|
||||
DateTimeOffset.FromUnixTimeMilliseconds(reader.GetInt64(3)),
|
||||
new ChatCode(
|
||||
(byte)reader.GetInt32(4),
|
||||
(byte)reader.GetInt32(5),
|
||||
(byte)reader.GetInt32(6)
|
||||
),
|
||||
MessagePackSerializer.Deserialize<List<Chunk>>(
|
||||
reader.GetFieldValue<byte[]>(7),
|
||||
MsgPackOptions
|
||||
),
|
||||
MessagePackSerializer.Deserialize<List<Chunk>>(
|
||||
reader.GetFieldValue<byte[]>(8),
|
||||
MsgPackOptions
|
||||
),
|
||||
MessagePackSerializer.Deserialize<SeString>(
|
||||
reader.GetFieldValue<byte[]>(9),
|
||||
MsgPackOptions
|
||||
),
|
||||
MessagePackSerializer.Deserialize<SeString>(
|
||||
reader.GetFieldValue<byte[]>(10),
|
||||
MsgPackOptions
|
||||
),
|
||||
reader.GetGuid(11)
|
||||
);
|
||||
}
|
||||
|
||||
private readonly IPlatformUtil _platformUtil;
|
||||
private readonly IPluginLogProxy _logger;
|
||||
|
||||
@@ -816,35 +853,10 @@ internal class MessageEnumerator(DbDataReader reader, IPluginLogProxy logger)
|
||||
Message msg;
|
||||
try
|
||||
{
|
||||
// GetGuid up-front so we have an id for the failure log even
|
||||
// when the rest of the deserialisation throws downstream.
|
||||
id = reader.GetGuid(0);
|
||||
msg = new Message(
|
||||
id,
|
||||
(ulong)reader.GetInt64(1),
|
||||
(ulong)reader.GetInt64(2),
|
||||
DateTimeOffset.FromUnixTimeMilliseconds(reader.GetInt64(3)),
|
||||
new ChatCode(
|
||||
(byte)reader.GetInt32(4),
|
||||
(byte)reader.GetInt32(5),
|
||||
(byte)reader.GetInt32(6)
|
||||
),
|
||||
MessagePackSerializer.Deserialize<List<Chunk>>(
|
||||
reader.GetFieldValue<byte[]>(7),
|
||||
MessageStore.MsgPackOptions
|
||||
),
|
||||
MessagePackSerializer.Deserialize<List<Chunk>>(
|
||||
reader.GetFieldValue<byte[]>(8),
|
||||
MessageStore.MsgPackOptions
|
||||
),
|
||||
MessagePackSerializer.Deserialize<SeString>(
|
||||
reader.GetFieldValue<byte[]>(9),
|
||||
MessageStore.MsgPackOptions
|
||||
),
|
||||
MessagePackSerializer.Deserialize<SeString>(
|
||||
reader.GetFieldValue<byte[]>(10),
|
||||
MessageStore.MsgPackOptions
|
||||
),
|
||||
reader.GetGuid(11)
|
||||
);
|
||||
msg = MessageStore.ReadMessageRow(reader);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user