cshannon commented on code in PR #3286:
URL: https://github.com/apache/accumulo/pull/3286#discussion_r1166700511
##########
core/src/main/java/org/apache/accumulo/core/metadata/schema/DataFileValue.java:
##########
@@ -20,42 +20,76 @@
import static java.nio.charset.StandardCharsets.UTF_8;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Optional;
+
+import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.iteratorsImpl.system.InterruptibleIterator;
import org.apache.accumulo.core.iteratorsImpl.system.TimeSettingIterator;
+import org.apache.accumulo.core.util.json.RangeAdapter;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonSyntaxException;
public class DataFileValue {
- private long size;
- private long numEntries;
+
+ private static final Gson gson = RangeAdapter.createRangeGson();
+
+ private final long size;
+ private final long numEntries;
private long time = -1;
+ private final List<Range> ranges;
- public DataFileValue(long size, long numEntries, long time) {
- this.size = size;
- this.numEntries = numEntries;
- this.time = time;
+ public DataFileValue(final long size, final long numEntries, final long
time) {
+ this(size, numEntries, time, null);
+ }
+
+ public DataFileValue(final long size, final long numEntries) {
+ this(size, numEntries, null);
}
- public DataFileValue(long size, long numEntries) {
+ public DataFileValue(final long size, final long numEntries, final long time,
+ final Collection<Range> ranges) {
this.size = size;
this.numEntries = numEntries;
- this.time = -1;
+ this.time = time;
+ // If ranges is null then just set to empty list and also merge
overlapping to reduce
+ // the data stored if possible.
+ this.ranges = Optional.ofNullable(ranges).map(Range::mergeOverlapping)
Review Comment:
I'm fine requiring non-null and making the user just pass an empty list so I
can switch it. I wasn't sure which we to go here here as whether or not you
allow null and just convert to an empty list or make the user pass in an empty
list is mostly preference and I wasn't sure if there was an established pattern
people preferred. The other option is to always require at least 1 range (the
range could be infinite if the whole file) but that seems pointless and I like
the idea of having an empty list just mean the entire file as it's backwards
compatible
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]