Example #1
0
// IteratorSequenceInit create an iterator to traverse a ForestDB snapshot by sequence number range
func (k *KVStore) IteratorSequenceInit(startSeq, endSeq SeqNum, opt IteratorOpt) (*Iterator, error) {
	k.Lock()
	defer k.Unlock()

	rv := Iterator{db: k}
	Log.Tracef("fdb_iterator_sequence_init call k:%p db:%v sseq:%v eseq:%v opt:%v", k, k.db, startSeq, endSeq, opt)
	errNo := C.fdb_iterator_sequence_init(k.db, &rv.iter, C.fdb_seqnum_t(startSeq), C.fdb_seqnum_t(endSeq), C.fdb_iterator_opt_t(opt))
	Log.Tracef("fdb_iterator_sequence_init retn k:%p rv:%v", k, rv.iter)
	if errNo != RESULT_SUCCESS {
		return nil, Error(errNo)
	}
	return &rv, nil
}
Example #2
0
// Rollback a database to a specified point represented by the sequence number
func (k *KVStore) Rollback(sn SeqNum) error {
	k.Lock()
	defer k.Unlock()

	Log.Tracef("fdb_rollback call k:%p db:%v sn:%v", k, k.db, sn)
	errNo := C.fdb_rollback(&k.db, C.fdb_seqnum_t(sn))
	Log.Tracef("fdb_rollback retn k:%p errNo:%v db:%v", k, errNo, k.db)
	if errNo != RESULT_SUCCESS {
		return Error(errNo)
	}
	return nil
}
Example #3
0
// SnapshotClone clones a snapshot of a database file in ForestDB
// It is expected that the kvstore is only used for cloning so that
// it is possible not to retain lock.
func (k *KVStore) SnapshotClone(sn SeqNum) (*KVStore, error) {

	rv := KVStore{advLock: newAdvLock(), name: k.name}

	Log.Tracef("fdb_snapshot_open call k:%p db:%v sn:%v", k, k.db, sn)
	errNo := C.fdb_snapshot_open(k.db, &rv.db, C.fdb_seqnum_t(sn))
	Log.Tracef("fdb_snapshot_open retn k:%p errNo:%v rv:%v", k, errNo, rv.db)
	if errNo != RESULT_SUCCESS {
		return nil, Error(errNo)
	}
	rv.setupLogging()
	return &rv, nil
}
Example #4
0
// SetSeqNum sets the document sequence number
// NOTE: only to be used when initiating a sequence number lookup
func (d *Doc) SetSeqNum(sn SeqNum) {
	d.doc.seqnum = C.fdb_seqnum_t(sn)
}