-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.3dtiles to tileset command #62
Conversation
tools/lib/databaseToTileset.js
Outdated
|
||
module.exports = tilesetToDatabase; | ||
|
||
function tilesetToDatabase(inputFile, outputDirectory) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably should be databaseToTileset
.
tools/lib/databaseToTileset.js
Outdated
} | ||
|
||
function readAndWriteFile(outputDirectory, dbGet, index) { | ||
return dbGet('SELECT * FROM media LIMIT 1 OFFSET ?', index) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running a new query for each row isn't efficient. We should do a select in chunks. Maybe like run the query to grab in 10,000 row chunks. You want to be careful with the gzipping and file writing as to not thrash disk IO.
I've done something similar like this:
var offset = 0;
var limit = 10000; // Or some reasonable limit
var asyncLimit = ??; // Number of cores or whatever
var processChunk = function() {
return dbAll('SELECT * FROM media LIMIT ? OFFSET ?', limit, offset).then(function(rows) {
if (rows.length === 0) {
// No more rows left
return Promise.resolve();
}
return Promise.map(rows, function(row) {
// TODO: Handle gzipping/file writing
++offset;
}, {concurrency: asyncLimit})
.then(function () {
return processChunk();
});
});
};
return processChunk();
e8fa0e2
to
da3e721
Compare
Updated. Thanks @tfili that code snippet was very helpful. The command is pretty fast now. |
LGTM. |
@lilleyse Do you think it would be good to deprecate instead of break this immediately? Probably have |
This early in development, I think its fine to have the occasional breaking breaking change as long as it is documented - which means I should document it |
I'll add that and document the rest of the changes since the first release in a bit. |
626cc22
to
fcf6d72
Compare
fcf6d72
to
e2dbc6d
Compare
Ready now. |
c74998e
to
e0cad18
Compare
Fixes #56
Breaking changes:
tileset2sqlite3
is now calledtilesetToDatabase
. This will need to be fixed elsewhere once a new version of 3d-tiles-tools is published.@tfili can you quickly check that the sql commands are sane?
@shehzan10 can you do a full review? No rush on this.