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
33b8a83a
Commit
33b8a83a
authored
10 years ago
by
Mick Jordan
Browse files
Options
Downloads
Patches
Plain Diff
temp remove WriteTable
parent
b1b40dc8
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/utils/WriteTable.java
+0
-126
0 additions, 126 deletions
.../com/oracle/truffle/r/nodes/builtin/utils/WriteTable.java
with
0 additions
and
126 deletions
com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/utils/WriteTable.java
deleted
100644 → 0
+
0
−
126
View file @
b1b40dc8
/*
* This material is distributed under the GNU General Public License
* Version 2. You may review the terms of this license at
* http://www.gnu.org/licenses/gpl-2.0.html
*
* Copyright (c) 1995-2012, The R Core Team
* Copyright (c) 2003, The R Foundation
* Copyright (c) 2014, Oracle and/or its affiliates
*
* All rights reserved.
*/
package
com.oracle.truffle.r.nodes.builtin.utils
;
import
com.oracle.truffle.r.runtime.*
;
import
com.oracle.truffle.r.runtime.data.*
;
//Transcribed from GnuR, library/utils/src/io.c
//Checkstyle: stop
public
class
WriteTable
{
private
static
class
WtInfo
{
boolean
wasopen
;
RConnection
con
;
int
savedigits
;
}
// @formatter: off
public
Object
execute
(
RConnection
con
,
Object
xx
,
int
nr
,
int
nc
,
Object
rnames
,
String
csep
,
String
ceol
,
String
cna
,
char
cdec
,
byte
qmethod
,
boolean
[]
quoteCol
,
boolean
quoteRn
)
{
// @formatter: on
if
(
xx
instanceof
RDataFrame
)
{
/* A data frame */
/* handle factors internally, check integrity */
levels
=
(
SEXP
*)
R_alloc
(
nc
,
sizeof
(
SEXP
));
for
(
int
j
=
0
;
j
<
nc
;
j
++)
{
xj
=
VECTOR_ELT
(
x
,
j
);
if
(
LENGTH
(
xj
)
!=
nr
)
error
(
_
(
"corrupt data frame -- length of column %d does not not match nrows"
),
j
+
1
);
if
(
inherits
(
xj
,
"factor"
))
{
levels
[
j
]
=
getAttrib
(
xj
,
R_LevelsSymbol
);
}
else
levels
[
j
]
=
R_NilValue
;
}
for
(
int
i
=
0
;
i
<
nr
;
i
++)
{
if
(
i
%
1000
==
999
)
R_CheckUserInterrupt
();
if
(!
isNull
(
rnames
))
Rconn_printf
(
con
,
"%s%s"
,
EncodeElement2
(
rnames
,
i
,
quote_rn
,
qmethod
,
&
strBuf
,
cdec
),
csep
);
for
(
int
j
=
0
;
j
<
nc
;
j
++)
{
xj
=
VECTOR_ELT
(
x
,
j
);
if
(
j
>
0
)
Rconn_printf
(
con
,
"%s"
,
csep
);
if
(
isna
(
xj
,
i
))
tmp
=
cna
;
else
{
if
(!
isNull
(
levels
[
j
]))
{
/* We do not assume factors have integer levels,
although they should. */
if
(
TYPEOF
(
xj
)
==
INTSXP
)
tmp
=
EncodeElement2
(
levels
[
j
],
INTEGER
(
xj
)[
i
]
-
1
,
quote_col
[
j
],
qmethod
,
&
strBuf
,
cdec
);
else
if
(
TYPEOF
(
xj
)
==
REALSXP
)
tmp
=
EncodeElement2
(
levels
[
j
],
(
int
)
(
REAL
(
xj
)[
i
]
-
1
),
quote_col
[
j
],
qmethod
,
&
strBuf
,
cdec
);
else
error
(
_
(
"column %s claims to be a factor but does not have numeric codes"
),
j
+
1
);
}
else
{
tmp
=
EncodeElement2
(
xj
,
i
,
quote_col
[
j
],
qmethod
,
&
strBuf
,
cdec
);
}
/* if(cdec) change_dec(tmp, cdec, TYPEOF(xj)); */
}
Rconn_printf
(
con
,
"%s"
,
tmp
);
}
Rconn_printf
(
con
,
"%s"
,
ceol
);
}
}
else
{
/* A matrix */
//if (!isVectorAtomic(x))
// UNIMPLEMENTED_TYPE("write.table, matrix method", x);
RVector
x
=
(
RVector
)
xx
;
/* quick integrity check */
if
(
x
.
getLength
()
!=
nr
*
nc
)
{
throw
new
IllegalArgumentException
(
"corrupt matrix -- dims not not match length"
);
for
(
int
i
=
0
;
i
<
nr
;
i
++)
{
if
(
i
%
1000
==
999
)
{
// R_CheckUserInterrupt();
}
if
(!(
rnames
instanceof
RNull
))
{
Rconn_printf
(
con
,
"%s%s"
,
EncodeElement2
(
rnames
,
i
,
quote_rn
,
qmethod
,
&
strBuf
,
cdec
),
csep
);
}
for
(
int
j
=
0
;
j
<
nc
;
j
++)
{
if
(
j
>
0
)
{
Rconn_printf
(
con
,
"%s"
,
csep
);
}
if
(
isna
(
x
,
i
+
j
*
nr
))
{
tmp
=
cna
;
}
else
{
tmp
=
EncodeElement2
(
x
,
i
+
j
*
nr
,
quote_col
[
j
],
qmethod
,
&
strBuf
,
cdec
);
/* if(cdec) change_dec(tmp, cdec, TYPEOF(x)); */
}
Rconn_printf
(
con
,
"%s"
,
tmp
);
}
Rconn_printf
(
con
,
"%s"
,
ceol
);
}
}
return
RNull
.
instance
;
}
}
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