-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: dedup in user defined source (#1613)
Signed-off-by: Yashash H L <[email protected]> Signed-off-by: Vigith Maurice <[email protected]> Co-authored-by: Vigith Maurice <[email protected]>
- Loading branch information
Showing
7 changed files
with
112 additions
and
88 deletions.
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
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,70 @@ | ||
/* | ||
Copyright 2022 The Numaproj Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package udsource | ||
|
||
import ( | ||
"encoding/base64" | ||
"fmt" | ||
|
||
sourcepb "github.com/numaproj/numaflow-go/pkg/apis/proto/source/v1" | ||
|
||
"github.com/numaproj/numaflow/pkg/isb" | ||
) | ||
|
||
// userDefinedSourceOffset is a implementation of isb.Offset from the user-defined source side. | ||
type userDefinedSourceOffset struct { | ||
// NOTE: encodedOffsetStr is base64 encoded string because we use encodedOffsetStr to construct message ID | ||
// and message ID is a string. | ||
encodedOffsetStr string | ||
offset []byte | ||
partitionIdx int32 | ||
} | ||
|
||
func NewUserDefinedSourceOffset(offset *sourcepb.Offset) isb.Offset { | ||
return &userDefinedSourceOffset{ | ||
offset: offset.GetOffset(), | ||
encodedOffsetStr: base64.StdEncoding.EncodeToString(offset.GetOffset()), | ||
partitionIdx: offset.GetPartitionId(), | ||
} | ||
} | ||
|
||
func (s *userDefinedSourceOffset) String() string { | ||
return fmt.Sprintf("%s-%d", s.encodedOffsetStr, s.partitionIdx) | ||
} | ||
|
||
func (s *userDefinedSourceOffset) PartitionIdx() int32 { | ||
return s.partitionIdx | ||
} | ||
|
||
func (s *userDefinedSourceOffset) Sequence() (int64, error) { | ||
panic("Sequence is not supported by userDefinedSourceOffset") | ||
} | ||
|
||
func (s *userDefinedSourceOffset) AckIt() error { | ||
panic("AckIt is not supported by userDefinedSourceOffset") | ||
} | ||
|
||
func (s *userDefinedSourceOffset) NoAck() error { | ||
panic("NoAck is not supported by userDefinedSourceOffset") | ||
} | ||
|
||
func ConvertToUserDefinedSourceOffset(offset isb.Offset) *sourcepb.Offset { | ||
return &sourcepb.Offset{ | ||
PartitionId: offset.PartitionIdx(), | ||
Offset: offset.(*userDefinedSourceOffset).offset, | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.