Skip to content

Conversation

@unknowntpo
Copy link
Contributor

@unknowntpo unknowntpo commented Nov 20, 2024

Changes and cautions:

  • docker-compose
    • add compat-redisearch service for testing RediSearch with RESP2
  • FT.CREATE:
    • search_command.json
      • Add options: INDEXEMPTY, INDEXMISSING, WITHCOUNT, ADDSCORES
      • Add field_type: GEOSHAPE
  • FT.AGGREGATE:
    • search_command.json:
      • Add option: WITHCOUNT
  • FT.SEARCH
    • go-redis doesn't implement SUMMARIZE option
    • Add option: WITHCOUNT

@unknowntpo unknowntpo force-pushed the feat-rueidiscompat-redisearch branch from 9e209e6 to 9320786 Compare November 24, 2024 10:57
@unknowntpo unknowntpo marked this pull request as ready for review November 24, 2024 11:13
message.go Outdated
Comment on lines 475 to 482
func (r RedisResult) IsMap() bool {
return r.val.IsMap()
}

// IsArray delegates to RedisMessage.IsArray
func (r RedisResult) IsArray() bool {
return r.val.IsArray()
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func (r RedisResult) IsMap() bool {
return r.val.IsMap()
}
// IsArray delegates to RedisMessage.IsArray
func (r RedisResult) IsArray() bool {
return r.val.IsArray()
}
func (r RedisResult) isMap() bool {
return r.val.IsMap()
}
// IsArray delegates to RedisMessage.IsArray
func (r RedisResult) isArray() bool {
return r.val.IsArray()
}

Can we make these 2 methods private first? I am concerned about making these direct delegations to r.val as public APIs. I think we should at least ask users to check the r.err first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if we make IsMap private, functions in command.go can not access it,
I think we could check if any error exists, then delegate to r.val.IsMap.

func (r RedisResult) IsMap() bool {
	if r.err != nil {
		panic(fmt.Errorf("RedisResult has error: %w, please check the error before calling RedisResult.IsMap", r.err))
	}
	return r.val.IsMap()
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UPDATE: I'll use res.ToMessage() to get underlying message first, then do the IsMap, IsArray check.

Comment on lines 37 to 47
func Sleep(ctx context.Context, dur time.Duration) error {
t := time.NewTimer(dur)
defer t.Stop()

select {
case <-t.C:
return nil
case <-ctx.Done():
return ctx.Err()
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove unused functions in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay.

message.go Outdated
err = r.err
} else {
v, err = r.val.ToMap()
v, err = r.val.AsMap()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this change? I think we already have an AsMap delegation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is accidentally committed, I've reverted it.

@unknowntpo unknowntpo force-pushed the feat-rueidiscompat-redisearch branch from afb8492 to ec1b389 Compare November 25, 2024 03:22
@rueian rueian merged commit 131aad3 into redis:main Nov 25, 2024
28 checks passed
@unknowntpo unknowntpo deleted the feat-rueidiscompat-redisearch branch November 25, 2024 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants