segstore: add default unhandled methods to ISegmentStore
[deliverable/tracecompass.git] / statesystem / org.eclipse.tracecompass.segmentstore.core / src / org / eclipse / tracecompass / internal / segmentstore / core / arraylist / LazyArrayListStore.java
index d6e6ea3969a5f3aed678f4c1c0bbc30d5b788c8f..d78479dc9972142e829d1333532c008f8e1099d0 100644 (file)
@@ -56,8 +56,6 @@ import com.google.common.collect.Ordering;
  */
 public class LazyArrayListStore<@NonNull E extends ISegment> implements ISegmentStore<E> {
 
-    private static final String ERROR_MESSAGE = "Cannot remove from a segment store"; //$NON-NLS-1$
-
     private final Comparator<E> COMPARATOR = Ordering.from(SegmentComparators.INTERVAL_START_COMPARATOR)
             .compound(SegmentComparators.INTERVAL_END_COMPARATOR);
 
@@ -150,7 +148,12 @@ public class LazyArrayListStore<@NonNull E extends ISegment> implements ISegment
 
     @Override
     public int size() {
-        return fStore.size();
+        fLock.lock();
+        try {
+            return fStore.size();
+        } finally {
+            fLock.unlock();
+        }
     }
 
     @Override
@@ -229,21 +232,6 @@ public class LazyArrayListStore<@NonNull E extends ISegment> implements ISegment
         }
     }
 
-    @Override
-    public boolean removeAll(@Nullable Collection<?> c) {
-        throw new UnsupportedOperationException(ERROR_MESSAGE);
-    }
-
-    @Override
-    public boolean retainAll(@Nullable Collection<?> c) {
-        throw new UnsupportedOperationException(ERROR_MESSAGE);
-    }
-
-    @Override
-    public boolean remove(@Nullable Object o) {
-        throw new UnsupportedOperationException(ERROR_MESSAGE);
-    }
-
     @Override
     public void clear() {
         fLock.lock();
@@ -260,29 +248,6 @@ public class LazyArrayListStore<@NonNull E extends ISegment> implements ISegment
     // Methods added by ISegmentStore
     // ------------------------------------------------------------------------
 
-    @Override
-    public Iterable<E> getIntersectingElements(long position) {
-        fLock.lock();
-        if (fDirty) {
-            sortStore();
-        }
-        /*
-         * The intervals intersecting 't' are those whose 1) start time is
-         * *lower* than 't' AND 2) end time is *higher* than 't'.
-         */
-        try {
-            /*
-             * as fStore is sorted by start then end times, restrict sub array
-             * to elements whose start times <= t as stream.filter won't do it.
-             */
-            int index = Collections.binarySearch(fStore, new BasicSegment(position, Long.MAX_VALUE));
-            index = (index >= 0) ? index : -index - 1;
-            return fStore.subList(0, index).stream().filter(element -> position >= element.getStart() && position <= element.getEnd()).collect(Collectors.toList());
-        } finally {
-            fLock.unlock();
-        }
-    }
-
     @Override
     public Iterable<E> getIntersectingElements(long start, long end) {
         fLock.lock();
This page took 0.025399 seconds and 5 git commands to generate.