(key string, start rangeCap, stop rangeCap, offset int64, count int64, forward bool, attribute string)
| 298 | } |
| 299 | |
| 300 | func (c Client) zGeneralRange(key string, |
| 301 | start rangeCap, stop rangeCap, |
| 302 | offset int64, count int64, |
| 303 | forward bool, attribute string) (membersWithScores map[string]float64, err error) { |
| 304 | membersWithScores = make(map[string]float64) |
| 305 | index := int64(0) |
| 306 | remainingCount := count |
| 307 | hasMoreResults := true |
| 308 | |
| 309 | var lastKey map[string]dynamodb.AttributeValue |
| 310 | |
| 311 | for hasMoreResults { |
| 312 | var queryLimit *int64 |
| 313 | if remainingCount > 0 { |
| 314 | queryLimit = aws.Int64(remainingCount + offset - index) |
| 315 | } |
| 316 | |
| 317 | builder := newExpresionBuilder() |
| 318 | builder.addConditionEquality(c.pk, StringValue{key}) |
| 319 | |
| 320 | if start.present() { |
| 321 | builder.values["start"] = start.ToAV() |
| 322 | } |
| 323 | |
| 324 | if stop.present() { |
| 325 | builder.values["stop"] = stop.ToAV() |
| 326 | } |
| 327 | |
| 328 | switch { |
| 329 | case start.present() && stop.present(): |
| 330 | builder.condition(fmt.Sprintf("#%v BETWEEN :start AND :stop", attribute), attribute) |
| 331 | case start.present(): |
| 332 | builder.condition(fmt.Sprintf("#%v >= :start", attribute), attribute) |
| 333 | case stop.present(): |
| 334 | builder.condition(fmt.Sprintf("#%v <= :stop", attribute), attribute) |
| 335 | } |
| 336 | |
| 337 | var queryIndex *string |
| 338 | if attribute == c.skN { |
| 339 | queryIndex = aws.String(c.index) |
| 340 | } |
| 341 | |
| 342 | resp, err := c.ddbClient.QueryRequest(&dynamodb.QueryInput{ |
| 343 | ConsistentRead: aws.Bool(c.consistentReads), |
| 344 | ExclusiveStartKey: lastKey, |
| 345 | ExpressionAttributeNames: builder.expressionAttributeNames(), |
| 346 | ExpressionAttributeValues: builder.expressionAttributeValues(), |
| 347 | IndexName: queryIndex, |
| 348 | KeyConditionExpression: builder.conditionExpression(), |
| 349 | Limit: queryLimit, |
| 350 | ScanIndexForward: aws.Bool(forward), |
| 351 | TableName: aws.String(c.table), |
| 352 | }).Send(context.TODO()) |
| 353 | |
| 354 | if err != nil { |
| 355 | return membersWithScores, err |
| 356 | } |
| 357 |
no test coverage detected