Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Cosmos] Bulk/Batch APIs with v1/v2 hashing in JS #10168

Merged
merged 31 commits into from
Jul 28, 2020
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8b7f6b0
Adds v1 partitionKey hashing
zfoster Jun 30, 2020
a5e78ac
Fix comment
zfoster Jun 30, 2020
e066237
Adds murmurhash library and uses Bytes
zfoster Jun 30, 2020
b212ecf
Try es2020
zfoster Jun 30, 2020
60034c2
Use BigInt init everywhere
zfoster Jul 1, 2020
ea7a53f
Adds v2 hashing support
zfoster Jul 2, 2020
90aae54
Adds back Bulk operations for v1 and v2 containers
zfoster Jul 7, 2020
684772b
Replaces bigint with JSBI
zfoster Jul 9, 2020
6c03482
Try other keys
zfoster Jul 10, 2020
4cdef29
revert comments
zfoster Jul 11, 2020
61d41ce
Pushes logs to mess with number partitioning
zfoster Jul 14, 2020
18864b5
Remove pk from public API, fix test
zfoster Jul 16, 2020
68b1fe7
Correctly orders operations
zfoster Jul 17, 2020
5ef791c
Adds recursive bulk calls on 410 errors
zfoster Jul 20, 2020
c677566
Use BytePrefix everywhere
zfoster Jul 20, 2020
5e256ff
Fix hash prefix
zfoster Jul 20, 2020
0247870
Fixes {} case and errors on 410s
zfoster Jul 20, 2020
5c9841b
Merge branch 'master' into zf/bulk
zfoster Jul 21, 2020
0e6948f
Rush update and es6
zfoster Jul 21, 2020
7fe7dcb
Merge master and add declaration module
zfoster Jul 22, 2020
8025fcf
Add .d.ts murmurHash file
zfoster Jul 22, 2020
ec1d194
Adds murmurHash as ts file
zfoster Jul 22, 2020
d74f1e3
Fix converted murmurhash by removing vars
zfoster Jul 22, 2020
00d33b4
Exposes types publicly, makes partitionKeyRangeId consistent
zfoster Jul 23, 2020
03115d1
Adds 100 operation limit, removes lint issues
zfoster Jul 24, 2020
91bfcac
Adds 100 item limit, changelog, string docs
zfoster Jul 24, 2020
dd162ea
Fixes api diff
zfoster Jul 24, 2020
8e08212
Update sdk/cosmosdb/cosmos/CHANGELOG.md
zfoster Jul 27, 2020
efd1572
Remove partitionKey as header in top level
zfoster Jul 27, 2020
6842c09
Merge branch 'zf/bulk' of https://github.com/zfoster/azure-sdk-for-js…
zfoster Jul 27, 2020
dcaa388
Merge with master
zfoster Jul 27, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
983 changes: 494 additions & 489 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions sdk/cosmosdb/cosmos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"@types/debug": "^4.1.4",
"debug": "^4.1.1",
"fast-json-stable-stringify": "^2.0.0",
"jsbi": "^3.1.3",
"node-abort-controller": "^1.0.4",
"node-fetch": "^2.6.0",
"os-name": "^3.1.0",
Expand Down
87 changes: 80 additions & 7 deletions sdk/cosmosdb/cosmos/review/cosmos.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,17 @@ export class ChangeFeedResponse<T> {
export class ClientContext {
constructor(cosmosClientOptions: CosmosClientOptions, globalEndpointManager: GlobalEndpointManager);
// (undocumented)
bulk<T>({ body, path, resourceId, partitionKeyRangeId, options, }: {
body: T;
path: string;
partitionKeyRangeId: string;
resourceId: string;
options?: RequestOptions;
}): Promise<Response<any>>;
// (undocumented)
clearSessionToken(path: string): void;
// (undocumented)
create<T, U = T>({ body, path, resourceType, resourceId, options, partitionKey }: {
create<T, U = T>({ body, path, resourceType, resourceId, options, partitionKey, }: {
body: T;
path: string;
resourceType: ResourceType;
Expand All @@ -65,15 +73,15 @@ export class ClientContext {
partitionKey?: PartitionKey;
}): Promise<Response<T & U & Resource>>;
// (undocumented)
delete<T>({ path, resourceType, resourceId, options, partitionKey }: {
delete<T>({ path, resourceType, resourceId, options, partitionKey, }: {
path: string;
resourceType: ResourceType;
resourceId: string;
options?: RequestOptions;
partitionKey?: PartitionKey;
}): Promise<Response<T & Resource>>;
// (undocumented)
execute<T>({ sprocLink, params, options, partitionKey }: {
execute<T>({ sprocLink, params, options, partitionKey, }: {
sprocLink: string;
params?: any[];
options?: RequestOptions;
Expand All @@ -91,7 +99,7 @@ export class ClientContext {
[containerUrl: string]: any;
};
// (undocumented)
queryFeed<T>({ path, resourceType, resourceId, resultFn, query, options, partitionKeyRangeId, partitionKey }: {
queryFeed<T>({ path, resourceType, resourceId, resultFn, query, options, partitionKeyRangeId, partitionKey, }: {
path: string;
resourceType: ResourceType;
resourceId: string;
Expand All @@ -106,15 +114,15 @@ export class ClientContext {
// (undocumented)
queryPartitionKeyRanges(collectionLink: string, query?: string | SqlQuerySpec, options?: FeedOptions): QueryIterator<PartitionKeyRange>;
// (undocumented)
read<T>({ path, resourceType, resourceId, options, partitionKey }: {
read<T>({ path, resourceType, resourceId, options, partitionKey, }: {
path: string;
resourceType: ResourceType;
resourceId: string;
options?: RequestOptions;
partitionKey?: PartitionKey;
}): Promise<Response<T & Resource>>;
// (undocumented)
replace<T>({ body, path, resourceType, resourceId, options, partitionKey }: {
replace<T>({ body, path, resourceType, resourceId, options, partitionKey, }: {
body: any;
path: string;
resourceType: ResourceType;
Expand All @@ -123,7 +131,7 @@ export class ClientContext {
partitionKey?: PartitionKey;
}): Promise<Response<T & Resource>>;
// (undocumented)
upsert<T, U = T>({ body, path, resourceType, resourceId, options, partitionKey }: {
upsert<T, U = T>({ body, path, resourceType, resourceId, options, partitionKey, }: {
body: T;
path: string;
resourceType: ResourceType;
Expand Down Expand Up @@ -330,6 +338,9 @@ export const Constants: {
EnableScriptLogging: string;
ScriptLogResults: string;
ALLOW_MULTIPLE_WRITES: string;
IsBatchRequest: string;
IsBatchAtomic: string;
ForceRefresh: string;
};
WritableLocations: string;
ReadableLocations: string;
Expand Down Expand Up @@ -481,6 +492,11 @@ export interface CosmosHeaders {
[key: string]: any;
}

// @public (undocumented)
export type CreateOperation = OperationWithItem & {
operationType: "Create";
};

// @public
export class Database {
constructor(client: CosmosClient, id: string, clientContext: ClientContext);
Expand Down Expand Up @@ -565,6 +581,12 @@ export enum DataType {
// @public (undocumented)
export const DEFAULT_PARTITION_KEY_PATH: "/_partitionKey";

// @public (undocumented)
export type DeleteOperation = OperationBase & {
operationType: "Delete";
id: string;
};

// @public (undocumented)
export interface ErrorBody {
// (undocumented)
Expand Down Expand Up @@ -759,6 +781,8 @@ export class ItemResponse<T extends ItemDefinition> extends ResourceResponse<T &
// @public
export class Items {
constructor(container: Container, clientContext: ClientContext);
// (undocumented)
bulk(operations: Operation[], options?: RequestOptions): Promise<OperationResponse[]>;
changeFeed(partitionKey: string | number | boolean, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
changeFeed(changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<any>;
changeFeed<T>(partitionKey: string | number | boolean, changeFeedOptions?: ChangeFeedOptions): ChangeFeedIterator<T>;
Expand Down Expand Up @@ -855,8 +879,35 @@ export class Offers {
readAll(options?: FeedOptions): QueryIterator<OfferDefinition & Resource>;
}

// @public (undocumented)
export type Operation = CreateOperation | UpsertOperation | ReadOperation | DeleteOperation | ReplaceOperation;

// @public (undocumented)
export interface OperationBase {
// (undocumented)
ifMatch?: string;
// (undocumented)
ifNoneMatch?: string;
// (undocumented)
partitionKey?: string;
}

// @public (undocumented)
export interface OperationResponse {
// (undocumented)
eTag?: string;
// (undocumented)
requestCharge: number;
// (undocumented)
resourceBody?: JSONObject;
// (undocumented)
statusCode: number;
}

// @public (undocumented)
export enum OperationType {
// (undocumented)
Batch = "batch",
// (undocumented)
Create = "create",
// (undocumented)
Expand All @@ -873,6 +924,11 @@ export enum OperationType {
Upsert = "upsert"
}

// @public (undocumented)
export type OperationWithItem = OperationBase & {
resourceBody: JSONObject;
};

// @public (undocumented)
export interface PartitionedQueryExecutionInfo {
// (undocumented)
Expand Down Expand Up @@ -1131,6 +1187,18 @@ export interface QueryRange {
min: string;
}

// @public (undocumented)
export type ReadOperation = OperationBase & {
operationType: "Read";
id: string;
};

// @public (undocumented)
export type ReplaceOperation = OperationWithItem & {
operationType: "Replace";
id: string;
};

// @public (undocumented)
export interface RequestContext {
// (undocumented)
Expand Down Expand Up @@ -1589,6 +1657,11 @@ export interface UniqueKeyPolicy {
uniqueKeys: UniqueKey[];
}

// @public (undocumented)
export type UpsertOperation = OperationWithItem & {
operationType: "Upsert";
};

// @public
export class User {
constructor(database: Database, id: string, clientContext: ClientContext);
Expand Down
Loading