Old format (v1): Stored in "chat-history.mv" file. Map keys like "bibDatabasePath-entry-citationKey" or "bibDatabasePath-group-groupName" containing Map<Integer, ChatHistoryRecord> where ChatHistoryRecord was a private inner class of MVStoreChatHistoryStorage (full name: org.jabref.logic.ai.chatting.chathistory.storages.MVStoreChatHistoryStorage$ChatHistoryRecord).
New format (v2): Stored via repository using ChatIdentifier(libraryId, chatType, chatName).
Problem: The old inner class no longer exists, so MVStore's ObjectDataType fails with ClassNotFoundException before our code can intercept.
Solution: Open the map with a custom RawBytesDataType that returns the raw
Java-serialized bytes for each value without invoking standard Java deserialization.
Then a ClassRemappingObjectInputStream deserializes those bytes while remapping
the deleted inner class name to the current ChatHistoryRecord.
| Modifier and Type | Class and Description |
|---|---|
| private static class | ChatHistoryMigrationV1.
Custom ObjectInputStream that remaps the deleted old inner class name
to the current |
| private static class | ChatHistoryMigrationV1.
Reads raw Java-serialized bytes from MVStore's binary page format without invoking Java deserialization. |
| Modifier and Type | Field and Description |
|---|---|
| private static final String | |
| private static final String | |
| private static final Logger | |
| private static final String | |
| private static final String | OLD_CHAT_HISTORY_RECORD_CLASS
Old inner class full name that is no longer in the classpath. |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private static ChatMessage | |
| private static ChatHistoryRecord | deserializeOldRecord(byte[] data)
Deserializes old ChatHistoryRecord bytes using a remapping ObjectInputStream. |
| private static boolean | |
| public static void | migrate(BibDatabaseContext
The database context containing the AI library ID bibDatabaseContext, ChatHistoryRepository The new v2 chat history repository to migrate to repository, NotificationService Service for notifying user of errors notificationService)Migrates old chat history data from v1 file to v2 repository. |
| public static void | migrate(Path oldFilePath, String libraryId, BibDatabaseContext bibDatabaseContext, ChatHistoryRepository repository, NotificationService notificationService)
|
| private static boolean | migrateOldMap(String oldMapName, String libraryId, BibDatabaseContext bibDatabaseContext, ChatHistoryRepository repository, MVStore oldMvStore)
|
| private static boolean | pathMatchesCurrentLibrary(String pathPrefix, BibDatabaseContext bibDatabaseContext)
Returns |
| ENTRY_CHAT_HISTORY_INFIX | back to summary |
|---|---|
| private static final String ENTRY_CHAT_HISTORY_INFIX | |
| GROUP_CHAT_HISTORY_INFIX | back to summary |
|---|---|
| private static final String GROUP_CHAT_HISTORY_INFIX | |
| LOGGER | back to summary |
|---|---|
| private static final Logger LOGGER | |
| OLD_CHAT_HISTORY_FILE_NAME | back to summary |
|---|---|
| private static final String OLD_CHAT_HISTORY_FILE_NAME | |
| OLD_CHAT_HISTORY_RECORD_CLASS | back to summary |
|---|---|
| private static final String OLD_CHAT_HISTORY_RECORD_CLASS Old inner class full name that is no longer in the classpath. Was: private record ChatHistoryRecord inside MVStoreChatHistoryStorage. | |
| ChatHistoryMigrationV1 | back to summary |
|---|---|
| private ChatHistoryMigrationV1() | |
| convertToNewChatMessage | back to summary |
|---|---|
| private static ChatMessage convertToNewChatMessage(ChatHistoryRecord oldRecord, Instant timestamp) | |
| deserializeOldRecord | back to summary |
|---|---|
| private static ChatHistoryRecord deserializeOldRecord(byte[] data) Deserializes old ChatHistoryRecord bytes using a remapping ObjectInputStream.
Remaps the deleted inner class name to the current | |
| isOldChatHistoryMap | back to summary |
|---|---|
| private static boolean isOldChatHistoryMap(String mapName) | |
| migrate | back to summary |
|---|---|
| public static void migrate(BibDatabaseContext bibDatabaseContext, ChatHistoryRepository repository, NotificationService notificationService) Migrates old chat history data from v1 file to v2 repository.
| |
| migrate | back to summary |
|---|---|
| public static void migrate(Path oldFilePath, String libraryId, BibDatabaseContext bibDatabaseContext, ChatHistoryRepository repository, NotificationService notificationService) | |
| migrateOldMap | back to summary |
|---|---|
| private static boolean migrateOldMap(String oldMapName, String libraryId, BibDatabaseContext bibDatabaseContext, ChatHistoryRepository repository, MVStore oldMvStore) | |
| pathMatchesCurrentLibrary | back to summary |
|---|---|
| private static boolean pathMatchesCurrentLibrary(String pathPrefix, BibDatabaseContext bibDatabaseContext) Returns
| |
ChatHistoryRecord class.
The old and new records have identical components (className: String, content: String), so Java record deserialization will call the canonical constructor successfully.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected ObjectStreamClass | readClassDescriptor()
Overrides java. Read a class descriptor from the serialization stream. |
| ClassRemappingObjectInputStream | back to summary |
|---|---|
| public ClassRemappingObjectInputStream(InputStream in) throws IOException | |
| readClassDescriptor | back to summary |
|---|---|
| protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException Overrides java. Doc from java. Read a class descriptor from the serialization stream. This method is
called when the ObjectInputStream expects a class descriptor as the next
item in the serialization stream. Subclasses of ObjectInputStream may
override this method to read in class descriptors that have been written
in non-standard formats (by subclasses of ObjectOutputStream which have
overridden the
| |
19 (TYPE_SERIALIZED_OBJECT in H2 2.3.232)
| Modifier and Type | Field and Description |
|---|---|
| private static final int |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public byte[][] | createStorage(int size)
Implements org. Create storage object of array type to hold values |
| public int | getMemory(byte[] obj)
Implements abstract org. Implements org. Calculates the amount of used memory in bytes. |
| public byte[] | read(ByteBuffer buff)
Implements abstract org. Implements org. Read an object. |
| private static int | |
| public void | write(WriteBuffer buff, byte[] obj)
Implements abstract org. Implements org. Write an object. |
| TYPE_SERIALIZED_OBJECT | back to summary |
|---|---|
| private static final int TYPE_SERIALIZED_OBJECT | |
| RawBytesDataType | back to summary |
|---|---|
| private RawBytesDataType() | |
| createStorage | back to summary |
|---|---|
| public byte[][] createStorage(int size) Implements org. Doc from org. Create storage object of array type to hold values
| |
| getMemory | back to summary |
|---|---|
| public int getMemory(byte[] obj) Implements abstract org. Implements org. Doc from org. Calculates the amount of used memory in bytes.
| |
| read | back to summary |
|---|---|
| public byte[] read(ByteBuffer buff) Implements abstract org. Implements org. Doc from org. Read an object.
| |
| readVarInt | back to summary |
|---|---|
| private static int readVarInt(ByteBuffer buff) | |
| write | back to summary |
|---|---|
| public void write(WriteBuffer buff, byte[] obj) Implements abstract org. Implements org. Doc from org. Write an object.
| |