23 lines
618 B
Python
23 lines
618 B
Python
import os
|
|
import tempfile
|
|
from typing import Optional
|
|
|
|
from raven.util.int2intmap import Int2IntMap
|
|
|
|
|
|
class LineToLineMap:
|
|
def __init__(self):
|
|
(handle, self.tmpfilename) = tempfile.mkstemp()
|
|
os.close(handle)
|
|
self._int2intmap = Int2IntMap(self.tmpfilename)
|
|
|
|
def close(self):
|
|
self._int2intmap.close()
|
|
os.remove(self.tmpfilename)
|
|
|
|
def add_line(self, key_byte_start: int, value_byte_start):
|
|
self._int2intmap.add(key_byte_start, value_byte_start)
|
|
|
|
def get_line(self, key_byte_start: int) -> Optional[int]:
|
|
return self._int2intmap.find(key_byte_start)
|