Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Molstar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Michal Malý
Molstar
Commits
5a874967
Commit
5a874967
authored
7 years ago
by
Alexander Rose
Browse files
Options
Downloads
Patches
Plain Diff
added Column.copyToArray and Table.concat helpers
parent
d1bbe015
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/mol-data/db.ts
+1
-1
1 addition, 1 deletion
src/mol-data/db.ts
src/mol-data/db/column.ts
+13
-0
13 additions, 0 deletions
src/mol-data/db/column.ts
src/mol-data/db/table.ts
+26
-0
26 additions, 0 deletions
src/mol-data/db/table.ts
src/mol-io/writer/cif.ts
+1
-1
1 addition, 1 deletion
src/mol-io/writer/cif.ts
with
41 additions
and
2 deletions
src/mol-data/db.ts
+
1
−
1
View file @
5a874967
...
@@ -10,6 +10,6 @@ import Table from './db/table'
...
@@ -10,6 +10,6 @@ import Table from './db/table'
import
Column
from
'
./db/column
'
import
Column
from
'
./db/column
'
import
*
as
ColumnHelpers
from
'
./db/column-helpers
'
import
*
as
ColumnHelpers
from
'
./db/column-helpers
'
type
DatabaseCollection
=
{
[
name
:
string
]:
Database
<
Database
.
Schema
>
}
type
DatabaseCollection
<
T
extends
Database
.
Schema
>
=
{
[
name
:
string
]:
Database
<
T
>
}
export
{
DatabaseCollection
,
Database
,
Table
,
Column
,
ColumnHelpers
}
export
{
DatabaseCollection
,
Database
,
Table
,
Column
,
ColumnHelpers
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/mol-data/db/column.ts
+
13
−
0
View file @
5a874967
...
@@ -150,6 +150,19 @@ namespace Column {
...
@@ -150,6 +150,19 @@ namespace Column {
if
(
!
c
.
isDefined
)
return
Undefined
(
c
.
rowCount
,
c
.
schema
)
as
any
as
Column
<
T
>
;
if
(
!
c
.
isDefined
)
return
Undefined
(
c
.
rowCount
,
c
.
schema
)
as
any
as
Column
<
T
>
;
return
arrayColumn
({
array
:
c
.
toArray
({
array
}),
schema
:
c
.
schema
,
valueKind
:
c
.
valueKind
});
return
arrayColumn
({
array
:
c
.
toArray
({
array
}),
schema
:
c
.
schema
,
valueKind
:
c
.
valueKind
});
}
}
export
function
copyToArray
<
T
>
(
c
:
Column
<
T
>
,
array
:
ArrayLike
<
T
>
,
offset
=
0
)
{
if
(
!
c
.
isDefined
)
return
;
const
cArray
=
c
[
'
@array
'
]
if
(
cArray
)
{
// TODO Index signature of 'ArrayLike<T>' only permits reading
for
(
let
i
=
0
,
_i
=
cArray
.
length
;
i
<
_i
;
i
++
)
(
array
[
offset
+
i
]
as
any
)
=
cArray
[
i
];
}
else
{
// TODO Index signature of 'ArrayLike<T>' only permits reading
for
(
let
i
=
0
,
_i
=
c
.
rowCount
;
i
<
_i
;
i
++
)
(
array
[
offset
+
i
]
as
any
)
=
c
.
value
(
i
);
}
}
}
}
export
default
Column
;
export
default
Column
;
...
...
This diff is collapsed.
Click to expand it.
src/mol-data/db/table.ts
+
26
−
0
View file @
5a874967
...
@@ -100,6 +100,32 @@ namespace Table {
...
@@ -100,6 +100,32 @@ namespace Table {
return
ret
as
Table
<
R
>
;
return
ret
as
Table
<
R
>
;
}
}
export
function
concat
<
S
extends
R
,
R
extends
Schema
>
(
tables
:
Table
<
S
>
[],
schema
:
R
)
{
const
ret
=
Object
.
create
(
null
);
const
columns
=
Object
.
keys
(
schema
);
ret
.
_rowCount
=
0
for
(
const
table
of
tables
)
{
ret
.
_rowCount
+=
table
.
_rowCount
}
const
arrays
:
any
=
{}
for
(
const
column
of
columns
)
{
arrays
[
column
]
=
new
Array
(
ret
.
_rowCount
)
}
ret
.
_columns
=
columns
;
ret
.
_schema
=
schema
;
let
offset
=
0
for
(
const
table
of
tables
)
{
for
(
const
k
of
columns
)
{
Column
.
copyToArray
(
table
[
k
],
arrays
[
k
],
offset
)
}
offset
+=
table
.
_rowCount
}
for
(
const
k
of
columns
)
{
ret
[
k
]
=
Column
.
ofArray
({
array
:
arrays
[
k
],
schema
:
schema
[
k
]
})
}
return
ret
as
Table
<
R
>
;
}
export
function
columnToArray
<
S
extends
Schema
>
(
table
:
Table
<
S
>
,
name
:
keyof
S
,
array
?:
Column
.
ArrayCtor
<
any
>
)
{
export
function
columnToArray
<
S
extends
Schema
>
(
table
:
Table
<
S
>
,
name
:
keyof
S
,
array
?:
Column
.
ArrayCtor
<
any
>
)
{
(
table
as
Columns
<
S
>
)[
name
]
=
Column
.
asArrayColumn
((
table
as
Columns
<
S
>
)[
name
],
array
);
(
table
as
Columns
<
S
>
)[
name
]
=
Column
.
asArrayColumn
((
table
as
Columns
<
S
>
)[
name
],
array
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/mol-io/writer/cif.ts
+
1
−
1
View file @
5a874967
...
@@ -29,7 +29,7 @@ export function writeDatabase(encoder: CIFEncoder, name: string, database: Datab
...
@@ -29,7 +29,7 @@ export function writeDatabase(encoder: CIFEncoder, name: string, database: Datab
}
}
}
}
export
function
writeDatabaseCollection
(
encoder
:
CIFEncoder
,
collection
:
DatabaseCollection
)
{
export
function
writeDatabaseCollection
(
encoder
:
CIFEncoder
,
collection
:
DatabaseCollection
<
Database
.
Schema
>
)
{
for
(
const
name
of
Object
.
keys
(
collection
))
{
for
(
const
name
of
Object
.
keys
(
collection
))
{
writeDatabase
(
encoder
,
name
,
collection
[
name
])
writeDatabase
(
encoder
,
name
,
collection
[
name
])
}
}
...
...
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