You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2023/01/03 11:35:06 UTC

[GitHub] [pulsar-client-go] BewareMyPower opened a new pull request, #938: [feature] Support batch index ACK

BewareMyPower opened a new pull request, #938:
URL: https://github.com/apache/pulsar-client-go/pull/938

   Fixes https://github.com/apache/pulsar-client-go/issues/894
   
   ### Modifications
   
   Add an `EnableBatchIndexAcknowledgment` to specify whether batch index ACK is enabled. Since this feature requires the conversion between a bit set and its underlying long array, which is similar to Java's `BitSet`, this commit introduces github.com/bits-and-blooms/bitset dependency to replace the `big.Int` based implementation of the bit set.
   
   Add a `BatchSize()` method to `MessageId` to indicate the size of the `ack_set` field. When the batch index ACK happens, convert the `[]uint64` to the `[]int64` as the `ack_set` field in `CommandAck`. When receiving messages, convert the `ack_set` field in `CommandMessage` to filter the acknowledged single messages.
   
   Remove the duplicated code in `AckID` and `AckIDWithResponse`.
   
   ### Verifications
   
   `TestBatchIndexAck` is added to cover the case whether `AckWithResponse` is enabled and both individual and cumulative ACK.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar-client-go] BewareMyPower merged pull request #938: [feature] Support batch index ACK

Posted by GitBox <gi...@apache.org>.
BewareMyPower merged PR #938:
URL: https://github.com/apache/pulsar-client-go/pull/938


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar-client-go] BewareMyPower commented on a diff in pull request #938: [feature] Support batch index ACK

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on code in PR #938:
URL: https://github.com/apache/pulsar-client-go/pull/938#discussion_r1063041437


##########
pulsar/impl_message.go:
##########
@@ -21,36 +21,38 @@ import (
 	"errors"
 	"fmt"
 	"math"
-	"math/big"
-	"strings"
 	"sync"
 	"sync/atomic"
 	"time"
 
 	"google.golang.org/protobuf/proto"
 
 	pb "github.com/apache/pulsar-client-go/pulsar/internal/pulsar_proto"
+	"github.com/bits-and-blooms/bitset"
 )
 
 type messageID struct {
 	ledgerID     int64
 	entryID      int64
 	batchIdx     int32
 	partitionIdx int32
+	batchSize    int32

Review Comment:
   #316 just changes the type from `int` to the portable `int32` that only occupies 4 bytes for all architectures. If you want to mention #324, it's also different. #324 moves some fields that are responsible for tracking the acknowledgment into the `MessageID` returned by consumer. For producer, only the required fields are reserved.
   
   However, batch size field is a part of the Pulsar protocol. https://github.com/apache/pulsar-client-go/blob/44dc85c9323f5e64d1acf250fcafe8580617ce52/pulsar/internal/pulsar_proto/PulsarApi.proto#L64 Even the `MessageID` returned by producer should set this field.
   
   >  otherwise the expression of messageID is not very correct,
   
   Could you give an example?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar-client-go] BewareMyPower commented on a diff in pull request #938: [feature] Support batch index ACK

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on code in PR #938:
URL: https://github.com/apache/pulsar-client-go/pull/938#discussion_r1063049263


