Skip to content

Commit 53cd36d

Browse files
authored
Merge branch 'main' into feature/better-composite-filtering
2 parents 8a1f5dd + ed9f225 commit 53cd36d

File tree

9 files changed

+499
-152
lines changed

9 files changed

+499
-152
lines changed

pom.xml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<relativePath>../../../microservices/microservice-parent/pom.xml</relativePath>
99
</parent>
1010
<artifactId>metadata-utils</artifactId>
11-
<version>4.0.9-SNAPSHOT</version>
11+
<version>4.0.11-SNAPSHOT</version>
1212
<url>https://code.nsa.gov/datawave-metadata-utils</url>
1313
<licenses>
1414
<license>
@@ -169,4 +169,28 @@
169169
<url>https://maven.pkg.github.com/NationalSecurityAgency/datawave</url>
170170
</repository>
171171
</repositories>
172+
<build>
173+
<pluginManagement>
174+
<plugins>
175+
<plugin>
176+
<artifactId>maven-compiler-plugin</artifactId>
177+
<version>3.8.1</version>
178+
<configuration>
179+
<encoding>UTF-8</encoding>
180+
<showDeprecation>true</showDeprecation>
181+
<showWarnings>true</showWarnings>
182+
<source>${maven.compiler.source}</source>
183+
<target>${maven.compiler.target}</target>
184+
<compilerArgs>
185+
<arg>-parameters</arg>
186+
<arg>-Xlint:all</arg>
187+
<arg>-Xlint:-processing</arg>
188+
<arg>-Xmaxwarns</arg>
189+
<arg>5</arg>
190+
</compilerArgs>
191+
</configuration>
192+
</plugin>
193+
</plugins>
194+
</pluginManagement>
195+
</build>
172196
</project>

src/main/java/datawave/query/composite/CompositeMetadataHelper.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,15 @@ public String getMetadataTableName() {
7878
return metadataTableName;
7979
}
8080

81-
@Cacheable(value = "getCompositeMetadata", key = "{#root.target.auths,#root.target.metadataTableName}", cacheManager = "metadataHelperCacheManager")
81+
@Cacheable(value = "getCompositeMetadata", key = "{#root.target.auths,#root.target.metadataTableName}", cacheManager = "metadataHelperCacheManager",
82+
sync = true)
8283
public CompositeMetadata getCompositeMetadata() throws TableNotFoundException {
8384
log.debug("cache fault for getCompositeMetadata(" + this.auths + "," + this.metadataTableName + ")");
8485
return this.getCompositeMetadata(null);
8586
}
8687

8788
@Cacheable(value = "getCompositeMetadata", key = "{#root.target.auths,#root.target.metadataTableName,#datatypeFilter}",
88-
cacheManager = "metadataHelperCacheManager")
89+
cacheManager = "metadataHelperCacheManager", sync = true)
8990
public CompositeMetadata getCompositeMetadata(Set<String> datatypeFilter) throws TableNotFoundException {
9091
log.debug("cache fault for getCompositeMetadata(" + this.auths + "," + this.metadataTableName + "," + datatypeFilter + ")");
9192
CompositeMetadata compositeMetadata = new CompositeMetadata();

src/main/java/datawave/query/model/FieldIndexHole.java renamed to src/main/java/datawave/query/model/IndexFieldHole.java

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package datawave.query.model;
22

3+
import java.time.Instant;
4+
import java.time.temporal.ChronoUnit;
35
import java.util.Collection;
46
import java.util.Comparator;
57
import java.util.Date;
@@ -16,21 +18,52 @@
1618
* This class represents a set of calculated field index holes for a given fieldName and datatype. A field index hole is effectively a date where a frequency
1719
* row was seen, but an index and/or reversed indexed row was not.
1820
*/
19-
public class FieldIndexHole {
21+
public class IndexFieldHole {
2022

2123
private final String fieldName;
2224
private final String datatype;
2325
private final SortedSet<Pair<Date,Date>> dateRanges;
26+
private static long DAY_MILLIS = 1000L * 60 * 60 * 24;
2427

25-
public FieldIndexHole(String fieldName, String dataType, Collection<Pair<Date,Date>> holes) {
28+
public IndexFieldHole(String fieldName, String dataType, Collection<Pair<Date,Date>> holes) {
2629
this.fieldName = fieldName;
2730
this.datatype = dataType;
28-
// Ensure the date range set is immutable.
31+
// Ensure the date range set is immutable, and starts at the beginning of the start date, and ends at the end of the end date
2932
ImmutableSortedSet.Builder<Pair<Date,Date>> builder = new ImmutableSortedSet.Builder<>(Comparator.naturalOrder());
30-
holes.forEach(p -> builder.add(new ImmutablePair<>(p.getLeft(), p.getRight())));
33+
holes.forEach(p -> builder.add(new ImmutablePair<>(floor(p.getLeft()), ceil(p.getRight()))));
3134
dateRanges = builder.build();
3235
}
3336

37+
/**
38+
* return the date instant at 00:00:00
39+
*
40+
* @param d
41+
* @return instant of d with time reset to 00:00:00
42+
*/
43+
private static Instant floorInstant(Date d) {
44+
return Instant.ofEpochMilli(d.getTime()).truncatedTo(ChronoUnit.DAYS);
45+
}
46+
47+
/**
48+
* return the date at 00:00:00
49+
*
50+
* @param d
51+
* @return d with time reset to 00:00:00
52+
*/
53+
private static Date floor(Date d) {
54+
return Date.from(floorInstant(d));
55+
}
56+
57+
/**
58+
* return the date at 23:59:59
59+
*
60+
* @param d
61+
* @return d with time reset to 23:59:59
62+
*/
63+
private static Date ceil(Date d) {
64+
return Date.from(floorInstant(d).plusMillis(DAY_MILLIS - 1));
65+
}
66+
3467
/**
3568
* Return the field name.
3669
*
@@ -50,7 +83,7 @@ public String getDatatype() {
5083
}
5184

5285
/**
53-
* Returns the set of date ranges that span over field index holes for the fieldName and datatype of this {@link FieldIndexHole}. Each date range represents
86+
* Returns the set of date ranges that span over field index holes for the fieldName and datatype of this {@link IndexFieldHole}. Each date range represents
5487
* a span of consecutive days for which a frequency row exist, but an index row does not. All date ranges are start(inclusive)-end(inclusive).
5588
*
5689
* @return the date ranges
@@ -67,7 +100,7 @@ public boolean equals(Object o) {
67100
if (o == null || getClass() != o.getClass()) {
68101
return false;
69102
}
70-
FieldIndexHole indexHole = (FieldIndexHole) o;
103+
IndexFieldHole indexHole = (IndexFieldHole) o;
71104
return Objects.equals(fieldName, indexHole.fieldName) && Objects.equals(datatype, indexHole.datatype)
72105
&& Objects.equals(dateRanges, indexHole.dateRanges);
73106
}
@@ -79,7 +112,7 @@ public int hashCode() {
79112

80113
@Override
81114
public String toString() {
82-
return new StringJoiner(", ", FieldIndexHole.class.getSimpleName() + "[", "]").add("fieldName='" + fieldName + "'").add("dataType='" + datatype + "'")
115+
return new StringJoiner(", ", IndexFieldHole.class.getSimpleName() + "[", "]").add("fieldName='" + fieldName + "'").add("dataType='" + datatype + "'")
83116
.add("dateRanges=" + dateRanges).toString();
84117
}
85118
}

0 commit comments

Comments
 (0)