@@ -1972,13 +1972,17 @@ cdef class DB(object):
19721972 cdef string db_path
19731973
19741974 def __cinit__ (self , db_name , Options opts , dict column_families = None ,
1975- read_only = False , *args , **kwargs ):
1975+ read_only = False , secondary_path = None , *args , **kwargs ):
19761976 cdef Status st
19771977 cdef bytes default_cf_name = db.kDefaultColumnFamilyName
19781978 self .wrapped_db = NULL
19791979 self .opts = None
19801980 self .cf_handles = []
19811981 self .cf_options = []
1982+ if isinstance (secondary_path, str ):
1983+ self .db_path = path_to_string(secondary_path)
1984+ else :
1985+ self .db_path = path_to_string(db_name)
19821986
19831987 if opts.in_use:
19841988 raise InvalidArgument(
@@ -2019,12 +2023,21 @@ cdef class DB(object):
20192023 self .cf_options.append(cf_options)
20202024 if type (self ) != DB:
20212025 return
2022- db_path = path_to_string(db_name)
2023- if read_only:
2026+ if isinstance (secondary_path, str ):
2027+ primary_db = path_to_string(db_name)
2028+ with nogil:
2029+ st = db.DB_OpenSecondary_ColumnFamilies(
2030+ deref(opts.opts),
2031+ primary_db,
2032+ self .db_path,
2033+ self .column_family_descriptors,
2034+ & self .column_family_handles,
2035+ & self .wrapped_db)
2036+ elif read_only:
20242037 with nogil:
20252038 st = db.DB_OpenForReadOnly_ColumnFamilies(
20262039 deref(opts.opts),
2027- db_path,
2040+ self . db_path,
20282041 self .column_family_descriptors,
20292042 & self .column_family_handles,
20302043 & self .wrapped_db,
@@ -2033,7 +2046,7 @@ cdef class DB(object):
20332046 with nogil:
20342047 st = db.DB_Open_ColumnFamilies(
20352048 deref(opts.opts),
2036- db_path,
2049+ self . db_path,
20372050 self .column_family_descriptors,
20382051 & self .column_family_handles,
20392052 & self .wrapped_db)
@@ -2635,6 +2648,10 @@ cdef class DB(object):
26352648 if copts:
26362649 copts.in_use = False
26372650
2651+ def try_catch_up_with_primary (self ):
2652+ with nogil:
2653+ self .wrapped_db.TryCatchUpWithPrimary()
2654+
26382655
26392656def repair_db (db_name , Options opts ):
26402657 cdef Status st
0 commit comments