##########
pulsar/impl_message.go:
##########
@@ -21,36 +21,38 @@ import (
 	"errors"
 	"fmt"
 	"math"
-	"math/big"
-	"strings"
 	"sync"
 	"sync/atomic"
 	"time"
 
 	"google.golang.org/protobuf/proto"
 
 	pb "github.com/apache/pulsar-client-go/pulsar/internal/pulsar_proto"
+	"github.com/bits-and-blooms/bitset"
 )
 
 type messageID struct {
 	ledgerID     int64
 	entryID      int64
 	batchIdx     int32
 	partitionIdx int32
+	batchSize    int32

Review Comment:
   If you want to differ the non-batch message id with batch message id like Java's `MessageIdImpl` and `BatchMessageIdImpl`, the `batchIdx` and `batchSize` fields should be moved together.
   
   ```go
   type messageID struct {
   	ledgerID     int64
   	entryID      int64
   	partitionIdx int32
   }
   
   type batchMessageID struct {
           msgID        messageID
   	batchIdx     int32
   	batchSize    int32
   }
   ```
   
   But I'm not sure if it could make the code complicated. And moving an existing field (`batchIdx`) out of a struct might lead incompatibility issues (not sure).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar-client-go] wolfstudy commented on a diff in pull request #938: [feature] Support batch index ACK

Posted by GitBox <gi...@apache.org>.
wolfstudy commented on code in PR #938:
URL: https://github.com/apache/pulsar-client-go/pull/938#discussion_r1062402013


##########
pulsar/impl_message.go:
##########
@@ -21,36 +21,38 @@ import (
 	"errors"
 	"fmt"
 	"math"
-	"math/big"
-	"strings"
 	"sync"
 	"sync/atomic"
 	"time"
 
 	"google.golang.org/protobuf/proto"
 
 	pb "github.com/apache/pulsar-client-go/pulsar/internal/pulsar_proto"
+	"github.com/bits-and-blooms/bitset"
 )
 
 type messageID struct {
 	ledgerID     int64
 	entryID      int64
 	batchIdx     int32
 	partitionIdx int32
+	batchSize    int32

Review Comment:
   A more elegant way here is that we can abstract a new struct which contains the following:
   
   ```
   type xxx struct {
       msgID messageID
       batchSize    int32
   }
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar-client-go] BewareMyPower commented on a diff in pull request #938: [feature] Support batch index ACK

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on code in PR #938:
URL: https://github.com/apache/pulsar-client-go/pull/938#discussion_r1063049263


##########
pulsar/impl_message.go:
##########
@@ -21,36 +21,38 @@ import (
 	"errors"
 	"fmt"
 	"math"
-	"math/big"
-	"strings"
 	"sync"
 	"sync/atomic"
 	"time"
 
 	"google.golang.org/protobuf/proto"
 
 	pb "github.com/apache/pulsar-client-go/pulsar/internal/pulsar_proto"
+	"github.com/bits-and-blooms/bitset"
 )
 
 type messageID struct {
 	ledgerID     int64
 	entryID      int64
 	batchIdx     int32
 	partitionIdx int32
+	batchSize    int32

Review Comment:
   If you want to differ the non-batch message id with batch message id like Java's `MessageIdImpl` and `BatchMessageIdImpl`, the `batchIdx` and `batchSize` fields should be moved together.
   
   ```go
   type messageID struct {
   	ledgerID     int64
   	entryID      int64
   	partitionIdx int32
   }
   
   type batchMessageID struct {
           msgID        messageID
   	batchIdx     int32
   	batchSize    int32
   }
   ```
   
   But I'm not sure if it could make the code complicated.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar-client-go] wolfstudy commented on a diff in pull request #938: [feature] Support batch index ACK

Posted by GitBox <gi...@apache.org>.
wolfstudy commented on code in PR #938:
URL: https://github.com/apache/pulsar-client-go/pull/938#discussion_r1062395498


##########
pulsar/impl_message.go:
##########
@@ -21,36 +21,38 @@ import (
 	"errors"
 	"fmt"
 	"math"
-	"math/big"
-	"strings"
 	"sync"
 	"sync/atomic"
 	"time"
 
 	"google.golang.org/protobuf/proto"
 
 	pb "github.com/apache/pulsar-client-go/pulsar/internal/pulsar_proto"
+	"github.com/bits-and-blooms/bitset"
 )
 
 type messageID struct {
 	ledgerID     int64
 	entryID      int64
 	batchIdx     int32
 	partitionIdx int32
+	batchSize    int32

Review Comment:
   Please do not add new field information in this structure, otherwise the expression of messageID is not very correct, and there will be performance problems. Refer to the repair of this pr: https://github.com/apache/pulsar-client-go/pull/316



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar-client-go] BewareMyPower commented on a diff in pull request #938: [feature] Support batch index ACK

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on code in PR #938:
URL: https://github.com/apache/pulsar-client-go/pull/938#discussion_r1063049263


##########
pulsar/impl_message.go:
##########
@@ -21,36 +21,38 @@ import (
 	"errors"
 	"fmt"
 	"math"
-	"math/big"
-	"strings"
 	"sync"
 	"sync/atomic"
 	"time"
 
 	"google.golang.org/protobuf/proto"
 
 	pb "github.com/apache/pulsar-client-go/pulsar/internal/pulsar_proto"
+	"github.com/bits-and-blooms/bitset"
 )
 
 type messageID struct {
 	ledgerID     int64
 	entryID      int64
 	batchIdx     int32
 	partitionIdx int32
+	batchSize    int32

Review Comment:
   If you want to differ the non-batch message id with batch message id like Java's `MessageIdImpl` and `BatchMessageIdImpl`, the `batchIdx` and `batchSize` fields should be moved together.
   
   ```go
   type messageID struct {
   	ledgerID     int64
   	entryID      int64
   	partitionIdx int32
   }
   
   type batchMessageID struct {
           msgID        messageID
   	batchIdx     int32
   	batchSize    int32
   }
   ```
   
   But I'm not sure if it could make the code complicated. And moving an existing field (`batchIdx`) out of a struct might lead to incompatibility issues (not sure).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar-client-go] BewareMyPower commented on a diff in pull request #938: [feature] Support batch index ACK

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on code in PR #938:
URL: https://github.com/apache/pulsar-client-go/pull/938#discussion_r1063049263


##########
pulsar/impl_message.go:
##########
@@ -21,36 +21,38 @@ import (
 	"errors"
 	"fmt"
 	"math"
-	"math/big"
-	"strings"
 	"sync"
 	"sync/atomic"
 	"time"
 
 	"google.golang.org/protobuf/proto"
 
 	pb "github.com/apache/pulsar-client-go/pulsar/internal/pulsar_proto"
+	"github.com/bits-and-blooms/bitset"
 )
 
 type messageID struct {
 	ledgerID     int64
 	entryID      int64
 	batchIdx     int32
 	partitionIdx int32
+	batchSize    int32

Review Comment:
   If you want to differ the non-batch message id with batch message id like Java's `MessageIdImpl` and `BatchMessageIdImpl`, the `batchIdx` and `batchSize` fields should be moved together.
   
   ```go
   type messageID struct {
   	ledgerID     int64
   	entryID      int64
   	partitionIdx int32
   }
   
   type batchMessageID struct {
           msgID messageID
   	batchIdx     int32
   	batchSize    int32
   }
   ```
   
   But I'm not sure if it could make the code complicated.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org