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
73d4e676
Commit
73d4e676
authored
8 years ago
by
Adam Welc
Browse files
Options
Downloads
Patches
Plain Diff
Fixed a problem with vapply related to non-complete vectors.
parent
c525f27f
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/VApply.java
+21
-9
21 additions, 9 deletions
...n/src/com/oracle/truffle/r/nodes/builtin/base/VApply.java
with
21 additions
and
9 deletions
com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/VApply.java
+
21
−
9
View file @
73d4e676
...
...
@@ -59,6 +59,7 @@ import com.oracle.truffle.r.runtime.data.model.RAbstractIntVector;
import
com.oracle.truffle.r.runtime.data.model.RAbstractLogicalVector
;
import
com.oracle.truffle.r.runtime.data.model.RAbstractStringVector
;
import
com.oracle.truffle.r.runtime.data.model.RAbstractVector
;
import
com.oracle.truffle.r.runtime.ops.na.NACheck
;
/**
* The {@code vapply} builtin. The closure definition for {@code vapply} is
...
...
@@ -79,6 +80,7 @@ public abstract class VApply extends RBuiltinNode {
private
final
ConditionProfile
dimsProfile
=
ConditionProfile
.
createBinaryProfile
();
private
final
BranchProfile
errorProfile
=
BranchProfile
.
create
();
private
final
RAttributeProfiles
attrProfiles
=
RAttributeProfiles
.
create
();
private
final
NACheck
naCheck
=
NACheck
.
create
();
@Child
private
LapplyInternalNode
doApply
=
LapplyInternalNodeGen
.
create
();
...
...
@@ -156,22 +158,23 @@ public abstract class VApply extends RBuiltinNode {
RVector
result
=
null
;
boolean
applyResultZeroLength
=
applyResult
.
length
==
0
;
naCheck
.
enable
(
true
);
// TODO check funValueLen against length of result
if
(
funValueVec
instanceof
RAbstractIntVector
)
{
int
[]
data
=
applyResultZeroLength
?
new
int
[
0
]
:
convertIntVector
(
applyResult
,
funValueVecLen
);
result
=
RDataFactory
.
createIntVector
(
data
,
RDataFactory
.
COMPLETE_VECTOR
);
result
=
RDataFactory
.
createIntVector
(
data
,
naCheck
.
neverSeenNA
()
);
}
else
if
(
funValueVec
instanceof
RAbstractDoubleVector
)
{
double
[]
data
=
applyResultZeroLength
?
new
double
[
0
]
:
convertDoubleVector
(
applyResult
,
funValueVecLen
);
result
=
RDataFactory
.
createDoubleVector
(
data
,
RDataFactory
.
COMPLETE_VECTOR
);
result
=
RDataFactory
.
createDoubleVector
(
data
,
naCheck
.
neverSeenNA
()
);
}
else
if
(
funValueVec
instanceof
RAbstractLogicalVector
)
{
byte
[]
data
=
applyResultZeroLength
?
new
byte
[
0
]
:
convertLogicalVector
(
applyResult
,
funValueVecLen
);
result
=
RDataFactory
.
createLogicalVector
(
data
,
RDataFactory
.
COMPLETE_VECTOR
);
result
=
RDataFactory
.
createLogicalVector
(
data
,
naCheck
.
neverSeenNA
()
);
}
else
if
(
funValueVec
instanceof
RAbstractStringVector
)
{
String
[]
data
=
applyResultZeroLength
?
new
String
[
0
]
:
convertStringVector
(
applyResult
,
funValueVecLen
);
result
=
RDataFactory
.
createStringVector
(
data
,
RDataFactory
.
COMPLETE_VECTOR
);
result
=
RDataFactory
.
createStringVector
(
data
,
naCheck
.
neverSeenNA
()
);
}
else
if
(
funValueVec
instanceof
RAbstractComplexVector
)
{
double
[]
data
=
applyResultZeroLength
?
new
double
[
1
]
:
convertComplexVector
(
applyResult
,
funValueVecLen
);
result
=
RDataFactory
.
createComplexVector
(
data
,
RDataFactory
.
COMPLETE_VECTOR
);
result
=
RDataFactory
.
createComplexVector
(
data
,
naCheck
.
neverSeenNA
()
);
}
else
{
throw
RInternalError
.
shouldNotReachHere
();
}
...
...
@@ -202,7 +205,9 @@ public abstract class VApply extends RBuiltinNode {
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
RAbstractDoubleVector
v
=
(
RAbstractDoubleVector
)
RRuntime
.
asAbstractVector
(
castDouble
(
values
[
i
],
false
));
for
(
int
j
=
0
;
j
<
v
.
getLength
();
j
++)
{
newArray
[
ind
++]
=
v
.
getDataAt
(
j
);
double
val
=
v
.
getDataAt
(
j
);
naCheck
.
check
(
val
);
newArray
[
ind
++]
=
val
;
}
}
return
newArray
;
...
...
@@ -214,7 +219,9 @@ public abstract class VApply extends RBuiltinNode {
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
RAbstractIntVector
v
=
(
RAbstractIntVector
)
RRuntime
.
asAbstractVector
(
castInteger
(
values
[
i
],
false
));
for
(
int
j
=
0
;
j
<
v
.
getLength
();
j
++)
{
newArray
[
ind
++]
=
v
.
getDataAt
(
j
);
int
val
=
v
.
getDataAt
(
j
);
naCheck
.
check
(
val
);
newArray
[
ind
++]
=
val
;
}
}
return
newArray
;
...
...
@@ -226,7 +233,9 @@ public abstract class VApply extends RBuiltinNode {
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
RAbstractLogicalVector
v
=
(
RAbstractLogicalVector
)
RRuntime
.
asAbstractVector
(
castLogical
(
values
[
i
],
false
));
for
(
int
j
=
0
;
j
<
v
.
getLength
();
j
++)
{
newArray
[
ind
++]
=
v
.
getDataAt
(
j
);
byte
val
=
v
.
getDataAt
(
j
);
naCheck
.
check
(
val
);
newArray
[
ind
++]
=
val
;
}
}
return
newArray
;
...
...
@@ -238,7 +247,9 @@ public abstract class VApply extends RBuiltinNode {
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
RAbstractStringVector
v
=
(
RAbstractStringVector
)
RRuntime
.
asAbstractVector
(
castString
(
values
[
i
],
false
));
for
(
int
j
=
0
;
j
<
v
.
getLength
();
j
++)
{
newArray
[
ind
++]
=
v
.
getDataAt
(
j
);
String
val
=
v
.
getDataAt
(
j
);
naCheck
.
check
(
val
);
newArray
[
ind
++]
=
val
;
}
}
return
newArray
;
...
...
@@ -251,6 +262,7 @@ public abstract class VApply extends RBuiltinNode {
RAbstractComplexVector
v
=
(
RAbstractComplexVector
)
RRuntime
.
asAbstractVector
(
castComplex
(
values
[
i
],
false
));
for
(
int
j
=
0
;
j
<
v
.
getLength
();
j
++)
{
RComplex
val
=
v
.
getDataAt
(
j
);
naCheck
.
check
(
val
);
newArray
[
ind
++]
=
val
.
getRealPart
();
newArray
[
ind
++]
=
val
.
getImaginaryPart
();
}
...
...
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