This repository has been archived by the owner on Nov 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 265
Use COPY to speed up database writes for blocks and traces #211
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
93bdb7c
Write blocks as proof of concept
lukevs bab2043
Abstract out csv writing
lukevs 6b1c469
Move classified_traces to csv write
lukevs ada540c
Write using an iterator
lukevs 9b8cac5
Credit
lukevs 0ed4f54
Move list util to db shared
lukevs 24a6ba6
Bring back the array for diff checks
lukevs f84b9d4
Add placeholder file to detect which code is running
lukevs 02a0adc
Break it to prove tests work
lukevs 28b37c7
Put it back
lukevs eff77dd
goodbye
lukevs 17823b5
comment => variable
lukevs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""This is taken from https://hakibenita.com/fast-load-data-python-postgresql""" | ||
|
||
import io | ||
from typing import Iterator, Optional | ||
|
||
|
||
class StringIteratorIO(io.TextIOBase): | ||
def __init__(self, iter: Iterator[str]): | ||
self._iter = iter | ||
self._buff = "" | ||
|
||
def readable(self) -> bool: | ||
return True | ||
|
||
def _read1(self, n: Optional[int] = None) -> str: | ||
while not self._buff: | ||
try: | ||
self._buff = next(self._iter) | ||
except StopIteration: | ||
break | ||
ret = self._buff[:n] | ||
self._buff = self._buff[len(ret) :] | ||
return ret | ||
|
||
def read(self, n: Optional[int] = None) -> str: | ||
line = [] | ||
if n is None or n < 0: | ||
while True: | ||
m = self._read1() | ||
if not m: | ||
break | ||
line.append(m) | ||
else: | ||
while n > 0: | ||
m = self._read1(n) | ||
if not m: | ||
break | ||
n -= len(m) | ||
line.append(m) | ||
return "".join(line) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this is because of this #209
kept it for now so the diffs work
will do a follow on to fix and backfill