-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed offset and limit query clause returning partial query results w…
…hen used with distinct (#37860) * Fixed offset and limit query clause when used with distinct * Added offset limit order by distinct tests
- Loading branch information
1 parent
8c6a63f
commit 2b506b7
Showing
10 changed files
with
448 additions
and
209 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
75 changes: 75 additions & 0 deletions
75
...re-cosmos/src/main/java/com/azure/cosmos/implementation/query/LimitContinuationToken.java
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,75 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.cosmos.implementation.query; | ||
|
||
import com.azure.cosmos.BridgeInternal; | ||
import com.azure.cosmos.implementation.JsonSerializable; | ||
import com.azure.cosmos.implementation.Utils.ValueHolder; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
||
/** | ||
* While this class is public, but it is not part of our published public APIs. | ||
* This is meant to be internally used only by our sdk. | ||
*/ | ||
public final class LimitContinuationToken extends JsonSerializable { | ||
private static final String LIMIT_PROPERTY_NAME = "limit"; | ||
private static final String SOURCE_TOKEN_PROPERTY_NAME = "sourceToken"; | ||
private static final Logger logger = LoggerFactory.getLogger(LimitContinuationToken.class); | ||
|
||
public LimitContinuationToken(int limitCount, String sourceToken) { | ||
if (limitCount < 0) { | ||
throw new IllegalArgumentException("limitCount must be a non negative number."); | ||
} | ||
|
||
this.setLimitCount(limitCount); | ||
this.setSourceToken(sourceToken); | ||
} | ||
|
||
private LimitContinuationToken(String serializedTakeContinuationToken) { | ||
super(serializedTakeContinuationToken); | ||
} | ||
|
||
public static boolean tryParse(String serializedTakeContinuationToken, ValueHolder<LimitContinuationToken> outTakeContinuationToken) { | ||
boolean parsed; | ||
try { | ||
LimitContinuationToken takeContinuationToken = new LimitContinuationToken(serializedTakeContinuationToken); | ||
takeContinuationToken.getSourceToken(); | ||
takeContinuationToken.getLimitCount(); | ||
outTakeContinuationToken.v = takeContinuationToken; | ||
parsed = true; | ||
} catch (Exception ex) { | ||
logger.debug( | ||
"Received exception {} when trying to parse: {}", | ||
ex.getMessage(), | ||
serializedTakeContinuationToken); | ||
parsed = false; | ||
outTakeContinuationToken.v = null; | ||
} | ||
|
||
return parsed; | ||
} | ||
|
||
public int getLimitCount() { | ||
return super.getInt(LIMIT_PROPERTY_NAME); | ||
} | ||
|
||
public String getSourceToken() { | ||
return super.getString(SOURCE_TOKEN_PROPERTY_NAME); | ||
} | ||
|
||
private void setLimitCount(int limitCount) { | ||
BridgeInternal.setProperty(this, LIMIT_PROPERTY_NAME, limitCount); | ||
} | ||
|
||
private void setSourceToken(String sourceToken) { | ||
BridgeInternal.setProperty(this, SOURCE_TOKEN_PROPERTY_NAME, sourceToken); | ||
} | ||
|
||
@Override | ||
public String toJson() { | ||
return super.toJson(); | ||
} | ||
} |
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
Oops, something went wrong.