Skip to content

Commit

Permalink
For old style index markers, consider them marking the previous day as
Browse files Browse the repository at this point in the history
we can assume the current day is only partially indexed
  • Loading branch information
ivakegg committed Feb 4, 2025
1 parent 362c4dc commit ccf5dff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/main/java/datawave/query/util/AllFieldMetadataHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -1487,7 +1487,7 @@ Map<String,Map<String,IndexFieldHole>> findHoles() throws IOException {
}

// we can treat this like an index marker but the ts of the entry denotes the boundary
currDate = getBaseDate(key.getTimestamp());
currDate = getPreviousDay(key.getTimestamp());
log.warn("Found an index entry missing the date, treating as an index marker at " + currDate + " : " + key);
currBoundaryValue = true;
currCount = 0;
Expand Down Expand Up @@ -1517,7 +1517,7 @@ Map<String,Map<String,IndexFieldHole>> findHoles() throws IOException {
} catch (DateTimeParseException e) {
// probably the really old type classname format instead of a date.
// we can treat this like an index marker but the ts of the entry denotes the boundary
currDate = getBaseDate(key.getTimestamp());
currDate = getPreviousDay(key.getTimestamp());
log.warn("Found an index entry missing the date, treating as an index marker at " + currDate + " : " + key);
currBoundaryValue = true;
currCount = 0;
Expand Down Expand Up @@ -1588,13 +1588,14 @@ Map<String,Map<String,IndexFieldHole>> findHoles() throws IOException {
return getImmutableFieldIndexHoles();
}

private Date getBaseDate(long ts) {
private Date getPreviousDay(long ts) {
Calendar c = Calendar.getInstance();
c.setTimeInMillis(ts);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.SECOND, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.MILLISECOND, 0);
c.add(Calendar.DATE, -1);
return c.getTime();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ void testFieldIndexHoleWithIndexedMarkerSansDate(String cf) {

Map<String,Map<String,IndexFieldHole>> fieldIndexHoles = getIndexHoleFunction(cf).get();
// @formatter:on
Map<String,Map<String,IndexFieldHole>> expected = createFieldIndexHoleMap(createFieldIndexHole("NAME", "wiki", dateRange("20200104", "20200106")));
Map<String,Map<String,IndexFieldHole>> expected = createFieldIndexHoleMap(createFieldIndexHole("NAME", "wiki", dateRange("20200103", "20200106")));
// @formatter:off
Assertions.assertEquals(expected, fieldIndexHoles);
}
Expand All @@ -375,7 +375,7 @@ void testFieldIndexHoleWithIndexedMarkerOldTypeFormat(String cf) {

Map<String,Map<String,IndexFieldHole>> fieldIndexHoles = getIndexHoleFunction(cf).get();
// @formatter:on
Map<String,Map<String,IndexFieldHole>> expected = createFieldIndexHoleMap(createFieldIndexHole("NAME", "wiki", dateRange("20200104", "20200106")));
Map<String,Map<String,IndexFieldHole>> expected = createFieldIndexHoleMap(createFieldIndexHole("NAME", "wiki", dateRange("20200103", "20200106")));
// @formatter:off
Assertions.assertEquals(expected, fieldIndexHoles);
}
Expand Down

0 comments on commit ccf5dff

Please sign in to comment.