mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-28 15:45:32 +08:00
GP-0: Fix compilation of stream using Generics (ecj vs. javac)
This commit is contained in:
+7
-9
@@ -19,6 +19,7 @@ import java.io.IOException;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import db.DBRecord;
|
import db.DBRecord;
|
||||||
import generic.NestedIterator;
|
import generic.NestedIterator;
|
||||||
@@ -557,17 +558,17 @@ public abstract class AbstractConstraintsTree< //
|
|||||||
node.setDataCount(node.getDataCount() - 1);
|
node.setDataCount(node.getDataCount() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected NS unionStream(Stream<NS> shapes) {
|
||||||
|
return shapes.reduce(BoundingShape::unionBounds).orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
protected void doRecomputeBounds(NR node) {
|
protected void doRecomputeBounds(NR node) {
|
||||||
/*
|
/*
|
||||||
* TODO: There may be optimizations here, esp. if no bound of the removed node is on the
|
* TODO: There may be optimizations here, esp. if no bound of the removed node is on the
|
||||||
* edge of the parent. Furthermore, since an implementation may index on those bounds, there
|
* edge of the parent. Furthermore, since an implementation may index on those bounds, there
|
||||||
* may be a fast way to discover the "next child in".
|
* may be a fast way to discover the "next child in".
|
||||||
*/
|
*/
|
||||||
NS bounds = getChildrenOf(node).stream()
|
node.setShape(unionStream(getChildrenOf(node).stream().map(DBTreeRecord::getBounds)));
|
||||||
.map(DBTreeRecord::getBounds)
|
|
||||||
.reduce(BoundingShape::unionBounds)
|
|
||||||
.orElse(null);
|
|
||||||
node.setShape(bounds);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <R> void doRemoveFromCachedChildren(long parentKey, R child,
|
protected <R> void doRemoveFromCachedChildren(long parentKey, R child,
|
||||||
@@ -765,10 +766,7 @@ public abstract class AbstractConstraintsTree< //
|
|||||||
*/
|
*/
|
||||||
protected void checkNodeIntegrity(NR n) {
|
protected void checkNodeIntegrity(NR n) {
|
||||||
// Check parent has exactly the minimum bounds of its children
|
// Check parent has exactly the minimum bounds of its children
|
||||||
NS expectedBounds = getChildrenOf(n).stream()
|
NS expectedBounds = unionStream(getChildrenOf(n).stream().map(DBTreeRecord::getBounds));
|
||||||
.map(DBTreeRecord::getBounds)
|
|
||||||
.reduce(BoundingShape::unionBounds)
|
|
||||||
.orElse(null);
|
|
||||||
if (expectedBounds == null && n != root) {
|
if (expectedBounds == null && n != root) {
|
||||||
throw new AssertionError("Non-root node cannot be empty");
|
throw new AssertionError("Non-root node cannot be empty");
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-31
@@ -280,18 +280,12 @@ public abstract class AbstractRStarConstraintsTree< //
|
|||||||
n2.setType(n.getType());
|
n2.setType(n.getType());
|
||||||
|
|
||||||
// Update existing node's metadata
|
// Update existing node's metadata
|
||||||
n1.setShape(firstGroup.stream()
|
n1.setShape(unionStream(firstGroup.stream().map(DBTreeRecord::getBounds)));
|
||||||
.map(DBTreeRecord::getBounds)
|
|
||||||
.reduce(BoundingShape::unionBounds)
|
|
||||||
.orElse(null));
|
|
||||||
n1.setChildCount(index);
|
n1.setChildCount(index);
|
||||||
n1.setDataCount(firstGroup.stream().mapToInt(DBTreeRecord::getDataCount).sum());
|
n1.setDataCount(firstGroup.stream().mapToInt(DBTreeRecord::getDataCount).sum());
|
||||||
|
|
||||||
// Set new node's metadata
|
// Set new node's metadata
|
||||||
n2.setShape(secondGroup.stream()
|
n2.setShape(unionStream(secondGroup.stream().map(DBTreeRecord::getBounds)));
|
||||||
.map(DBTreeRecord::getBounds)
|
|
||||||
.reduce(BoundingShape::unionBounds)
|
|
||||||
.orElse(null));
|
|
||||||
n2.setChildCount(maxChildren + 1 - index);
|
n2.setChildCount(maxChildren + 1 - index);
|
||||||
n2.setDataCount(secondGroup.stream().mapToInt(DBTreeRecord::getDataCount).sum());
|
n2.setDataCount(secondGroup.stream().mapToInt(DBTreeRecord::getDataCount).sum());
|
||||||
|
|
||||||
@@ -329,17 +323,12 @@ public abstract class AbstractRStarConstraintsTree< //
|
|||||||
// ************X (M = 12)
|
// ************X (M = 12)
|
||||||
// mmm-------mmm (m = 3)
|
// mmm-------mmm (m = 3)
|
||||||
// 8 distributions : 12 - 2*3 + 2
|
// 8 distributions : 12 - 2*3 + 2
|
||||||
NS boundsFirstKChildren = children.subList(0, minChildren)
|
NS boundsFirstKChildren =
|
||||||
.stream()
|
unionStream(children.subList(0, minChildren).stream().map(DBTreeRecord::getBounds));
|
||||||
.map(DBTreeRecord::getBounds)
|
|
||||||
.reduce(BoundingShape::unionBounds)
|
|
||||||
.orElse(null);
|
|
||||||
NS boundsLastKChildren =
|
NS boundsLastKChildren =
|
||||||
children.subList(maxChildren + 1 - minChildren, maxChildren + 1)
|
unionStream(children.subList(maxChildren + 1 - minChildren, maxChildren + 1)
|
||||||
.stream()
|
.stream()
|
||||||
.map(DBTreeRecord::getBounds)
|
.map(DBTreeRecord::getBounds));
|
||||||
.reduce(BoundingShape::unionBounds)
|
|
||||||
.orElse(null);
|
|
||||||
int maxK = maxChildren + 1 - minChildren * 2;
|
int maxK = maxChildren + 1 - minChildren * 2;
|
||||||
|
|
||||||
double marginValue = 0;
|
double marginValue = 0;
|
||||||
@@ -376,16 +365,12 @@ public abstract class AbstractRStarConstraintsTree< //
|
|||||||
// mmm-------mmm (m = 3)
|
// mmm-------mmm (m = 3)
|
||||||
// 8 distributions : 12 - 2*3 + 2
|
// 8 distributions : 12 - 2*3 + 2
|
||||||
|
|
||||||
NS boundsFirstKChildren = children.subList(0, minChildren)
|
NS boundsFirstKChildren =
|
||||||
.stream()
|
unionStream(children.subList(0, minChildren).stream().map(DBTreeRecord::getBounds));
|
||||||
.map(DBTreeRecord::getBounds)
|
NS boundsLastKChildren =
|
||||||
.reduce(BoundingShape::unionBounds)
|
unionStream(children.subList(maxChildren + 1 - minChildren, maxChildren + 1)
|
||||||
.orElse(null);
|
.stream()
|
||||||
NS boundsLastKChildren = children.subList(maxChildren + 1 - minChildren, maxChildren + 1)
|
.map(DBTreeRecord::getBounds));
|
||||||
.stream()
|
|
||||||
.map(DBTreeRecord::getBounds)
|
|
||||||
.reduce(BoundingShape::unionBounds)
|
|
||||||
.orElse(null);
|
|
||||||
int maxK = maxChildren + 1 - minChildren * 2;
|
int maxK = maxChildren + 1 - minChildren * 2;
|
||||||
|
|
||||||
Deque<NS> boundsFirsts = new ArrayDeque<>();
|
Deque<NS> boundsFirsts = new ArrayDeque<>();
|
||||||
@@ -580,10 +565,7 @@ public abstract class AbstractRStarConstraintsTree< //
|
|||||||
p.setDataCount(newDataCount);
|
p.setDataCount(newDataCount);
|
||||||
|
|
||||||
// I can't think of a better way to re-compute the bounds in the path
|
// I can't think of a better way to re-compute the bounds in the path
|
||||||
p.setShape(getChildrenOf(p).stream()
|
p.setShape(unionStream(getChildrenOf(p).stream().map(DBTreeRecord::getBounds)));
|
||||||
.map(DBTreeRecord::getBounds)
|
|
||||||
.reduce(BoundingShape::unionBounds)
|
|
||||||
.orElse(null));
|
|
||||||
p = getParentOf(p);
|
p = getParentOf(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user