Skip to content
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

Storing the proto in the DB would save 10+% space #26

Closed
vicb opened this issue Jun 27, 2020 · 0 comments
Closed

Storing the proto in the DB would save 10+% space #26

vicb opened this issue Jun 27, 2020 · 0 comments

Comments

@vicb
Copy link
Owner

vicb commented Jun 27, 2020

  const tracks = JSON.parse(zlib.gunzipSync(Buffer.from(trackStr, 'base64')));

  console.log(`initialSize: ${trackStr.length}`);

  const pbf = new Pbf();
  (protos.Tracks as any).write({ track: tracks }, pbf);
  const pbfBuffer = Buffer.from(pbf.finish());

  console.log(`pbfBuffer`, pbfBuffer);

  const zipPbfBuffer = zlib.gzipSync(pbfBuffer, { level: 9 });

  console.log(`zipPbfBuffer`, zipPbfBuffer);
  console.log(`zipPbfBuffer.toString().length`, zipPbfBuffer.toString().length);
  console.log(`zipPbfBuffer.toString('base64').length`, zipPbfBuffer.toString('base64').length);
initialSize: 6284
zipPbfBuffer.toString().length 3925
zipPbfBuffer.toString('base64').length 5576
vicb added a commit that referenced this issue Jul 14, 2020
@vicb vicb closed this as completed Jul 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant