1 | /*!
|
2 | * Copyright 2022 Google LLC. All Rights Reserved.
|
3 | *
|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | * you may not use this file except in compliance with the License.
|
6 | * You may obtain a copy of the License at
|
7 | *
|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
9 | *
|
10 | * Unless required by applicable law or agreed to in writing, software
|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | * See the License for the specific language governing permissions and
|
14 | * limitations under the License.
|
15 | */
|
16 | import { InsertRowsCallback } from './rowQueue';
|
17 | import { RowBatchOptions, RowMetadata } from './table';
|
18 | export interface BatchLimits {
|
19 | maxBytes: number;
|
20 | maxRows: number;
|
21 | }
|
22 | export declare const BATCH_LIMITS: BatchLimits;
|
23 | export interface InsertOptions {
|
24 | maxBytes?: number;
|
25 | maxRows?: number;
|
26 | maxMilliseconds?: number;
|
27 | }
|
28 | /**
|
29 | * Call used to help batch rows.
|
30 | *
|
31 | * @private
|
32 | *
|
33 | * @param {BatchInsertOptions} options The batching options.
|
34 | */
|
35 | export declare class RowBatch {
|
36 | batchOptions: RowBatchOptions;
|
37 | rows: RowMetadata[];
|
38 | callbacks: InsertRowsCallback[];
|
39 | created: number;
|
40 | bytes: number;
|
41 | constructor(options: RowBatchOptions);
|
42 | /**
|
43 | * Adds a row to the current batch.
|
44 | *
|
45 | * @param {object} row The row to insert.
|
46 | * function.
{InsertRowsCallback} callback The callback |
47 | */
|
48 | add(row: RowMetadata, callback?: InsertRowsCallback): void;
|
49 | /**
|
50 | * Indicates if a given row can fit in the batch.
|
51 | *
|
52 | * @param {object} row The row in question.
|
53 | * @returns {boolean}
|
54 | */
|
55 | canFit(row: RowMetadata): boolean;
|
56 | /**
|
57 | * Checks to see if this batch is at the maximum allowed payload size.
|
58 | *
|
59 | * @returns {boolean}
|
60 | */
|
61 | isAtMax(): boolean;
|
62 | /**
|
63 | * Indicates if the batch is at capacity.
|
64 | *
|
65 | * @returns {boolean}
|
66 | */
|
67 | isFull(): boolean;
|
68 | }
|