Skip to content

Commit

Permalink
updates to fix test issue
Browse files Browse the repository at this point in the history
  • Loading branch information
gregns1 committed Oct 5, 2023
1 parent 6b688cb commit 8410ffe
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
4 changes: 1 addition & 3 deletions db/crud.go
Original file line number Diff line number Diff line change
Expand Up @@ -871,9 +871,7 @@ func (db *DatabaseCollectionWithUser) OnDemandImportForWrite(ctx context.Context

// updateHLV updates the HLV in the sync data appropriately based on what type of document update event we are encountering
func (db *DatabaseCollectionWithUser) updateHLV(d *Document, docUpdateEvent uint32) (*Document, error) {
if d.HLV == nil {
d.HLV = &HybridLogicalVector{}
}

switch docUpdateEvent {
case BlipWriteEvent:
// preserve any other logic on the HLV that has been done by the client, only update to cvCAS will be needed
Expand Down
36 changes: 18 additions & 18 deletions db/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,24 @@ type ChannelSetEntry struct {

// The sync-gateway metadata stored in the "_sync" property of a Couchbase document.
type SyncData struct {
CurrentRev string `json:"rev"`
NewestRev string `json:"new_rev,omitempty"` // Newest rev, if different from CurrentRev
Flags uint8 `json:"flags,omitempty"`
Sequence uint64 `json:"sequence,omitempty"`
UnusedSequences []uint64 `json:"unused_sequences,omitempty"` // unused sequences due to update conflicts/CAS retry
RecentSequences []uint64 `json:"recent_sequences,omitempty"` // recent sequences for this doc - used in server dedup handling
Channels channels.ChannelMap `json:"channels,omitempty"`
Access UserAccessMap `json:"access,omitempty"`
RoleAccess UserAccessMap `json:"role_access,omitempty"`
Expiry *time.Time `json:"exp,omitempty"` // Document expiry. Information only - actual expiry/delete handling is done by bucket storage. Needs to be pointer for omitempty to work (see https://github.com/golang/go/issues/4357)
Cas string `json:"cas"` // String representation of a cas value, populated via macro expansion
Crc32c string `json:"value_crc32c"` // String representation of crc32c hash of doc body, populated via macro expansion
Crc32cUserXattr string `json:"user_xattr_value_crc32c,omitempty"` // String representation of crc32c hash of user xattr
TombstonedAt int64 `json:"tombstoned_at,omitempty"` // Time the document was tombstoned. Used for view compaction
Attachments AttachmentsMeta `json:"attachments,omitempty"`
ChannelSet []ChannelSetEntry `json:"channel_set"`
ChannelSetHistory []ChannelSetEntry `json:"channel_set_history"`
HLV *HybridLogicalVector `json:"_vv,omitempty"`
CurrentRev string `json:"rev"`
NewestRev string `json:"new_rev,omitempty"` // Newest rev, if different from CurrentRev
Flags uint8 `json:"flags,omitempty"`
Sequence uint64 `json:"sequence,omitempty"`
UnusedSequences []uint64 `json:"unused_sequences,omitempty"` // unused sequences due to update conflicts/CAS retry
RecentSequences []uint64 `json:"recent_sequences,omitempty"` // recent sequences for this doc - used in server dedup handling
Channels channels.ChannelMap `json:"channels,omitempty"`
Access UserAccessMap `json:"access,omitempty"`
RoleAccess UserAccessMap `json:"role_access,omitempty"`
Expiry *time.Time `json:"exp,omitempty"` // Document expiry. Information only - actual expiry/delete handling is done by bucket storage. Needs to be pointer for omitempty to work (see https://github.com/golang/go/issues/4357)
Cas string `json:"cas"` // String representation of a cas value, populated via macro expansion
Crc32c string `json:"value_crc32c"` // String representation of crc32c hash of doc body, populated via macro expansion
Crc32cUserXattr string `json:"user_xattr_value_crc32c,omitempty"` // String representation of crc32c hash of user xattr
TombstonedAt int64 `json:"tombstoned_at,omitempty"` // Time the document was tombstoned. Used for view compaction
Attachments AttachmentsMeta `json:"attachments,omitempty"`
ChannelSet []ChannelSetEntry `json:"channel_set"`
ChannelSetHistory []ChannelSetEntry `json:"channel_set_history"`
HLV HybridLogicalVector `json:"_vv,omitempty"`

// Only used for performance metrics:
TimeSaved time.Time `json:"time_saved,omitempty"` // Timestamp of save.
Expand Down
5 changes: 4 additions & 1 deletion db/hybrid_logical_vector.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,13 @@ func (hlv *HybridLogicalVector) UnmarshalJSON(inputjson []byte) error {
func (hlv *HybridLogicalVector) convertHLVToPersistedFormat() (*PersistedHybridLogicalVector, error) {
persistedHLV := PersistedHybridLogicalVector{}
var cvCasByteArray []byte
var vrsCasByteArray []byte
if hlv.CurrentVersionCAS != 0 {
cvCasByteArray = base.Uint64CASToLittleEndianHex(hlv.CurrentVersionCAS)
}
vrsCasByteArray := base.Uint64CASToLittleEndianHex(hlv.Version)
if hlv.Version != 0 {
vrsCasByteArray = base.Uint64CASToLittleEndianHex(hlv.Version)
}

pvPersistedFormat, err := convertMapToPersistedFormat(hlv.PreviousVersions)
if err != nil {
Expand Down

0 comments on commit 8410ffe

Please sign in to comment.