Skip to content

Commit 034b28f

Browse files
author
Abdelrahman Mostafa
committed
Added java comments
1 parent 7b77db9 commit 034b28f

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

src/main/java/org/jabref/logic/search/indexing/BibFieldsIndexer.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,10 @@ private void insertField(BibEntry entry, Field field) {
310310
FIELD_NAME,
311311
FIELD_VALUE_LITERAL,
312312
FIELD_VALUE_TRANSFORMED);
313-
// Inserts a new record into the table, or updates the existing record if there's a conflict
313+
314+
// Inserts or updates date-related fields (e.g., date, year, month, day) into the index.
315+
// If a conflict occurs (e.g., the same ENTRY_ID and FIELD_NAME already exist),
316+
// the existing values are overwritten with the new ones to ensure the latest data is stored.
314317
String insertDateFieldQuery = """
315318
INSERT INTO %s ("%s", "%s", "%s", "%s")
316319
VALUES (?, ?, ?, ?)
@@ -325,8 +328,9 @@ ON CONFLICT ("%s", "%s")
325328
ENTRY_ID, FIELD_NAME,
326329
FIELD_VALUE_LITERAL, FIELD_VALUE_LITERAL,
327330
FIELD_VALUE_TRANSFORMED, FIELD_VALUE_TRANSFORMED);
331+
328332
String entryId = entry.getId();
329-
// If the updated field is date-related, re-index all date fields to overwrite the previous value.
333+
// If the updated field is date-related,iterate through all date fields and update the index accordingly.
330334
if (dateFields.contains(field)) {
331335
try (PreparedStatement preparedStatement = connection.prepareStatement(insertDateFieldQuery)) {
332336
for (Field dateField : dateFields) {

src/main/java/org/jabref/model/search/PostgreConstants.java

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public static String getMainTableSchemaReference(String mainTable) {
6363
return BIB_FIELDS_SCHEME + ".\"" + mainTable + "\"";
6464
}
6565

66+
/**
67+
* Generates the schema reference for the split table, which is used to store multi-value fields (e.g., authors, keywords)
68+
* in a normalized form to facilitate efficient querying and indexing of the data.
69+
*/
6670
public static String getSplitTableSchemaReference(String mainTable) {
6771
return BIB_FIELDS_SCHEME + ".\"" + mainTable + SPLIT_TABLE_SUFFIX + "\"";
6872
}

0 commit comments

Comments
 (0)