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
d9e18431
Commit
d9e18431
authored
8 years ago
by
Lukas Stadler
Browse files
Options
Downloads
Patches
Plain Diff
class cache in Unique
parent
a8d861a2
Branches
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/Unique.java
+16
-2
16 additions, 2 deletions
...n/src/com/oracle/truffle/r/nodes/builtin/base/Unique.java
with
16 additions
and
2 deletions
com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/Unique.java
+
16
−
2
View file @
d9e18431
...
@@ -93,8 +93,11 @@ public abstract class Unique extends RBuiltinNode {
...
@@ -93,8 +93,11 @@ public abstract class Unique extends RBuiltinNode {
}
}
@SuppressWarnings
(
"unused"
)
@SuppressWarnings
(
"unused"
)
@Specialization
@Specialization
(
guards
=
"vecIn.getClass() == vecClass"
)
protected
RStringVector
doUnique
(
RAbstractStringVector
vec
,
byte
incomparables
,
byte
fromLast
,
int
nmax
)
{
protected
RStringVector
doUniqueCachedString
(
RAbstractStringVector
vecIn
,
byte
incomparables
,
byte
fromLast
,
int
nmax
,
@Cached
(
"vecIn.getClass()"
)
Class
<?
extends
RAbstractStringVector
>
vecClass
)
{
RAbstractStringVector
vec
=
vecClass
.
cast
(
vecIn
);
reportWork
(
vec
.
getLength
());
if
(
bigProfile
.
profile
(
vec
.
getLength
()
*
(
long
)
vec
.
getLength
()
>
BIG_THRESHOLD
))
{
if
(
bigProfile
.
profile
(
vec
.
getLength
()
*
(
long
)
vec
.
getLength
()
>
BIG_THRESHOLD
))
{
NonRecursiveHashSet
<
String
>
set
=
new
NonRecursiveHashSet
<>(
vec
.
getLength
());
NonRecursiveHashSet
<
String
>
set
=
new
NonRecursiveHashSet
<>(
vec
.
getLength
());
String
[]
data
=
new
String
[
vec
.
getLength
()];
String
[]
data
=
new
String
[
vec
.
getLength
()];
...
@@ -120,6 +123,11 @@ public abstract class Unique extends RBuiltinNode {
...
@@ -120,6 +123,11 @@ public abstract class Unique extends RBuiltinNode {
}
}
}
}
@Specialization
(
replaces
=
"doUniqueCachedString"
)
protected
RStringVector
doUnique
(
RAbstractStringVector
vec
,
byte
incomparables
,
byte
fromLast
,
int
nmax
)
{
return
doUniqueCachedString
(
vec
,
incomparables
,
fromLast
,
nmax
,
RAbstractStringVector
.
class
);
}
// these are intended to stay private as they will go away once we figure out which external
// these are intended to stay private as they will go away once we figure out which external
// library to use
// library to use
...
@@ -245,6 +253,7 @@ public abstract class Unique extends RBuiltinNode {
...
@@ -245,6 +253,7 @@ public abstract class Unique extends RBuiltinNode {
protected
RIntVector
doUniqueCached
(
RAbstractIntVector
vecIn
,
byte
incomparables
,
byte
fromLast
,
int
nmax
,
protected
RIntVector
doUniqueCached
(
RAbstractIntVector
vecIn
,
byte
incomparables
,
byte
fromLast
,
int
nmax
,
@Cached
(
"vecIn.getClass()"
)
Class
<?
extends
RAbstractIntVector
>
vecClass
)
{
@Cached
(
"vecIn.getClass()"
)
Class
<?
extends
RAbstractIntVector
>
vecClass
)
{
RAbstractIntVector
vec
=
vecClass
.
cast
(
vecIn
);
RAbstractIntVector
vec
=
vecClass
.
cast
(
vecIn
);
reportWork
(
vec
.
getLength
());
if
(
bigProfile
.
profile
(
vec
.
getLength
()
*
(
long
)
vec
.
getLength
()
>
BIG_THRESHOLD
))
{
if
(
bigProfile
.
profile
(
vec
.
getLength
()
*
(
long
)
vec
.
getLength
()
>
BIG_THRESHOLD
))
{
NonRecursiveHashSetInt
set
=
new
NonRecursiveHashSetInt
();
NonRecursiveHashSetInt
set
=
new
NonRecursiveHashSetInt
();
int
[]
data
=
new
int
[
16
];
int
[]
data
=
new
int
[
16
];
...
@@ -296,6 +305,7 @@ public abstract class Unique extends RBuiltinNode {
...
@@ -296,6 +305,7 @@ public abstract class Unique extends RBuiltinNode {
@Specialization
(
guards
=
"!lengthOne(list)"
)
@Specialization
(
guards
=
"!lengthOne(list)"
)
@TruffleBoundary
@TruffleBoundary
protected
RList
doUnique
(
RList
list
,
byte
incomparables
,
byte
fromLast
,
int
nmax
)
{
protected
RList
doUnique
(
RList
list
,
byte
incomparables
,
byte
fromLast
,
int
nmax
)
{
reportWork
(
list
.
getLength
());
/*
/*
* Brute force, as manual says: Using this for lists is potentially slow, especially if the
* Brute force, as manual says: Using this for lists is potentially slow, especially if the
* elements are not atomic vectors (see vector) or differ only in their attributes. In the
* elements are not atomic vectors (see vector) or differ only in their attributes. In the
...
@@ -375,6 +385,7 @@ public abstract class Unique extends RBuiltinNode {
...
@@ -375,6 +385,7 @@ public abstract class Unique extends RBuiltinNode {
@SuppressWarnings
(
"unused"
)
@SuppressWarnings
(
"unused"
)
@Specialization
@Specialization
protected
RDoubleVector
doUnique
(
RAbstractDoubleVector
vec
,
byte
incomparables
,
byte
fromLast
,
int
nmax
)
{
protected
RDoubleVector
doUnique
(
RAbstractDoubleVector
vec
,
byte
incomparables
,
byte
fromLast
,
int
nmax
)
{
reportWork
(
vec
.
getLength
());
if
(
bigProfile
.
profile
(
vec
.
getLength
()
*
(
long
)
vec
.
getLength
()
>
BIG_THRESHOLD
))
{
if
(
bigProfile
.
profile
(
vec
.
getLength
()
*
(
long
)
vec
.
getLength
()
>
BIG_THRESHOLD
))
{
NonRecursiveHashSetDouble
set
=
new
NonRecursiveHashSetDouble
(
vec
.
getLength
());
NonRecursiveHashSetDouble
set
=
new
NonRecursiveHashSetDouble
(
vec
.
getLength
());
double
[]
data
=
new
double
[
vec
.
getLength
()];
double
[]
data
=
new
double
[
vec
.
getLength
()];
...
@@ -401,6 +412,7 @@ public abstract class Unique extends RBuiltinNode {
...
@@ -401,6 +412,7 @@ public abstract class Unique extends RBuiltinNode {
@SuppressWarnings
(
"unused"
)
@SuppressWarnings
(
"unused"
)
@Specialization
@Specialization
protected
RLogicalVector
doUnique
(
RAbstractLogicalVector
vec
,
byte
incomparables
,
byte
fromLast
,
int
nmax
)
{
protected
RLogicalVector
doUnique
(
RAbstractLogicalVector
vec
,
byte
incomparables
,
byte
fromLast
,
int
nmax
)
{
reportWork
(
vec
.
getLength
());
ByteArray
dataList
=
new
ByteArray
(
vec
.
getLength
());
ByteArray
dataList
=
new
ByteArray
(
vec
.
getLength
());
for
(
int
i
=
0
;
i
<
vec
.
getLength
();
i
++)
{
for
(
int
i
=
0
;
i
<
vec
.
getLength
();
i
++)
{
byte
val
=
vec
.
getDataAt
(
i
);
byte
val
=
vec
.
getDataAt
(
i
);
...
@@ -414,6 +426,7 @@ public abstract class Unique extends RBuiltinNode {
...
@@ -414,6 +426,7 @@ public abstract class Unique extends RBuiltinNode {
@SuppressWarnings
(
"unused"
)
@SuppressWarnings
(
"unused"
)
@Specialization
@Specialization
protected
RComplexVector
doUnique
(
RAbstractComplexVector
vec
,
byte
incomparables
,
byte
fromLast
,
int
nmax
)
{
protected
RComplexVector
doUnique
(
RAbstractComplexVector
vec
,
byte
incomparables
,
byte
fromLast
,
int
nmax
)
{
reportWork
(
vec
.
getLength
());
if
(
bigProfile
.
profile
(
vec
.
getLength
()
*
(
long
)
vec
.
getLength
()
>
BIG_THRESHOLD
))
{
if
(
bigProfile
.
profile
(
vec
.
getLength
()
*
(
long
)
vec
.
getLength
()
>
BIG_THRESHOLD
))
{
NonRecursiveHashSet
<
RComplex
>
set
=
new
NonRecursiveHashSet
<>(
vec
.
getLength
());
NonRecursiveHashSet
<
RComplex
>
set
=
new
NonRecursiveHashSet
<>(
vec
.
getLength
());
double
[]
data
=
new
double
[
vec
.
getLength
()
*
2
];
double
[]
data
=
new
double
[
vec
.
getLength
()
*
2
];
...
@@ -441,6 +454,7 @@ public abstract class Unique extends RBuiltinNode {
...
@@ -441,6 +454,7 @@ public abstract class Unique extends RBuiltinNode {
@SuppressWarnings
(
"unused"
)
@SuppressWarnings
(
"unused"
)
@Specialization
@Specialization
protected
RRawVector
doUnique
(
RAbstractRawVector
vec
,
byte
incomparables
,
byte
fromLast
,
int
nmax
)
{
protected
RRawVector
doUnique
(
RAbstractRawVector
vec
,
byte
incomparables
,
byte
fromLast
,
int
nmax
)
{
reportWork
(
vec
.
getLength
());
if
(
bigProfile
.
profile
(
vec
.
getLength
()
*
(
long
)
vec
.
getLength
()
>
BIG_THRESHOLD
))
{
if
(
bigProfile
.
profile
(
vec
.
getLength
()
*
(
long
)
vec
.
getLength
()
>
BIG_THRESHOLD
))
{
NonRecursiveHashSet
<
RRaw
>
set
=
new
NonRecursiveHashSet
<>(
vec
.
getLength
());
NonRecursiveHashSet
<
RRaw
>
set
=
new
NonRecursiveHashSet
<>(
vec
.
getLength
());
byte
[]
data
=
new
byte
[
vec
.
getLength
()];
byte
[]
data
=
new
byte
[
vec
.
getLength
()];
...
...
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