MCPcopy Create free account
hub / github.com/dbProjectRED/redimo.go / zGeneralRange

Method zGeneralRange

sorted_sets.go:300–375  ·  view source on GitHub ↗
(key string,
	start rangeCap, stop rangeCap,
	offset int64, count int64,
	forward bool, attribute string)

Source from the content-addressed store, hash-verified

298}
299
300func (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

Callers 6

zPopMethod · 0.95
zRangeMethod · 0.95
ZRANGEBYLEXMethod · 0.95
ZRANGEBYSCOREMethod · 0.95
ZREVRANGEBYLEXMethod · 0.95
ZREVRANGEBYSCOREMethod · 0.95

Calls 11

newExpresionBuilderFunction · 0.85
parseItemFunction · 0.85
zScoreFromAVFunction · 0.85
addConditionEqualityMethod · 0.80
conditionMethod · 0.80
conditionExpressionMethod · 0.80
presentMethod · 0.65
ToAVMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected