Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
QueryR
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julien Lopez
QueryR
Commits
98462955
Commit
98462955
authored
7 years ago
by
Christian Humer
Browse files
Options
Downloads
Patches
Plain Diff
Extract one more cached class to make the DSL happy.
parent
108de3c6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/fastpaths/IntersectFastPath.java
+41
-20
41 additions, 20 deletions
...fle/r/nodes/builtin/base/fastpaths/IntersectFastPath.java
with
41 additions
and
20 deletions
com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/fastpaths/IntersectFastPath.java
+
41
−
20
View file @
98462955
...
...
@@ -138,47 +138,53 @@ public abstract class IntersectFastPath extends RFastPathNode {
return
new
IntersectSortedNode
(
false
);
}
@Specialization
(
limit
=
"1"
,
guards
=
{
"x.getClass() == xClass"
,
"y.getClass() == yClass"
,
"length(x, xClass) > 0"
,
"length(y, yClass) > 0"
},
rewriteOn
=
IllegalArgumentException
.
class
)
@Specialization
(
limit
=
"1"
,
guards
=
{
"x.getClass() == cached.xClass"
,
"y.getClass() == cached.yClass"
,
"length(x, cached.xClass) > 0"
,
"length(y, cached.yClass) > 0"
},
rewriteOn
=
IllegalArgumentException
.
class
)
protected
RAbstractIntVector
intersectMaybeSorted
(
RAbstractIntVector
x
,
RAbstractIntVector
y
,
@Cached
(
"x.getClass()"
)
Class
<?
extends
RAbstractIntVector
>
xClass
,
@Cached
(
"y.getClass()"
)
Class
<?
extends
RAbstractIntVector
>
yClass
,
@Cached
(
"createMaybeSorted()"
)
IntersectSortedNode
intersect
)
{
@Cached
(
"new(x.getClass(), y.getClass())"
)
IntersectMaybeSortedNode
cached
)
{
// apply the type profiles:
RAbstractIntVector
profiledX
=
xClass
.
cast
(
x
);
RAbstractIntVector
profiledY
=
yClass
.
cast
(
y
);
RAbstractIntVector
profiledX
=
cached
.
xClass
.
cast
(
x
);
RAbstractIntVector
profiledY
=
cached
.
yClass
.
cast
(
y
);
int
xLength
=
profiledX
.
getLength
();
int
yLength
=
profiledY
.
getLength
();
RBaseNode
.
reportWork
(
this
,
xLength
+
yLength
);
int
[]
result
=
intersect
.
execute
(
profiledX
,
xLength
,
yLength
,
profiledY
);
int
[]
result
=
cached
.
intersect
.
execute
(
profiledX
,
xLength
,
yLength
,
profiledY
);
return
RDataFactory
.
createIntVector
(
result
,
profiledX
.
isComplete
()
|
profiledY
.
isComplete
());
}
public
static
class
IntersectMaybeSortedNode
extends
Node
{
public
final
Class
<?
extends
RAbstractIntVector
>
xClass
;
public
final
Class
<?
extends
RAbstractIntVector
>
yClass
;
@Child
IntersectSortedNode
intersect
;
public
IntersectMaybeSortedNode
(
Class
<?
extends
RAbstractIntVector
>
xClass
,
Class
<?
extends
RAbstractIntVector
>
yClass
)
{
this
.
xClass
=
xClass
;
this
.
yClass
=
yClass
;
this
.
intersect
=
createMaybeSorted
();
}
}
protected
static
IntersectSortedNode
createSorted
()
{
return
new
IntersectSortedNode
(
true
);
}
@Specialization
(
limit
=
"1"
,
guards
=
{
"x.getClass() == xClass"
,
"y.getClass() == yClass"
,
"length(x, xClass) > 0"
,
"length(y, yClass) > 0"
})
@Specialization
(
limit
=
"1"
,
guards
=
{
"x.getClass() ==
cached.
xClass"
,
"y.getClass() ==
cached.
yClass"
,
"length(x,
cached.
xClass) > 0"
,
"length(y,
cached.
yClass) > 0"
})
protected
RAbstractIntVector
intersect
(
RAbstractIntVector
x
,
RAbstractIntVector
y
,
@Cached
(
"x.getClass()"
)
Class
<?
extends
RAbstractIntVector
>
xClass
,
@Cached
(
"y.getClass()"
)
Class
<?
extends
RAbstractIntVector
>
yClass
,
@Cached
(
"createBinaryProfile()"
)
ConditionProfile
isXSortedProfile
,
@Cached
(
"createBinaryProfile()"
)
ConditionProfile
isYSortedProfile
,
@Cached
(
"createBinaryProfile()"
)
ConditionProfile
resultLengthMatchProfile
,
@Cached
(
"createSorted()"
)
IntersectSortedNode
intersect
)
{
@Cached
(
"new(x.getClass(), y.getClass())"
)
IntersectNode
cached
)
{
// apply the type profiles:
RAbstractIntVector
profiledX
=
xClass
.
cast
(
x
);
RAbstractIntVector
profiledY
=
yClass
.
cast
(
y
);
RAbstractIntVector
profiledX
=
cached
.
xClass
.
cast
(
x
);
RAbstractIntVector
profiledY
=
cached
.
yClass
.
cast
(
y
);
int
xLength
=
profiledX
.
getLength
();
int
yLength
=
profiledY
.
getLength
();
RBaseNode
.
reportWork
(
this
,
xLength
+
yLength
);
int
[]
result
;
if
(
isXSortedProfile
.
profile
(
isSorted
(
profiledX
)))
{
if
(
cached
.
isXSortedProfile
.
profile
(
isSorted
(
profiledX
)))
{
RAbstractIntVector
tempY
;
if
(
isYSortedProfile
.
profile
(
isSorted
(
profiledY
)))
{
if
(
cached
.
isYSortedProfile
.
profile
(
isSorted
(
profiledY
)))
{
tempY
=
profiledY
;
}
else
{
int
[]
temp
=
new
int
[
yLength
];
...
...
@@ -188,7 +194,7 @@ public abstract class IntersectFastPath extends RFastPathNode {
sort
(
temp
);
tempY
=
RDataFactory
.
createIntVector
(
temp
,
profiledY
.
isComplete
());
}
result
=
intersect
.
execute
(
profiledX
,
xLength
,
yLength
,
tempY
);
result
=
cached
.
intersect
.
execute
(
profiledX
,
xLength
,
yLength
,
tempY
);
}
else
{
result
=
EMPTY_INT_ARRAY
;
int
maxResultLength
=
Math
.
min
(
xLength
,
yLength
);
...
...
@@ -211,11 +217,26 @@ public abstract class IntersectFastPath extends RFastPathNode {
result
[
count
++]
=
value
;
}
}
result
=
resultLengthMatchProfile
.
profile
(
count
==
result
.
length
)
?
result
:
Arrays
.
copyOf
(
result
,
count
);
result
=
cached
.
resultLengthMatchProfile
.
profile
(
count
==
result
.
length
)
?
result
:
Arrays
.
copyOf
(
result
,
count
);
}
return
RDataFactory
.
createIntVector
(
result
,
profiledX
.
isComplete
()
|
profiledY
.
isComplete
());
}
public
static
class
IntersectNode
extends
Node
{
public
final
Class
<?
extends
RAbstractIntVector
>
xClass
;
public
final
Class
<?
extends
RAbstractIntVector
>
yClass
;
final
ConditionProfile
isXSortedProfile
=
ConditionProfile
.
createBinaryProfile
();
final
ConditionProfile
isYSortedProfile
=
ConditionProfile
.
createBinaryProfile
();
final
ConditionProfile
resultLengthMatchProfile
=
ConditionProfile
.
createBinaryProfile
();
@Child
IntersectSortedNode
intersect
;
public
IntersectNode
(
Class
<?
extends
RAbstractIntVector
>
xClass
,
Class
<?
extends
RAbstractIntVector
>
yClass
)
{
this
.
xClass
=
xClass
;
this
.
yClass
=
yClass
;
this
.
intersect
=
createMaybeSorted
();
}
}
private
static
boolean
isSorted
(
RAbstractIntVector
vector
)
{
int
length
=
vector
.
getLength
();
int
lastValue
=
vector
.
getDataAt
(
0
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment