diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ed440a0c5cc..f9b7f12a289 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -24,3 +24,4 @@ /py @chipkent @jmao-denver @rcaudy /R @chipkent @alexpeters1208 @rcaudy *.proto @devinrsmith @nbauernfeind @niloc132 @rcaudy +*.gwt.xml @niloc132 @rcaudy @nbauernfeind diff --git a/Base/src/main/resources/io/deephaven/base/Base.gwt.xml b/Base/src/main/resources/io/deephaven/base/Base.gwt.xml new file mode 100644 index 00000000000..6cf87067eae --- /dev/null +++ b/Base/src/main/resources/io/deephaven/base/Base.gwt.xml @@ -0,0 +1,4 @@ + + + + diff --git a/IO/src/main/resources/io/deephaven/io/IO.gwt.xml b/IO/src/main/resources/io/deephaven/io/IO.gwt.xml new file mode 100644 index 00000000000..51000b6cea3 --- /dev/null +++ b/IO/src/main/resources/io/deephaven/io/IO.gwt.xml @@ -0,0 +1,3 @@ + + + diff --git a/Util/src/main/java/io/deephaven/util/MultiException.java b/Util/src/main/java/io/deephaven/util/MultiException.java index f2dcc13a90c..e5ce94740c8 100644 --- a/Util/src/main/java/io/deephaven/util/MultiException.java +++ b/Util/src/main/java/io/deephaven/util/MultiException.java @@ -105,7 +105,7 @@ public void printStackTrace(PrintStream s) { @Override public String getMessage() { StringBuilder sb = new StringBuilder(); - sb.append(super.getMessage()).append(": \n"); + sb.append(super.getMessage()).append(":\n"); for (int i = 0; i < causes.length; i++) { sb.append("Cause ").append(i).append(": "); sb.append(causes[i].toString()); diff --git a/Util/src/main/resources/io/deephaven/Util.gwt.xml b/Util/src/main/resources/io/deephaven/Util.gwt.xml new file mode 100644 index 00000000000..0a6e96c6463 --- /dev/null +++ b/Util/src/main/resources/io/deephaven/Util.gwt.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/buildSrc/src/main/groovy/GwtTools.groovy b/buildSrc/src/main/groovy/GwtTools.groovy index 23b5711d005..148eacfa0d4 100644 --- a/buildSrc/src/main/groovy/GwtTools.groovy +++ b/buildSrc/src/main/groovy/GwtTools.groovy @@ -63,6 +63,7 @@ class GwtTools { generateJsInteropExports = true // TODO move this down a line when we want to give clients js that is not super strict / rigged to blow checkAssertions = true + setExtraArgs('-includeJsInteropExports', 'io.deephaven.*') if (gwtDev) { saveSource = true extra = extras diff --git a/engine/chunk/src/main/resources/io/deephaven/chunk/Chunk.gwt.xml b/engine/chunk/src/main/resources/io/deephaven/chunk/Chunk.gwt.xml new file mode 100644 index 00000000000..1f53956d9ae --- /dev/null +++ b/engine/chunk/src/main/resources/io/deephaven/chunk/Chunk.gwt.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/engine/primitive/src/main/resources/io/deephaven/engine/primitive/function/Function.gwt.xml b/engine/primitive/src/main/resources/io/deephaven/engine/primitive/function/Function.gwt.xml new file mode 100644 index 00000000000..c78151ef021 --- /dev/null +++ b/engine/primitive/src/main/resources/io/deephaven/engine/primitive/function/Function.gwt.xml @@ -0,0 +1,3 @@ + + + diff --git a/extensions/barrage/src/main/resources/io/deephaven/extensions/barrage/Barrage.gwt.xml b/extensions/barrage/src/main/resources/io/deephaven/extensions/barrage/Barrage.gwt.xml new file mode 100644 index 00000000000..a29af5b6ca8 --- /dev/null +++ b/extensions/barrage/src/main/resources/io/deephaven/extensions/barrage/Barrage.gwt.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index b4fb36cbd85..e02cdb202c5 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -76,7 +76,8 @@ tdunning = "3.2" trove = "3.0.3" undercouch = "2.15.1" univocity = "2.6.0" -vertispan-nio = "1.0-alpha-1" +vertispan-nio = "1.0-alpha-2" +vertispan-flatbuffers-gwt = "1.12.0-1" vertispan-ts-defs = "1.0.0-RC4" # test versions @@ -287,6 +288,8 @@ univocity-parsers = { module = "com.univocity:univocity-parsers", version.ref = vertispan-nio-gwt = { module = "com.vertispan.nio:gwt-nio", version.ref = "vertispan-nio" } +vertispan-flatbuffers-gwt = { module = "com.vertispan.flatbuffers:flatbuffers-gwt", version.ref = "vertispan-flatbuffers-gwt" } + vertispan-ts-defs-annotations = { module = "com.vertispan.tsdefs:jsinterop-ts-defs-annotations", version.ref = "vertispan-ts-defs" } vertispan-ts-defs-doclet = { module = "com.vertispan.tsdefs:jsinterop-ts-defs-doclet", version.ref = "vertispan-ts-defs" } diff --git a/props/configs/src/main/resources/dh-defaults.prop b/props/configs/src/main/resources/dh-defaults.prop index 877a9f8d056..d3e0c6d2ede 100644 --- a/props/configs/src/main/resources/dh-defaults.prop +++ b/props/configs/src/main/resources/dh-defaults.prop @@ -57,12 +57,15 @@ web.storage.notebook.directory=/notebooks web.webgl=true web.webgl.editable=true +# Default to not flattening web viewports, but allow it as an option +web.flattenViewports=false + # List of configuration properties to provide to unauthenticated clients, so that they can decide how best to prove their # identity to the server. authentication.client.configuration.list=AuthHandlers # List of configuration properties to provide to authenticated clients, so they can interact with the server. -client.configuration.list=java.version,deephaven.version,barrage.version,groovy.version,python.version,http.session.durationMs,file.separator,web.storage.layout.directory,web.storage.notebook.directory,web.webgl,web.webgl.editable +client.configuration.list=java.version,deephaven.version,barrage.version,groovy.version,python.version,http.session.durationMs,file.separator,web.storage.layout.directory,web.storage.notebook.directory,web.webgl,web.webgl.editable,web.flattenViewports # Version list to add to the configuration property list. Each `=`-delimited pair denotes a short name for a versioned # jar, and a class that is found in that jar. Any such keys will be made available to the client.configuration.list diff --git a/proto/raw-js-openapi/flight_format/Message.fbs b/proto/raw-js-openapi/flight_format/Message.fbs deleted file mode 100644 index b93c9e991e9..00000000000 --- a/proto/raw-js-openapi/flight_format/Message.fbs +++ /dev/null @@ -1,138 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -include "Schema.fbs"; - -namespace org.apache.arrow.flatbuf; - -/// ---------------------------------------------------------------------- -/// Data structures for describing a table row batch (a collection of -/// equal-length Arrow arrays) - -/// Metadata about a field at some level of a nested type tree (but not -/// its children). -/// -/// For example, a List with values `[[1, 2, 3], null, [4], [5, 6], null]` -/// would have {length: 5, null_count: 2} for its List node, and {length: 6, -/// null_count: 0} for its Int16 node, as separate FieldNode structs -struct FieldNode { - /// The number of value slots in the Arrow array at this level of a nested - /// tree - length: long; - - /// The number of observed nulls. Fields with null_count == 0 may choose not - /// to write their physical validity bitmap out as a materialized buffer, - /// instead setting the length of the bitmap buffer to 0. - null_count: long; -} - -enum CompressionType:byte { - // LZ4 frame format, for portability, as provided by lz4frame.h or wrappers - // thereof. Not to be confused with "raw" (also called "block") format - // provided by lz4.h - LZ4_FRAME, - - // Zstandard - ZSTD -} - -/// Provided for forward compatibility in case we need to support different -/// strategies for compressing the IPC message body (like whole-body -/// compression rather than buffer-level) in the future -enum BodyCompressionMethod:byte { - /// Each constituent buffer is first compressed with the indicated - /// compressor, and then written with the uncompressed length in the first 8 - /// bytes as a 64-bit little-endian signed integer followed by the compressed - /// buffer bytes (and then padding as required by the protocol). The - /// uncompressed length may be set to -1 to indicate that the data that - /// follows is not compressed, which can be useful for cases where - /// compression does not yield appreciable savings. - BUFFER -} - -/// Optional compression for the memory buffers constituting IPC message -/// bodies. Intended for use with RecordBatch but could be used for other -/// message types -table BodyCompression { - /// Compressor library - codec: CompressionType = LZ4_FRAME; - - /// Indicates the way the record batch body was compressed - method: BodyCompressionMethod = BUFFER; -} - -/// A data header describing the shared memory layout of a "record" or "row" -/// batch. Some systems call this a "row batch" internally and others a "record -/// batch". -table RecordBatch { - /// number of records / rows. The arrays in the batch should all have this - /// length - length: long; - - /// Nodes correspond to the pre-ordered flattened logical schema - nodes: [FieldNode]; - - /// Buffers correspond to the pre-ordered flattened buffer tree - /// - /// The number of buffers appended to this list depends on the schema. For - /// example, most primitive arrays will have 2 buffers, 1 for the validity - /// bitmap and 1 for the values. For struct arrays, there will only be a - /// single buffer for the validity (nulls) bitmap - buffers: [Buffer]; - - /// Optional compression of the message body - compression: BodyCompression; -} - -/// For sending dictionary encoding information. Any Field can be -/// dictionary-encoded, but in this case none of its children may be -/// dictionary-encoded. -/// There is one vector / column per dictionary, but that vector / column -/// may be spread across multiple dictionary batches by using the isDelta -/// flag - -table DictionaryBatch { - id: long; - data: RecordBatch; - - /// If isDelta is true the values in the dictionary are to be appended to a - /// dictionary with the indicated id. If isDelta is false this dictionary - /// should replace the existing dictionary. - isDelta: bool = false; -} - -/// ---------------------------------------------------------------------- -/// The root Message type - -/// This union enables us to easily send different message types without -/// redundant storage, and in the future we can easily add new message types. -/// -/// Arrow implementations do not need to implement all of the message types, -/// which may include experimental metadata types. For maximum compatibility, -/// it is best to send data using RecordBatch -union MessageHeader { - Schema, DictionaryBatch, RecordBatch -} - -table Message { - version: org.apache.arrow.flatbuf.MetadataVersion; - header: MessageHeader; - bodyLength: long; - custom_metadata: [ KeyValue ]; -} - -root_type Message; diff --git a/proto/raw-js-openapi/flight_format/README.md b/proto/raw-js-openapi/flight_format/README.md deleted file mode 100644 index 52d45ad2b7e..00000000000 --- a/proto/raw-js-openapi/flight_format/README.md +++ /dev/null @@ -1,3 +0,0 @@ -Currently we are generating flatbuffer files manually. See [deephaven-core/#1052](https://github.com/deephaven/deephaven-core/issues/1052) to track the work to automate this. - -${FLATC} --ts --no-fb-import --no-ts-reexport -o src/arrow/flight/flatbuf/ flight_format/\*.fbs diff --git a/proto/raw-js-openapi/flight_format/Schema.fbs b/proto/raw-js-openapi/flight_format/Schema.fbs deleted file mode 100644 index 2d447d30791..00000000000 --- a/proto/raw-js-openapi/flight_format/Schema.fbs +++ /dev/null @@ -1,430 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -/// Logical types, vector layouts, and schemas - -namespace org.apache.arrow.flatbuf; - -enum MetadataVersion:short { - /// 0.1.0 (October 2016). - V1, - - /// 0.2.0 (February 2017). Non-backwards compatible with V1. - V2, - - /// 0.3.0 -> 0.7.1 (May - December 2017). Non-backwards compatible with V2. - V3, - - /// >= 0.8.0 (December 2017). Non-backwards compatible with V3. - V4, - - /// >= 1.0.0 (July 2020. Backwards compatible with V4 (V5 readers can read V4 - /// metadata and IPC messages). Implementations are recommended to provide a - /// V4 compatibility mode with V5 format changes disabled. - /// - /// Incompatible changes between V4 and V5: - /// - Union buffer layout has changed. In V5, Unions don't have a validity - /// bitmap buffer. - V5, -} - -/// Represents Arrow Features that might not have full support -/// within implementations. This is intended to be used in -/// two scenarios: -/// 1. A mechanism for readers of Arrow Streams -/// and files to understand that the stream or file makes -/// use of a feature that isn't supported or unknown to -/// the implementation (and therefore can meet the Arrow -/// forward compatibility guarantees). -/// 2. A means of negotiating between a client and server -/// what features a stream is allowed to use. The enums -/// values here are intented to represent higher level -/// features, additional details maybe negotiated -/// with key-value pairs specific to the protocol. -/// -/// Enums added to this list should be assigned power-of-two values -/// to facilitate exchanging and comparing bitmaps for supported -/// features. -enum Feature : long { - /// Needed to make flatbuffers happy. - UNUSED = 0, - /// The stream makes use of multiple full dictionaries with the - /// same ID and assumes clients implement dictionary replacement - /// correctly. - DICTIONARY_REPLACEMENT = 1, - /// The stream makes use of compressed bodies as described - /// in Message.fbs. - COMPRESSED_BODY = 2 -} - -/// These are stored in the flatbuffer in the Type union below - -table Null { -} - -/// A Struct_ in the flatbuffer metadata is the same as an Arrow Struct -/// (according to the physical memory layout). We used Struct_ here as -/// Struct is a reserved word in Flatbuffers -table Struct_ { -} - -table List { -} - -/// Same as List, but with 64-bit offsets, allowing to represent -/// extremely large data values. -table LargeList { -} - -table FixedSizeList { - /// Number of list items per value - listSize: int; -} - -/// A Map is a logical nested type that is represented as -/// -/// List> -/// -/// In this layout, the keys and values are each respectively contiguous. We do -/// not constrain the key and value types, so the application is responsible -/// for ensuring that the keys are hashable and unique. Whether the keys are sorted -/// may be set in the metadata for this field. -/// -/// In a field with Map type, the field has a child Struct field, which then -/// has two children: key type and the second the value type. The names of the -/// child fields may be respectively "entries", "key", and "value", but this is -/// not enforced. -/// -/// Map -/// ```text -/// - child[0] entries: Struct -/// - child[0] key: K -/// - child[1] value: V -/// ``` -/// Neither the "entries" field nor the "key" field may be nullable. -/// -/// The metadata is structured so that Arrow systems without special handling -/// for Map can make Map an alias for List. The "layout" attribute for the Map -/// field must have the same contents as a List. -table Map { - /// Set to true if the keys within each value are sorted - keysSorted: bool; -} - -enum UnionMode:short { Sparse, Dense } - -/// A union is a complex type with children in Field -/// By default ids in the type vector refer to the offsets in the children -/// optionally typeIds provides an indirection between the child offset and the type id -/// for each child `typeIds[offset]` is the id used in the type vector -table Union { - mode: UnionMode; - typeIds: [ int ]; // optional, describes typeid of each child. -} - -table Int { - bitWidth: int; // restricted to 8, 16, 32, and 64 in v1 - is_signed: bool; -} - -enum Precision:short {HALF, SINGLE, DOUBLE} - -table FloatingPoint { - precision: Precision; -} - -/// Unicode with UTF-8 encoding -table Utf8 { -} - -/// Opaque binary data -table Binary { -} - -/// Same as Utf8, but with 64-bit offsets, allowing to represent -/// extremely large data values. -table LargeUtf8 { -} - -/// Same as Binary, but with 64-bit offsets, allowing to represent -/// extremely large data values. -table LargeBinary { -} - -table FixedSizeBinary { - /// Number of bytes per value - byteWidth: int; -} - -table Bool { -} - -/// Exact decimal value represented as an integer value in two's -/// complement. Currently only 128-bit (16-byte) and 256-bit (32-byte) integers -/// are used. The representation uses the endianness indicated -/// in the Schema. -table Decimal { - /// Total number of decimal digits - precision: int; - - /// Number of digits after the decimal point "." - scale: int; - - /// Number of bits per value. The only accepted widths are 128 and 256. - /// We use bitWidth for consistency with Int::bitWidth. - bitWidth: int = 128; -} - -enum DateUnit: short { - DAY, - MILLISECOND -} - -/// Date is either a 32-bit or 64-bit type representing elapsed time since UNIX -/// epoch (1970-01-01), stored in either of two units: -/// -/// * Milliseconds (64 bits) indicating UNIX time elapsed since the epoch (no -/// leap seconds), where the values are evenly divisible by 86400000 -/// * Days (32 bits) since the UNIX epoch -table Date { - unit: DateUnit = MILLISECOND; -} - -enum TimeUnit: short { SECOND, MILLISECOND, MICROSECOND, NANOSECOND } - -/// Time type. The physical storage type depends on the unit -/// - SECOND and MILLISECOND: 32 bits -/// - MICROSECOND and NANOSECOND: 64 bits -table Time { - unit: TimeUnit = MILLISECOND; - bitWidth: int = 32; -} - -/// Time elapsed from the Unix epoch, 00:00:00.000 on 1 January 1970, excluding -/// leap seconds, as a 64-bit integer. Note that UNIX time does not include -/// leap seconds. -/// -/// Date & time libraries often have multiple different data types for temporal -/// data. In order to ease interoperability between different implementations the -/// Arrow project has some recommendations for encoding these types into a Timestamp -/// column. -/// -/// An "instant" represents a single moment in time that has no meaningful time zone -/// or the time zone is unknown. A column of instants can also contain values from -/// multiple time zones. To encode an instant set the timezone string to "UTC". -/// -/// A "zoned date-time" represents a single moment in time that has a meaningful -/// reference time zone. To encode a zoned date-time as a Timestamp set the timezone -/// string to the name of the timezone. There is some ambiguity between an instant -/// and a zoned date-time with the UTC time zone. Both of these are stored the same. -/// Typically, this distinction does not matter. If it does, then an application should -/// use custom metadata or an extension type to distinguish between the two cases. -/// -/// An "offset date-time" represents a single moment in time combined with a meaningful -/// offset from UTC. To encode an offset date-time as a Timestamp set the timezone string -/// to the numeric time zone offset string (e.g. "+03:00"). -/// -/// A "local date-time" does not represent a single moment in time. It represents a wall -/// clock time combined with a date. Because of daylight savings time there may multiple -/// instants that correspond to a single local date-time in any given time zone. A -/// local date-time is often stored as a struct or a Date32/Time64 pair. However, it can -/// also be encoded into a Timestamp column. To do so the value should be the the time -/// elapsed from the Unix epoch so that a wall clock in UTC would display the desired time. -/// The timezone string should be set to null or the empty string. -table Timestamp { - unit: TimeUnit; - - /// The time zone is a string indicating the name of a time zone, one of: - /// - /// * As used in the Olson time zone database (the "tz database" or - /// "tzdata"), such as "America/New_York" - /// * An absolute time zone offset of the form +XX:XX or -XX:XX, such as +07:30 - /// - /// Whether a timezone string is present indicates different semantics about - /// the data: - /// - /// * If the time zone is null or an empty string, the data is a local date-time - /// and does not represent a single moment in time. Instead it represents a wall clock - /// time and care should be taken to avoid interpreting it semantically as an instant. - /// - /// * If the time zone is set to a valid value, values can be displayed as - /// "localized" to that time zone, even though the underlying 64-bit - /// integers are identical to the same data stored in UTC. Converting - /// between time zones is a metadata-only operation and does not change the - /// underlying values - timezone: string; -} - -enum IntervalUnit: short { YEAR_MONTH, DAY_TIME} -// A "calendar" interval which models types that don't necessarily -// have a precise duration without the context of a base timestamp (e.g. -// days can differ in length during day light savings time transitions). -// YEAR_MONTH - Indicates the number of elapsed whole months, stored as -// 4-byte integers. -// DAY_TIME - Indicates the number of elapsed days and milliseconds, -// stored as 2 contiguous 32-bit integers (8-bytes in total). Support -// of this IntervalUnit is not required for full arrow compatibility. -table Interval { - unit: IntervalUnit; -} - -// An absolute length of time unrelated to any calendar artifacts. -// -// For the purposes of Arrow Implementations, adding this value to a Timestamp -// ("t1") naively (i.e. simply summing the two number) is acceptable even -// though in some cases the resulting Timestamp (t2) would not account for -// leap-seconds during the elapsed time between "t1" and "t2". Similarly, -// representing the difference between two Unix timestamp is acceptable, but -// would yield a value that is possibly a few seconds off from the true elapsed -// time. -// -// The resolution defaults to millisecond, but can be any of the other -// supported TimeUnit values as with Timestamp and Time types. This type is -// always represented as an 8-byte integer. -table Duration { - unit: TimeUnit = MILLISECOND; -} - -/// ---------------------------------------------------------------------- -/// Top-level Type value, enabling extensible type-specific metadata. We can -/// add new logical types to Type without breaking backwards compatibility - -union Type { - Null, - Int, - FloatingPoint, - Binary, - Utf8, - Bool, - Decimal, - Date, - Time, - Timestamp, - Interval, - List, - Struct_, - Union, - FixedSizeBinary, - FixedSizeList, - Map, - Duration, - LargeBinary, - LargeUtf8, - LargeList, -} - -/// ---------------------------------------------------------------------- -/// user defined key value pairs to add custom metadata to arrow -/// key namespacing is the responsibility of the user - -table KeyValue { - key: string; - value: string; -} - -/// ---------------------------------------------------------------------- -/// Dictionary encoding metadata -/// Maintained for forwards compatibility, in the future -/// Dictionaries might be explicit maps between integers and values -/// allowing for non-contiguous index values -enum DictionaryKind : short { DenseArray } -table DictionaryEncoding { - /// The known dictionary id in the application where this data is used. In - /// the file or streaming formats, the dictionary ids are found in the - /// DictionaryBatch messages - id: long; - - /// The dictionary indices are constrained to be non-negative integers. If - /// this field is null, the indices must be signed int32. To maximize - /// cross-language compatibility and performance, implementations are - /// recommended to prefer signed integer types over unsigned integer types - /// and to avoid uint64 indices unless they are required by an application. - indexType: Int; - - /// By default, dictionaries are not ordered, or the order does not have - /// semantic meaning. In some statistical, applications, dictionary-encoding - /// is used to represent ordered categorical data, and we provide a way to - /// preserve that metadata here - isOrdered: bool; - - dictionaryKind: DictionaryKind; -} - -/// ---------------------------------------------------------------------- -/// A field represents a named column in a record / row batch or child of a -/// nested type. - -table Field { - /// Name is not required, in i.e. a List - name: string; - - /// Whether or not this field can contain nulls. Should be true in general. - nullable: bool; - - /// This is the type of the decoded value if the field is dictionary encoded. - type: Type; - - /// Present only if the field is dictionary encoded. - dictionary: DictionaryEncoding; - - /// children apply only to nested data types like Struct, List and Union. For - /// primitive types children will have length 0. - children: [ Field ]; - - /// User-defined metadata - custom_metadata: [ KeyValue ]; -} - -/// ---------------------------------------------------------------------- -/// Endianness of the platform producing the data - -enum Endianness:short { Little, Big } - -/// ---------------------------------------------------------------------- -/// A Buffer represents a single contiguous memory segment -struct Buffer { - /// The relative offset into the shared memory page where the bytes for this - /// buffer starts - offset: long; - - /// The absolute length (in bytes) of the memory buffer. The memory is found - /// from offset (inclusive) to offset + length (non-inclusive). When building - /// messages using the encapsulated IPC message, padding bytes may be written - /// after a buffer, but such padding bytes do not need to be accounted for in - /// the size here. - length: long; -} - -/// ---------------------------------------------------------------------- -/// A Schema describes the columns in a row batch - -table Schema { - - /// endianness of the buffer - /// it is Little Endian by default - /// if endianness doesn't match the underlying system then the vectors need to be converted - endianness: Endianness=Little; - - fields: [Field]; - // User-defined metadata - custom_metadata: [ KeyValue ]; - - /// Features used in the stream/file. - features : [ Feature ]; -} - -root_type Schema; diff --git a/proto/raw-js-openapi/package.json b/proto/raw-js-openapi/package.json index 455c3d67837..fdb83f4ec86 100644 --- a/proto/raw-js-openapi/package.json +++ b/proto/raw-js-openapi/package.json @@ -1,9 +1,6 @@ { "dependencies": { - "@deephaven/barrage": "0.5.0", "@improbable-eng/grpc-web": "^0.14.0", - "apache-arrow": "7.0.0", - "flatbuffers": "1.12.0", "google-protobuf": "^3.20.1" }, "devDependencies": { diff --git a/proto/raw-js-openapi/src/arrow/flight/flatbuf/Message_generated.ts b/proto/raw-js-openapi/src/arrow/flight/flatbuf/Message_generated.ts deleted file mode 100644 index 8d86b6aa04f..00000000000 --- a/proto/raw-js-openapi/src/arrow/flight/flatbuf/Message_generated.ts +++ /dev/null @@ -1,741 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -import * as NS17716817176095924048 from "./Schema_generated"; -/** - * @enum {number} - */ -export namespace org.apache.arrow.flatbuf{ -export enum CompressionType{ - LZ4_FRAME= 0, - ZSTD= 1 -}; -} - -/** - * Provided for forward compatibility in case we need to support different - * strategies for compressing the IPC message body (like whole-body - * compression rather than buffer-level) in the future - * - * @enum {number} - */ -export namespace org.apache.arrow.flatbuf{ -export enum BodyCompressionMethod{ - /** - * Each constituent buffer is first compressed with the indicated - * compressor, and then written with the uncompressed length in the first 8 - * bytes as a 64-bit little-endian signed integer followed by the compressed - * buffer bytes (and then padding as required by the protocol). The - * uncompressed length may be set to -1 to indicate that the data that - * follows is not compressed, which can be useful for cases where - * compression does not yield appreciable savings. - */ - BUFFER= 0 -}; -} - -/** - * ---------------------------------------------------------------------- - * The root Message type - * This union enables us to easily send different message types without - * redundant storage, and in the future we can easily add new message types. - * - * Arrow implementations do not need to implement all of the message types, - * which may include experimental metadata types. For maximum compatibility, - * it is best to send data using RecordBatch - * - * @enum {number} - */ -export namespace org.apache.arrow.flatbuf{ -export enum MessageHeader{ - NONE= 0, - Schema= 1, - DictionaryBatch= 2, - RecordBatch= 3 -}; - -export function unionToMessageHeader( - type: MessageHeader, - accessor: (obj:NS17716817176095924048.org.apache.arrow.flatbuf.Schema|org.apache.arrow.flatbuf.DictionaryBatch|org.apache.arrow.flatbuf.RecordBatch) => NS17716817176095924048.org.apache.arrow.flatbuf.Schema|org.apache.arrow.flatbuf.DictionaryBatch|org.apache.arrow.flatbuf.RecordBatch|null -): NS17716817176095924048.org.apache.arrow.flatbuf.Schema|org.apache.arrow.flatbuf.DictionaryBatch|org.apache.arrow.flatbuf.RecordBatch|null { - switch(org.apache.arrow.flatbuf.MessageHeader[type]) { - case 'NONE': return null; - case 'Schema': return accessor(new NS17716817176095924048.org.apache.arrow.flatbuf.Schema())! as NS17716817176095924048.org.apache.arrow.flatbuf.Schema; - case 'DictionaryBatch': return accessor(new org.apache.arrow.flatbuf.DictionaryBatch())! as org.apache.arrow.flatbuf.DictionaryBatch; - case 'RecordBatch': return accessor(new org.apache.arrow.flatbuf.RecordBatch())! as org.apache.arrow.flatbuf.RecordBatch; - default: return null; - } -} - -export function unionListToMessageHeader( - type: MessageHeader, - accessor: (index: number, obj:NS17716817176095924048.org.apache.arrow.flatbuf.Schema|org.apache.arrow.flatbuf.DictionaryBatch|org.apache.arrow.flatbuf.RecordBatch) => NS17716817176095924048.org.apache.arrow.flatbuf.Schema|org.apache.arrow.flatbuf.DictionaryBatch|org.apache.arrow.flatbuf.RecordBatch|null, - index: number -): NS17716817176095924048.org.apache.arrow.flatbuf.Schema|org.apache.arrow.flatbuf.DictionaryBatch|org.apache.arrow.flatbuf.RecordBatch|null { - switch(org.apache.arrow.flatbuf.MessageHeader[type]) { - case 'NONE': return null; - case 'Schema': return accessor(index, new NS17716817176095924048.org.apache.arrow.flatbuf.Schema())! as NS17716817176095924048.org.apache.arrow.flatbuf.Schema; - case 'DictionaryBatch': return accessor(index, new org.apache.arrow.flatbuf.DictionaryBatch())! as org.apache.arrow.flatbuf.DictionaryBatch; - case 'RecordBatch': return accessor(index, new org.apache.arrow.flatbuf.RecordBatch())! as org.apache.arrow.flatbuf.RecordBatch; - default: return null; - } -} -} - -/** - * ---------------------------------------------------------------------- - * Data structures for describing a table row batch (a collection of - * equal-length Arrow arrays) - * Metadata about a field at some level of a nested type tree (but not - * its children). - * - * For example, a List with values `[[1, 2, 3], null, [4], [5, 6], null]` - * would have {length: 5, null_count: 2} for its List node, and {length: 6, - * null_count: 0} for its Int16 node, as separate FieldNode structs - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class FieldNode { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns FieldNode - */ -__init(i:number, bb:flatbuffers.ByteBuffer):FieldNode { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * The number of value slots in the Arrow array at this level of a nested - * tree - * - * @returns flatbuffers.Long - */ -length():flatbuffers.Long { - return this.bb!.readInt64(this.bb_pos); -}; - -/** - * The number of observed nulls. Fields with null_count == 0 may choose not - * to write their physical validity bitmap out as a materialized buffer, - * instead setting the length of the bitmap buffer to 0. - * - * @returns flatbuffers.Long - */ -nullCount():flatbuffers.Long { - return this.bb!.readInt64(this.bb_pos + 8); -}; - -/** - * @returns number - */ -static sizeOf():number { - return 16; -} - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Long length - * @param flatbuffers.Long null_count - * @returns flatbuffers.Offset - */ -static createFieldNode(builder:flatbuffers.Builder, length: flatbuffers.Long, null_count: flatbuffers.Long):flatbuffers.Offset { - builder.prep(8, 16); - builder.writeInt64(null_count); - builder.writeInt64(length); - return builder.offset(); -}; - -} -} -/** - * Optional compression for the memory buffers constituting IPC message - * bodies. Intended for use with RecordBatch but could be used for other - * message types - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class BodyCompression { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns BodyCompression - */ -__init(i:number, bb:flatbuffers.ByteBuffer):BodyCompression { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param BodyCompression= obj - * @returns BodyCompression - */ -static getRootAsBodyCompression(bb:flatbuffers.ByteBuffer, obj?:BodyCompression):BodyCompression { - return (obj || new BodyCompression()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param BodyCompression= obj - * @returns BodyCompression - */ -static getSizePrefixedRootAsBodyCompression(bb:flatbuffers.ByteBuffer, obj?:BodyCompression):BodyCompression { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new BodyCompression()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * Compressor library - * - * @returns org.apache.arrow.flatbuf.CompressionType - */ -codec():org.apache.arrow.flatbuf.CompressionType { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? /** */ (this.bb!.readInt8(this.bb_pos + offset)) : org.apache.arrow.flatbuf.CompressionType.LZ4_FRAME; -}; - -/** - * Indicates the way the record batch body was compressed - * - * @returns org.apache.arrow.flatbuf.BodyCompressionMethod - */ -method():org.apache.arrow.flatbuf.BodyCompressionMethod { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? /** */ (this.bb!.readInt8(this.bb_pos + offset)) : org.apache.arrow.flatbuf.BodyCompressionMethod.BUFFER; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startBodyCompression(builder:flatbuffers.Builder) { - builder.startObject(2); -}; - -/** - * @param flatbuffers.Builder builder - * @param org.apache.arrow.flatbuf.CompressionType codec - */ -static addCodec(builder:flatbuffers.Builder, codec:org.apache.arrow.flatbuf.CompressionType) { - builder.addFieldInt8(0, codec, org.apache.arrow.flatbuf.CompressionType.LZ4_FRAME); -}; - -/** - * @param flatbuffers.Builder builder - * @param org.apache.arrow.flatbuf.BodyCompressionMethod method - */ -static addMethod(builder:flatbuffers.Builder, method:org.apache.arrow.flatbuf.BodyCompressionMethod) { - builder.addFieldInt8(1, method, org.apache.arrow.flatbuf.BodyCompressionMethod.BUFFER); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endBodyCompression(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createBodyCompression(builder:flatbuffers.Builder, codec:org.apache.arrow.flatbuf.CompressionType, method:org.apache.arrow.flatbuf.BodyCompressionMethod):flatbuffers.Offset { - BodyCompression.startBodyCompression(builder); - BodyCompression.addCodec(builder, codec); - BodyCompression.addMethod(builder, method); - return BodyCompression.endBodyCompression(builder); -} -} -} -/** - * A data header describing the shared memory layout of a "record" or "row" - * batch. Some systems call this a "row batch" internally and others a "record - * batch". - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class RecordBatch { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns RecordBatch - */ -__init(i:number, bb:flatbuffers.ByteBuffer):RecordBatch { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param RecordBatch= obj - * @returns RecordBatch - */ -static getRootAsRecordBatch(bb:flatbuffers.ByteBuffer, obj?:RecordBatch):RecordBatch { - return (obj || new RecordBatch()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param RecordBatch= obj - * @returns RecordBatch - */ -static getSizePrefixedRootAsRecordBatch(bb:flatbuffers.ByteBuffer, obj?:RecordBatch):RecordBatch { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new RecordBatch()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * number of records / rows. The arrays in the batch should all have this - * length - * - * @returns flatbuffers.Long - */ -length():flatbuffers.Long { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0); -}; - -/** - * Nodes correspond to the pre-ordered flattened logical schema - * - * @param number index - * @param org.apache.arrow.flatbuf.FieldNode= obj - * @returns org.apache.arrow.flatbuf.FieldNode - */ -nodes(index: number, obj?:org.apache.arrow.flatbuf.FieldNode):org.apache.arrow.flatbuf.FieldNode|null { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? (obj || new org.apache.arrow.flatbuf.FieldNode()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 16, this.bb!) : null; -}; - -/** - * @returns number - */ -nodesLength():number { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * Buffers correspond to the pre-ordered flattened buffer tree - * - * The number of buffers appended to this list depends on the schema. For - * example, most primitive arrays will have 2 buffers, 1 for the validity - * bitmap and 1 for the values. For struct arrays, there will only be a - * single buffer for the validity (nulls) bitmap - * - * @param number index - * @param org.apache.arrow.flatbuf.Buffer= obj - * @returns org.apache.arrow.flatbuf.Buffer - */ -buffers(index: number, obj?:NS17716817176095924048.org.apache.arrow.flatbuf.Buffer):NS17716817176095924048.org.apache.arrow.flatbuf.Buffer|null { - var offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? (obj || new NS17716817176095924048.org.apache.arrow.flatbuf.Buffer()).__init(this.bb!.__vector(this.bb_pos + offset) + index * 16, this.bb!) : null; -}; - -/** - * @returns number - */ -buffersLength():number { - var offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * Optional compression of the message body - * - * @param org.apache.arrow.flatbuf.BodyCompression= obj - * @returns org.apache.arrow.flatbuf.BodyCompression|null - */ -compression(obj?:org.apache.arrow.flatbuf.BodyCompression):org.apache.arrow.flatbuf.BodyCompression|null { - var offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? (obj || new org.apache.arrow.flatbuf.BodyCompression()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startRecordBatch(builder:flatbuffers.Builder) { - builder.startObject(4); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Long length - */ -static addLength(builder:flatbuffers.Builder, length:flatbuffers.Long) { - builder.addFieldInt64(0, length, builder.createLong(0, 0)); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset nodesOffset - */ -static addNodes(builder:flatbuffers.Builder, nodesOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, nodesOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param number numElems - */ -static startNodesVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(16, numElems, 8); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset buffersOffset - */ -static addBuffers(builder:flatbuffers.Builder, buffersOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, buffersOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param number numElems - */ -static startBuffersVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(16, numElems, 8); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset compressionOffset - */ -static addCompression(builder:flatbuffers.Builder, compressionOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, compressionOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endRecordBatch(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -} -} -/** - * For sending dictionary encoding information. Any Field can be - * dictionary-encoded, but in this case none of its children may be - * dictionary-encoded. - * There is one vector / column per dictionary, but that vector / column - * may be spread across multiple dictionary batches by using the isDelta - * flag - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class DictionaryBatch { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns DictionaryBatch - */ -__init(i:number, bb:flatbuffers.ByteBuffer):DictionaryBatch { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param DictionaryBatch= obj - * @returns DictionaryBatch - */ -static getRootAsDictionaryBatch(bb:flatbuffers.ByteBuffer, obj?:DictionaryBatch):DictionaryBatch { - return (obj || new DictionaryBatch()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param DictionaryBatch= obj - * @returns DictionaryBatch - */ -static getSizePrefixedRootAsDictionaryBatch(bb:flatbuffers.ByteBuffer, obj?:DictionaryBatch):DictionaryBatch { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new DictionaryBatch()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns flatbuffers.Long - */ -id():flatbuffers.Long { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0); -}; - -/** - * @param org.apache.arrow.flatbuf.RecordBatch= obj - * @returns org.apache.arrow.flatbuf.RecordBatch|null - */ -data(obj?:org.apache.arrow.flatbuf.RecordBatch):org.apache.arrow.flatbuf.RecordBatch|null { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? (obj || new org.apache.arrow.flatbuf.RecordBatch()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -}; - -/** - * If isDelta is true the values in the dictionary are to be appended to a - * dictionary with the indicated id. If isDelta is false this dictionary - * should replace the existing dictionary. - * - * @returns boolean - */ -isDelta():boolean { - var offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startDictionaryBatch(builder:flatbuffers.Builder) { - builder.startObject(3); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Long id - */ -static addId(builder:flatbuffers.Builder, id:flatbuffers.Long) { - builder.addFieldInt64(0, id, builder.createLong(0, 0)); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset dataOffset - */ -static addData(builder:flatbuffers.Builder, dataOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, dataOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param boolean isDelta - */ -static addIsDelta(builder:flatbuffers.Builder, isDelta:boolean) { - builder.addFieldInt8(2, +isDelta, +false); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endDictionaryBatch(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -} -} -/** - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Message { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Message - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Message { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Message= obj - * @returns Message - */ -static getRootAsMessage(bb:flatbuffers.ByteBuffer, obj?:Message):Message { - return (obj || new Message()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Message= obj - * @returns Message - */ -static getSizePrefixedRootAsMessage(bb:flatbuffers.ByteBuffer, obj?:Message):Message { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Message()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns org.apache.arrow.flatbuf.MetadataVersion - */ -version():NS17716817176095924048.org.apache.arrow.flatbuf.MetadataVersion { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? /** */ (this.bb!.readInt16(this.bb_pos + offset)) : NS17716817176095924048.org.apache.arrow.flatbuf.MetadataVersion.V1; -}; - -/** - * @returns org.apache.arrow.flatbuf.MessageHeader - */ -headerType():org.apache.arrow.flatbuf.MessageHeader { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? /** */ (this.bb!.readUint8(this.bb_pos + offset)) : org.apache.arrow.flatbuf.MessageHeader.NONE; -}; - -/** - * @param flatbuffers.Table obj - * @returns ?flatbuffers.Table - */ -header(obj:T):T|null { - var offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; -}; - -/** - * @returns flatbuffers.Long - */ -bodyLength():flatbuffers.Long { - var offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0); -}; - -/** - * @param number index - * @param org.apache.arrow.flatbuf.KeyValue= obj - * @returns org.apache.arrow.flatbuf.KeyValue - */ -customMetadata(index: number, obj?:NS17716817176095924048.org.apache.arrow.flatbuf.KeyValue):NS17716817176095924048.org.apache.arrow.flatbuf.KeyValue|null { - var offset = this.bb!.__offset(this.bb_pos, 12); - return offset ? (obj || new NS17716817176095924048.org.apache.arrow.flatbuf.KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; -}; - -/** - * @returns number - */ -customMetadataLength():number { - var offset = this.bb!.__offset(this.bb_pos, 12); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startMessage(builder:flatbuffers.Builder) { - builder.startObject(5); -}; - -/** - * @param flatbuffers.Builder builder - * @param org.apache.arrow.flatbuf.MetadataVersion version - */ -static addVersion(builder:flatbuffers.Builder, version:NS17716817176095924048.org.apache.arrow.flatbuf.MetadataVersion) { - builder.addFieldInt16(0, version, NS17716817176095924048.org.apache.arrow.flatbuf.MetadataVersion.V1); -}; - -/** - * @param flatbuffers.Builder builder - * @param org.apache.arrow.flatbuf.MessageHeader headerType - */ -static addHeaderType(builder:flatbuffers.Builder, headerType:org.apache.arrow.flatbuf.MessageHeader) { - builder.addFieldInt8(1, headerType, org.apache.arrow.flatbuf.MessageHeader.NONE); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset headerOffset - */ -static addHeader(builder:flatbuffers.Builder, headerOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, headerOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Long bodyLength - */ -static addBodyLength(builder:flatbuffers.Builder, bodyLength:flatbuffers.Long) { - builder.addFieldInt64(3, bodyLength, builder.createLong(0, 0)); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset customMetadataOffset - */ -static addCustomMetadata(builder:flatbuffers.Builder, customMetadataOffset:flatbuffers.Offset) { - builder.addFieldOffset(4, customMetadataOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param Array. data - * @returns flatbuffers.Offset - */ -static createCustomMetadataVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param flatbuffers.Builder builder - * @param number numElems - */ -static startCustomMetadataVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endMessage(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset offset - */ -static finishMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset offset - */ -static finishSizePrefixedMessageBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset, undefined, true); -}; - -static createMessage(builder:flatbuffers.Builder, version:NS17716817176095924048.org.apache.arrow.flatbuf.MetadataVersion, headerType:org.apache.arrow.flatbuf.MessageHeader, headerOffset:flatbuffers.Offset, bodyLength:flatbuffers.Long, customMetadataOffset:flatbuffers.Offset):flatbuffers.Offset { - Message.startMessage(builder); - Message.addVersion(builder, version); - Message.addHeaderType(builder, headerType); - Message.addHeader(builder, headerOffset); - Message.addBodyLength(builder, bodyLength); - Message.addCustomMetadata(builder, customMetadataOffset); - return Message.endMessage(builder); -} -} -} diff --git a/proto/raw-js-openapi/src/arrow/flight/flatbuf/Schema_generated.ts b/proto/raw-js-openapi/src/arrow/flight/flatbuf/Schema_generated.ts deleted file mode 100644 index 1c485ed3b78..00000000000 --- a/proto/raw-js-openapi/src/arrow/flight/flatbuf/Schema_generated.ts +++ /dev/null @@ -1,2807 +0,0 @@ -// automatically generated by the FlatBuffers compiler, do not modify - -/** - * @enum {number} - */ -export namespace org.apache.arrow.flatbuf{ -export enum MetadataVersion{ - /** - * 0.1.0 (October 2016). - */ - V1= 0, - - /** - * 0.2.0 (February 2017). Non-backwards compatible with V1. - */ - V2= 1, - - /** - * 0.3.0 -> 0.7.1 (May - December 2017). Non-backwards compatible with V2. - */ - V3= 2, - - /** - * >= 0.8.0 (December 2017). Non-backwards compatible with V3. - */ - V4= 3, - - /** - * >= 1.0.0 (July 2020. Backwards compatible with V4 (V5 readers can read V4 - * metadata and IPC messages). Implementations are recommended to provide a - * V4 compatibility mode with V5 format changes disabled. - * - * Incompatible changes between V4 and V5: - * - Union buffer layout has changed. In V5, Unions don't have a validity - * bitmap buffer. - */ - V5= 4 -}; -} - -/** - * Represents Arrow Features that might not have full support - * within implementations. This is intended to be used in - * two scenarios: - * 1. A mechanism for readers of Arrow Streams - * and files to understand that the stream or file makes - * use of a feature that isn't supported or unknown to - * the implementation (and therefore can meet the Arrow - * forward compatibility guarantees). - * 2. A means of negotiating between a client and server - * what features a stream is allowed to use. The enums - * values here are intented to represent higher level - * features, additional details maybe negotiated - * with key-value pairs specific to the protocol. - * - * Enums added to this list should be assigned power-of-two values - * to facilitate exchanging and comparing bitmaps for supported - * features. - * - * @enum {number} - */ -export namespace org.apache.arrow.flatbuf{ -export enum Feature{ - /** - * Needed to make flatbuffers happy. - */ - UNUSED= 0, - - /** - * The stream makes use of multiple full dictionaries with the - * same ID and assumes clients implement dictionary replacement - * correctly. - */ - DICTIONARY_REPLACEMENT= 1, - - /** - * The stream makes use of compressed bodies as described - * in Message.fbs. - */ - COMPRESSED_BODY= 2 -}; -} - -/** - * @enum {number} - */ -export namespace org.apache.arrow.flatbuf{ -export enum UnionMode{ - Sparse= 0, - Dense= 1 -}; -} - -/** - * @enum {number} - */ -export namespace org.apache.arrow.flatbuf{ -export enum Precision{ - HALF= 0, - SINGLE= 1, - DOUBLE= 2 -}; -} - -/** - * @enum {number} - */ -export namespace org.apache.arrow.flatbuf{ -export enum DateUnit{ - DAY= 0, - MILLISECOND= 1 -}; -} - -/** - * @enum {number} - */ -export namespace org.apache.arrow.flatbuf{ -export enum TimeUnit{ - SECOND= 0, - MILLISECOND= 1, - MICROSECOND= 2, - NANOSECOND= 3 -}; -} - -/** - * @enum {number} - */ -export namespace org.apache.arrow.flatbuf{ -export enum IntervalUnit{ - YEAR_MONTH= 0, - DAY_TIME= 1 -}; -} - -/** - * ---------------------------------------------------------------------- - * Top-level Type value, enabling extensible type-specific metadata. We can - * add new logical types to Type without breaking backwards compatibility - * - * @enum {number} - */ -export namespace org.apache.arrow.flatbuf{ -export enum Type{ - NONE= 0, - Null= 1, - Int= 2, - FloatingPoint= 3, - Binary= 4, - Utf8= 5, - Bool= 6, - Decimal= 7, - Date= 8, - Time= 9, - Timestamp= 10, - Interval= 11, - List= 12, - Struct_= 13, - Union= 14, - FixedSizeBinary= 15, - FixedSizeList= 16, - Map= 17, - Duration= 18, - LargeBinary= 19, - LargeUtf8= 20, - LargeList= 21 -}; - -export function unionToType( - type: Type, - accessor: (obj:org.apache.arrow.flatbuf.Binary|org.apache.arrow.flatbuf.Bool|org.apache.arrow.flatbuf.Date|org.apache.arrow.flatbuf.Decimal|org.apache.arrow.flatbuf.Duration|org.apache.arrow.flatbuf.FixedSizeBinary|org.apache.arrow.flatbuf.FixedSizeList|org.apache.arrow.flatbuf.FloatingPoint|org.apache.arrow.flatbuf.Int|org.apache.arrow.flatbuf.Interval|org.apache.arrow.flatbuf.LargeBinary|org.apache.arrow.flatbuf.LargeList|org.apache.arrow.flatbuf.LargeUtf8|org.apache.arrow.flatbuf.List|org.apache.arrow.flatbuf.Map|org.apache.arrow.flatbuf.Null|org.apache.arrow.flatbuf.Struct_|org.apache.arrow.flatbuf.Time|org.apache.arrow.flatbuf.Timestamp|org.apache.arrow.flatbuf.Union|org.apache.arrow.flatbuf.Utf8) => org.apache.arrow.flatbuf.Binary|org.apache.arrow.flatbuf.Bool|org.apache.arrow.flatbuf.Date|org.apache.arrow.flatbuf.Decimal|org.apache.arrow.flatbuf.Duration|org.apache.arrow.flatbuf.FixedSizeBinary|org.apache.arrow.flatbuf.FixedSizeList|org.apache.arrow.flatbuf.FloatingPoint|org.apache.arrow.flatbuf.Int|org.apache.arrow.flatbuf.Interval|org.apache.arrow.flatbuf.LargeBinary|org.apache.arrow.flatbuf.LargeList|org.apache.arrow.flatbuf.LargeUtf8|org.apache.arrow.flatbuf.List|org.apache.arrow.flatbuf.Map|org.apache.arrow.flatbuf.Null|org.apache.arrow.flatbuf.Struct_|org.apache.arrow.flatbuf.Time|org.apache.arrow.flatbuf.Timestamp|org.apache.arrow.flatbuf.Union|org.apache.arrow.flatbuf.Utf8|null -): org.apache.arrow.flatbuf.Binary|org.apache.arrow.flatbuf.Bool|org.apache.arrow.flatbuf.Date|org.apache.arrow.flatbuf.Decimal|org.apache.arrow.flatbuf.Duration|org.apache.arrow.flatbuf.FixedSizeBinary|org.apache.arrow.flatbuf.FixedSizeList|org.apache.arrow.flatbuf.FloatingPoint|org.apache.arrow.flatbuf.Int|org.apache.arrow.flatbuf.Interval|org.apache.arrow.flatbuf.LargeBinary|org.apache.arrow.flatbuf.LargeList|org.apache.arrow.flatbuf.LargeUtf8|org.apache.arrow.flatbuf.List|org.apache.arrow.flatbuf.Map|org.apache.arrow.flatbuf.Null|org.apache.arrow.flatbuf.Struct_|org.apache.arrow.flatbuf.Time|org.apache.arrow.flatbuf.Timestamp|org.apache.arrow.flatbuf.Union|org.apache.arrow.flatbuf.Utf8|null { - switch(org.apache.arrow.flatbuf.Type[type]) { - case 'NONE': return null; - case 'Null': return accessor(new org.apache.arrow.flatbuf.Null())! as org.apache.arrow.flatbuf.Null; - case 'Int': return accessor(new org.apache.arrow.flatbuf.Int())! as org.apache.arrow.flatbuf.Int; - case 'FloatingPoint': return accessor(new org.apache.arrow.flatbuf.FloatingPoint())! as org.apache.arrow.flatbuf.FloatingPoint; - case 'Binary': return accessor(new org.apache.arrow.flatbuf.Binary())! as org.apache.arrow.flatbuf.Binary; - case 'Utf8': return accessor(new org.apache.arrow.flatbuf.Utf8())! as org.apache.arrow.flatbuf.Utf8; - case 'Bool': return accessor(new org.apache.arrow.flatbuf.Bool())! as org.apache.arrow.flatbuf.Bool; - case 'Decimal': return accessor(new org.apache.arrow.flatbuf.Decimal())! as org.apache.arrow.flatbuf.Decimal; - case 'Date': return accessor(new org.apache.arrow.flatbuf.Date())! as org.apache.arrow.flatbuf.Date; - case 'Time': return accessor(new org.apache.arrow.flatbuf.Time())! as org.apache.arrow.flatbuf.Time; - case 'Timestamp': return accessor(new org.apache.arrow.flatbuf.Timestamp())! as org.apache.arrow.flatbuf.Timestamp; - case 'Interval': return accessor(new org.apache.arrow.flatbuf.Interval())! as org.apache.arrow.flatbuf.Interval; - case 'List': return accessor(new org.apache.arrow.flatbuf.List())! as org.apache.arrow.flatbuf.List; - case 'Struct_': return accessor(new org.apache.arrow.flatbuf.Struct_())! as org.apache.arrow.flatbuf.Struct_; - case 'Union': return accessor(new org.apache.arrow.flatbuf.Union())! as org.apache.arrow.flatbuf.Union; - case 'FixedSizeBinary': return accessor(new org.apache.arrow.flatbuf.FixedSizeBinary())! as org.apache.arrow.flatbuf.FixedSizeBinary; - case 'FixedSizeList': return accessor(new org.apache.arrow.flatbuf.FixedSizeList())! as org.apache.arrow.flatbuf.FixedSizeList; - case 'Map': return accessor(new org.apache.arrow.flatbuf.Map())! as org.apache.arrow.flatbuf.Map; - case 'Duration': return accessor(new org.apache.arrow.flatbuf.Duration())! as org.apache.arrow.flatbuf.Duration; - case 'LargeBinary': return accessor(new org.apache.arrow.flatbuf.LargeBinary())! as org.apache.arrow.flatbuf.LargeBinary; - case 'LargeUtf8': return accessor(new org.apache.arrow.flatbuf.LargeUtf8())! as org.apache.arrow.flatbuf.LargeUtf8; - case 'LargeList': return accessor(new org.apache.arrow.flatbuf.LargeList())! as org.apache.arrow.flatbuf.LargeList; - default: return null; - } -} - -export function unionListToType( - type: Type, - accessor: (index: number, obj:org.apache.arrow.flatbuf.Binary|org.apache.arrow.flatbuf.Bool|org.apache.arrow.flatbuf.Date|org.apache.arrow.flatbuf.Decimal|org.apache.arrow.flatbuf.Duration|org.apache.arrow.flatbuf.FixedSizeBinary|org.apache.arrow.flatbuf.FixedSizeList|org.apache.arrow.flatbuf.FloatingPoint|org.apache.arrow.flatbuf.Int|org.apache.arrow.flatbuf.Interval|org.apache.arrow.flatbuf.LargeBinary|org.apache.arrow.flatbuf.LargeList|org.apache.arrow.flatbuf.LargeUtf8|org.apache.arrow.flatbuf.List|org.apache.arrow.flatbuf.Map|org.apache.arrow.flatbuf.Null|org.apache.arrow.flatbuf.Struct_|org.apache.arrow.flatbuf.Time|org.apache.arrow.flatbuf.Timestamp|org.apache.arrow.flatbuf.Union|org.apache.arrow.flatbuf.Utf8) => org.apache.arrow.flatbuf.Binary|org.apache.arrow.flatbuf.Bool|org.apache.arrow.flatbuf.Date|org.apache.arrow.flatbuf.Decimal|org.apache.arrow.flatbuf.Duration|org.apache.arrow.flatbuf.FixedSizeBinary|org.apache.arrow.flatbuf.FixedSizeList|org.apache.arrow.flatbuf.FloatingPoint|org.apache.arrow.flatbuf.Int|org.apache.arrow.flatbuf.Interval|org.apache.arrow.flatbuf.LargeBinary|org.apache.arrow.flatbuf.LargeList|org.apache.arrow.flatbuf.LargeUtf8|org.apache.arrow.flatbuf.List|org.apache.arrow.flatbuf.Map|org.apache.arrow.flatbuf.Null|org.apache.arrow.flatbuf.Struct_|org.apache.arrow.flatbuf.Time|org.apache.arrow.flatbuf.Timestamp|org.apache.arrow.flatbuf.Union|org.apache.arrow.flatbuf.Utf8|null, - index: number -): org.apache.arrow.flatbuf.Binary|org.apache.arrow.flatbuf.Bool|org.apache.arrow.flatbuf.Date|org.apache.arrow.flatbuf.Decimal|org.apache.arrow.flatbuf.Duration|org.apache.arrow.flatbuf.FixedSizeBinary|org.apache.arrow.flatbuf.FixedSizeList|org.apache.arrow.flatbuf.FloatingPoint|org.apache.arrow.flatbuf.Int|org.apache.arrow.flatbuf.Interval|org.apache.arrow.flatbuf.LargeBinary|org.apache.arrow.flatbuf.LargeList|org.apache.arrow.flatbuf.LargeUtf8|org.apache.arrow.flatbuf.List|org.apache.arrow.flatbuf.Map|org.apache.arrow.flatbuf.Null|org.apache.arrow.flatbuf.Struct_|org.apache.arrow.flatbuf.Time|org.apache.arrow.flatbuf.Timestamp|org.apache.arrow.flatbuf.Union|org.apache.arrow.flatbuf.Utf8|null { - switch(org.apache.arrow.flatbuf.Type[type]) { - case 'NONE': return null; - case 'Null': return accessor(index, new org.apache.arrow.flatbuf.Null())! as org.apache.arrow.flatbuf.Null; - case 'Int': return accessor(index, new org.apache.arrow.flatbuf.Int())! as org.apache.arrow.flatbuf.Int; - case 'FloatingPoint': return accessor(index, new org.apache.arrow.flatbuf.FloatingPoint())! as org.apache.arrow.flatbuf.FloatingPoint; - case 'Binary': return accessor(index, new org.apache.arrow.flatbuf.Binary())! as org.apache.arrow.flatbuf.Binary; - case 'Utf8': return accessor(index, new org.apache.arrow.flatbuf.Utf8())! as org.apache.arrow.flatbuf.Utf8; - case 'Bool': return accessor(index, new org.apache.arrow.flatbuf.Bool())! as org.apache.arrow.flatbuf.Bool; - case 'Decimal': return accessor(index, new org.apache.arrow.flatbuf.Decimal())! as org.apache.arrow.flatbuf.Decimal; - case 'Date': return accessor(index, new org.apache.arrow.flatbuf.Date())! as org.apache.arrow.flatbuf.Date; - case 'Time': return accessor(index, new org.apache.arrow.flatbuf.Time())! as org.apache.arrow.flatbuf.Time; - case 'Timestamp': return accessor(index, new org.apache.arrow.flatbuf.Timestamp())! as org.apache.arrow.flatbuf.Timestamp; - case 'Interval': return accessor(index, new org.apache.arrow.flatbuf.Interval())! as org.apache.arrow.flatbuf.Interval; - case 'List': return accessor(index, new org.apache.arrow.flatbuf.List())! as org.apache.arrow.flatbuf.List; - case 'Struct_': return accessor(index, new org.apache.arrow.flatbuf.Struct_())! as org.apache.arrow.flatbuf.Struct_; - case 'Union': return accessor(index, new org.apache.arrow.flatbuf.Union())! as org.apache.arrow.flatbuf.Union; - case 'FixedSizeBinary': return accessor(index, new org.apache.arrow.flatbuf.FixedSizeBinary())! as org.apache.arrow.flatbuf.FixedSizeBinary; - case 'FixedSizeList': return accessor(index, new org.apache.arrow.flatbuf.FixedSizeList())! as org.apache.arrow.flatbuf.FixedSizeList; - case 'Map': return accessor(index, new org.apache.arrow.flatbuf.Map())! as org.apache.arrow.flatbuf.Map; - case 'Duration': return accessor(index, new org.apache.arrow.flatbuf.Duration())! as org.apache.arrow.flatbuf.Duration; - case 'LargeBinary': return accessor(index, new org.apache.arrow.flatbuf.LargeBinary())! as org.apache.arrow.flatbuf.LargeBinary; - case 'LargeUtf8': return accessor(index, new org.apache.arrow.flatbuf.LargeUtf8())! as org.apache.arrow.flatbuf.LargeUtf8; - case 'LargeList': return accessor(index, new org.apache.arrow.flatbuf.LargeList())! as org.apache.arrow.flatbuf.LargeList; - default: return null; - } -} -} - -/** - * ---------------------------------------------------------------------- - * Dictionary encoding metadata - * Maintained for forwards compatibility, in the future - * Dictionaries might be explicit maps between integers and values - * allowing for non-contiguous index values - * - * @enum {number} - */ -export namespace org.apache.arrow.flatbuf{ -export enum DictionaryKind{ - DenseArray= 0 -}; -} - -/** - * ---------------------------------------------------------------------- - * Endianness of the platform producing the data - * - * @enum {number} - */ -export namespace org.apache.arrow.flatbuf{ -export enum Endianness{ - Little= 0, - Big= 1 -}; -} - -/** - * These are stored in the flatbuffer in the Type union below - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Null { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Null - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Null { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Null= obj - * @returns Null - */ -static getRootAsNull(bb:flatbuffers.ByteBuffer, obj?:Null):Null { - return (obj || new Null()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Null= obj - * @returns Null - */ -static getSizePrefixedRootAsNull(bb:flatbuffers.ByteBuffer, obj?:Null):Null { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Null()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.Builder builder - */ -static startNull(builder:flatbuffers.Builder) { - builder.startObject(0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endNull(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createNull(builder:flatbuffers.Builder):flatbuffers.Offset { - Null.startNull(builder); - return Null.endNull(builder); -} -} -} -/** - * A Struct_ in the flatbuffer metadata is the same as an Arrow Struct - * (according to the physical memory layout). We used Struct_ here as - * Struct is a reserved word in Flatbuffers - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Struct_ { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Struct_ - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Struct_ { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Struct_= obj - * @returns Struct_ - */ -static getRootAsStruct_(bb:flatbuffers.ByteBuffer, obj?:Struct_):Struct_ { - return (obj || new Struct_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Struct_= obj - * @returns Struct_ - */ -static getSizePrefixedRootAsStruct_(bb:flatbuffers.ByteBuffer, obj?:Struct_):Struct_ { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Struct_()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.Builder builder - */ -static startStruct_(builder:flatbuffers.Builder) { - builder.startObject(0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endStruct_(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createStruct_(builder:flatbuffers.Builder):flatbuffers.Offset { - Struct_.startStruct_(builder); - return Struct_.endStruct_(builder); -} -} -} -/** - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class List { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns List - */ -__init(i:number, bb:flatbuffers.ByteBuffer):List { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param List= obj - * @returns List - */ -static getRootAsList(bb:flatbuffers.ByteBuffer, obj?:List):List { - return (obj || new List()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param List= obj - * @returns List - */ -static getSizePrefixedRootAsList(bb:flatbuffers.ByteBuffer, obj?:List):List { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new List()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.Builder builder - */ -static startList(builder:flatbuffers.Builder) { - builder.startObject(0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endList(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createList(builder:flatbuffers.Builder):flatbuffers.Offset { - List.startList(builder); - return List.endList(builder); -} -} -} -/** - * Same as List, but with 64-bit offsets, allowing to represent - * extremely large data values. - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class LargeList { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns LargeList - */ -__init(i:number, bb:flatbuffers.ByteBuffer):LargeList { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param LargeList= obj - * @returns LargeList - */ -static getRootAsLargeList(bb:flatbuffers.ByteBuffer, obj?:LargeList):LargeList { - return (obj || new LargeList()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param LargeList= obj - * @returns LargeList - */ -static getSizePrefixedRootAsLargeList(bb:flatbuffers.ByteBuffer, obj?:LargeList):LargeList { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new LargeList()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.Builder builder - */ -static startLargeList(builder:flatbuffers.Builder) { - builder.startObject(0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endLargeList(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createLargeList(builder:flatbuffers.Builder):flatbuffers.Offset { - LargeList.startLargeList(builder); - return LargeList.endLargeList(builder); -} -} -} -/** - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class FixedSizeList { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns FixedSizeList - */ -__init(i:number, bb:flatbuffers.ByteBuffer):FixedSizeList { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param FixedSizeList= obj - * @returns FixedSizeList - */ -static getRootAsFixedSizeList(bb:flatbuffers.ByteBuffer, obj?:FixedSizeList):FixedSizeList { - return (obj || new FixedSizeList()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param FixedSizeList= obj - * @returns FixedSizeList - */ -static getSizePrefixedRootAsFixedSizeList(bb:flatbuffers.ByteBuffer, obj?:FixedSizeList):FixedSizeList { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new FixedSizeList()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * Number of list items per value - * - * @returns number - */ -listSize():number { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startFixedSizeList(builder:flatbuffers.Builder) { - builder.startObject(1); -}; - -/** - * @param flatbuffers.Builder builder - * @param number listSize - */ -static addListSize(builder:flatbuffers.Builder, listSize:number) { - builder.addFieldInt32(0, listSize, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endFixedSizeList(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createFixedSizeList(builder:flatbuffers.Builder, listSize:number):flatbuffers.Offset { - FixedSizeList.startFixedSizeList(builder); - FixedSizeList.addListSize(builder, listSize); - return FixedSizeList.endFixedSizeList(builder); -} -} -} -/** - * A Map is a logical nested type that is represented as - * - * List> - * - * In this layout, the keys and values are each respectively contiguous. We do - * not constrain the key and value types, so the application is responsible - * for ensuring that the keys are hashable and unique. Whether the keys are sorted - * may be set in the metadata for this field. - * - * In a field with Map type, the field has a child Struct field, which then - * has two children: key type and the second the value type. The names of the - * child fields may be respectively "entries", "key", and "value", but this is - * not enforced. - * - * Map - * ```text - * - child[0] entries: Struct - * - child[0] key: K - * - child[1] value: V - * ``` - * Neither the "entries" field nor the "key" field may be nullable. - * - * The metadata is structured so that Arrow systems without special handling - * for Map can make Map an alias for List. The "layout" attribute for the Map - * field must have the same contents as a List. - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Map { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Map - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Map { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Map= obj - * @returns Map - */ -static getRootAsMap(bb:flatbuffers.ByteBuffer, obj?:Map):Map { - return (obj || new Map()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Map= obj - * @returns Map - */ -static getSizePrefixedRootAsMap(bb:flatbuffers.ByteBuffer, obj?:Map):Map { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Map()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * Set to true if the keys within each value are sorted - * - * @returns boolean - */ -keysSorted():boolean { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startMap(builder:flatbuffers.Builder) { - builder.startObject(1); -}; - -/** - * @param flatbuffers.Builder builder - * @param boolean keysSorted - */ -static addKeysSorted(builder:flatbuffers.Builder, keysSorted:boolean) { - builder.addFieldInt8(0, +keysSorted, +false); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endMap(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createMap(builder:flatbuffers.Builder, keysSorted:boolean):flatbuffers.Offset { - Map.startMap(builder); - Map.addKeysSorted(builder, keysSorted); - return Map.endMap(builder); -} -} -} -/** - * A union is a complex type with children in Field - * By default ids in the type vector refer to the offsets in the children - * optionally typeIds provides an indirection between the child offset and the type id - * for each child `typeIds[offset]` is the id used in the type vector - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Union { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Union - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Union { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Union= obj - * @returns Union - */ -static getRootAsUnion(bb:flatbuffers.ByteBuffer, obj?:Union):Union { - return (obj || new Union()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Union= obj - * @returns Union - */ -static getSizePrefixedRootAsUnion(bb:flatbuffers.ByteBuffer, obj?:Union):Union { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Union()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns org.apache.arrow.flatbuf.UnionMode - */ -mode():org.apache.arrow.flatbuf.UnionMode { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? /** */ (this.bb!.readInt16(this.bb_pos + offset)) : org.apache.arrow.flatbuf.UnionMode.Sparse; -}; - -/** - * @param number index - * @returns number - */ -typeIds(index: number):number|null { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.readInt32(this.bb!.__vector(this.bb_pos + offset) + index * 4) : 0; -}; - -/** - * @returns number - */ -typeIdsLength():number { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @returns Int32Array - */ -typeIdsArray():Int32Array|null { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? new Int32Array(this.bb!.bytes().buffer, this.bb!.bytes().byteOffset + this.bb!.__vector(this.bb_pos + offset), this.bb!.__vector_len(this.bb_pos + offset)) : null; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startUnion(builder:flatbuffers.Builder) { - builder.startObject(2); -}; - -/** - * @param flatbuffers.Builder builder - * @param org.apache.arrow.flatbuf.UnionMode mode - */ -static addMode(builder:flatbuffers.Builder, mode:org.apache.arrow.flatbuf.UnionMode) { - builder.addFieldInt16(0, mode, org.apache.arrow.flatbuf.UnionMode.Sparse); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset typeIdsOffset - */ -static addTypeIds(builder:flatbuffers.Builder, typeIdsOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, typeIdsOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param Array. data - * @returns flatbuffers.Offset - */ -static createTypeIdsVector(builder:flatbuffers.Builder, data:number[]|Int32Array):flatbuffers.Offset; -/** - * @deprecated This Uint8Array overload will be removed in the future. - */ -static createTypeIdsVector(builder:flatbuffers.Builder, data:number[]|Uint8Array):flatbuffers.Offset; -static createTypeIdsVector(builder:flatbuffers.Builder, data:number[]|Int32Array|Uint8Array):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt32(data[i]); - } - return builder.endVector(); -}; - -/** - * @param flatbuffers.Builder builder - * @param number numElems - */ -static startTypeIdsVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endUnion(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createUnion(builder:flatbuffers.Builder, mode:org.apache.arrow.flatbuf.UnionMode, typeIdsOffset:flatbuffers.Offset):flatbuffers.Offset { - Union.startUnion(builder); - Union.addMode(builder, mode); - Union.addTypeIds(builder, typeIdsOffset); - return Union.endUnion(builder); -} -} -} -/** - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Int { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Int - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Int { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Int= obj - * @returns Int - */ -static getRootAsInt(bb:flatbuffers.ByteBuffer, obj?:Int):Int { - return (obj || new Int()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Int= obj - * @returns Int - */ -static getSizePrefixedRootAsInt(bb:flatbuffers.ByteBuffer, obj?:Int):Int { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Int()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns number - */ -bitWidth():number { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * @returns boolean - */ -isSigned():boolean { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startInt(builder:flatbuffers.Builder) { - builder.startObject(2); -}; - -/** - * @param flatbuffers.Builder builder - * @param number bitWidth - */ -static addBitWidth(builder:flatbuffers.Builder, bitWidth:number) { - builder.addFieldInt32(0, bitWidth, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param boolean isSigned - */ -static addIsSigned(builder:flatbuffers.Builder, isSigned:boolean) { - builder.addFieldInt8(1, +isSigned, +false); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endInt(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createInt(builder:flatbuffers.Builder, bitWidth:number, isSigned:boolean):flatbuffers.Offset { - Int.startInt(builder); - Int.addBitWidth(builder, bitWidth); - Int.addIsSigned(builder, isSigned); - return Int.endInt(builder); -} -} -} -/** - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class FloatingPoint { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns FloatingPoint - */ -__init(i:number, bb:flatbuffers.ByteBuffer):FloatingPoint { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param FloatingPoint= obj - * @returns FloatingPoint - */ -static getRootAsFloatingPoint(bb:flatbuffers.ByteBuffer, obj?:FloatingPoint):FloatingPoint { - return (obj || new FloatingPoint()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param FloatingPoint= obj - * @returns FloatingPoint - */ -static getSizePrefixedRootAsFloatingPoint(bb:flatbuffers.ByteBuffer, obj?:FloatingPoint):FloatingPoint { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new FloatingPoint()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns org.apache.arrow.flatbuf.Precision - */ -precision():org.apache.arrow.flatbuf.Precision { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? /** */ (this.bb!.readInt16(this.bb_pos + offset)) : org.apache.arrow.flatbuf.Precision.HALF; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startFloatingPoint(builder:flatbuffers.Builder) { - builder.startObject(1); -}; - -/** - * @param flatbuffers.Builder builder - * @param org.apache.arrow.flatbuf.Precision precision - */ -static addPrecision(builder:flatbuffers.Builder, precision:org.apache.arrow.flatbuf.Precision) { - builder.addFieldInt16(0, precision, org.apache.arrow.flatbuf.Precision.HALF); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endFloatingPoint(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createFloatingPoint(builder:flatbuffers.Builder, precision:org.apache.arrow.flatbuf.Precision):flatbuffers.Offset { - FloatingPoint.startFloatingPoint(builder); - FloatingPoint.addPrecision(builder, precision); - return FloatingPoint.endFloatingPoint(builder); -} -} -} -/** - * Unicode with UTF-8 encoding - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Utf8 { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Utf8 - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Utf8 { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Utf8= obj - * @returns Utf8 - */ -static getRootAsUtf8(bb:flatbuffers.ByteBuffer, obj?:Utf8):Utf8 { - return (obj || new Utf8()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Utf8= obj - * @returns Utf8 - */ -static getSizePrefixedRootAsUtf8(bb:flatbuffers.ByteBuffer, obj?:Utf8):Utf8 { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Utf8()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.Builder builder - */ -static startUtf8(builder:flatbuffers.Builder) { - builder.startObject(0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endUtf8(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createUtf8(builder:flatbuffers.Builder):flatbuffers.Offset { - Utf8.startUtf8(builder); - return Utf8.endUtf8(builder); -} -} -} -/** - * Opaque binary data - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Binary { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Binary - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Binary { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Binary= obj - * @returns Binary - */ -static getRootAsBinary(bb:flatbuffers.ByteBuffer, obj?:Binary):Binary { - return (obj || new Binary()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Binary= obj - * @returns Binary - */ -static getSizePrefixedRootAsBinary(bb:flatbuffers.ByteBuffer, obj?:Binary):Binary { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Binary()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.Builder builder - */ -static startBinary(builder:flatbuffers.Builder) { - builder.startObject(0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endBinary(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createBinary(builder:flatbuffers.Builder):flatbuffers.Offset { - Binary.startBinary(builder); - return Binary.endBinary(builder); -} -} -} -/** - * Same as Utf8, but with 64-bit offsets, allowing to represent - * extremely large data values. - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class LargeUtf8 { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns LargeUtf8 - */ -__init(i:number, bb:flatbuffers.ByteBuffer):LargeUtf8 { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param LargeUtf8= obj - * @returns LargeUtf8 - */ -static getRootAsLargeUtf8(bb:flatbuffers.ByteBuffer, obj?:LargeUtf8):LargeUtf8 { - return (obj || new LargeUtf8()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param LargeUtf8= obj - * @returns LargeUtf8 - */ -static getSizePrefixedRootAsLargeUtf8(bb:flatbuffers.ByteBuffer, obj?:LargeUtf8):LargeUtf8 { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new LargeUtf8()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.Builder builder - */ -static startLargeUtf8(builder:flatbuffers.Builder) { - builder.startObject(0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endLargeUtf8(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createLargeUtf8(builder:flatbuffers.Builder):flatbuffers.Offset { - LargeUtf8.startLargeUtf8(builder); - return LargeUtf8.endLargeUtf8(builder); -} -} -} -/** - * Same as Binary, but with 64-bit offsets, allowing to represent - * extremely large data values. - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class LargeBinary { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns LargeBinary - */ -__init(i:number, bb:flatbuffers.ByteBuffer):LargeBinary { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param LargeBinary= obj - * @returns LargeBinary - */ -static getRootAsLargeBinary(bb:flatbuffers.ByteBuffer, obj?:LargeBinary):LargeBinary { - return (obj || new LargeBinary()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param LargeBinary= obj - * @returns LargeBinary - */ -static getSizePrefixedRootAsLargeBinary(bb:flatbuffers.ByteBuffer, obj?:LargeBinary):LargeBinary { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new LargeBinary()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.Builder builder - */ -static startLargeBinary(builder:flatbuffers.Builder) { - builder.startObject(0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endLargeBinary(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createLargeBinary(builder:flatbuffers.Builder):flatbuffers.Offset { - LargeBinary.startLargeBinary(builder); - return LargeBinary.endLargeBinary(builder); -} -} -} -/** - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class FixedSizeBinary { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns FixedSizeBinary - */ -__init(i:number, bb:flatbuffers.ByteBuffer):FixedSizeBinary { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param FixedSizeBinary= obj - * @returns FixedSizeBinary - */ -static getRootAsFixedSizeBinary(bb:flatbuffers.ByteBuffer, obj?:FixedSizeBinary):FixedSizeBinary { - return (obj || new FixedSizeBinary()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param FixedSizeBinary= obj - * @returns FixedSizeBinary - */ -static getSizePrefixedRootAsFixedSizeBinary(bb:flatbuffers.ByteBuffer, obj?:FixedSizeBinary):FixedSizeBinary { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new FixedSizeBinary()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * Number of bytes per value - * - * @returns number - */ -byteWidth():number { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startFixedSizeBinary(builder:flatbuffers.Builder) { - builder.startObject(1); -}; - -/** - * @param flatbuffers.Builder builder - * @param number byteWidth - */ -static addByteWidth(builder:flatbuffers.Builder, byteWidth:number) { - builder.addFieldInt32(0, byteWidth, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endFixedSizeBinary(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createFixedSizeBinary(builder:flatbuffers.Builder, byteWidth:number):flatbuffers.Offset { - FixedSizeBinary.startFixedSizeBinary(builder); - FixedSizeBinary.addByteWidth(builder, byteWidth); - return FixedSizeBinary.endFixedSizeBinary(builder); -} -} -} -/** - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Bool { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Bool - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Bool { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Bool= obj - * @returns Bool - */ -static getRootAsBool(bb:flatbuffers.ByteBuffer, obj?:Bool):Bool { - return (obj || new Bool()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Bool= obj - * @returns Bool - */ -static getSizePrefixedRootAsBool(bb:flatbuffers.ByteBuffer, obj?:Bool):Bool { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Bool()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.Builder builder - */ -static startBool(builder:flatbuffers.Builder) { - builder.startObject(0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endBool(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createBool(builder:flatbuffers.Builder):flatbuffers.Offset { - Bool.startBool(builder); - return Bool.endBool(builder); -} -} -} -/** - * Exact decimal value represented as an integer value in two's - * complement. Currently only 128-bit (16-byte) and 256-bit (32-byte) integers - * are used. The representation uses the endianness indicated - * in the Schema. - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Decimal { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Decimal - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Decimal { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Decimal= obj - * @returns Decimal - */ -static getRootAsDecimal(bb:flatbuffers.ByteBuffer, obj?:Decimal):Decimal { - return (obj || new Decimal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Decimal= obj - * @returns Decimal - */ -static getSizePrefixedRootAsDecimal(bb:flatbuffers.ByteBuffer, obj?:Decimal):Decimal { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Decimal()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * Total number of decimal digits - * - * @returns number - */ -precision():number { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * Number of digits after the decimal point "." - * - * @returns number - */ -scale():number { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 0; -}; - -/** - * Number of bits per value. The only accepted widths are 128 and 256. - * We use bitWidth for consistency with Int::bitWidth. - * - * @returns number - */ -bitWidth():number { - var offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 128; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startDecimal(builder:flatbuffers.Builder) { - builder.startObject(3); -}; - -/** - * @param flatbuffers.Builder builder - * @param number precision - */ -static addPrecision(builder:flatbuffers.Builder, precision:number) { - builder.addFieldInt32(0, precision, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param number scale - */ -static addScale(builder:flatbuffers.Builder, scale:number) { - builder.addFieldInt32(1, scale, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param number bitWidth - */ -static addBitWidth(builder:flatbuffers.Builder, bitWidth:number) { - builder.addFieldInt32(2, bitWidth, 128); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endDecimal(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createDecimal(builder:flatbuffers.Builder, precision:number, scale:number, bitWidth:number):flatbuffers.Offset { - Decimal.startDecimal(builder); - Decimal.addPrecision(builder, precision); - Decimal.addScale(builder, scale); - Decimal.addBitWidth(builder, bitWidth); - return Decimal.endDecimal(builder); -} -} -} -/** - * Date is either a 32-bit or 64-bit type representing elapsed time since UNIX - * epoch (1970-01-01), stored in either of two units: - * - * * Milliseconds (64 bits) indicating UNIX time elapsed since the epoch (no - * leap seconds), where the values are evenly divisible by 86400000 - * * Days (32 bits) since the UNIX epoch - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Date { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Date - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Date { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Date= obj - * @returns Date - */ -static getRootAsDate(bb:flatbuffers.ByteBuffer, obj?:Date):Date { - return (obj || new Date()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Date= obj - * @returns Date - */ -static getSizePrefixedRootAsDate(bb:flatbuffers.ByteBuffer, obj?:Date):Date { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Date()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns org.apache.arrow.flatbuf.DateUnit - */ -unit():org.apache.arrow.flatbuf.DateUnit { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? /** */ (this.bb!.readInt16(this.bb_pos + offset)) : org.apache.arrow.flatbuf.DateUnit.MILLISECOND; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startDate(builder:flatbuffers.Builder) { - builder.startObject(1); -}; - -/** - * @param flatbuffers.Builder builder - * @param org.apache.arrow.flatbuf.DateUnit unit - */ -static addUnit(builder:flatbuffers.Builder, unit:org.apache.arrow.flatbuf.DateUnit) { - builder.addFieldInt16(0, unit, org.apache.arrow.flatbuf.DateUnit.MILLISECOND); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endDate(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createDate(builder:flatbuffers.Builder, unit:org.apache.arrow.flatbuf.DateUnit):flatbuffers.Offset { - Date.startDate(builder); - Date.addUnit(builder, unit); - return Date.endDate(builder); -} -} -} -/** - * Time type. The physical storage type depends on the unit - * - SECOND and MILLISECOND: 32 bits - * - MICROSECOND and NANOSECOND: 64 bits - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Time { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Time - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Time { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Time= obj - * @returns Time - */ -static getRootAsTime(bb:flatbuffers.ByteBuffer, obj?:Time):Time { - return (obj || new Time()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Time= obj - * @returns Time - */ -static getSizePrefixedRootAsTime(bb:flatbuffers.ByteBuffer, obj?:Time):Time { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Time()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns org.apache.arrow.flatbuf.TimeUnit - */ -unit():org.apache.arrow.flatbuf.TimeUnit { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? /** */ (this.bb!.readInt16(this.bb_pos + offset)) : org.apache.arrow.flatbuf.TimeUnit.MILLISECOND; -}; - -/** - * @returns number - */ -bitWidth():number { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.readInt32(this.bb_pos + offset) : 32; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startTime(builder:flatbuffers.Builder) { - builder.startObject(2); -}; - -/** - * @param flatbuffers.Builder builder - * @param org.apache.arrow.flatbuf.TimeUnit unit - */ -static addUnit(builder:flatbuffers.Builder, unit:org.apache.arrow.flatbuf.TimeUnit) { - builder.addFieldInt16(0, unit, org.apache.arrow.flatbuf.TimeUnit.MILLISECOND); -}; - -/** - * @param flatbuffers.Builder builder - * @param number bitWidth - */ -static addBitWidth(builder:flatbuffers.Builder, bitWidth:number) { - builder.addFieldInt32(1, bitWidth, 32); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endTime(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createTime(builder:flatbuffers.Builder, unit:org.apache.arrow.flatbuf.TimeUnit, bitWidth:number):flatbuffers.Offset { - Time.startTime(builder); - Time.addUnit(builder, unit); - Time.addBitWidth(builder, bitWidth); - return Time.endTime(builder); -} -} -} -/** - * Time elapsed from the Unix epoch, 00:00:00.000 on 1 January 1970, excluding - * leap seconds, as a 64-bit integer. Note that UNIX time does not include - * leap seconds. - * - * Date & time libraries often have multiple different data types for temporal - * data. In order to ease interoperability between different implementations the - * Arrow project has some recommendations for encoding these types into a Timestamp - * column. - * - * An "instant" represents a single moment in time that has no meaningful time zone - * or the time zone is unknown. A column of instants can also contain values from - * multiple time zones. To encode an instant set the timezone string to "UTC". - * - * A "zoned date-time" represents a single moment in time that has a meaningful - * reference time zone. To encode a zoned date-time as a Timestamp set the timezone - * string to the name of the timezone. There is some ambiguity between an instant - * and a zoned date-time with the UTC time zone. Both of these are stored the same. - * Typically, this distinction does not matter. If it does, then an application should - * use custom metadata or an extension type to distinguish between the two cases. - * - * An "offset date-time" represents a single moment in time combined with a meaningful - * offset from UTC. To encode an offset date-time as a Timestamp set the timezone string - * to the numeric time zone offset string (e.g. "+03:00"). - * - * A "local date-time" does not represent a single moment in time. It represents a wall - * clock time combined with a date. Because of daylight savings time there may multiple - * instants that correspond to a single local date-time in any given time zone. A - * local date-time is often stored as a struct or a Date32/Time64 pair. However, it can - * also be encoded into a Timestamp column. To do so the value should be the the time - * elapsed from the Unix epoch so that a wall clock in UTC would display the desired time. - * The timezone string should be set to null or the empty string. - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Timestamp { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Timestamp - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Timestamp { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Timestamp= obj - * @returns Timestamp - */ -static getRootAsTimestamp(bb:flatbuffers.ByteBuffer, obj?:Timestamp):Timestamp { - return (obj || new Timestamp()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Timestamp= obj - * @returns Timestamp - */ -static getSizePrefixedRootAsTimestamp(bb:flatbuffers.ByteBuffer, obj?:Timestamp):Timestamp { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Timestamp()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns org.apache.arrow.flatbuf.TimeUnit - */ -unit():org.apache.arrow.flatbuf.TimeUnit { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? /** */ (this.bb!.readInt16(this.bb_pos + offset)) : org.apache.arrow.flatbuf.TimeUnit.SECOND; -}; - -/** - * The time zone is a string indicating the name of a time zone, one of: - * - * * As used in the Olson time zone database (the "tz database" or - * "tzdata"), such as "America/New_York" - * * An absolute time zone offset of the form +XX:XX or -XX:XX, such as +07:30 - * - * Whether a timezone string is present indicates different semantics about - * the data: - * - * * If the time zone is null or an empty string, the data is a local date-time - * and does not represent a single moment in time. Instead it represents a wall clock - * time and care should be taken to avoid interpreting it semantically as an instant. - * - * * If the time zone is set to a valid value, values can be displayed as - * "localized" to that time zone, even though the underlying 64-bit - * integers are identical to the same data stored in UTC. Converting - * between time zones is a metadata-only operation and does not change the - * underlying values - * - * @param flatbuffers.Encoding= optionalEncoding - * @returns string|Uint8Array|null - */ -timezone():string|null -timezone(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -timezone(optionalEncoding?:any):string|Uint8Array|null { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startTimestamp(builder:flatbuffers.Builder) { - builder.startObject(2); -}; - -/** - * @param flatbuffers.Builder builder - * @param org.apache.arrow.flatbuf.TimeUnit unit - */ -static addUnit(builder:flatbuffers.Builder, unit:org.apache.arrow.flatbuf.TimeUnit) { - builder.addFieldInt16(0, unit, org.apache.arrow.flatbuf.TimeUnit.SECOND); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset timezoneOffset - */ -static addTimezone(builder:flatbuffers.Builder, timezoneOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, timezoneOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endTimestamp(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createTimestamp(builder:flatbuffers.Builder, unit:org.apache.arrow.flatbuf.TimeUnit, timezoneOffset:flatbuffers.Offset):flatbuffers.Offset { - Timestamp.startTimestamp(builder); - Timestamp.addUnit(builder, unit); - Timestamp.addTimezone(builder, timezoneOffset); - return Timestamp.endTimestamp(builder); -} -} -} -/** - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Interval { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Interval - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Interval { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Interval= obj - * @returns Interval - */ -static getRootAsInterval(bb:flatbuffers.ByteBuffer, obj?:Interval):Interval { - return (obj || new Interval()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Interval= obj - * @returns Interval - */ -static getSizePrefixedRootAsInterval(bb:flatbuffers.ByteBuffer, obj?:Interval):Interval { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Interval()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns org.apache.arrow.flatbuf.IntervalUnit - */ -unit():org.apache.arrow.flatbuf.IntervalUnit { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? /** */ (this.bb!.readInt16(this.bb_pos + offset)) : org.apache.arrow.flatbuf.IntervalUnit.YEAR_MONTH; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startInterval(builder:flatbuffers.Builder) { - builder.startObject(1); -}; - -/** - * @param flatbuffers.Builder builder - * @param org.apache.arrow.flatbuf.IntervalUnit unit - */ -static addUnit(builder:flatbuffers.Builder, unit:org.apache.arrow.flatbuf.IntervalUnit) { - builder.addFieldInt16(0, unit, org.apache.arrow.flatbuf.IntervalUnit.YEAR_MONTH); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endInterval(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createInterval(builder:flatbuffers.Builder, unit:org.apache.arrow.flatbuf.IntervalUnit):flatbuffers.Offset { - Interval.startInterval(builder); - Interval.addUnit(builder, unit); - return Interval.endInterval(builder); -} -} -} -/** - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Duration { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Duration - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Duration { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Duration= obj - * @returns Duration - */ -static getRootAsDuration(bb:flatbuffers.ByteBuffer, obj?:Duration):Duration { - return (obj || new Duration()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Duration= obj - * @returns Duration - */ -static getSizePrefixedRootAsDuration(bb:flatbuffers.ByteBuffer, obj?:Duration):Duration { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Duration()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @returns org.apache.arrow.flatbuf.TimeUnit - */ -unit():org.apache.arrow.flatbuf.TimeUnit { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? /** */ (this.bb!.readInt16(this.bb_pos + offset)) : org.apache.arrow.flatbuf.TimeUnit.MILLISECOND; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startDuration(builder:flatbuffers.Builder) { - builder.startObject(1); -}; - -/** - * @param flatbuffers.Builder builder - * @param org.apache.arrow.flatbuf.TimeUnit unit - */ -static addUnit(builder:flatbuffers.Builder, unit:org.apache.arrow.flatbuf.TimeUnit) { - builder.addFieldInt16(0, unit, org.apache.arrow.flatbuf.TimeUnit.MILLISECOND); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endDuration(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createDuration(builder:flatbuffers.Builder, unit:org.apache.arrow.flatbuf.TimeUnit):flatbuffers.Offset { - Duration.startDuration(builder); - Duration.addUnit(builder, unit); - return Duration.endDuration(builder); -} -} -} -/** - * ---------------------------------------------------------------------- - * user defined key value pairs to add custom metadata to arrow - * key namespacing is the responsibility of the user - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class KeyValue { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns KeyValue - */ -__init(i:number, bb:flatbuffers.ByteBuffer):KeyValue { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param KeyValue= obj - * @returns KeyValue - */ -static getRootAsKeyValue(bb:flatbuffers.ByteBuffer, obj?:KeyValue):KeyValue { - return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param KeyValue= obj - * @returns KeyValue - */ -static getSizePrefixedRootAsKeyValue(bb:flatbuffers.ByteBuffer, obj?:KeyValue):KeyValue { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new KeyValue()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.Encoding= optionalEncoding - * @returns string|Uint8Array|null - */ -key():string|null -key(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -key(optionalEncoding?:any):string|Uint8Array|null { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -}; - -/** - * @param flatbuffers.Encoding= optionalEncoding - * @returns string|Uint8Array|null - */ -value():string|null -value(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -value(optionalEncoding?:any):string|Uint8Array|null { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startKeyValue(builder:flatbuffers.Builder) { - builder.startObject(2); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset keyOffset - */ -static addKey(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, keyOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset valueOffset - */ -static addValue(builder:flatbuffers.Builder, valueOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, valueOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endKeyValue(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -static createKeyValue(builder:flatbuffers.Builder, keyOffset:flatbuffers.Offset, valueOffset:flatbuffers.Offset):flatbuffers.Offset { - KeyValue.startKeyValue(builder); - KeyValue.addKey(builder, keyOffset); - KeyValue.addValue(builder, valueOffset); - return KeyValue.endKeyValue(builder); -} -} -} -/** - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class DictionaryEncoding { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns DictionaryEncoding - */ -__init(i:number, bb:flatbuffers.ByteBuffer):DictionaryEncoding { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param DictionaryEncoding= obj - * @returns DictionaryEncoding - */ -static getRootAsDictionaryEncoding(bb:flatbuffers.ByteBuffer, obj?:DictionaryEncoding):DictionaryEncoding { - return (obj || new DictionaryEncoding()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param DictionaryEncoding= obj - * @returns DictionaryEncoding - */ -static getSizePrefixedRootAsDictionaryEncoding(bb:flatbuffers.ByteBuffer, obj?:DictionaryEncoding):DictionaryEncoding { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new DictionaryEncoding()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * The known dictionary id in the application where this data is used. In - * the file or streaming formats, the dictionary ids are found in the - * DictionaryBatch messages - * - * @returns flatbuffers.Long - */ -id():flatbuffers.Long { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0); -}; - -/** - * The dictionary indices are constrained to be non-negative integers. If - * this field is null, the indices must be signed int32. To maximize - * cross-language compatibility and performance, implementations are - * recommended to prefer signed integer types over unsigned integer types - * and to avoid uint64 indices unless they are required by an application. - * - * @param org.apache.arrow.flatbuf.Int= obj - * @returns org.apache.arrow.flatbuf.Int|null - */ -indexType(obj?:org.apache.arrow.flatbuf.Int):org.apache.arrow.flatbuf.Int|null { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? (obj || new org.apache.arrow.flatbuf.Int()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -}; - -/** - * By default, dictionaries are not ordered, or the order does not have - * semantic meaning. In some statistical, applications, dictionary-encoding - * is used to represent ordered categorical data, and we provide a way to - * preserve that metadata here - * - * @returns boolean - */ -isOrdered():boolean { - var offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; -}; - -/** - * @returns org.apache.arrow.flatbuf.DictionaryKind - */ -dictionaryKind():org.apache.arrow.flatbuf.DictionaryKind { - var offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? /** */ (this.bb!.readInt16(this.bb_pos + offset)) : org.apache.arrow.flatbuf.DictionaryKind.DenseArray; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startDictionaryEncoding(builder:flatbuffers.Builder) { - builder.startObject(4); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Long id - */ -static addId(builder:flatbuffers.Builder, id:flatbuffers.Long) { - builder.addFieldInt64(0, id, builder.createLong(0, 0)); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset indexTypeOffset - */ -static addIndexType(builder:flatbuffers.Builder, indexTypeOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, indexTypeOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param boolean isOrdered - */ -static addIsOrdered(builder:flatbuffers.Builder, isOrdered:boolean) { - builder.addFieldInt8(2, +isOrdered, +false); -}; - -/** - * @param flatbuffers.Builder builder - * @param org.apache.arrow.flatbuf.DictionaryKind dictionaryKind - */ -static addDictionaryKind(builder:flatbuffers.Builder, dictionaryKind:org.apache.arrow.flatbuf.DictionaryKind) { - builder.addFieldInt16(3, dictionaryKind, org.apache.arrow.flatbuf.DictionaryKind.DenseArray); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endDictionaryEncoding(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -} -} -/** - * ---------------------------------------------------------------------- - * A field represents a named column in a record / row batch or child of a - * nested type. - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Field { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Field - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Field { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Field= obj - * @returns Field - */ -static getRootAsField(bb:flatbuffers.ByteBuffer, obj?:Field):Field { - return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Field= obj - * @returns Field - */ -static getSizePrefixedRootAsField(bb:flatbuffers.ByteBuffer, obj?:Field):Field { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Field()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * Name is not required, in i.e. a List - * - * @param flatbuffers.Encoding= optionalEncoding - * @returns string|Uint8Array|null - */ -name():string|null -name(optionalEncoding:flatbuffers.Encoding):string|Uint8Array|null -name(optionalEncoding?:any):string|Uint8Array|null { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? this.bb!.__string(this.bb_pos + offset, optionalEncoding) : null; -}; - -/** - * Whether or not this field can contain nulls. Should be true in general. - * - * @returns boolean - */ -nullable():boolean { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? !!this.bb!.readInt8(this.bb_pos + offset) : false; -}; - -/** - * @returns org.apache.arrow.flatbuf.Type - */ -typeType():org.apache.arrow.flatbuf.Type { - var offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? /** */ (this.bb!.readUint8(this.bb_pos + offset)) : org.apache.arrow.flatbuf.Type.NONE; -}; - -/** - * This is the type of the decoded value if the field is dictionary encoded. - * - * @param flatbuffers.Table obj - * @returns ?flatbuffers.Table - */ -type(obj:T):T|null { - var offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.__union(obj, this.bb_pos + offset) : null; -}; - -/** - * Present only if the field is dictionary encoded. - * - * @param org.apache.arrow.flatbuf.DictionaryEncoding= obj - * @returns org.apache.arrow.flatbuf.DictionaryEncoding|null - */ -dictionary(obj?:org.apache.arrow.flatbuf.DictionaryEncoding):org.apache.arrow.flatbuf.DictionaryEncoding|null { - var offset = this.bb!.__offset(this.bb_pos, 12); - return offset ? (obj || new org.apache.arrow.flatbuf.DictionaryEncoding()).__init(this.bb!.__indirect(this.bb_pos + offset), this.bb!) : null; -}; - -/** - * children apply only to nested data types like Struct, List and Union. For - * primitive types children will have length 0. - * - * @param number index - * @param org.apache.arrow.flatbuf.Field= obj - * @returns org.apache.arrow.flatbuf.Field - */ -children(index: number, obj?:org.apache.arrow.flatbuf.Field):org.apache.arrow.flatbuf.Field|null { - var offset = this.bb!.__offset(this.bb_pos, 14); - return offset ? (obj || new org.apache.arrow.flatbuf.Field()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; -}; - -/** - * @returns number - */ -childrenLength():number { - var offset = this.bb!.__offset(this.bb_pos, 14); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * User-defined metadata - * - * @param number index - * @param org.apache.arrow.flatbuf.KeyValue= obj - * @returns org.apache.arrow.flatbuf.KeyValue - */ -customMetadata(index: number, obj?:org.apache.arrow.flatbuf.KeyValue):org.apache.arrow.flatbuf.KeyValue|null { - var offset = this.bb!.__offset(this.bb_pos, 16); - return offset ? (obj || new org.apache.arrow.flatbuf.KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; -}; - -/** - * @returns number - */ -customMetadataLength():number { - var offset = this.bb!.__offset(this.bb_pos, 16); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startField(builder:flatbuffers.Builder) { - builder.startObject(7); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset nameOffset - */ -static addName(builder:flatbuffers.Builder, nameOffset:flatbuffers.Offset) { - builder.addFieldOffset(0, nameOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param boolean nullable - */ -static addNullable(builder:flatbuffers.Builder, nullable:boolean) { - builder.addFieldInt8(1, +nullable, +false); -}; - -/** - * @param flatbuffers.Builder builder - * @param org.apache.arrow.flatbuf.Type typeType - */ -static addTypeType(builder:flatbuffers.Builder, typeType:org.apache.arrow.flatbuf.Type) { - builder.addFieldInt8(2, typeType, org.apache.arrow.flatbuf.Type.NONE); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset typeOffset - */ -static addType(builder:flatbuffers.Builder, typeOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, typeOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset dictionaryOffset - */ -static addDictionary(builder:flatbuffers.Builder, dictionaryOffset:flatbuffers.Offset) { - builder.addFieldOffset(4, dictionaryOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset childrenOffset - */ -static addChildren(builder:flatbuffers.Builder, childrenOffset:flatbuffers.Offset) { - builder.addFieldOffset(5, childrenOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param Array. data - * @returns flatbuffers.Offset - */ -static createChildrenVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param flatbuffers.Builder builder - * @param number numElems - */ -static startChildrenVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset customMetadataOffset - */ -static addCustomMetadata(builder:flatbuffers.Builder, customMetadataOffset:flatbuffers.Offset) { - builder.addFieldOffset(6, customMetadataOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param Array. data - * @returns flatbuffers.Offset - */ -static createCustomMetadataVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param flatbuffers.Builder builder - * @param number numElems - */ -static startCustomMetadataVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endField(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -} -} -/** - * ---------------------------------------------------------------------- - * A Buffer represents a single contiguous memory segment - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Buffer { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Buffer - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Buffer { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * The relative offset into the shared memory page where the bytes for this - * buffer starts - * - * @returns flatbuffers.Long - */ -offset():flatbuffers.Long { - return this.bb!.readInt64(this.bb_pos); -}; - -/** - * The absolute length (in bytes) of the memory buffer. The memory is found - * from offset (inclusive) to offset + length (non-inclusive). When building - * messages using the encapsulated IPC message, padding bytes may be written - * after a buffer, but such padding bytes do not need to be accounted for in - * the size here. - * - * @returns flatbuffers.Long - */ -length():flatbuffers.Long { - return this.bb!.readInt64(this.bb_pos + 8); -}; - -/** - * @returns number - */ -static sizeOf():number { - return 16; -} - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Long offset - * @param flatbuffers.Long length - * @returns flatbuffers.Offset - */ -static createBuffer(builder:flatbuffers.Builder, offset: flatbuffers.Long, length: flatbuffers.Long):flatbuffers.Offset { - builder.prep(8, 16); - builder.writeInt64(length); - builder.writeInt64(offset); - return builder.offset(); -}; - -} -} -/** - * ---------------------------------------------------------------------- - * A Schema describes the columns in a row batch - * - * @constructor - */ -export namespace org.apache.arrow.flatbuf{ -export class Schema { - bb: flatbuffers.ByteBuffer|null = null; - - bb_pos:number = 0; -/** - * @param number i - * @param flatbuffers.ByteBuffer bb - * @returns Schema - */ -__init(i:number, bb:flatbuffers.ByteBuffer):Schema { - this.bb_pos = i; - this.bb = bb; - return this; -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Schema= obj - * @returns Schema - */ -static getRootAsSchema(bb:flatbuffers.ByteBuffer, obj?:Schema):Schema { - return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * @param flatbuffers.ByteBuffer bb - * @param Schema= obj - * @returns Schema - */ -static getSizePrefixedRootAsSchema(bb:flatbuffers.ByteBuffer, obj?:Schema):Schema { - bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); - return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); -}; - -/** - * endianness of the buffer - * it is Little Endian by default - * if endianness doesn't match the underlying system then the vectors need to be converted - * - * @returns org.apache.arrow.flatbuf.Endianness - */ -endianness():org.apache.arrow.flatbuf.Endianness { - var offset = this.bb!.__offset(this.bb_pos, 4); - return offset ? /** */ (this.bb!.readInt16(this.bb_pos + offset)) : org.apache.arrow.flatbuf.Endianness.Little; -}; - -/** - * @param number index - * @param org.apache.arrow.flatbuf.Field= obj - * @returns org.apache.arrow.flatbuf.Field - */ -fields(index: number, obj?:org.apache.arrow.flatbuf.Field):org.apache.arrow.flatbuf.Field|null { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? (obj || new org.apache.arrow.flatbuf.Field()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; -}; - -/** - * @returns number - */ -fieldsLength():number { - var offset = this.bb!.__offset(this.bb_pos, 6); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param number index - * @param org.apache.arrow.flatbuf.KeyValue= obj - * @returns org.apache.arrow.flatbuf.KeyValue - */ -customMetadata(index: number, obj?:org.apache.arrow.flatbuf.KeyValue):org.apache.arrow.flatbuf.KeyValue|null { - var offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? (obj || new org.apache.arrow.flatbuf.KeyValue()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null; -}; - -/** - * @returns number - */ -customMetadataLength():number { - var offset = this.bb!.__offset(this.bb_pos, 8); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * Features used in the stream/file. - * - * @param number index - * @returns flatbuffers.Long - */ -features(index: number):flatbuffers.Long|null { - var offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? /** */ (this.bb!.readInt64(this.bb!.__vector(this.bb_pos + offset) + index * 8)) : this.bb!.createLong(0, 0); -}; - -/** - * @returns number - */ -featuresLength():number { - var offset = this.bb!.__offset(this.bb_pos, 10); - return offset ? this.bb!.__vector_len(this.bb_pos + offset) : 0; -}; - -/** - * @param flatbuffers.Builder builder - */ -static startSchema(builder:flatbuffers.Builder) { - builder.startObject(4); -}; - -/** - * @param flatbuffers.Builder builder - * @param org.apache.arrow.flatbuf.Endianness endianness - */ -static addEndianness(builder:flatbuffers.Builder, endianness:org.apache.arrow.flatbuf.Endianness) { - builder.addFieldInt16(0, endianness, org.apache.arrow.flatbuf.Endianness.Little); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset fieldsOffset - */ -static addFields(builder:flatbuffers.Builder, fieldsOffset:flatbuffers.Offset) { - builder.addFieldOffset(1, fieldsOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param Array. data - * @returns flatbuffers.Offset - */ -static createFieldsVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param flatbuffers.Builder builder - * @param number numElems - */ -static startFieldsVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset customMetadataOffset - */ -static addCustomMetadata(builder:flatbuffers.Builder, customMetadataOffset:flatbuffers.Offset) { - builder.addFieldOffset(2, customMetadataOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param Array. data - * @returns flatbuffers.Offset - */ -static createCustomMetadataVector(builder:flatbuffers.Builder, data:flatbuffers.Offset[]):flatbuffers.Offset { - builder.startVector(4, data.length, 4); - for (var i = data.length - 1; i >= 0; i--) { - builder.addOffset(data[i]); - } - return builder.endVector(); -}; - -/** - * @param flatbuffers.Builder builder - * @param number numElems - */ -static startCustomMetadataVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(4, numElems, 4); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset featuresOffset - */ -static addFeatures(builder:flatbuffers.Builder, featuresOffset:flatbuffers.Offset) { - builder.addFieldOffset(3, featuresOffset, 0); -}; - -/** - * @param flatbuffers.Builder builder - * @param Array. data - * @returns flatbuffers.Offset - */ -static createFeaturesVector(builder:flatbuffers.Builder, data:flatbuffers.Long[]):flatbuffers.Offset { - builder.startVector(8, data.length, 8); - for (var i = data.length - 1; i >= 0; i--) { - builder.addInt64(data[i]); - } - return builder.endVector(); -}; - -/** - * @param flatbuffers.Builder builder - * @param number numElems - */ -static startFeaturesVector(builder:flatbuffers.Builder, numElems:number) { - builder.startVector(8, numElems, 8); -}; - -/** - * @param flatbuffers.Builder builder - * @returns flatbuffers.Offset - */ -static endSchema(builder:flatbuffers.Builder):flatbuffers.Offset { - var offset = builder.endObject(); - return offset; -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset offset - */ -static finishSchemaBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset); -}; - -/** - * @param flatbuffers.Builder builder - * @param flatbuffers.Offset offset - */ -static finishSizePrefixedSchemaBuffer(builder:flatbuffers.Builder, offset:flatbuffers.Offset) { - builder.finish(offset, undefined, true); -}; - -static createSchema(builder:flatbuffers.Builder, endianness:org.apache.arrow.flatbuf.Endianness, fieldsOffset:flatbuffers.Offset, customMetadataOffset:flatbuffers.Offset, featuresOffset:flatbuffers.Offset):flatbuffers.Offset { - Schema.startSchema(builder); - Schema.addEndianness(builder, endianness); - Schema.addFields(builder, fieldsOffset); - Schema.addCustomMetadata(builder, customMetadataOffset); - Schema.addFeatures(builder, featuresOffset); - return Schema.endSchema(builder); -} -} -} diff --git a/proto/raw-js-openapi/src/index.js b/proto/raw-js-openapi/src/index.js index 1e9c688f910..4e2312ce3aa 100644 --- a/proto/raw-js-openapi/src/index.js +++ b/proto/raw-js-openapi/src/index.js @@ -28,11 +28,6 @@ var browserHeaders = require("browser-headers"); var grpcWeb = require("@improbable-eng/grpc-web");//usually .grpc var jspb = require("google-protobuf"); -var flatbuffers = require("flatbuffers").flatbuffers; -var barrage = require("@deephaven/barrage"); - -var message = require('./arrow/flight/flatbuf/Message_generated'); -var schema = require('./arrow/flight/flatbuf/Schema_generated'); var io = { deephaven: { proto: { @@ -58,17 +53,8 @@ var io = { deephaven: { hierarchicaltable_pb, hierarchicaltable_pb_service }, - barrage: { - "flatbuf": { - "Barrage_generated": barrage, - } - } }}; var arrow = { flight: { - flatbuf: { - Message_generated: message, - Schema_generated: schema, - }, protocol: { Flight_pb, Flight_pb_service, @@ -80,7 +66,6 @@ var dhinternal = { browserHeaders, jspb, grpcWeb,//TODO need to expand this to the specific things we need - flatbuffers, io, arrow }; diff --git a/replication/static/src/main/java/io/deephaven/replicators/ReplicateBarrageUtils.java b/replication/static/src/main/java/io/deephaven/replicators/ReplicateBarrageUtils.java index 6824f8d91f9..35dadff92d0 100644 --- a/replication/static/src/main/java/io/deephaven/replicators/ReplicateBarrageUtils.java +++ b/replication/static/src/main/java/io/deephaven/replicators/ReplicateBarrageUtils.java @@ -36,6 +36,9 @@ public static void main(final String[] args) throws IOException { fixupVectorExpansionKernel(CHUNK_PACKAGE + "/vector/IntVectorExpansionKernel.java", "Int"); fixupVectorExpansionKernel(CHUNK_PACKAGE + "/vector/LongVectorExpansionKernel.java", "Long"); fixupVectorExpansionKernel(CHUNK_PACKAGE + "/vector/DoubleVectorExpansionKernel.java", "Double"); + + ReplicatePrimitiveCode.charToAllButBoolean("replicateBarrageUtils", + "web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebCharColumnData.java"); } private static void fixupVectorExpansionKernel(final @NotNull String path, final @NotNull String type) diff --git a/web/client-api/client-api.gradle b/web/client-api/client-api.gradle index f9f9067a65b..93f8930f32f 100644 --- a/web/client-api/client-api.gradle +++ b/web/client-api/client-api.gradle @@ -15,15 +15,32 @@ configurations { dts typescriptDoclet } - dependencies { + implementation platform(libs.grpc.bom) + implementation variantOf(libs.grpc.api) { classifier('sources') } + + implementation project(':engine-chunk') + implementation project(':extensions-barrage') + implementation project(':DataStructures') implementation project(':web-shared-beans') implementation project(':web-client-backplane') + implementation libs.jetbrains.annotations + implementation variantOf(libs.jetbrains.annotations) { classifier("sources") } + implementation libs.immutables.value.annotations + implementation variantOf(libs.immutables.value.annotations) { classifier("sources") } + + implementation libs.flatbuffers.java + implementation variantOf(libs.flatbuffers.java) { classifier("sources") } + implementation libs.arrow.format + implementation variantOf(libs.arrow.format) { classifier('sources') } + implementation libs.deephaven.barrage.format + implementation variantOf(libs.deephaven.barrage.format) { classifier('sources') } implementation libs.vertispan.ts.defs.annotations typescriptDoclet libs.vertispan.ts.defs.doclet implementation libs.vertispan.nio.gwt + implementation libs.vertispan.flatbuffers.gwt js project(path: ':proto:raw-js-openapi', configuration: 'js') @@ -76,10 +93,14 @@ def gwtUnitTest = tasks.register('gwtUnitTest', Test) { t -> '-runStyle HtmlUnit', '-ea', '-style PRETTY', + '-generateJsInteropExports', + '-includeJsInteropExports io.deephaven.*', + '-excludeJsInteropExports io.deephaven.web.client.api.widget.plot.*', "-war ${layout.buildDirectory.dir('unitTest-war').get().asFile.absolutePath}" ].join(' '), 'gwt.persistentunitcachedir': layout.buildDirectory.dir('unitTest-unitCache').get().asFile.absolutePath, ] + t.classpath += tasks.getByName('gwtCompile').src t.include '**/ClientUnitTestSuite.class' t.useJUnit() t.scanForTestClasses = false @@ -148,6 +169,9 @@ def gwtIntegrationTest = tasks.register('gwtIntegrationTest', Test) { t -> "-runStyle io.deephaven.web.junit.RunStyleRemoteWebDriver:${webdriverUrl}?firefox", '-ea', '-style PRETTY', + '-generateJsInteropExports', + '-includeJsInteropExports io.deephaven.*', + '-excludeJsInteropExports io.deephaven.web.client.api.widget.plot.*', "-setProperty dh.server=http://${deephavenDocker.containerName.get()}:10000", "-war ${layout.buildDirectory.dir('integrationTest-war').get().asFile.absolutePath}" ].join(' ')) @@ -181,6 +205,9 @@ Click the URL that is printed out to run the test in your browser, or refresh an '-runStyle Manual:1', '-ea', '-style PRETTY', + '-generateJsInteropExports', + '-includeJsInteropExports io.deephaven.*', + '-excludeJsInteropExports io.deephaven.web.client.api.widget.plot.*', '-setProperty dh.server=http://localhost:10000', '-setProperty compiler.useSourceMaps=true', "-war ${layout.buildDirectory.dir('manualTest-war').get().asFile.absolutePath}" diff --git a/web/client-api/src/main/java/io/deephaven/web/DeephavenApi.gwt.xml b/web/client-api/src/main/java/io/deephaven/web/DeephavenApi.gwt.xml index 4f6177621b8..9649d1d487c 100644 --- a/web/client-api/src/main/java/io/deephaven/web/DeephavenApi.gwt.xml +++ b/web/client-api/src/main/java/io/deephaven/web/DeephavenApi.gwt.xml @@ -2,8 +2,20 @@ + + + + + + + + + + + + diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/Column.java b/web/client-api/src/main/java/io/deephaven/web/client/api/Column.java index 4e4840754dd..00e97223b86 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/Column.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/Column.java @@ -10,6 +10,7 @@ import jsinterop.annotations.JsProperty; import jsinterop.base.Any; +import java.util.Objects; import java.util.stream.IntStream; import java.util.stream.IntStream.Builder; @@ -21,7 +22,6 @@ public class Column { private final int index; - private final Integer formatColumnIndex; private final Integer styleColumnIndex; private final Integer formatStringColumnIndex; @@ -75,7 +75,7 @@ public Column(int jsIndex, int index, Integer formatColumnIndex, Integer styleCo boolean inputTableKeyColumn, boolean isSortable) { this.jsIndex = jsIndex; this.index = index; - this.formatColumnIndex = formatColumnIndex; + assert Objects.equals(formatColumnIndex, styleColumnIndex); this.styleColumnIndex = styleColumnIndex; this.type = type; this.name = name; @@ -170,14 +170,6 @@ public void setConstituentType(final String constituentType) { this.constituentType = constituentType; } - /** - * @deprecated Prefer {@link #getFormatStringColumnIndex()}. - */ - @Deprecated - public Integer getFormatColumnIndex() { - return formatColumnIndex; - } - public Integer getFormatStringColumnIndex() { return formatStringColumnIndex; } @@ -266,7 +258,6 @@ public CustomColumn formatDate(String expression) { public String toString() { return "Column{" + "index=" + index + - ", formatColumnIndex=" + formatColumnIndex + ", styleColumnIndex=" + styleColumnIndex + ", formatStringColumnIndex=" + formatStringColumnIndex + ", type='" + type + '\'' + @@ -285,9 +276,6 @@ public boolean equals(Object o) { if (index != column.index) return false; - if (formatColumnIndex != null ? !formatColumnIndex.equals(column.formatColumnIndex) - : column.formatColumnIndex != null) - return false; if (styleColumnIndex != null ? !styleColumnIndex.equals(column.styleColumnIndex) : column.styleColumnIndex != null) return false; @@ -302,7 +290,6 @@ public boolean equals(Object o) { @Override public int hashCode() { int result = index; - result = 31 * result + (formatColumnIndex != null ? formatColumnIndex.hashCode() : 0); result = 31 * result + (styleColumnIndex != null ? styleColumnIndex.hashCode() : 0); result = 31 * result + (formatStringColumnIndex != null ? formatStringColumnIndex.hashCode() : 0); result = 31 * result + type.hashCode(); @@ -311,12 +298,12 @@ public int hashCode() { } public Column withFormatStringColumnIndex(int formatStringColumnIndex) { - return new Column(jsIndex, index, formatColumnIndex, styleColumnIndex, type, name, isPartitionColumn, + return new Column(jsIndex, index, styleColumnIndex, styleColumnIndex, type, name, isPartitionColumn, formatStringColumnIndex, description, isInputTableKeyColumn, isSortable); } public Column withStyleColumnIndex(int styleColumnIndex) { - return new Column(jsIndex, index, formatColumnIndex, styleColumnIndex, type, name, isPartitionColumn, + return new Column(jsIndex, index, styleColumnIndex, styleColumnIndex, type, name, isPartitionColumn, formatStringColumnIndex, description, isInputTableKeyColumn, isSortable); } } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/DateWrapper.java b/web/client-api/src/main/java/io/deephaven/web/client/api/DateWrapper.java index 4e6580b57c0..f53d2a35928 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/DateWrapper.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/DateWrapper.java @@ -4,6 +4,7 @@ package io.deephaven.web.client.api; import elemental2.core.JsDate; +import io.deephaven.util.QueryConstants; import io.deephaven.web.client.api.i18n.JsDateTimeFormat; import jsinterop.annotations.JsIgnore; import jsinterop.annotations.JsType; @@ -17,6 +18,9 @@ public DateWrapper(long valueInNanos) { @JsIgnore public static DateWrapper of(long dateInNanos) { + if (dateInNanos == QueryConstants.NULL_LONG) { + return null; + } return new DateWrapper(dateInNanos); } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/Format.java b/web/client-api/src/main/java/io/deephaven/web/client/api/Format.java index 747a3402b39..2aea9065a9c 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/Format.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/Format.java @@ -10,12 +10,16 @@ import jsinterop.annotations.JsNullable; import jsinterop.annotations.JsProperty; +import java.util.Objects; + /** * This object may be pooled internally or discarded and not updated. Do not retain references to it. */ @TsInterface @TsName(namespace = "dh") -public class Format { +public final class Format { + public static final Format EMPTY = new Format(0, 0, null, null); + private final long cellColors; private final long rowColors; @@ -23,8 +27,8 @@ public class Format { private final String formatString; public Format(long cellColors, long rowColors, String numberFormat, String formatString) { - this.cellColors = cellColors; - this.rowColors = rowColors; + this.cellColors = cellColors == Long.MIN_VALUE ? 0 : cellColors; + this.rowColors = rowColors == Long.MIN_VALUE ? 0 : rowColors; this.numberFormat = numberFormat; this.formatString = formatString; } @@ -103,4 +107,30 @@ public String getFormatString() { return formatString; } + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Format format = (Format) o; + return cellColors == format.cellColors && rowColors == format.rowColors + && Objects.equals(numberFormat, format.numberFormat) + && Objects.equals(formatString, format.formatString); + } + + @Override + public int hashCode() { + return Objects.hash(cellColors, rowColors, numberFormat, formatString); + } + + @Override + public String toString() { + return "Format{" + + "cellColors=" + cellColors + + ", rowColors=" + rowColors + + ", numberFormat='" + numberFormat + '\'' + + ", formatString='" + formatString + '\'' + + '}'; + } } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/JsColumnStatistics.java b/web/client-api/src/main/java/io/deephaven/web/client/api/JsColumnStatistics.java index 7b117047e80..d66034f67d4 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/JsColumnStatistics.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/JsColumnStatistics.java @@ -8,7 +8,6 @@ import com.vertispan.tsdefs.annotations.TsName; import elemental2.core.JsArray; import elemental2.core.JsMap; -import io.deephaven.web.shared.data.ColumnStatistics; import jsinterop.annotations.JsIgnore; import jsinterop.annotations.JsMethod; import jsinterop.annotations.JsProperty; @@ -18,8 +17,7 @@ import java.util.Map; /** - * Javascript wrapper for {@link ColumnStatistics} This class holds the results of a call to generate statistics on a - * table column. + * Represents statistics for a given table column. */ @TsInterface @TsName(name = "ColumnStatistics", namespace = "dh") diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/JsPartitionedTable.java b/web/client-api/src/main/java/io/deephaven/web/client/api/JsPartitionedTable.java index acc260335e0..aa7aca03f00 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/JsPartitionedTable.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/JsPartitionedTable.java @@ -26,7 +26,6 @@ import io.deephaven.web.client.state.ClientTableState; import io.deephaven.web.shared.data.RangeSet; import jsinterop.annotations.JsIgnore; -import jsinterop.annotations.JsMethod; import jsinterop.annotations.JsNullable; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; @@ -143,11 +142,10 @@ private Promise subscribeToBaseTable() { private void handleKeys(Event update) { // noinspection unchecked - CustomEvent event = - (CustomEvent) update; + CustomEvent event = (CustomEvent) update; // We're only interested in added rows, send an event indicating the new keys that are available - SubscriptionTableData.UpdateEventData eventData = event.detail; + SubscriptionTableData eventData = event.detail; RangeSet added = eventData.getAdded().getRange(); added.indexIterator().forEachRemaining((long index) -> { // extract the key to use diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/JsRangeSet.java b/web/client-api/src/main/java/io/deephaven/web/client/api/JsRangeSet.java index 50e09604c73..85872589483 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/JsRangeSet.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/JsRangeSet.java @@ -24,6 +24,9 @@ public class JsRangeSet { private final RangeSet range; public static JsRangeSet ofRange(double first, double last) { + if (first > last) { + throw new IllegalStateException(first + " > " + last); + } return new JsRangeSet(RangeSet.ofRange((long) first, (long) last)); } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/JsTable.java b/web/client-api/src/main/java/io/deephaven/web/client/api/JsTable.java index 4e380631ad7..21fd3ca9eff 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/JsTable.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/JsTable.java @@ -9,7 +9,6 @@ import com.vertispan.tsdefs.annotations.TsUnionMember; import elemental2.core.JsArray; import elemental2.dom.CustomEventInit; -import elemental2.dom.DomGlobal; import elemental2.promise.IThenable.ThenOnFulfilledCallbackFn; import elemental2.promise.Promise; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.hierarchicaltable_pb.RollupRequest; @@ -38,27 +37,22 @@ import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.runchartdownsamplerequest.ZoomRange; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.ticket_pb.Ticket; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.ticket_pb.TypedTicket; -import io.deephaven.web.client.api.barrage.def.ColumnDefinition; import io.deephaven.web.client.api.barrage.def.TableAttributesDefinition; import io.deephaven.web.client.api.barrage.stream.ResponseStreamWrapper; import io.deephaven.web.client.api.batch.RequestBatcher; -import io.deephaven.web.client.api.batch.TableConfig; import io.deephaven.web.client.api.console.JsVariableType; import io.deephaven.web.client.api.filter.FilterCondition; -import io.deephaven.web.client.api.filter.FilterValue; import io.deephaven.web.client.api.input.JsInputTable; import io.deephaven.web.client.api.lifecycle.HasLifecycle; import io.deephaven.web.client.api.state.StateCache; +import io.deephaven.web.client.api.subscription.AbstractTableSubscription; import io.deephaven.web.client.api.subscription.TableSubscription; import io.deephaven.web.client.api.subscription.TableViewportSubscription; import io.deephaven.web.client.api.subscription.ViewportData; -import io.deephaven.web.client.api.subscription.ViewportData.MergeResults; -import io.deephaven.web.client.api.subscription.ViewportRow; import io.deephaven.web.client.api.tree.JsRollupConfig; import io.deephaven.web.client.api.tree.JsTreeTable; import io.deephaven.web.client.api.tree.JsTreeTableConfig; import io.deephaven.web.client.api.widget.JsWidget; -import io.deephaven.web.client.fu.JsData; import io.deephaven.web.client.fu.JsItr; import io.deephaven.web.client.fu.JsLog; import io.deephaven.web.client.fu.LazyPromise; @@ -66,14 +60,11 @@ import io.deephaven.web.client.state.ClientTableState; import io.deephaven.web.client.state.HasTableBinding; import io.deephaven.web.shared.data.*; -import io.deephaven.web.shared.data.TableSnapshot.SnapshotType; -import io.deephaven.web.shared.data.columns.ColumnData; import io.deephaven.web.shared.fu.JsConsumer; import io.deephaven.web.shared.fu.JsProvider; import io.deephaven.web.shared.fu.JsRunnable; import io.deephaven.web.shared.fu.RemoverFn; import javaemul.internal.annotations.DoNotAutobox; -import jsinterop.annotations.JsIgnore; import jsinterop.annotations.JsMethod; import jsinterop.annotations.JsNullable; import jsinterop.annotations.JsOptional; @@ -88,7 +79,6 @@ import java.util.*; import java.util.stream.Stream; -import static io.deephaven.web.client.api.subscription.ViewportData.NO_ROW_FORMAT_COLUMN; import static io.deephaven.web.client.fu.LazyPromise.logError; /** @@ -155,15 +145,11 @@ public class JsTable extends HasLifecycle implements HasTableBinding, JoinableTa // change in some table data INTERNAL_EVENT_SIZELISTENER = "sizelistener-internal"; - // Amount of debounce to use when eating snapshot events. - public static final int DEBOUNCE_TIME = 20; public static final int MAX_BATCH_TIME = 600_000; private final WorkerConnection workerConnection; - private Map subscriptions = new HashMap<>(); - @Deprecated // TODO refactor this inside of the viewportSubscription type - private ViewportData currentViewportData; + private final Map subscriptions = new HashMap<>(); private ClientTableState lastVisibleState; @@ -181,7 +167,6 @@ public class JsTable extends HasLifecycle implements HasTableBinding, JoinableTa private final int subscriptionId; private static int nextSubscriptionId; - private TableSubscription nonViewportSub; /** * Creates a new Table directly from an existing ClientTableState. The CTS manages all fetch operations, so this is @@ -312,7 +297,9 @@ public boolean isAlive() { @Override public ClientTableState state() { - assert currentState != null : "Table already closed, cannot be used again"; + if (currentState == null) { + throw new IllegalStateException("Table already closed, cannot be used again"); + } return currentState; } @@ -467,6 +454,7 @@ public double getSize() { if (isUncoalesced()) { return JsTable.SIZE_UNCOALESCED; } + // Only return the size from ETUM if we have no other choice return size; } @@ -486,10 +474,9 @@ public String getDescription() { */ @JsProperty public double getTotalSize() { - TableViewportSubscription subscription = subscriptions.get(getHandle()); - if (subscription != null && subscription.getStatus() == TableViewportSubscription.Status.ACTIVE) { - // only ask the viewport for the size if it is alive and ticking - return subscription.totalSize(); + if (state().getFilters().isEmpty()) { + // If there are no filters, use the subscription size (if any) + return getSize(); } return getHeadState().getSize(); } @@ -683,14 +670,14 @@ public JsArray getCustomColumns() { * Overload for Java (since JS just omits the optional params) */ public TableViewportSubscription setViewport(double firstRow, double lastRow) { - return setViewport(firstRow, lastRow, null, null); + return setViewport(firstRow, lastRow, null, null, null); } /** * Overload for Java (since JS just omits the optional param) */ public TableViewportSubscription setViewport(double firstRow, double lastRow, JsArray columns) { - return setViewport(firstRow, lastRow, columns, null); + return setViewport(firstRow, lastRow, columns, null, null); } /** @@ -709,13 +696,14 @@ public TableViewportSubscription setViewport(double firstRow, double lastRow, Js @JsMethod public TableViewportSubscription setViewport(double firstRow, double lastRow, @JsOptional @JsNullable JsArray columns, - @JsOptional @JsNullable Double updateIntervalMs) { - Column[] columnsCopy = columns != null ? Js.uncheckedCast(columns.slice()) : null; + @JsOptional @JsNullable Double updateIntervalMs, + @JsOptional @JsNullable Boolean isReverseViewport) { + Column[] columnsCopy = columns != null ? Js.uncheckedCast(columns.slice()) : state().getColumns(); ClientTableState currentState = state(); TableViewportSubscription activeSubscription = subscriptions.get(getHandle()); if (activeSubscription != null && activeSubscription.getStatus() != TableViewportSubscription.Status.DONE) { // hasn't finished, lets reuse it - activeSubscription.setInternalViewport(firstRow, lastRow, columnsCopy, updateIntervalMs); + activeSubscription.setInternalViewport(firstRow, lastRow, columnsCopy, updateIntervalMs, isReverseViewport); return activeSubscription; } else { // In the past, we left the old sub going until the new one was ready, then started the new one. But now, @@ -727,35 +715,23 @@ public TableViewportSubscription setViewport(double firstRow, double lastRow, // rewrap current state in a new one, when ready the viewport will be applied TableViewportSubscription replacement = - new TableViewportSubscription(firstRow, lastRow, columnsCopy, updateIntervalMs, this); + TableViewportSubscription.make(firstRow, lastRow, columnsCopy, updateIntervalMs, this); subscriptions.put(currentState.getHandle(), replacement); return replacement; } } - public void setInternalViewport(double firstRow, double lastRow, Column[] columns) { - if (firstRow > lastRow) { - throw new IllegalArgumentException(firstRow + " > " + lastRow); - } - if (firstRow < 0) { - throw new IllegalArgumentException(firstRow + " < " + 0); - } - currentViewportData = null; - // we must wait for the latest stack entry that can add columns (so we get an appropriate BitSet) - state().setDesiredViewport(this, (long) firstRow, (long) lastRow, columns); - } - /** * Gets the currently visible viewport. If the current set of operations has not yet resulted in data, it will not * resolve until that data is ready. If this table is closed before the promise resolves, it will be rejected - to * separate the lifespan of this promise from the table itself, call * {@link TableViewportSubscription#getViewportData()} on the result from {@link #setViewport(double, double)}. - * + * * @return Promise of {@link TableData} */ @JsMethod - public Promise getViewportData() { + public Promise getViewportData() { TableViewportSubscription subscription = subscriptions.get(getHandle()); if (subscription == null) { return Promise.reject("No viewport currently set"); @@ -763,20 +739,6 @@ public Promise getViewportData() { return subscription.getInternalViewportData(); } - public Promise getInternalViewportData() { - final LazyPromise promise = new LazyPromise<>(); - final ClientTableState active = state(); - active.onRunning(state -> { - if (currentViewportData == null) { - // no viewport data received yet; let's set up a one-shot UPDATED event listener - addEventListenerOneShot(EVENT_UPDATED, ignored -> promise.succeed(currentViewportData)); - } else { - promise.succeed(currentViewportData); - } - }, promise::fail, () -> promise.fail("Table closed before viewport data was read")); - return promise.asPromise(MAX_BATCH_TIME); - } - /** * Overload for java (since js just omits the optional var) */ @@ -798,20 +760,9 @@ public TableSubscription subscribe(JsArray columns) { */ @JsMethod public TableSubscription subscribe(JsArray columns, @JsOptional Double updateIntervalMs) { - assert nonViewportSub == null : "Can't directly subscribe to the 'private' table instance"; - // make a new table with a pUT call, listen to the subscription there return new TableSubscription(columns, this, updateIntervalMs); } - public void internalSubscribe(JsArray columns, TableSubscription sub) { - if (columns == null) { - columns = getColumns(); - } - this.nonViewportSub = sub; - - state().subscribe(this, Js.uncheckedCast(columns)); - } - /** * a new table containing the distinct tuples of values from the given columns that are present in the original * table. This table can be manipulated as any other table. Sorting is often desired as the default sort is the @@ -1512,7 +1463,6 @@ public void revive(ClientTableState state) { unsuppressEvents(); LazyPromise.runLater(() -> { fireEvent(EVENT_RECONNECT); - getBinding().maybeReviveSubscription(); }); } } @@ -1550,205 +1500,6 @@ public Promise downsample(LongWrapper[] zoomRange, int pixelCount, Stri .then(state -> Promise.resolve(new JsTable(workerConnection, state))); } - private final class Debounce { - private final ClientTableState state; - private final TableTicket handle; - private final SnapshotType type; - private final RangeSet includedRows; - private final BitSet columns; - private final Object[] dataColumns; - private final double timestamp; - private final long maxRows; - - public Debounce( - TableTicket table, - SnapshotType snapshotType, - RangeSet includedRows, - BitSet columns, - Object[] dataColumns, - long maxRows) { - this.handle = table; - this.type = snapshotType; - this.includedRows = includedRows; - this.columns = columns; - this.dataColumns = dataColumns; - this.state = currentState; - this.maxRows = maxRows; - timestamp = System.currentTimeMillis(); - } - - public boolean isEqual(Debounce o) { - if (type == o.type) { - // this is intentionally weird. We only want to debounce when one instance is column snapshot and the - // other is row snapshot, - // so we consider two events of the same type to be incompatible with debouncing. - return false; - } - if (handle != o.handle) { - assert !handle.equals(o.handle); - return false; - } - if (state != o.state) { - assert state.getHandle() != o.state.getHandle(); - return false; - } - if (!includedRows.equals(o.includedRows)) { - return false; - } - if (!columns.equals(o.columns)) { - return false; - } - if (maxRows != o.maxRows) { - return false; - } - assert Arrays.deepEquals(dataColumns, o.dataColumns) : "Debounce is broken, remove it."; - return true; - } - } - - private Debounce debounce; - - private void handleSnapshot(TableTicket table, SnapshotType snapshotType, RangeSet includedRows, - Object[] dataColumns, BitSet columns, long maxRows) { - assert table.equals(state().getHandle()) : "Table received incorrect snapshot"; - // if the type is initial_snapshot, we've already recorded the size, so only watch for the other two updates. - // note that this will sometimes result in multiple updates on startup, so we do this ugly debounce-dance. - // When IDS-2113 is fixed, we can likely remove this code. - JsLog.debug("Received snapshot for ", table, snapshotType, includedRows, dataColumns, columns); - Debounce operation = new Debounce(table, snapshotType, includedRows, columns, dataColumns, maxRows); - if (debounce == null) { - debounce = operation; - DomGlobal.setTimeout(ignored -> processSnapshot(), DEBOUNCE_TIME); - } else if (debounce.isEqual(operation)) { - // If we think the problem is fixed, we can put `assert false` here for a while before deleting Debounce - // class - JsLog.debug("Eating duplicated operation", debounce, operation); - } else { - processSnapshot(); - debounce = operation; - DomGlobal.setTimeout(ignored -> processSnapshot(), DEBOUNCE_TIME); - } - } - - public void handleSnapshot(TableTicket handle, TableSnapshot snapshot) { - if (!handle.equals(state().getHandle())) { - return; - } - Viewport viewport = getBinding().getSubscription(); - if (viewport == null || viewport.getRows() == null || viewport.getRows().size() == 0) { - // check out if we have a non-viewport sub attached - if (nonViewportSub != null) { - nonViewportSub.handleSnapshot(snapshot); - } - return; - } - - RangeSet viewportRows = viewport.getRows(); - JsLog.debug("handleSnapshot on " + viewportRows, handle, snapshot, viewport); - - RangeSet includedRows = snapshot.getIncludedRows(); - ColumnData[] dataColumns = snapshot.getDataColumns(); - JsArray[] remappedData = new JsArray[dataColumns.length]; - // remap dataColumns to the expected range for that table's viewport - long lastRow = -1; - for (int col = viewport.getColumns().nextSetBit(0); col >= 0; col = viewport.getColumns().nextSetBit(col + 1)) { - ColumnData dataColumn = dataColumns[col]; - if (dataColumn == null) { - // skip this, at least one column requested by that table isn't present, waiting on a later update - // TODO when IDS-2138 is fixed stop throwing this data away - return; - } - Object columnData = dataColumn.getData(); - - final ColumnDefinition def = state().getTableDef().getColumns()[col]; - remappedData[col] = JsData.newArray(def.getType()); - - PrimitiveIterator.OfLong viewportIterator = viewportRows.indexIterator(); - PrimitiveIterator.OfLong includedRowsIterator = includedRows.indexIterator(); - int dataIndex = 0; - while (viewportIterator.hasNext()) { - long viewportIndex = viewportIterator.nextLong(); - if (viewportIndex >= snapshot.getTableSize()) { - // reached or passed the end of the table, we'll still make a snapshot - break; - } - if (!includedRowsIterator.hasNext()) { - // we've reached the end, the viewport apparently goes past the end of what the server sent, - // so there is another snapshot on its way - // TODO when IDS-2138 is fixed stop throwing this data away - return; - } - - long possibleMatch = includedRowsIterator.nextLong(); - while (includedRowsIterator.hasNext() && possibleMatch < viewportIndex) { - dataIndex++;// skip, still seeking to the next item - - possibleMatch = includedRowsIterator.nextLong(); - } - if (!includedRowsIterator.hasNext() && possibleMatch < viewportIndex) { - // we didn't find any items which match, just give up - return; - } - - if (possibleMatch > viewportIndex) { - // if we hit a gap (more data coming, doesn't match viewport), skip the - // rest of this table entirely, a later update will get us caught up - return; - } - Object data = Js.>uncheckedCast(columnData).getAt(dataIndex); - remappedData[col].push(data); - dataIndex++;// increment for the next row - - // Track how many rows were actually present, allowing the snapshot to stop before the viewport's end - lastRow = Math.max(lastRow, possibleMatch); - } - } - - // TODO correct this - assumes max one range per table viewport, and nothing skipped - RangeSet actualViewport = - lastRow == -1 ? RangeSet.empty() : RangeSet.ofRange(viewportRows.indexIterator().nextLong(), lastRow); - - handleSnapshot(handle, snapshot.getSnapshotType(), actualViewport, remappedData, viewport.getColumns(), - viewportRows.size()); - } - - @JsIgnore - public void processSnapshot() { - try { - if (debounce == null) { - JsLog.debug("Skipping snapshot b/c debounce is null"); - return; - } - if (debounce.state != currentState) { - JsLog.debug("Skipping snapshot because state has changed ", debounce.state, " != ", currentState); - return; - } - if (isClosed()) { - JsLog.debug("Skipping snapshot because table is closed", this); - return; - } - JsArray viewportColumns = - getColumns().filter((item, index) -> debounce.columns.get(item.getIndex())); - ViewportData data = new ViewportData(debounce.includedRows, debounce.dataColumns, viewportColumns, - currentState.getRowFormatColumn() == null ? NO_ROW_FORMAT_COLUMN - : currentState.getRowFormatColumn().getIndex(), - debounce.maxRows); - this.currentViewportData = data; - CustomEventInit updatedEvent = CustomEventInit.create(); - updatedEvent.setDetail(data); - fireEvent(EVENT_UPDATED, updatedEvent); - - // also fire rowadded events - TODO also fire some kind of remove event for now-missing rows? - for (int i = 0; i < data.getRows().length; i++) { - CustomEventInit addedEvent = CustomEventInit.create(); - addedEvent.setDetail(wrap(data.getRows().getAt(i), i)); - fireEvent(EVENT_ROWADDED, addedEvent); - } - } finally { - debounce = null; - } - } - /** * True if this table has been closed. * @@ -1788,59 +1539,6 @@ public String getPluginName() { return lastVisibleState().getTableDef().getAttributes().getPluginName(); } - // Factored out so that we always apply the same format - private Object wrap(ViewportRow at, int index) { - return JsPropertyMap.of("row", at, "index", (double) index); - } - - public void handleDelta(ClientTableState current, DeltaUpdates updates) { - current.onRunning(s -> { - if (current != state()) { - return; - } - if (nonViewportSub != null) { - nonViewportSub.handleDelta(updates); - return; - } - final ViewportData vpd = currentViewportData; - if (vpd == null) { - // if the current viewport data is null, we're waiting on an initial snapshot to arrive for a different - // part of the viewport - JsLog.debug("Received delta while waiting for reinitialization"); - return; - } - MergeResults mergeResults = vpd.merge(updates); - if (mergeResults.added.size() == 0 && mergeResults.modified.size() == 0 - && mergeResults.removed.size() == 0) { - return; - } - CustomEventInit event = CustomEventInit.create(); - event.setDetail(vpd); - // user might call setViewport, and wind up nulling our currentViewportData - fireEvent(EVENT_UPDATED, event); - - // fire rowadded/rowupdated/rowremoved - // TODO when we keep more rows loaded than the user is aware of, check if a given row is actually in the - // viewport - // here - for (Integer index : mergeResults.added) { - CustomEventInit addedEvent = CustomEventInit.create(); - addedEvent.setDetail(wrap(vpd.getRows().getAt(index), index)); - fireEvent(EVENT_ROWADDED, addedEvent); - } - for (Integer index : mergeResults.modified) { - CustomEventInit addedEvent = CustomEventInit.create(); - addedEvent.setDetail(wrap(vpd.getRows().getAt(index), index)); - fireEvent(EVENT_ROWUPDATED, addedEvent); - } - for (Integer index : mergeResults.removed) { - CustomEventInit addedEvent = CustomEventInit.create(); - addedEvent.setDetail(wrap(vpd.getRows().getAt(index), index)); - fireEvent(EVENT_ROWREMOVED, addedEvent); - } - }, JsRunnable.doNothing()); - } - @Override public TableTicket getHandle() { return state().getHandle(); @@ -1875,62 +1573,6 @@ public WorkerConnection getConnection() { return workerConnection; } - public void refreshViewport(ClientTableState state, Viewport vp) { - assert state() == state : "Called refreshViewport with wrong state (" + state + " instead of " + state() + ")"; - assert state.getResolution() == ClientTableState.ResolutionState.RUNNING - : "Do not call refreshViewport for a state that is not running! (" + state + ")"; - - currentViewportData = null; // ignore any deltas for past viewports - workerConnection.scheduleCheck(state); - // now that we've made sure the server knows, if we already know that the viewport is beyond what exists, we - // can go ahead and fire an update event. We're in the onResolved call, so we know the handle has resolved - // and if size is not -1, then we've already at least gotten the initial snapshot (otherwise, that snapshot - // will be here soon, and will fire its own event) - if (state.getSize() != ClientTableState.SIZE_UNINITIALIZED && state.getSize() <= vp.getRows().getFirstRow()) { - JsLog.debug("Preparing to send a 'fake' update event since " + state.getSize() + "<=" - + vp.getRows().getFirstRow(), state); - LazyPromise.runLater(() -> { - if (state != state()) { - return; - } - - // get the column expected to be in the snapshot - JsArray columns = Js.uncheckedCast(getBinding().getColumns()); - Column[] allColumns = state.getColumns(); - if (columns == null) { - columns = Js.uncheckedCast(allColumns); - } - // build an array of empty column data for this snapshot - Object[] dataColumns = new Object[allColumns.length]; - - for (int i = 0; i < columns.length; i++) { - Column c = columns.getAt(i); - dataColumns[c.getIndex()] = JsData.newArray(c.getType()); - if (c.getFormatStringColumnIndex() != null) { - dataColumns[c.getFormatStringColumnIndex()] = JsData.newArray("java.lang.String"); - } - if (c.getStyleColumnIndex() != null) { - dataColumns[c.getStyleColumnIndex()] = JsData.newArray("long"); - } - } - if (currentState.getRowFormatColumn() != null) { - dataColumns[currentState.getRowFormatColumn().getIndex()] = JsData.newArray("long"); - } - - ViewportData data = new ViewportData(RangeSet.empty(), dataColumns, columns, - currentState.getRowFormatColumn() == null ? NO_ROW_FORMAT_COLUMN - : currentState.getRowFormatColumn().getIndex(), - 0); - this.currentViewportData = data; - CustomEventInit updatedEvent = CustomEventInit.create(); - updatedEvent.setDetail(data); - JsLog.debug("Sending 'fake' update event since " + state.getSize() + "<=" + vp.getRows().getFirstRow(), - vp, state); - fireEvent(EVENT_UPDATED, updatedEvent); - }); - } - } - public boolean isActive(ClientTableState state) { return currentState == state; } @@ -2110,7 +1752,10 @@ public int getSubscriptionId() { @Override public void maybeReviveSubscription() { - getBinding().maybeReviveSubscription(); + TableViewportSubscription viewportSubscription = subscriptions.get(getHandle()); + if (viewportSubscription != null) { + viewportSubscription.revive(); + } } } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/JsTotalsTable.java b/web/client-api/src/main/java/io/deephaven/web/client/api/JsTotalsTable.java index 652bfd4f55f..0bab10ea1d5 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/JsTotalsTable.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/JsTotalsTable.java @@ -5,14 +5,16 @@ import com.vertispan.tsdefs.annotations.TsInterface; import com.vertispan.tsdefs.annotations.TsName; +import com.vertispan.tsdefs.annotations.TsTypeRef; import elemental2.core.JsArray; import elemental2.core.JsString; import elemental2.dom.CustomEvent; -import elemental2.dom.Event; import elemental2.promise.Promise; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.ticket_pb.TypedTicket; import io.deephaven.web.client.api.console.JsVariableType; import io.deephaven.web.client.api.filter.FilterCondition; +import io.deephaven.web.client.api.subscription.AbstractTableSubscription; +import io.deephaven.web.client.api.subscription.ViewportData; import io.deephaven.web.client.state.ClientTableState; import io.deephaven.web.shared.fu.RemoverFn; import jsinterop.annotations.JsIgnore; @@ -66,7 +68,7 @@ public JsTotalsTable(JsTable wrappedTable, String directive, JsArray gro public void refreshViewport() { if (firstRow != null && lastRow != null) { - setViewport(firstRow, lastRow, Js.uncheckedCast(columns), updateIntervalMs); + setViewport(firstRow, lastRow, Js.uncheckedCast(columns), updateIntervalMs, null); } } @@ -109,12 +111,12 @@ public JsTotalsTableConfig getTotalsTableConfig() { */ @JsMethod public void setViewport(double firstRow, double lastRow, @JsOptional JsArray columns, - @JsOptional Double updateIntervalMs) { + @JsOptional Double updateIntervalMs, @JsOptional @JsNullable Boolean isReverseViewport) { this.firstRow = firstRow; this.lastRow = lastRow; this.columns = columns != null ? Js.uncheckedCast(columns.slice()) : null; this.updateIntervalMs = updateIntervalMs; - wrappedTable.setViewport(firstRow, lastRow, columns, updateIntervalMs); + wrappedTable.setViewport(firstRow, lastRow, columns, updateIntervalMs, isReverseViewport); } /** @@ -124,7 +126,7 @@ public void setViewport(double firstRow, double lastRow, @JsOptional JsArray getViewportData() { + public Promise getViewportData() { return wrappedTable.getViewportData(); } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/LongWrapper.java b/web/client-api/src/main/java/io/deephaven/web/client/api/LongWrapper.java index ec679c0442a..ea2647184b0 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/LongWrapper.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/LongWrapper.java @@ -3,6 +3,7 @@ // package io.deephaven.web.client.api; +import io.deephaven.util.QueryConstants; import jsinterop.annotations.JsIgnore; import jsinterop.annotations.JsType; @@ -12,6 +13,9 @@ public class LongWrapper { @JsIgnore public static LongWrapper of(long value) { + if (value == QueryConstants.NULL_LONG) { + return null; + } return new LongWrapper(value); } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/TableData.java b/web/client-api/src/main/java/io/deephaven/web/client/api/TableData.java index 5018db59ab7..19df98c4221 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/TableData.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/TableData.java @@ -3,11 +3,11 @@ // package io.deephaven.web.client.api; -import com.vertispan.tsdefs.annotations.TsName; import com.vertispan.tsdefs.annotations.TsTypeRef; import com.vertispan.tsdefs.annotations.TsUnion; import com.vertispan.tsdefs.annotations.TsUnionMember; import elemental2.core.JsArray; +import jsinterop.annotations.JsIgnore; import jsinterop.annotations.JsMethod; import jsinterop.annotations.JsOverlay; import jsinterop.annotations.JsPackage; @@ -17,13 +17,25 @@ import jsinterop.base.Js; /** - * Common interface for various ways of accessing table data and formatting. - * + * Common interface for various ways of accessing table data and formatting for viewport or non-viewport subscriptions + * on tables, data in trees, and snapshots. + *

+ * Generally speaking, it is more efficient to access data in column-major order, rather than iterating through each Row + * and accessing all columns that it holds. The {@link #getRows()} accessor can be useful to read row data, but may + * incur other costs - it is likely faster to access data by columns using {@link #getData(RowPositionUnion, Column)}. + */ +/* * Java note: this interface contains some extra overloads that aren't available in JS. Implementations are expected to * implement only abstract methods, and default methods present in this interface will dispatch accordingly. */ -@TsName(namespace = "dh") +@JsType(namespace = "dh") public interface TableData { + @JsIgnore + int NO_ROW_FORMAT_COLUMN = -1; + + /** + * TS type union to allow either "int" or "LongWrapper" to be passed as an argument for various methods. + */ @TsUnion @JsType(name = "?", namespace = JsPackage.GLOBAL, isNative = true) interface RowPositionUnion { @@ -53,9 +65,18 @@ default int asInt() { @JsProperty JsArray getColumns(); + /** + * A lazily computed array of all rows available on the client. + */ @JsProperty JsArray<@TsTypeRef(Row.class) ? extends Row> getRows(); + /** + * Reads a row object from the table, from which any subscribed column can be read. + * + * @param index the position or key to access + * @return the row at the given location + */ @JsMethod default Row get(RowPositionUnion index) { if (index.isLongWrapper()) { @@ -64,10 +85,20 @@ default Row get(RowPositionUnion index) { return get(Js.coerceToInt(index)); } + @JsIgnore Row get(long index); + @JsIgnore Row get(int index); + /** + * Reads a specific cell from the table, by row key and column. + * + * @param index the row in the table to get data from + * @param column the column to read + * @return the value in the table + */ + // TODO (deephaven-core#5927) Consider a get/fillChunk API as an efficient alternative @JsMethod default Any getData(RowPositionUnion index, Column column) { if (index.isLongWrapper()) { @@ -76,10 +107,19 @@ default Any getData(RowPositionUnion index, Column column) { return getData(index.asInt(), column); } + @JsIgnore Any getData(int index, Column column); + @JsIgnore Any getData(long index, Column column); + /** + * The server-specified Format to use for the cell at the given position. + * + * @param index the row to read + * @param column the column to read + * @return a Format instance with any server-specified details + */ @JsMethod default Format getFormat(RowPositionUnion index, Column column) { if (index.isLongWrapper()) { @@ -88,12 +128,19 @@ default Format getFormat(RowPositionUnion index, Column column) { return getFormat(index.asInt(), column); } + @JsIgnore Format getFormat(int index, Column column); + @JsIgnore Format getFormat(long index, Column column); - @TsName(namespace = "dh") - public interface Row { + /** + * Represents a row available in a subscription/snapshot on the client. Do not retain references to rows - they will + * not function properly when the event isn't actively going off (or promise resolving). Instead, wait for the next + * event, or re-request the viewport data. + */ + @JsType(namespace = "dh") + interface Row { @JsProperty LongWrapper getIndex(); diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/WorkerConnection.java b/web/client-api/src/main/java/io/deephaven/web/client/api/WorkerConnection.java index ab88008a3de..239dd2efbd0 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/WorkerConnection.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/WorkerConnection.java @@ -3,6 +3,7 @@ // package io.deephaven.web.client.api; +import com.google.flatbuffers.FlatBufferBuilder; import com.vertispan.tsdefs.annotations.TsIgnore; import elemental2.core.JsArray; import elemental2.core.JsObject; @@ -12,33 +13,17 @@ import elemental2.dom.CustomEventInit; import elemental2.dom.DomGlobal; import elemental2.promise.Promise; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.FieldNode; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.Message; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.MessageHeader; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.RecordBatch; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Buffer; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Field; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.KeyValue; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.MetadataVersion; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Schema; import io.deephaven.javascript.proto.dhinternal.arrow.flight.protocol.browserflight_pb_service.BrowserFlightServiceClient; import io.deephaven.javascript.proto.dhinternal.arrow.flight.protocol.flight_pb.FlightData; import io.deephaven.javascript.proto.dhinternal.arrow.flight.protocol.flight_pb_service.FlightServiceClient; import io.deephaven.javascript.proto.dhinternal.browserheaders.BrowserHeaders; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Long; import io.deephaven.javascript.proto.dhinternal.grpcweb.grpc.Code; import io.deephaven.javascript.proto.dhinternal.grpcweb.grpc.UnaryOutput; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageMessageType; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageMessageWrapper; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageSubscriptionOptions; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageSubscriptionRequest; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageUpdateMetadata; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.ColumnConversionMode; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.application_pb.FieldInfo; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.application_pb.FieldsChangeUpdate; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.application_pb.ListFieldsRequest; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.application_pb_service.ApplicationServiceClient; +import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.config_pb.ConfigValue; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.config_pb.ConfigurationConstantsRequest; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.config_pb.ConfigurationConstantsResponse; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.config_pb_service.ConfigService; @@ -71,7 +56,6 @@ import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.ticket_pb.Ticket; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.ticket_pb.TypedTicket; import io.deephaven.web.client.api.barrage.WebBarrageUtils; -import io.deephaven.web.client.api.barrage.def.ColumnDefinition; import io.deephaven.web.client.api.barrage.def.InitialTableDefinition; import io.deephaven.web.client.api.barrage.stream.BiDiStream; import io.deephaven.web.client.api.barrage.stream.ResponseStreamWrapper; @@ -96,22 +80,25 @@ import io.deephaven.web.client.state.ClientTableState; import io.deephaven.web.client.state.HasTableBinding; import io.deephaven.web.client.state.TableReviver; -import io.deephaven.web.shared.data.DeltaUpdates; -import io.deephaven.web.shared.data.RangeSet; -import io.deephaven.web.shared.data.TableSnapshot; -import io.deephaven.web.shared.data.TableSubscriptionRequest; import io.deephaven.web.shared.fu.JsConsumer; import io.deephaven.web.shared.fu.JsRunnable; import jsinterop.annotations.JsMethod; import jsinterop.annotations.JsOptional; import jsinterop.base.Js; import jsinterop.base.JsPropertyMap; +import org.apache.arrow.flatbuf.Buffer; +import org.apache.arrow.flatbuf.Field; +import org.apache.arrow.flatbuf.FieldNode; +import org.apache.arrow.flatbuf.KeyValue; +import org.apache.arrow.flatbuf.Message; +import org.apache.arrow.flatbuf.MessageHeader; +import org.apache.arrow.flatbuf.MetadataVersion; +import org.apache.arrow.flatbuf.RecordBatch; +import org.apache.arrow.flatbuf.Schema; import javax.annotation.Nullable; -import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; -import java.util.BitSet; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -123,12 +110,6 @@ import java.util.stream.Collectors; import static io.deephaven.web.client.api.CoreClient.EVENT_REFRESH_TOKEN_UPDATED; -import static io.deephaven.web.client.api.barrage.WebBarrageUtils.DeltaUpdatesBuilder; -import static io.deephaven.web.client.api.barrage.WebBarrageUtils.createSnapshot; -import static io.deephaven.web.client.api.barrage.WebBarrageUtils.deltaUpdates; -import static io.deephaven.web.client.api.barrage.WebBarrageUtils.makeUint8ArrayFromBitset; -import static io.deephaven.web.client.api.barrage.WebBarrageUtils.serializeRanges; -import static io.deephaven.web.client.api.barrage.WebBarrageUtils.typedArrayToLittleEndianByteBuffer; import static io.deephaven.web.client.api.barrage.WebGrpcUtils.CLIENT_OPTIONS; /** @@ -205,7 +186,6 @@ private enum State { private final Set flushable = new HashSet<>(); private final JsSet> logCallbacks = new JsSet<>(); - private final Map> subscriptionStreams = new HashMap<>(); private ResponseStreamWrapper exportNotifications; private JsSet simpleReconnectableInstances = new JsSet<>(); @@ -220,6 +200,8 @@ private enum State { private Map knownFields = new HashMap<>(); private ResponseStreamWrapper fieldsChangeUpdateStream; + private ConfigurationConstantsResponse constants; + public WorkerConnection(QueryConnectable info) { this.info = info; this.config = new ClientConfiguration(); @@ -306,7 +288,6 @@ private void connectToWorker() { ClientTableState[] hasActiveSubs = cache.getAllStates().stream() .peek(cts -> { cts.getHandle().setConnected(false); - cts.setSubscribed(false); cts.forActiveLifecycles(item -> { assert !(item instanceof JsTable) || ((JsTable) item).state() == cts @@ -501,11 +482,11 @@ this, ConfigService.GetConfigurationConstants, new ConfigurationConstantsRequest } // Read the timeout from the server, we'll refresh at less than that - result.getMessage().getConfigValuesMap().forEach((item, key) -> { - if (key.equals("http.session.durationMs")) { - sessionTimeoutMs = Double.parseDouble(item.getStringValue()); - } - }); + constants = result.getMessage(); + ConfigValue sessionDuration = constants.getConfigValuesMap().get("http.session.durationMs"); + if (sessionDuration != null && sessionDuration.hasStringValue()) { + sessionTimeoutMs = Double.parseDouble(sessionDuration.getStringValue()); + } // schedule an update based on our currently configured delay scheduledAuthUpdate = DomGlobal.setTimeout(ignore -> { @@ -563,52 +544,10 @@ private void subscribeToTerminationNotification() { }); } - // @Override - public void initialSnapshot(TableTicket handle, TableSnapshot snapshot) { - LazyPromise.runLater(() -> { - // notify table that it has a snapshot available to replace viewport rows - // TODO looping in this way is not ideal, means that we're roughly O(n*m), where - // n is the number of rows, and m the number of tables with viewports. - // Instead, we should track all rows here in WorkerConnection, and then - // tell every table who might be interested about the rows it is interested in. - if (!cache.get(handle).isPresent()) { - JsLog.debug("Discarding snapshot for ", handle, " : ", snapshot); - } - cache.get(handle).ifPresent(s -> { - s.setSize(snapshot.getTableSize()); - s.forActiveTables(table -> { - table.handleSnapshot(handle, snapshot); - }); - }); - }); - } - - // @Override - public void incrementalUpdates(TableTicket tableHandle, DeltaUpdates updates) { - LazyPromise.runLater(() -> { - // notify table that it has individual row updates - final Optional cts = cache.get(tableHandle); - if (!cts.isPresent()) { - JsLog.debug("Discarding delta for disconnected state ", tableHandle, " : ", updates); - } - JsLog.debug("Delta received", tableHandle, updates); - cts.ifPresent(s -> { - if (!s.isSubscribed()) { - JsLog.debug("Discarding delta for unsubscribed table", tableHandle, updates); - return; - } - s.handleDelta(updates); - }); - }); - } - // @Override public void exportedTableUpdateMessage(TableTicket clientId, long size) { cache.get(clientId).ifPresent(state -> { - if (!state.isSubscribed()) { - // not presently subscribed so this is the only way to be informed of size changes - state.setSize(size); - } + state.setSize(size); }); } @@ -1080,12 +1019,12 @@ public Promise newTable(String[] columnNames, String[] types, Object[][ dataRef[0] = null; // make a schema that we can embed in the first DoPut message - Builder schema = new Builder(1024); + FlatBufferBuilder schema = new FlatBufferBuilder(1024); // while we're examining columns, build the copiers for data List columns = new ArrayList<>(); - double[] fields = new double[columnNames.length]; + int[] fields = new int[columnNames.length]; for (int i = 0; i < columnNames.length; i++) { String columnName = columnNames[i]; String columnType = types[i]; @@ -1093,9 +1032,9 @@ public Promise newTable(String[] columnNames, String[] types, Object[][ JsDataHandler writer = JsDataHandler.getHandler(columnType); columns.add(writer); - double nameOffset = schema.createString(columnName); - double typeOffset = writer.writeType(schema); - double metadataOffset = Field.createCustomMetadataVector(schema, new double[] { + int nameOffset = schema.createString(columnName); + int typeOffset = writer.writeType(schema); + int metadataOffset = Field.createCustomMetadataVector(schema, new int[] { KeyValue.createKeyValue(schema, schema.createString("deephaven:type"), schema.createString(writer.deephavenType())) }); @@ -1110,7 +1049,7 @@ public Promise newTable(String[] columnNames, String[] types, Object[][ fields[i] = Field.endField(schema); } - double fieldsOffset = Schema.createFieldsVector(schema, fields); + int fieldsOffset = Schema.createFieldsVector(schema, fields); Schema.startSchema(schema); Schema.addFields(schema, fieldsOffset); @@ -1152,7 +1091,7 @@ public Promise newTable(String[] columnNames, String[] types, Object[][ FlightData bodyMessage = new FlightData(); bodyMessage.setAppMetadata(WebBarrageUtils.emptyMessage()); - Builder bodyData = new Builder(1024); + FlatBufferBuilder bodyData = new FlatBufferBuilder(1024); // iterate each column, building buffers and fieldnodes, as well as building the actual payload List buffers = new ArrayList<>(); @@ -1176,25 +1115,25 @@ public Promise newTable(String[] columnNames, String[] types, Object[][ for (int i = buffers.size() - 1; i >= 0; i--) { Uint8Array buffer = buffers.get(i); cumulativeOffset -= buffer.byteLength; - Buffer.createBuffer(bodyData, Long.create(cumulativeOffset, 0), Long.create(buffer.byteLength, 0)); + Buffer.createBuffer(bodyData, cumulativeOffset, buffer.byteLength); } assert cumulativeOffset == 0; - double buffersOffset = bodyData.endVector(); + int buffersOffset = bodyData.endVector(); RecordBatch.startNodesVector(bodyData, nodes.size()); for (int i = nodes.size() - 1; i >= 0; i--) { JsDataHandler.Node node = nodes.get(i); - FieldNode.createFieldNode(bodyData, Long.create(node.length(), 0), Long.create(node.nullCount(), 0)); + FieldNode.createFieldNode(bodyData, node.length(), node.nullCount()); } - double nodesOffset = bodyData.endVector(); + int nodesOffset = bodyData.endVector(); RecordBatch.startRecordBatch(bodyData); RecordBatch.addBuffers(bodyData, buffersOffset); RecordBatch.addNodes(bodyData, nodesOffset); - RecordBatch.addLength(bodyData, Long.create(data[0].length, 0)); + RecordBatch.addLength(bodyData, data[0].length); - double recordBatchOffset = RecordBatch.endRecordBatch(bodyData); + int recordBatchOffset = RecordBatch.endRecordBatch(bodyData); bodyMessage.setDataHeader(createMessage(bodyData, MessageHeader.RecordBatch, recordBatchOffset, length, 0)); bodyMessage.setDataBody(padAndConcat(buffers, length)); @@ -1215,11 +1154,11 @@ private Uint8Array padAndConcat(List buffers, int length) { return all; } - private static Uint8Array createMessage(Builder payload, int messageHeaderType, double messageHeaderOffset, - int bodyLength, double customMetadataOffset) { + private static Uint8Array createMessage(FlatBufferBuilder payload, byte messageHeaderType, int messageHeaderOffset, + int bodyLength, int customMetadataOffset) { payload.finish(Message.createMessage(payload, MetadataVersion.V5, messageHeaderType, messageHeaderOffset, - Long.create(bodyLength, 0), customMetadataOffset)); - return payload.asUint8Array(); + bodyLength, customMetadataOffset)); + return WebBarrageUtils.bbToUint8ArrayView(payload.dataBuffer()); } public Promise mergeTables(JsTable[] tables, HasEventHandling failHandler) { @@ -1323,7 +1262,7 @@ public StateCache getCache() { } /** - * Schedules a deferred command to check the given state for active tables and adjust viewports accordingly. + * Schedules a deferred command to check the given state for active tables. */ public void scheduleCheck(ClientTableState state) { if (flushable.isEmpty()) { @@ -1348,209 +1287,23 @@ public void releaseTicket(Ticket ticket) { sessionServiceClient.release(releaseRequest, metadata, null); } - - /** - * For those calls where we don't really care what happens - */ - private static final Callback DONOTHING_CALLBACK = new Callback() { - @Override - public void onSuccess(Void value) { - // Do nothing. - } - - @Override - public void onFailure(String error) { - JsLog.error("Callback failed: " + error); - } - }; - private void flush() { - // LATER: instead of running a bunch of serial operations, - // condense these all into a single batch operation. - // All three server calls made by this method are _only_ called by this method, - // so we can reasonably merge all three into a single batched operation. ArrayList statesToFlush = new ArrayList<>(flushable); flushable.clear(); - for (ClientTableState state : statesToFlush) { - if (state.hasNoSubscriptions()) { - // state may be retained if it is held by at least one paused binding; - // it is either an unsubscribed active table, an interim state for an - // active table, or a pending rollback for an operation that has not - // yet completed (we leave orphaned nodes paused until a request completes). - if (state.isSubscribed()) { - state.setSubscribed(false); + if (state.isEmpty()) { + // completely empty; perform release + final ClientTableState.ResolutionState previousState = state.getResolution(); + state.setResolution(ClientTableState.ResolutionState.RELEASED); + if (previousState != ClientTableState.ResolutionState.RELEASED) { + cache.release(state); + + JsLog.debug("Releasing state", state, LazyString.of(state.getHandle())); + // don't send a release message to the server if the table isn't really there if (state.getHandle().isConnected()) { - BiDiStream stream = subscriptionStreams.remove(state); - if (stream != null) { - stream.end(); - stream.cancel(); - } - } - } - - if (state.isEmpty()) { - // completely empty; perform release - final ClientTableState.ResolutionState previousState = state.getResolution(); - state.setResolution(ClientTableState.ResolutionState.RELEASED); - state.setSubscribed(false); - if (previousState != ClientTableState.ResolutionState.RELEASED) { - cache.release(state); - - JsLog.debug("Releasing state", state, LazyString.of(state.getHandle())); - // don't send a release message to the server if the table isn't really there - if (state.getHandle().isConnected()) { - releaseHandle(state.getHandle()); - } - } - } - } else if (state.isRunning()) { - List vps = new ArrayList<>(); - state.forActiveSubscriptions((table, subscription) -> { - assert table.isActive(state) : "Inactive table has a viewport still attached"; - vps.add(new TableSubscriptionRequest(table.getSubscriptionId(), subscription.getRows(), - subscription.getColumns())); - }); - - boolean isViewport = vps.stream().allMatch(req -> req.getRows() != null); - assert isViewport || vps.stream().noneMatch(req -> req.getRows() != null) - : "All subscriptions to a given handle must be consistently viewport or non-viewport"; - - - BitSet includedColumns = vps.stream().map(TableSubscriptionRequest::getColumns).reduce((bs1, bs2) -> { - BitSet result = new BitSet(); - result.or(bs1); - result.or(bs2); - return result; - }).orElseThrow(() -> new IllegalStateException("Cannot call subscribe with zero subscriptions")); - String[] columnTypes = Arrays.stream(state.getTableDef().getColumns()) - .map(ColumnDefinition::getType) - .toArray(String[]::new); - - state.setSubscribed(true); - - Builder subscriptionReq = new Builder(1024); - - double columnsOffset = BarrageSubscriptionRequest.createColumnsVector(subscriptionReq, - makeUint8ArrayFromBitset(includedColumns)); - double viewportOffset = 0; - if (isViewport) { - viewportOffset = BarrageSubscriptionRequest.createViewportVector(subscriptionReq, serializeRanges( - vps.stream().map(TableSubscriptionRequest::getRows).collect(Collectors.toSet()))); - } - // TODO #188 support minUpdateIntervalMs - double serializationOptionsOffset = BarrageSubscriptionOptions - .createBarrageSubscriptionOptions(subscriptionReq, ColumnConversionMode.Stringify, true, 1000, - 0, 0); - double tableTicketOffset = - BarrageSubscriptionRequest.createTicketVector(subscriptionReq, state.getHandle().getTicket()); - BarrageSubscriptionRequest.startBarrageSubscriptionRequest(subscriptionReq); - BarrageSubscriptionRequest.addColumns(subscriptionReq, columnsOffset); - BarrageSubscriptionRequest.addSubscriptionOptions(subscriptionReq, serializationOptionsOffset); - BarrageSubscriptionRequest.addViewport(subscriptionReq, viewportOffset); - BarrageSubscriptionRequest.addTicket(subscriptionReq, tableTicketOffset); - subscriptionReq.finish(BarrageSubscriptionRequest.endBarrageSubscriptionRequest(subscriptionReq)); - - FlightData request = new FlightData(); - request.setAppMetadata( - WebBarrageUtils.wrapMessage(subscriptionReq, BarrageMessageType.BarrageSubscriptionRequest)); - - BiDiStream stream = this.streamFactory().create( - headers -> flightServiceClient.doExchange(headers), - (first, headers) -> browserFlightServiceClient.openDoExchange(first, headers), - (next, headers, c) -> browserFlightServiceClient.nextDoExchange(next, headers, c::apply), - new FlightData()); - - stream.send(request); - stream.onData(new JsConsumer() { - @Override - public void apply(FlightData data) { - ByteBuffer body = typedArrayToLittleEndianByteBuffer(data.getDataBody_asU8()); - Message headerMessage = Message - .getRootAsMessage(new io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer( - data.getDataHeader_asU8())); - if (body.limit() == 0 && headerMessage.headerType() != MessageHeader.RecordBatch) { - // a subscription stream presently ignores schemas and other message types - // TODO hang on to the schema to better handle the now-Utf8 columns - return; - } - RecordBatch header = headerMessage.header(new RecordBatch()); - BarrageMessageWrapper barrageMessageWrapper = - BarrageMessageWrapper.getRootAsBarrageMessageWrapper( - new io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer( - data.getAppMetadata_asU8())); - if (barrageMessageWrapper.msgType() == BarrageMessageType.None) { - // continue previous message, just read RecordBatch - appendAndMaybeFlush(header, body); - } else { - assert barrageMessageWrapper.msgType() == BarrageMessageType.BarrageUpdateMetadata; - BarrageUpdateMetadata barrageUpdate = BarrageUpdateMetadata.getRootAsBarrageUpdateMetadata( - new io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer( - new Uint8Array(barrageMessageWrapper.msgPayloadArray()))); - startAndMaybeFlush(barrageUpdate.isSnapshot(), header, body, barrageUpdate, isViewport, - columnTypes); - } + releaseHandle(state.getHandle()); } - - private DeltaUpdatesBuilder nextDeltaUpdates; - private DeltaUpdates deferredDeltaUpdates; - - private void appendAndMaybeFlush(RecordBatch header, ByteBuffer body) { - // using existing barrageUpdate, append to the current snapshot/delta - assert nextDeltaUpdates != null; - boolean shouldFlush = nextDeltaUpdates.appendRecordBatch(header, body); - if (shouldFlush) { - DeltaUpdates updates = nextDeltaUpdates.build(); - nextDeltaUpdates = null; - - if (state.getTableDef().getAttributes().isBlinkTable()) { - // blink tables remove all rows from the previous step, if there are no adds this step - // then defer removal until new data arrives -- this makes blink tables GUI friendly - if (updates.getAdded().isEmpty()) { - if (deferredDeltaUpdates != null) { - final RangeSet removed = deferredDeltaUpdates.getRemoved(); - updates.getRemoved().rangeIterator().forEachRemaining(removed::addRange); - } else { - deferredDeltaUpdates = updates; - } - return; - } else if (deferredDeltaUpdates != null) { - assert updates.getRemoved().isEmpty() - : "Blink table received two consecutive remove rowsets"; - updates.setRemoved(deferredDeltaUpdates.getRemoved()); - deferredDeltaUpdates = null; - } - } - incrementalUpdates(state.getHandle(), updates); - } - } - - private void startAndMaybeFlush(boolean isSnapshot, RecordBatch header, ByteBuffer body, - BarrageUpdateMetadata barrageUpdate, boolean isViewport, String[] columnTypes) { - if (isSnapshot) { - TableSnapshot snapshot = - createSnapshot(header, body, barrageUpdate, isViewport, columnTypes); - - // for now we always expect snapshots to arrive in a single payload - initialSnapshot(state.getHandle(), snapshot); - } else { - nextDeltaUpdates = deltaUpdates(barrageUpdate, isViewport, columnTypes); - appendAndMaybeFlush(header, body); - } - } - }); - stream.onStatus(err -> { - checkStatus(err); - if (!err.isOk() && !err.isTransportError()) { - state.setResolution(ClientTableState.ResolutionState.FAILED, err.getDetails()); - } - }); - BiDiStream oldStream = subscriptionStreams.put(state, stream); - if (oldStream != null) { - // cancel any old stream, we presently expect a fresh instance - oldStream.end(); - oldStream.cancel(); } } } @@ -1576,6 +1329,10 @@ public ClientConfiguration getConfig() { return config; } + public ConfigValue getServerConfigValue(String key) { + return constants.getConfigValuesMap().get(key); + } + public void onOpen(BiConsumer callback) { switch (state) { case Connected: diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/CompressedRangeSetReader.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/CompressedRangeSetReader.java index e4f14ef2fd4..1ee0c147621 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/CompressedRangeSetReader.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/CompressedRangeSetReader.java @@ -175,7 +175,7 @@ public RangeSet read(ByteBuffer data) { if (pending >= 0) { append(pending); } - return RangeSet.fromSortedRanges(sortedRanges.toArray(new Range[0])); + return RangeSet.fromSortedRanges(sortedRanges); default: throw new IllegalStateException("Bad command: " + command + " at position " + data.position()); } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/ShiftedRangeReader.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/ShiftedRangeReader.java index ac2b7524e6b..3c1c68fc3bb 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/ShiftedRangeReader.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/ShiftedRangeReader.java @@ -12,7 +12,7 @@ public class ShiftedRangeReader { - public ShiftedRange[] read(ByteBuffer data) { + public static ShiftedRange[] read(ByteBuffer data) { RangeSet start = new CompressedRangeSetReader().read(data); RangeSet end = new CompressedRangeSetReader().read(data); RangeSet postShiftStart = new CompressedRangeSetReader().read(data); @@ -30,4 +30,29 @@ public ShiftedRange[] read(ByteBuffer data) { return ranges; } + + public static ByteBuffer write(ShiftedRange[] shiftedRanges) { + RangeSet start = new RangeSet(); + RangeSet end = new RangeSet(); + RangeSet postShiftStart = new RangeSet(); + + for (int i = 0; i < shiftedRanges.length; i++) { + ShiftedRange range = shiftedRanges[i]; + long first = range.getRange().getFirst(); + long last = range.getRange().getLast(); + long delta = range.getDelta() + first; + start.addRange(new Range(first, first)); + end.addRange(new Range(last, last)); + postShiftStart.addRange(new Range(delta, delta)); + } + + ByteBuffer startBuf = CompressedRangeSetReader.writeRange(start); + ByteBuffer endBuf = CompressedRangeSetReader.writeRange(end); + ByteBuffer shiftBuf = CompressedRangeSetReader.writeRange(postShiftStart); + ByteBuffer all = ByteBuffer.allocateDirect(startBuf.remaining() + endBuf.remaining() + shiftBuf.remaining()); + all.put(startBuf); + all.put(endBuf); + all.put(shiftBuf); + return all; + } } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/WebBarrageMessage.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/WebBarrageMessage.java new file mode 100644 index 00000000000..1b26f2ccadb --- /dev/null +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/WebBarrageMessage.java @@ -0,0 +1,49 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.web.client.api.barrage; + +import io.deephaven.chunk.Chunk; +import io.deephaven.chunk.ChunkType; +import io.deephaven.chunk.attributes.Values; +import io.deephaven.web.shared.data.RangeSet; +import io.deephaven.web.shared.data.ShiftedRange; + +import java.util.ArrayList; +import java.util.BitSet; + +public class WebBarrageMessage { + public static class ModColumnData { + public RangeSet rowsModified; + public Class type; + public Class componentType; + public ArrayList> data; + public ChunkType chunkType; + } + public static class AddColumnData { + public Class type; + public Class componentType; + public ArrayList> data; + public ChunkType chunkType; + } + + public long firstSeq = -1; + public long lastSeq = -1; + public long step = -1; + + public boolean isSnapshot; + public RangeSet snapshotRowSet; + public boolean snapshotRowSetIsReversed; + public BitSet snapshotColumns; + + public RangeSet rowsAdded; + public RangeSet rowsIncluded; + public RangeSet rowsRemoved; + public ShiftedRange[] shifted; + + public AddColumnData[] addColumnData; + public ModColumnData[] modColumnData; + + // Underlying RecordBatch.length, visible for reading snapshots + public long length; +} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/WebBarrageStreamReader.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/WebBarrageStreamReader.java new file mode 100644 index 00000000000..6bf5196034e --- /dev/null +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/WebBarrageStreamReader.java @@ -0,0 +1,291 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.web.client.api.barrage; + +import com.google.common.io.LittleEndianDataInputStream; +import io.deephaven.barrage.flatbuf.BarrageMessageType; +import io.deephaven.barrage.flatbuf.BarrageMessageWrapper; +import io.deephaven.barrage.flatbuf.BarrageModColumnMetadata; +import io.deephaven.barrage.flatbuf.BarrageUpdateMetadata; +import io.deephaven.chunk.ChunkType; +import io.deephaven.chunk.WritableChunk; +import io.deephaven.chunk.attributes.Values; +import io.deephaven.extensions.barrage.chunk.ChunkInputStreamGenerator; +import io.deephaven.extensions.barrage.chunk.ChunkReader; +import io.deephaven.extensions.barrage.util.FlatBufferIteratorAdapter; +import io.deephaven.extensions.barrage.util.StreamReaderOptions; +import io.deephaven.io.streams.ByteBufferInputStream; +import io.deephaven.javascript.proto.dhinternal.arrow.flight.protocol.flight_pb.FlightData; +import io.deephaven.util.datastructures.LongSizedDataStructure; +import io.deephaven.web.client.fu.JsLog; +import io.deephaven.web.shared.data.RangeSet; +import io.deephaven.web.shared.data.ShiftedRange; +import org.apache.arrow.flatbuf.Field; +import org.apache.arrow.flatbuf.Message; +import org.apache.arrow.flatbuf.MessageHeader; +import org.apache.arrow.flatbuf.RecordBatch; +import org.apache.arrow.flatbuf.Schema; +import org.gwtproject.nio.TypedArrayHelper; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.BitSet; +import java.util.Iterator; +import java.util.List; +import java.util.PrimitiveIterator; + +/** + * Consumes FlightData fields from Flight/Barrage producers and builds browser-compatible WebBarrageMessage payloads + * that can be used to maintain table data. + */ +public class WebBarrageStreamReader { + private static final int MAX_CHUNK_SIZE = Integer.MAX_VALUE - 8; + + // record progress in reading + private long numAddRowsRead = 0; + private long numAddRowsTotal = 0; + private long numModRowsRead = 0; + private long numModRowsTotal = 0; + + // hold in-progress messages that aren't finished being built + private WebBarrageMessage msg; + + private final WebChunkReaderFactory chunkReaderFactory = new WebChunkReaderFactory(); + private final List readers = new ArrayList<>(); + + public WebBarrageMessage parseFrom( + final StreamReaderOptions options, + ChunkType[] columnChunkTypes, + Class[] columnTypes, + Class[] componentTypes, + FlightData flightData) throws IOException { + ByteBuffer headerAsBB = TypedArrayHelper.wrap(flightData.getDataHeader_asU8()); + Message header = headerAsBB.hasRemaining() ? Message.getRootAsMessage(headerAsBB) : null; + + ByteBuffer msgAsBB = TypedArrayHelper.wrap(flightData.getAppMetadata_asU8()); + if (msgAsBB.hasRemaining()) { + BarrageMessageWrapper wrapper = + BarrageMessageWrapper.getRootAsBarrageMessageWrapper(msgAsBB); + if (wrapper.magic() != WebBarrageUtils.FLATBUFFER_MAGIC) { + JsLog.warn( + "WebBarrageStreamReader: skipping app_metadata that does not look like BarrageMessageWrapper"); + } else if (wrapper.msgType() == BarrageMessageType.BarrageUpdateMetadata) { + if (msg != null) { + throw new IllegalStateException( + "Previous message was not complete; pending " + (numAddRowsTotal - numAddRowsRead) + + " add rows and " + (numModRowsTotal - numModRowsRead) + " mod rows"); + } + + final BarrageUpdateMetadata metadata = + BarrageUpdateMetadata.getRootAsBarrageUpdateMetadata(wrapper.msgPayloadAsByteBuffer()); + + msg = new WebBarrageMessage(); + + msg.isSnapshot = metadata.isSnapshot(); + msg.snapshotRowSetIsReversed = metadata.effectiveReverseViewport(); + + numAddRowsRead = 0; + numModRowsRead = 0; + + if (msg.isSnapshot) { + final ByteBuffer effectiveViewport = metadata.effectiveViewportAsByteBuffer(); + if (effectiveViewport != null) { + msg.snapshotRowSet = extractIndex(effectiveViewport); + } + final ByteBuffer effectiveSnapshotColumns = metadata.effectiveColumnSetAsByteBuffer(); + if (effectiveSnapshotColumns != null) { + msg.snapshotColumns = extractBitSet(effectiveSnapshotColumns); + } + } + + msg.firstSeq = metadata.firstSeq(); + msg.lastSeq = metadata.lastSeq(); + msg.rowsAdded = extractIndex(metadata.addedRowsAsByteBuffer()); + msg.rowsRemoved = extractIndex(metadata.removedRowsAsByteBuffer()); + msg.shifted = extractIndexShiftData(metadata.shiftDataAsByteBuffer()); + + final ByteBuffer rowsIncluded = metadata.addedRowsIncludedAsByteBuffer(); + msg.rowsIncluded = rowsIncluded != null ? extractIndex(rowsIncluded) : msg.rowsAdded; + msg.addColumnData = new WebBarrageMessage.AddColumnData[columnTypes.length]; + for (int ci = 0; ci < msg.addColumnData.length; ++ci) { + msg.addColumnData[ci] = new WebBarrageMessage.AddColumnData(); + // msg.addColumnData[ci].type = columnTypes[ci]; + // msg.addColumnData[ci].componentType = componentTypes[ci]; + msg.addColumnData[ci].data = new ArrayList<>(); + + // create an initial chunk of the correct size + final int chunkSize = (int) (Math.min(msg.rowsIncluded.size(), MAX_CHUNK_SIZE)); + final WritableChunk chunk = columnChunkTypes[ci].makeWritableChunk(chunkSize); + chunk.setSize(0); + msg.addColumnData[ci].data.add(chunk); + } + numAddRowsTotal = msg.rowsIncluded.size(); + + // if this message is a snapshot response (vs. subscription) then mod columns may be empty + numModRowsTotal = 0; + msg.modColumnData = new WebBarrageMessage.ModColumnData[metadata.modColumnNodesLength()]; + for (int ci = 0; ci < msg.modColumnData.length; ++ci) { + msg.modColumnData[ci] = new WebBarrageMessage.ModColumnData(); + // msg.modColumnData[ci].type = columnTypes[ci]; + // msg.modColumnData[ci].componentType = componentTypes[ci]; + msg.modColumnData[ci].data = new ArrayList<>(); + + final BarrageModColumnMetadata mcd = metadata.modColumnNodes(ci); + msg.modColumnData[ci].rowsModified = extractIndex(mcd.modifiedRowsAsByteBuffer()); + + // create an initial chunk of the correct size + final int chunkSize = (int) (Math.min(msg.modColumnData[ci].rowsModified.size(), + MAX_CHUNK_SIZE)); + final WritableChunk chunk = columnChunkTypes[ci].makeWritableChunk(chunkSize); + chunk.setSize(0); + msg.modColumnData[ci].data.add(chunk); + + numModRowsTotal = Math.max(numModRowsTotal, msg.modColumnData[ci].rowsModified.size()); + } + } + } + + byte headerType = header.headerType(); + if (headerType == MessageHeader.Schema) { + // there is no body and our clients do not want to see schema messages + Schema schema = new Schema(); + header.header(schema); + for (int i = 0; i < schema.fieldsLength(); i++) { + Field field = schema.fields(i); + ChunkReader chunkReader = chunkReaderFactory.getReader(options, + ChunkReader.typeInfo(columnChunkTypes[i], columnTypes[i], + componentTypes[i], field)); + readers.add(chunkReader); + } + return null; + } + if (headerType != MessageHeader.RecordBatch) { + throw new IllegalStateException("Only know how to decode Schema/RecordBatch messages"); + } + + + // throw an error when no app metadata (snapshots now provide by default) + if (msg == null) { + throw new IllegalStateException( + "Missing app metadata tag; cannot decode using BarrageStreamReader"); + } + + final RecordBatch batch = (RecordBatch) header.header(new RecordBatch()); + msg.length = batch.length(); + ByteBuffer body = TypedArrayHelper.wrap(flightData.getDataBody_asU8()); + final LittleEndianDataInputStream ois = + new LittleEndianDataInputStream(new ByteBufferInputStream(body)); + final Iterator fieldNodeIter = + new FlatBufferIteratorAdapter<>(batch.nodesLength(), + i -> new ChunkInputStreamGenerator.FieldNodeInfo(batch.nodes(i))); + + final long[] bufferInfo = new long[batch.buffersLength()]; + for (int bi = 0; bi < batch.buffersLength(); ++bi) { + int offset = LongSizedDataStructure.intSize("BufferInfo", batch.buffers(bi).offset()); + int length = LongSizedDataStructure.intSize("BufferInfo", batch.buffers(bi).length()); + if (bi < batch.buffersLength() - 1) { + final int nextOffset = + LongSizedDataStructure.intSize("BufferInfo", batch.buffers(bi + 1).offset()); + // our parsers handle overhanging buffers + length += Math.max(0, nextOffset - offset - length); + } + bufferInfo[bi] = length; + } + final PrimitiveIterator.OfLong bufferInfoIter = Arrays.stream(bufferInfo).iterator(); + + + // add and mod rows are never combined in a batch. all added rows must be received before the first + // mod rows will be received. + if (numAddRowsRead < numAddRowsTotal) { + for (int ci = 0; ci < msg.addColumnData.length; ++ci) { + final WebBarrageMessage.AddColumnData acd = msg.addColumnData[ci]; + + final long remaining = numAddRowsTotal - numAddRowsRead; + if (batch.length() > remaining) { + throw new IllegalStateException( + "Batch length exceeded the expected number of rows from app metadata"); + } + + // select the current chunk size and read the size + int lastChunkIndex = acd.data.size() - 1; + WritableChunk chunk = (WritableChunk) acd.data.get(lastChunkIndex); + + if (batch.length() > chunk.capacity() - chunk.size()) { + // reading the rows from this batch will overflow the existing chunk; create a new one + final int chunkSize = (int) (Math.min(remaining, MAX_CHUNK_SIZE)); + chunk = columnChunkTypes[ci].makeWritableChunk(chunkSize); + acd.data.add(chunk); + + chunk.setSize(0); + ++lastChunkIndex; + } + + // fill the chunk with data and assign back into the array + acd.data.set(lastChunkIndex, + readers.get(ci).readChunk(fieldNodeIter, bufferInfoIter, ois, chunk, chunk.size(), + (int) batch.length())); + chunk.setSize(chunk.size() + (int) batch.length()); + } + numAddRowsRead += batch.length(); + } else { + for (int ci = 0; ci < msg.modColumnData.length; ++ci) { + final WebBarrageMessage.ModColumnData mcd = msg.modColumnData[ci]; + + // another column may be larger than this column + long remaining = Math.max(0, mcd.rowsModified.size() - numModRowsRead); + + // need to add the batch row data to the column chunks + int lastChunkIndex = mcd.data.size() - 1; + WritableChunk chunk = (WritableChunk) mcd.data.get(lastChunkIndex); + + final int numRowsToRead = LongSizedDataStructure.intSize("BarrageStreamReader", + Math.min(remaining, batch.length())); + if (numRowsToRead > chunk.capacity() - chunk.size()) { + // reading the rows from this batch will overflow the existing chunk; create a new one + final int chunkSize = (int) (Math.min(remaining, MAX_CHUNK_SIZE)); + chunk = columnChunkTypes[ci].makeWritableChunk(chunkSize); + mcd.data.add(chunk); + + chunk.setSize(0); + ++lastChunkIndex; + } + + // fill the chunk with data and assign back into the array + mcd.data.set(lastChunkIndex, + readers.get(ci).readChunk(fieldNodeIter, bufferInfoIter, ois, chunk, chunk.size(), + numRowsToRead)); + chunk.setSize(chunk.size() + numRowsToRead); + } + numModRowsRead += batch.length(); + } + + if (numAddRowsRead == numAddRowsTotal && numModRowsRead == numModRowsTotal) { + final WebBarrageMessage retval = msg; + msg = null; + return retval; + } + + // otherwise, must wait for more data + return null; + } + + private static RangeSet extractIndex(final ByteBuffer bb) { + if (bb == null) { + return RangeSet.empty(); + } + return new CompressedRangeSetReader().read(bb); + } + + private static BitSet extractBitSet(final ByteBuffer bb) { + byte[] array = new byte[bb.remaining()]; + bb.get(array); + return BitSet.valueOf(array); + } + + private static ShiftedRange[] extractIndexShiftData(final ByteBuffer bb) { + return ShiftedRangeReader.read(bb); + } +} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/WebBarrageUtils.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/WebBarrageUtils.java index 8f11e5ebe27..648025723a5 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/WebBarrageUtils.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/WebBarrageUtils.java @@ -3,64 +3,58 @@ // package io.deephaven.web.client.api.barrage; +import com.google.flatbuffers.FlatBufferBuilder; import elemental2.core.*; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.FieldNode; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.Message; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.MessageHeader; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.RecordBatch; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Buffer; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Field; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.KeyValue; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Schema; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageMessageType; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageMessageWrapper; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageModColumnMetadata; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageUpdateMetadata; +import io.deephaven.barrage.flatbuf.BarrageMessageType; +import io.deephaven.barrage.flatbuf.BarrageMessageWrapper; import io.deephaven.web.client.api.barrage.def.ColumnDefinition; import io.deephaven.web.client.api.barrage.def.InitialTableDefinition; import io.deephaven.web.client.api.barrage.def.TableAttributesDefinition; import io.deephaven.web.shared.data.*; -import io.deephaven.web.shared.data.columns.*; -import jsinterop.base.Js; +import org.apache.arrow.flatbuf.KeyValue; +import org.apache.arrow.flatbuf.Message; +import org.apache.arrow.flatbuf.MessageHeader; +import org.apache.arrow.flatbuf.Schema; import org.gwtproject.nio.TypedArrayHelper; -import java.math.BigDecimal; -import java.math.BigInteger; import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.IntBuffer; -import java.nio.charset.StandardCharsets; -import java.util.BitSet; import java.util.HashMap; -import java.util.Iterator; import java.util.Map; import java.util.Set; -import java.util.function.DoubleFunction; -import java.util.stream.IntStream; +import java.util.function.IntFunction; /** * Utility to read barrage record batches. */ public class WebBarrageUtils { - private static final int MAGIC = 0x6E687064; - - public static Uint8Array wrapMessage(Builder innerBuilder, int messageType) { - Builder outerBuilder = new Builder(1024); - // This deprecation is incorrect, tsickle didn't understand that only one overload is deprecated - // noinspection deprecation - double messageOffset = BarrageMessageWrapper.createMsgPayloadVector(outerBuilder, innerBuilder.asUint8Array()); - double offset = - BarrageMessageWrapper.createBarrageMessageWrapper(outerBuilder, MAGIC, messageType, messageOffset); + public static final int FLATBUFFER_MAGIC = 0x6E687064; + + public static Uint8Array wrapMessage(FlatBufferBuilder innerBuilder, byte messageType) { + FlatBufferBuilder outerBuilder = new FlatBufferBuilder(1024); + int messageOffset = BarrageMessageWrapper.createMsgPayloadVector(outerBuilder, innerBuilder.dataBuffer()); + int offset = + BarrageMessageWrapper.createBarrageMessageWrapper(outerBuilder, FLATBUFFER_MAGIC, messageType, + messageOffset); outerBuilder.finish(offset); - return outerBuilder.asUint8Array(); + ByteBuffer byteBuffer = outerBuilder.dataBuffer(); + return bbToUint8ArrayView(byteBuffer); + } + + public static Uint8Array bbToUint8ArrayView(ByteBuffer byteBuffer) { + ArrayBufferView view = TypedArrayHelper.unwrap(byteBuffer); + return new Uint8Array(view.buffer, byteBuffer.position() + view.byteOffset, byteBuffer.remaining()); } public static Uint8Array emptyMessage() { - Builder builder = new Builder(1024); - double offset = BarrageMessageWrapper.createBarrageMessageWrapper(builder, MAGIC, BarrageMessageType.None, 0); + FlatBufferBuilder builder = new FlatBufferBuilder(1024); + int offset = BarrageMessageWrapper.createBarrageMessageWrapper(builder, FLATBUFFER_MAGIC, + BarrageMessageType.None, 0); builder.finish(offset); - return builder.asUint8Array(); + return bbToUint8ArrayView(builder.dataBuffer()); + } + + public static InitialTableDefinition readTableDefinition(Uint8Array flightSchemaMessage) { + return readTableDefinition(readSchemaMessage(flightSchemaMessage)); } public static InitialTableDefinition readTableDefinition(Schema schema) { @@ -76,50 +70,10 @@ public static InitialTableDefinition readTableDefinition(Schema schema) { .setColumns(cols); } - public static ColumnDefinition[] readColumnDefinitions(Schema schema) { + private static ColumnDefinition[] readColumnDefinitions(Schema schema) { ColumnDefinition[] cols = new ColumnDefinition[(int) schema.fieldsLength()]; for (int i = 0; i < schema.fieldsLength(); i++) { - cols[i] = new ColumnDefinition(); - Field f = schema.fields(i); - Map fieldMetadata = - keyValuePairs("deephaven:", f.customMetadataLength(), f::customMetadata); - cols[i].setName(f.name().asString()); - cols[i].setColumnIndex(i); - cols[i].setType(fieldMetadata.get("type")); - cols[i].setIsSortable("true".equals(fieldMetadata.get("isSortable"))); - cols[i].setStyleColumn("true".equals(fieldMetadata.get("isStyle"))); - cols[i].setFormatColumn("true".equals(fieldMetadata.get("isDateFormat")) - || "true".equals(fieldMetadata.get("isNumberFormat"))); - cols[i].setForRow("true".equals(fieldMetadata.get("isRowStyle"))); - - String formatColumnName = fieldMetadata.get("dateFormatColumn"); - if (formatColumnName == null) { - formatColumnName = fieldMetadata.get("numberFormatColumn"); - } - cols[i].setFormatColumnName(formatColumnName); - - cols[i].setStyleColumnName(fieldMetadata.get("styleColumn")); - - if (fieldMetadata.containsKey("inputtable.isKey")) { - cols[i].setInputTableKeyColumn("true".equals(fieldMetadata.get("inputtable.isKey"))); - } - - cols[i].setDescription(fieldMetadata.get("description")); - - cols[i].setPartitionColumn("true".equals(fieldMetadata.get("isPartitioning"))); - - cols[i].setHierarchicalExpandByColumn( - "true".equals(fieldMetadata.get("hierarchicalTable.isExpandByColumn"))); - cols[i].setHierarchicalRowDepthColumn( - "true".equals(fieldMetadata.get("hierarchicalTable.isRowDepthColumn"))); - cols[i].setHierarchicalRowExpandedColumn( - "true".equals(fieldMetadata.get("hierarchicalTable.isRowExpandedColumn"))); - cols[i].setRollupAggregatedNodeColumn( - "true".equals(fieldMetadata.get("rollupTable.isAggregatedNodeColumn"))); - cols[i].setRollupConstituentNodeColumn( - "true".equals(fieldMetadata.get("rollupTable.isConstituentNodeColumn"))); - cols[i].setRollupGroupByColumn("true".equals(fieldMetadata.get("rollupTable.isGroupByColumn"))); - cols[i].setRollupAggregationInputColumn(fieldMetadata.get("rollupTable.aggregationInputColumnName")); + cols[i] = new ColumnDefinition(i, schema.fields(i)); } return cols; } @@ -129,505 +83,42 @@ public static Schema readSchemaMessage(Uint8Array flightSchemaMessage) { // - IPC_CONTINUATION_TOKEN (4-byte int of -1) // - message size (4-byte int) // - a Message wrapping the schema - io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer bb = - new io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer(flightSchemaMessage); - bb.setPosition(bb.position() + 8); + ByteBuffer bb = TypedArrayHelper.wrap(flightSchemaMessage); + bb.position(bb.position() + 8); Message headerMessage = Message.getRootAsMessage(bb); assert headerMessage.headerType() == MessageHeader.Schema; - return headerMessage.header(new Schema()); + return (Schema) headerMessage.header(new Schema()); } public static Map keyValuePairs(String filterPrefix, double count, - DoubleFunction accessor) { + IntFunction accessor) { Map map = new HashMap<>(); for (int i = 0; i < count; i++) { KeyValue pair = accessor.apply(i); - String key = pair.key().asString(); + String key = pair.key(); if (key.startsWith(filterPrefix)) { key = key.substring(filterPrefix.length()); - String oldValue = map.put(key, pair.value().asString()); + String oldValue = map.put(key, pair.value()); assert oldValue == null : key + " had " + oldValue + ", replaced with " + pair.value(); } } return map; } - /** - * Iterator wrapper that allows peeking at the next item, if any. - */ - private static class Iter implements Iterator { - private final Iterator wrapped; - private T next; - - private Iter(Iterator wrapped) { - this.wrapped = wrapped; - } - - public T peek() { - if (next != null) { - return next; - } - return next = next(); - } - - @Override - public boolean hasNext() { - return next != null || wrapped.hasNext(); - } - - @Override - public T next() { - if (next == null) { - return wrapped.next(); - } - T val = next; - next = null; - return val; - } - } - - public static Uint8Array makeUint8ArrayFromBitset(BitSet bitset) { - int length = (bitset.previousSetBit(Integer.MAX_VALUE - 1) + 8) / 8; - Uint8Array array = new Uint8Array(length); - byte[] bytes = bitset.toByteArray(); - for (int i = 0; i < bytes.length; i++) { - array.setAt(i, (double) bytes[i]); - } - - return array; - } - - public static Uint8Array serializeRanges(Set rangeSets) { + public static ByteBuffer serializeRanges(Set rangeSets) { final RangeSet s; - if (rangeSets.size() == 0) { - return new Uint8Array(0); + if (rangeSets.isEmpty()) { + return ByteBuffer.allocate(0); } else if (rangeSets.size() == 1) { s = rangeSets.iterator().next(); } else { s = new RangeSet(); for (RangeSet rangeSet : rangeSets) { - rangeSet.rangeIterator().forEachRemaining(s::addRange); - } - } - - ByteBuffer payload = CompressedRangeSetReader.writeRange(s); - ArrayBufferView buffer = TypedArrayHelper.unwrap(payload); - return new Uint8Array(buffer); - } - - public static ByteBuffer typedArrayToLittleEndianByteBuffer(Uint8Array data) { - ArrayBuffer slicedBuffer = data.slice().buffer; - ByteBuffer bb = TypedArrayHelper.wrap(slicedBuffer); - bb.order(ByteOrder.LITTLE_ENDIAN); - return bb; - } - - public static ByteBuffer typedArrayToLittleEndianByteBuffer(Int8Array data) { - ArrayBuffer slicedBuffer = data.slice().buffer; - ByteBuffer bb = TypedArrayHelper.wrap(slicedBuffer); - bb.order(ByteOrder.LITTLE_ENDIAN); - return bb; - } - - public static TableSnapshot createSnapshot(RecordBatch header, ByteBuffer body, BarrageUpdateMetadata barrageUpdate, - boolean isViewport, String[] columnTypes) { - RangeSet added; - - final RangeSet includedAdditions; - if (barrageUpdate == null) { - includedAdditions = added = RangeSet.ofRange(0, (long) (header.length().toFloat64() - 1)); - } else { - added = new CompressedRangeSetReader() - .read(typedArrayToLittleEndianByteBuffer(barrageUpdate.addedRowsArray())); - - Int8Array addedRowsIncluded = barrageUpdate.addedRowsIncludedArray(); - if (isViewport && addedRowsIncluded != null) { - includedAdditions = new CompressedRangeSetReader() - .read(typedArrayToLittleEndianByteBuffer(addedRowsIncluded)); - } else { - // if this isn't a viewport, then a second index isn't sent, because all rows are included - includedAdditions = added; - } - } - - // read the nodes and buffers into iterators so that we can descend into the data columns as necessary - Iter nodes = - new Iter<>(IntStream.range(0, (int) header.nodesLength()).mapToObj(header::nodes).iterator()); - Iter buffers = - new Iter<>(IntStream.range(0, (int) header.buffersLength()).mapToObj(header::buffers).iterator()); - ColumnData[] columnData = new ColumnData[columnTypes.length]; - for (int columnIndex = 0; columnIndex < columnTypes.length; ++columnIndex) { - columnData[columnIndex] = - readArrowBuffer(body, nodes, buffers, (int) includedAdditions.size(), columnTypes[columnIndex]); - } - - return new TableSnapshot(includedAdditions, columnData, added.size()); - } - - public static DeltaUpdatesBuilder deltaUpdates(BarrageUpdateMetadata barrageUpdate, boolean isViewport, - String[] columnTypes) { - return new DeltaUpdatesBuilder(barrageUpdate, isViewport, columnTypes); - } - - public static class DeltaUpdatesBuilder { - private final DeltaUpdates deltaUpdates = new DeltaUpdates(); - private final BarrageUpdateMetadata barrageUpdate; - private final String[] columnTypes; - private long numAddRowsRemaining = 0; - private long numModRowsRemaining = 0; - - public DeltaUpdatesBuilder(BarrageUpdateMetadata barrageUpdate, boolean isViewport, String[] columnTypes) { - this.barrageUpdate = barrageUpdate; - this.columnTypes = columnTypes; - - deltaUpdates.setAdded(new CompressedRangeSetReader() - .read(typedArrayToLittleEndianByteBuffer(barrageUpdate.addedRowsArray()))); - deltaUpdates.setRemoved(new CompressedRangeSetReader() - .read(typedArrayToLittleEndianByteBuffer(barrageUpdate.removedRowsArray()))); - - deltaUpdates.setShiftedRanges( - new ShiftedRangeReader().read(typedArrayToLittleEndianByteBuffer(barrageUpdate.shiftDataArray()))); - - RangeSet includedAdditions; - - Int8Array addedRowsIncluded = barrageUpdate.addedRowsIncludedArray(); - if (isViewport && addedRowsIncluded != null) { - includedAdditions = new CompressedRangeSetReader() - .read(typedArrayToLittleEndianByteBuffer(addedRowsIncluded)); - } else { - // if this isn't a viewport, then a second index isn't sent, because all rows are included - includedAdditions = deltaUpdates.getAdded(); + s.addRangeSet(rangeSet); } - numAddRowsRemaining = includedAdditions.size(); - deltaUpdates.setIncludedAdditions(includedAdditions); - deltaUpdates.setSerializedAdditions(new DeltaUpdates.ColumnAdditions[0]); - deltaUpdates.setSerializedModifications(new DeltaUpdates.ColumnModifications[0]); - - for (int columnIndex = 0; columnIndex < columnTypes.length; ++columnIndex) { - BarrageModColumnMetadata columnMetadata = barrageUpdate.modColumnNodes(columnIndex); - RangeSet modifiedRows = new CompressedRangeSetReader() - .read(typedArrayToLittleEndianByteBuffer(columnMetadata.modifiedRowsArray())); - numModRowsRemaining = Math.max(numModRowsRemaining, modifiedRows.size()); - } - } - - /** - * Appends a new record batch and payload. Returns true if this was the final record batch that was expected. - */ - public boolean appendRecordBatch(RecordBatch recordBatch, ByteBuffer body) { - if (numAddRowsRemaining > 0) { - handleAddBatch(recordBatch, body); - } else if (numModRowsRemaining > 0) { - handleModBatch(recordBatch, body); - } - // return true when complete - return numAddRowsRemaining == 0 && numModRowsRemaining == 0; } - private void handleAddBatch(RecordBatch recordBatch, ByteBuffer body) { - Iter nodes = new Iter<>( - IntStream.range(0, (int) recordBatch.nodesLength()).mapToObj(recordBatch::nodes).iterator()); - Iter buffers = new Iter<>( - IntStream.range(0, (int) recordBatch.buffersLength()).mapToObj(recordBatch::buffers).iterator()); - - DeltaUpdates.ColumnAdditions[] addedColumnData = new DeltaUpdates.ColumnAdditions[columnTypes.length]; - for (int columnIndex = 0; columnIndex < columnTypes.length; ++columnIndex) { - assert nodes.hasNext() && buffers.hasNext(); - ColumnData columnData = readArrowBuffer(body, nodes, buffers, (int) nodes.peek().length().toFloat64(), - columnTypes[columnIndex]); - - addedColumnData[columnIndex] = new DeltaUpdates.ColumnAdditions(columnIndex, columnData); - } - deltaUpdates.setSerializedAdditions(addedColumnData); - numAddRowsRemaining -= (long) recordBatch.length().toFloat64(); - } - - private void handleModBatch(RecordBatch recordBatch, ByteBuffer body) { - Iter nodes = new Iter<>( - IntStream.range(0, (int) recordBatch.nodesLength()).mapToObj(recordBatch::nodes).iterator()); - Iter buffers = new Iter<>( - IntStream.range(0, (int) recordBatch.buffersLength()).mapToObj(recordBatch::buffers).iterator()); - - DeltaUpdates.ColumnModifications[] modifiedColumnData = - new DeltaUpdates.ColumnModifications[columnTypes.length]; - for (int columnIndex = 0; columnIndex < columnTypes.length; ++columnIndex) { - assert nodes.hasNext() && buffers.hasNext(); - - BarrageModColumnMetadata columnMetadata = barrageUpdate.modColumnNodes(columnIndex); - RangeSet modifiedRows = new CompressedRangeSetReader() - .read(typedArrayToLittleEndianByteBuffer(columnMetadata.modifiedRowsArray())); - - ColumnData columnData = readArrowBuffer(body, nodes, buffers, (int) nodes.peek().length().toFloat64(), - columnTypes[columnIndex]); - modifiedColumnData[columnIndex] = - new DeltaUpdates.ColumnModifications(columnIndex, modifiedRows, columnData); - } - deltaUpdates.setSerializedModifications(modifiedColumnData); - numModRowsRemaining -= (long) recordBatch.length().toFloat64(); - } - - public DeltaUpdates build() { - return deltaUpdates; - } + return CompressedRangeSetReader.writeRange(s); } - - private static ColumnData readArrowBuffer(ByteBuffer data, Iter nodes, Iter buffers, int size, - String columnType) { - // explicit cast to be clear that we're rounding down - BitSet valid = readValidityBufferAsBitset(data, size, buffers.next()); - FieldNode thisNode = nodes.next(); - boolean hasNulls = thisNode.nullCount().toFloat64() != 0; - size = Math.min(size, (int) thisNode.length().toFloat64()); - - Buffer positions = buffers.next(); - switch (columnType) { - // for simple well-supported typedarray types, wrap and return - case "int": - assert positions.length().toFloat64() >= size * 4; - Int32Array intArray = new Int32Array(TypedArrayHelper.unwrap(data).buffer, - (int) positions.offset().toFloat64(), size); - return new IntArrayColumnData(Js.uncheckedCast(intArray)); - case "short": - assert positions.length().toFloat64() >= size * 2; - Int16Array shortArray = new Int16Array(TypedArrayHelper.unwrap(data).buffer, - (int) positions.offset().toFloat64(), size); - return new ShortArrayColumnData(Js.uncheckedCast(shortArray)); - case "boolean": - case "java.lang.Boolean": - // noinspection IntegerDivisionInFloatingPointContext - assert positions.length().toFloat64() >= ((size + 63) / 64); - // booleans are stored as a bitset, but internally we represent booleans as bytes - data.position((int) positions.offset().toFloat64()); - BitSet wireValues = readBitSetWithLength(data, (int) (positions.length().toFloat64())); - Boolean[] boolArray = new Boolean[size]; - for (int i = 0; i < size; ++i) { - if (!hasNulls || valid.get(i)) { - boolArray[i] = wireValues.get(i); - } else { - boolArray[i] = null; - } - } - return new BooleanArrayColumnData(boolArray); - case "byte": - assert positions.length().toFloat64() >= size; - Int8Array byteArray = - new Int8Array(TypedArrayHelper.unwrap(data).buffer, (int) positions.offset().toFloat64(), size); - return new ByteArrayColumnData(Js.uncheckedCast(byteArray)); - case "double": - assert positions.length().toFloat64() >= size * 8; - Float64Array doubleArray = new Float64Array(TypedArrayHelper.unwrap(data).buffer, - (int) positions.offset().toFloat64(), size); - return new DoubleArrayColumnData(Js.uncheckedCast(doubleArray)); - case "float": - assert positions.length().toFloat64() >= size * 4; - Float32Array floatArray = new Float32Array(TypedArrayHelper.unwrap(data).buffer, - (int) positions.offset().toFloat64(), size); - return new FloatArrayColumnData(Js.uncheckedCast(floatArray)); - case "char": - assert positions.length().toFloat64() >= size * 2; - Uint16Array charArray = new Uint16Array(TypedArrayHelper.unwrap(data).buffer, - (int) positions.offset().toFloat64(), size); - return new CharArrayColumnData(Js.uncheckedCast(charArray)); - // longs are a special case despite being java primitives - case "long": - case "java.time.Instant": - case "java.time.ZonedDateTime": - assert positions.length().toFloat64() >= size * 8; - long[] longArray = new long[size]; - - data.position((int) positions.offset().toFloat64()); - for (int i = 0; i < size; i++) { - longArray[i] = data.getLong(); - } - return new LongArrayColumnData(longArray); - // all other types are read out in some custom way - case "java.time.LocalTime":// LocalDateArrayColumnData - assert positions.length().toFloat64() >= size * 6; - data.position((int) positions.offset().toFloat64()); - LocalDate[] localDateArray = new LocalDate[size]; - for (int i = 0; i < size; i++) { - int year = data.getInt(); - byte month = data.get(); - byte day = data.get(); - localDateArray[i] = new LocalDate(year, month, day); - } - return new LocalDateArrayColumnData(localDateArray); - case "java.time.LocalDate":// LocalTimeArrayColumnData - assert positions.length().toFloat64() == size * 7; - LocalTime[] localTimeArray = new LocalTime[size]; - - data.position((int) positions.offset().toFloat64()); - for (int i = 0; i < size; i++) { - int nano = data.getInt(); - byte hour = data.get(); - byte minute = data.get(); - byte second = data.get(); - data.position(data.position() + 1);// aligned for next read - localTimeArray[i] = new LocalTime(hour, minute, second, nano); - } - return new LocalTimeArrayColumnData(localTimeArray); - default: - // remaining types have an offset buffer to read first - IntBuffer offsets = readOffsets(data, size, positions); - - if (columnType.endsWith("[]")) { - FieldNode arrayNode = nodes.next(); - int innerSize = (int) arrayNode.length().toFloat64(); - boolean innerHasNulls = arrayNode.nullCount().toFloat64() != 0; - - // array type, also read the inner valid buffer and inner offset buffer - BitSet innerValid = readValidityBufferAsBitset(data, innerSize, buffers.next()); - IntBuffer innerOffsets = readOffsets(data, innerSize, buffers.next()); - - Buffer payload = buffers.next(); - - switch (columnType) { - case "java.lang.String[]": - String[][] strArrArr = new String[size][]; - - for (int i = 0; i < size; i++) { - if (hasNulls && !valid.get(i)) { - strArrArr[i] = null; - continue; - } - int arrayStart = offsets.get(i); - int instanceSize = offsets.get(i + 1) - arrayStart; - String[] strArr = new String[instanceSize]; - for (int j = 0; j < instanceSize; j++) { - int inner = j + arrayStart; - assert innerOffsets != null; - if (innerHasNulls && !innerValid.get(inner)) { - assert innerOffsets.get(inner) == innerOffsets.get(inner + 1) - : innerOffsets.get(inner) + " == " + innerOffsets.get(inner + 1); - strArr[j] = null; - continue; - } - // might be cheaper to do views on the underlying bb (which will be copied anyway - // into the String) - data.position((int) (payload.offset().toFloat64()) + innerOffsets.get(inner)); - int stringSize = innerOffsets.get(inner + 1) - innerOffsets.get(inner); - byte[] stringBytes = new byte[stringSize]; - data.get(stringBytes); - strArr[j] = new String(stringBytes, StandardCharsets.UTF_8); - } - strArrArr[i] = strArr; - } - - return new StringArrayArrayColumnData(strArrArr); - default: - throw new IllegalStateException("Can't decode column of type " + columnType); - } - - } else { - // non-array, variable length stuff, just grab the buffer and read ranges specified by offsets - Buffer payload = buffers.next(); - - switch (columnType) { - case "java.lang.String": { - String[] stringArray = new String[size]; - byte[] buf = new byte[32]; - for (int i = 0; i < size; i++) { - if (hasNulls && !valid.get(i)) { - stringArray[i] = null; - continue; - } - int ioff = offsets.get(i); - int len = offsets.get(i + 1) - ioff; - data.position((int) (payload.offset().toFloat64()) + ioff); - if (buf.length < len) { - buf = new byte[len]; - } - data.get(buf, 0, len); - stringArray[i] = new String(buf, 0, len, StandardCharsets.UTF_8);// new - // String(Js.uncheckedCast(stringBytes)); - } - return new StringArrayColumnData(stringArray); - } - case "java.math.BigDecimal": { - BigDecimal[] bigDecArray = new BigDecimal[size]; - byte[] buf = null; - for (int i = 0; i < size; i++) { - if (hasNulls && !valid.get(i)) { - bigDecArray[i] = null; - continue; - } - int ioff = offsets.get(i); - int len = offsets.get(i + 1) - ioff; - data.position((int) (payload.offset().toFloat64()) + ioff); - int scale = data.getInt(); - len -= 4; - if (buf == null || buf.length != len) { - buf = new byte[len]; - } - bigDecArray[i] = new BigDecimal(readBigInt(data, buf), scale); - } - return new BigDecimalArrayColumnData(bigDecArray); - } - case "java.math.BigInteger": { - BigInteger[] bigIntArray = new BigInteger[size]; - byte[] buf = null; - for (int i = 0; i < size; i++) { - if (hasNulls && !valid.get(i)) { - bigIntArray[i] = null; - continue; - } - int ioff = offsets.get(i); - int len = offsets.get(i + 1) - ioff; - if (buf == null || buf.length != len) { - buf = new byte[len]; - } - data.position((int) (payload.offset().toFloat64()) + ioff); - bigIntArray[i] = readBigInt(data, buf); - } - return new BigIntegerArrayColumnData(bigIntArray); - } - default: - throw new IllegalStateException("Can't decode column of type " + columnType); - } - } - } - } - - private static BigInteger readBigInt(ByteBuffer data, byte[] buf) { - // TODO: Change to the code below when the Java 9 BigInteger(byte[], int, int) constructor is available. - // https://github.com/deephaven/deephaven-core/issues/1626 - // Make the call take an additional len parameter, and make the calling logic reallocate only when - // there is a need to grow, instead of the current need for an exact match. - // - // data.get(buf, 0, len); - // return new BigInteger(buf, 0, len); - data.get(buf); - return new BigInteger(buf); - } - - private static BitSet readValidityBufferAsBitset(ByteBuffer data, int size, Buffer buffer) { - if (size == 0 || buffer.length().toFloat64() == 0) { - // these buffers are optional (and empty) if the column is empty, or if it has primitives and we've allowed - // DH nulls - return new BitSet(0); - } - data.position((int) buffer.offset().toFloat64()); - BitSet valid = readBitSetWithLength(data, (int) (buffer.length().toFloat64())); - return valid; - } - - private static BitSet readBitSetWithLength(ByteBuffer data, int lenInBytes) { - byte[] array = new byte[lenInBytes]; - data.get(array); - - return BitSet.valueOf(array); - } - - private static IntBuffer readOffsets(ByteBuffer data, int size, Buffer buffer) { - if (size == 0) { - IntBuffer emptyOffsets = IntBuffer.allocate(1); - return emptyOffsets; - } - data.position((int) buffer.offset().toFloat64()); - IntBuffer offsets = data.slice().asIntBuffer(); - offsets.limit(size + 1); - return offsets; - } - } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/WebChunkReaderFactory.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/WebChunkReaderFactory.java new file mode 100644 index 00000000000..d183aa491d3 --- /dev/null +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/WebChunkReaderFactory.java @@ -0,0 +1,327 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.web.client.api.barrage; + +import io.deephaven.base.verify.Assert; +import io.deephaven.chunk.WritableByteChunk; +import io.deephaven.chunk.WritableChunk; +import io.deephaven.chunk.WritableIntChunk; +import io.deephaven.chunk.WritableLongChunk; +import io.deephaven.chunk.WritableObjectChunk; +import io.deephaven.chunk.attributes.Values; +import io.deephaven.extensions.barrage.chunk.BooleanChunkReader; +import io.deephaven.extensions.barrage.chunk.ByteChunkReader; +import io.deephaven.extensions.barrage.chunk.CharChunkReader; +import io.deephaven.extensions.barrage.chunk.ChunkInputStreamGenerator; +import io.deephaven.extensions.barrage.chunk.ChunkReader; +import io.deephaven.extensions.barrage.chunk.DoubleChunkReader; +import io.deephaven.extensions.barrage.chunk.FloatChunkReader; +import io.deephaven.extensions.barrage.chunk.IntChunkReader; +import io.deephaven.extensions.barrage.chunk.LongChunkReader; +import io.deephaven.extensions.barrage.chunk.ShortChunkReader; +import io.deephaven.extensions.barrage.chunk.VarListChunkReader; +import io.deephaven.extensions.barrage.util.StreamReaderOptions; +import io.deephaven.util.BooleanUtils; +import io.deephaven.util.datastructures.LongSizedDataStructure; +import io.deephaven.web.client.api.BigDecimalWrapper; +import io.deephaven.web.client.api.BigIntegerWrapper; +import io.deephaven.web.client.api.DateWrapper; +import io.deephaven.web.client.api.LongWrapper; +import org.apache.arrow.flatbuf.Date; +import org.apache.arrow.flatbuf.DateUnit; +import org.apache.arrow.flatbuf.FloatingPoint; +import org.apache.arrow.flatbuf.Int; +import org.apache.arrow.flatbuf.Precision; +import org.apache.arrow.flatbuf.Time; +import org.apache.arrow.flatbuf.TimeUnit; +import org.apache.arrow.flatbuf.Timestamp; +import org.apache.arrow.flatbuf.Type; + +import java.io.DataInput; +import java.io.IOException; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.Iterator; +import java.util.PrimitiveIterator; + +/** + * Browser-compatible implementation of the ChunkReaderFactory, with a focus on reading from arrow types rather than + * successfully round-tripping to the Java server. + *

+ * Includes some specific workarounds to handle nullability that will make more sense for the browser. + */ +public class WebChunkReaderFactory implements ChunkReader.Factory { + @Override + public ChunkReader getReader(StreamReaderOptions options, int factor, ChunkReader.TypeInfo typeInfo) { + switch (typeInfo.arrowField().typeType()) { + case Type.Int: { + Int t = new Int(); + typeInfo.arrowField().type(t); + switch (t.bitWidth()) { + case 8: { + return new ByteChunkReader(options); + } + case 16: { + if (t.isSigned()) { + return new ShortChunkReader(options); + } + return new CharChunkReader(options); + } + case 32: { + return new IntChunkReader(options); + } + case 64: { + if (t.isSigned()) { + return new LongChunkReader(options).transform(LongWrapper::of); + } + throw new IllegalArgumentException("Unsigned 64bit integers not supported"); + } + default: + throw new IllegalArgumentException("Unsupported Int bitwidth: " + t.bitWidth()); + } + } + case Type.FloatingPoint: { + FloatingPoint t = new FloatingPoint(); + typeInfo.arrowField().type(t); + switch (t.precision()) { + case Precision.SINGLE: { + return new FloatChunkReader(options); + } + case Precision.DOUBLE: { + return new DoubleChunkReader(options); + } + default: + throw new IllegalArgumentException( + "Unsupported FloatingPoint precision " + Precision.name(t.precision())); + } + } + case Type.Binary: { + if (typeInfo.type() == BigIntegerWrapper.class) { + return (fieldNodeIter, bufferInfoIter, is, outChunk, outOffset, + totalRows) -> extractChunkFromInputStream( + is, + fieldNodeIter, + bufferInfoIter, + (val, off, len) -> new BigIntegerWrapper(new BigInteger(val, off, len)), + outChunk, outOffset, totalRows); + } + if (typeInfo.type() == BigDecimalWrapper.class) { + return (fieldNodeIter, bufferInfoIter, is, outChunk, outOffset, + totalRows) -> extractChunkFromInputStream( + is, + fieldNodeIter, + bufferInfoIter, + (final byte[] buf, final int offset, final int length) -> { + // read the int scale value as little endian, arrow's endianness. + final byte b1 = buf[offset]; + final byte b2 = buf[offset + 1]; + final byte b3 = buf[offset + 2]; + final byte b4 = buf[offset + 3]; + final int scale = b4 << 24 | (b3 & 0xFF) << 16 | (b2 & 0xFF) << 8 | (b1 & 0xFF); + BigDecimal bigDecimal = + new BigDecimal(new BigInteger(buf, offset + 4, length - 4), scale); + return new BigDecimalWrapper(bigDecimal); + }, + outChunk, outOffset, totalRows); + } + throw new IllegalArgumentException("Unsupported Binary type " + typeInfo.type()); + } + case Type.Utf8: { + return (fieldNodeIter, bufferInfoIter, is, outChunk, outOffset, + totalRows) -> extractChunkFromInputStream(is, fieldNodeIter, + bufferInfoIter, (buf, off, len) -> new String(buf, off, len, StandardCharsets.UTF_8), + outChunk, outOffset, totalRows); + } + case Type.Bool: { + BooleanChunkReader subReader = new BooleanChunkReader(); + return (fieldNodeIter, bufferInfoIter, is, outChunk, outOffset, totalRows) -> { + try (final WritableByteChunk inner = (WritableByteChunk) subReader.readChunk( + fieldNodeIter, bufferInfoIter, is, null, 0, 0)) { + + final WritableObjectChunk chunk; + if (outChunk != null) { + chunk = outChunk.asWritableObjectChunk(); + } else { + int numRows = Math.max(totalRows, inner.size()); + chunk = WritableObjectChunk.makeWritableChunk(numRows); + chunk.setSize(numRows); + } + + if (outChunk == null) { + // if we're not given an output chunk then we better be writing at the front of the new one + Assert.eqZero(outOffset, "outOffset"); + } + + for (int ii = 0; ii < inner.size(); ++ii) { + byte value = inner.get(ii); + chunk.set(outOffset + ii, BooleanUtils.byteAsBoolean(value)); + } + + return chunk; + } + + }; + } + case Type.Date: { + Date t = new Date(); + typeInfo.arrowField().type(t); + switch (t.unit()) { + case DateUnit.MILLISECOND: + return new LongChunkReader(options).transform(millis -> DateWrapper.of(millis * 1000 * 1000)); + default: + throw new IllegalArgumentException("Unsupported Date unit: " + DateUnit.name(t.unit())); + } + } + case Type.Time: { + Time t = new Time(); + typeInfo.arrowField().type(t); + switch (t.bitWidth()) { + case TimeUnit.NANOSECOND: { + return new LongChunkReader(options).transform(DateWrapper::of); + } + default: + throw new IllegalArgumentException("Unsupported Time unit: " + TimeUnit.name(t.unit())); + } + } + case Type.Timestamp: { + Timestamp t = new Timestamp(); + typeInfo.arrowField().type(t); + switch (t.unit()) { + case TimeUnit.NANOSECOND: { + if (!t.timezone().equals("UTC")) { + throw new IllegalArgumentException("Unsupported tz " + t.timezone()); + } + return new LongChunkReader(options).transform(DateWrapper::of); + } + default: + throw new IllegalArgumentException("Unsupported Timestamp unit: " + TimeUnit.name(t.unit())); + } + } + case Type.List: { + if (typeInfo.componentType() == byte.class) { + return (fieldNodeIter, bufferInfoIter, is, outChunk, outOffset, + totalRows) -> extractChunkFromInputStream( + is, + fieldNodeIter, + bufferInfoIter, + (buf, off, len) -> Arrays.copyOfRange(buf, off, off + len), + outChunk, outOffset, totalRows); + } + return new VarListChunkReader<>(options, typeInfo, this); + } + default: + throw new IllegalArgumentException("Unsupported type: " + Type.name(typeInfo.arrowField().typeType())); + } + } + + public interface Mapper { + T constructFrom(byte[] buf, int offset, int length) throws IOException; + } + + public static WritableObjectChunk extractChunkFromInputStream( + final DataInput is, + final Iterator fieldNodeIter, + final PrimitiveIterator.OfLong bufferInfoIter, + final Mapper mapper, + final WritableChunk outChunk, + final int outOffset, + final int totalRows) throws IOException { + final ChunkInputStreamGenerator.FieldNodeInfo nodeInfo = fieldNodeIter.next(); + final long validityBuffer = bufferInfoIter.nextLong(); + final long offsetsBuffer = bufferInfoIter.nextLong(); + final long payloadBuffer = bufferInfoIter.nextLong(); + + final int numElements = nodeInfo.numElements; + final WritableObjectChunk chunk; + if (outChunk != null) { + chunk = outChunk.asWritableObjectChunk(); + } else { + final int numRows = Math.max(totalRows, numElements); + chunk = WritableObjectChunk.makeWritableChunk(numRows); + chunk.setSize(numRows); + } + + if (numElements == 0) { + return chunk; + } + + final int numValidityWords = (numElements + 63) / 64; + try (final WritableLongChunk isValid = WritableLongChunk.makeWritableChunk(numValidityWords); + final WritableIntChunk offsets = WritableIntChunk.makeWritableChunk(numElements + 1)) { + // Read validity buffer: + int jj = 0; + for (; jj < Math.min(numValidityWords, validityBuffer / 8); ++jj) { + isValid.set(jj, is.readLong()); + } + final long valBufRead = jj * 8L; + if (valBufRead < validityBuffer) { + is.skipBytes(LongSizedDataStructure.intSize("VBCISG", validityBuffer - valBufRead)); + } + // we support short validity buffers + for (; jj < numValidityWords; ++jj) { + isValid.set(jj, -1); // -1 is bit-wise representation of all ones + } + + // Read offsets: + final long offBufRead = (numElements + 1L) * Integer.BYTES; + if (offsetsBuffer < offBufRead) { + throw new IllegalStateException("offset buffer is too short for the expected number of elements"); + } + for (int i = 0; i < numElements + 1; ++i) { + offsets.set(i, is.readInt()); + } + if (offBufRead < offsetsBuffer) { + is.skipBytes(LongSizedDataStructure.intSize("VBCISG", offsetsBuffer - offBufRead)); + } + + // Read data: + final int bytesRead = LongSizedDataStructure.intSize("VBCISG", payloadBuffer); + final byte[] serializedData = new byte[bytesRead]; + is.readFully(serializedData); + + // Deserialize: + int ei = 0; + int pendingSkips = 0; + + for (int vi = 0; vi < numValidityWords; ++vi) { + int bitsLeftInThisWord = Math.min(64, numElements - vi * 64); + long validityWord = isValid.get(vi); + do { + if ((validityWord & 1) == 1) { + if (pendingSkips > 0) { + chunk.fillWithNullValue(outOffset + ei, pendingSkips); + ei += pendingSkips; + pendingSkips = 0; + } + final int offset = offsets.get(ei); + final int length = offsets.get(ei + 1) - offset; + Assert.geq(length, "length", 0); + if (offset + length > serializedData.length) { + throw new IllegalStateException("not enough data was serialized to parse this element: " + + "elementIndex=" + ei + " offset=" + offset + " length=" + length + + " serializedLen=" + serializedData.length); + } + chunk.set(outOffset + ei++, mapper.constructFrom(serializedData, offset, length)); + validityWord >>= 1; + bitsLeftInThisWord--; + } else { + final int skips = Math.min(Long.numberOfTrailingZeros(validityWord), bitsLeftInThisWord); + pendingSkips += skips; + validityWord >>= skips; + bitsLeftInThisWord -= skips; + } + } while (bitsLeftInThisWord > 0); + } + + if (pendingSkips > 0) { + chunk.fillWithNullValue(outOffset + ei, pendingSkips); + } + } + + return chunk; + } + +} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebBarrageSubscription.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebBarrageSubscription.java new file mode 100644 index 00000000000..a46d8ec7f90 --- /dev/null +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebBarrageSubscription.java @@ -0,0 +1,515 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.web.client.api.barrage.data; + +import io.deephaven.chunk.Chunk; +import io.deephaven.chunk.ChunkType; +import io.deephaven.chunk.attributes.Values; +import io.deephaven.web.client.api.barrage.WebBarrageMessage; +import io.deephaven.web.client.api.barrage.def.InitialTableDefinition; +import io.deephaven.web.client.state.ClientTableState; +import io.deephaven.web.shared.data.Range; +import io.deephaven.web.shared.data.RangeSet; +import io.deephaven.web.shared.data.ShiftedRange; +import jsinterop.base.Any; + +import java.util.Arrays; +import java.util.BitSet; +import java.util.NavigableSet; +import java.util.NoSuchElementException; +import java.util.PrimitiveIterator; +import java.util.TreeMap; + +/** + * In contrast to the server implementation, the JS API holds the "table" as distinct from the "subscription", so that + * developers are acutely aware of extra async costs in requesting data, and can clearly indicate how much data is + * requested. This class represents a barrage subscription for the JS API, and exposes access to the data presently + * available on the client. + *

+ * This is a rough analog to {@link io.deephaven.extensions.barrage.table.BarrageTable} and its subtypes, but isn't + * directly exposed to API consumers. Instead, the subscription types wrap this, and delegate their data storage and + * snapshot/delta handling here. + */ +public abstract class WebBarrageSubscription { + + public static final boolean COLUMNS_AS_LIST = false; + public static final int MAX_MESSAGE_SIZE = 10_000_000; + public static final int BATCH_SIZE = 100_000; + + public static WebBarrageSubscription subscribe(ClientTableState cts, ViewportChangedHandler viewportChangedHandler, + DataChangedHandler dataChangedHandler) { + + WebColumnData[] dataSinks = new WebColumnData[cts.columnTypes().length]; + ChunkType[] chunkTypes = cts.chunkTypes(); + for (int i = 0; i < dataSinks.length; i++) { + switch (chunkTypes[i]) { + case Boolean: + throw new IllegalStateException("Boolean unsupported here"); + case Char: + dataSinks[i] = new WebCharColumnData(); + break; + case Byte: + dataSinks[i] = new WebByteColumnData(); + break; + case Short: + dataSinks[i] = new WebShortColumnData(); + break; + case Int: + dataSinks[i] = new WebIntColumnData(); + break; + case Long: + dataSinks[i] = new WebLongColumnData(); + break; + case Float: + dataSinks[i] = new WebFloatColumnData(); + break; + case Double: + dataSinks[i] = new WebDoubleColumnData(); + break; + case Object: + dataSinks[i] = new WebObjectColumnData(); + break; + } + } + + if (cts.getTableDef().getAttributes().isBlinkTable()) { + return new BlinkImpl(cts, viewportChangedHandler, dataChangedHandler, dataSinks); + } + return new RedirectedImpl(cts, viewportChangedHandler, dataChangedHandler, dataSinks); + } + + public interface ViewportChangedHandler { + void onServerViewportChanged(RangeSet serverViewport, BitSet serverColumns, boolean serverReverseViewport); + } + public interface DataChangedHandler { + void onDataChanged(RangeSet rowsAdded, RangeSet rowsRemoved, RangeSet totalMods, ShiftedRange[] shifted, + BitSet modifiedColumnSet); + } + + protected final ClientTableState state; + protected final ViewportChangedHandler viewportChangedHandler; + protected final DataChangedHandler dataChangedHandler; + protected final RangeSet currentRowSet = RangeSet.empty(); + + protected long capacity = 0; + protected WebColumnData[] destSources; + + protected RangeSet serverViewport; + protected BitSet serverColumns; + protected boolean serverReverseViewport; + + protected WebBarrageSubscription(ClientTableState state, ViewportChangedHandler viewportChangedHandler, + DataChangedHandler dataChangedHandler, WebColumnData[] dataSinks) { + this.state = state; + destSources = dataSinks; + this.viewportChangedHandler = viewportChangedHandler; + this.dataChangedHandler = dataChangedHandler; + } + + public abstract void applyUpdates(WebBarrageMessage message); + + protected void updateServerViewport(RangeSet viewport, BitSet columns, boolean reverseViewport) { + serverViewport = viewport; + serverColumns = columns == null || columns.cardinality() == numColumns() ? null : columns; + serverReverseViewport = reverseViewport; + } + + protected int numColumns() { + return getDefinition().getColumns().length; + } + + private InitialTableDefinition getDefinition() { + return state.getTableDef(); + } + + public RangeSet getCurrentRowSet() { + return currentRowSet; + } + + public RangeSet getServerViewport() { + return serverViewport; + } + + public boolean isReversed() { + return serverReverseViewport; + } + + /** + * Reads a value from the table subscription. + * + * @param key the row to read in key-space + * @param col the index of the column to read + * @return the value read from the table + */ + public abstract Any getData(long key, int col); + + protected boolean isSubscribedColumn(int ii) { + return serverColumns == null || serverColumns.get(ii); + } + + public static class BlinkImpl extends WebBarrageSubscription { + enum Mode { + BLINK, APPEND + } + + private final Mode mode; + + public BlinkImpl(ClientTableState state, ViewportChangedHandler viewportChangedHandler, + DataChangedHandler dataChangedHandler, WebColumnData[] dataSinks) { + super(state, viewportChangedHandler, dataChangedHandler, dataSinks); + mode = Mode.BLINK; + } + + @Override + public void applyUpdates(WebBarrageMessage message) { + if (message.isSnapshot) { + updateServerViewport(message.snapshotRowSet, message.snapshotColumns, message.snapshotRowSetIsReversed); + viewportChangedHandler.onServerViewportChanged(serverViewport, serverColumns, serverReverseViewport); + } + + assert message.shifted.length == 0; + for (int i = 0; i < message.modColumnData.length; i++) { + assert message.modColumnData[i].rowsModified.isEmpty(); + } + + if (message.rowsIncluded.isEmpty()) { + return; + } + + long addedRows = message.rowsIncluded.size(); + RangeSet destinationRowSet; + if (mode == Mode.APPEND) { + destinationRowSet = RangeSet.ofRange(capacity, capacity + addedRows - 1); + capacity += addedRows; + } else { + destinationRowSet = RangeSet.ofRange(0, addedRows - 1); + capacity = addedRows; + } + Arrays.stream(destSources).forEach(s -> s.ensureCapacity(capacity)); + for (int ii = 0; ii < message.addColumnData.length; ii++) { + if (isSubscribedColumn(ii)) { + WebBarrageMessage.AddColumnData column = message.addColumnData[ii]; + PrimitiveIterator.OfLong destIterator = destinationRowSet.indexIterator(); + for (int j = 0; j < column.data.size(); j++) { + Chunk chunk = column.data.get(j); + destSources[ii].fillChunk(chunk, destIterator); + } + assert !destIterator.hasNext(); + } + } + + currentRowSet.clear(); + + currentRowSet.addRangeSet(message.rowsAdded); + state.setSize(message.rowsAdded.size()); + dataChangedHandler.onDataChanged(message.rowsAdded, message.rowsRemoved, RangeSet.empty(), message.shifted, + new BitSet(0)); + } + + @Override + public Any getData(long key, int col) { + if (!isSubscribedColumn(col)) { + throw new NoSuchElementException("No column at index " + col); + } + return destSources[col].get(key); + } + } + + public static class RedirectedImpl extends WebBarrageSubscription { + private RangeSet freeset = new RangeSet(); + private final TreeMap redirectedIndexes = new TreeMap<>(); + + public RedirectedImpl(ClientTableState state, ViewportChangedHandler viewportChangedHandler, + DataChangedHandler dataChangedHandler, WebColumnData[] dataSinks) { + super(state, viewportChangedHandler, dataChangedHandler, dataSinks); + } + + @Override + public void applyUpdates(WebBarrageMessage message) { + RangeSet populatedRows = serverViewport != null + ? currentRowSet.subsetForPositions(serverViewport, serverReverseViewport) + : null; + + if (message.isSnapshot) { + updateServerViewport(message.snapshotRowSet, message.snapshotColumns, message.snapshotRowSetIsReversed); + viewportChangedHandler.onServerViewportChanged(serverViewport, serverColumns, serverReverseViewport); + } + + final boolean mightBeInitialSnapshot = getCurrentRowSet().isEmpty() && message.isSnapshot; + + // Apply removes to our local rowset + currentRowSet.removeRangeSet(message.rowsRemoved); + + RangeSet removed = message.rowsRemoved; + if (populatedRows != null) { + // limit the removed rows to what intersect the viewport + removed = populatedRows.extract(message.rowsRemoved); + } + // free rows that are no longer needed + freeRows(removed); + + // Apply shifts + + // Shift moved rows in the redir index + boolean hasReverseShift = false; + final ShiftedRange[] shiftedRanges = message.shifted; + currentRowSet.applyShifts(shiftedRanges); + RangeSetBulkHelper populatedRowsetShifter = populatedRows == null ? null + : new RangeSetBulkHelper(populatedRows, RangeSetBulkHelper.Operation.APPEND); + for (int i = shiftedRanges.length - 1; i >= 0; --i) { + final ShiftedRange shiftedRange = shiftedRanges[i]; + final long offset = shiftedRange.getDelta(); + if (offset < 0) { + hasReverseShift = true; + continue; + } + + // test if shift is in populatedRows before continuing + if (populatedRows != null) { + if (!populatedRows.includesAnyOf(shiftedRange.getRange())) { + // no rows were included, we can skip updating populatedRows and redirectedIndexes + continue; + } + populatedRows.removeRange(shiftedRange.getRange()); + } + final NavigableSet toMove = redirectedIndexes.navigableKeySet() + .subSet(shiftedRange.getRange().getFirst(), true, shiftedRange.getRange().getLast(), true); + // iterate backward and move them forward + for (Long key : toMove.descendingSet()) { + long shiftedKey = key + offset; + Long oldValue = redirectedIndexes.put(shiftedKey, redirectedIndexes.remove(key)); + assert oldValue == null : shiftedKey + " already has a value, " + oldValue; + if (populatedRowsetShifter != null) { + populatedRowsetShifter.append(shiftedKey); + } + } + } + + if (hasReverseShift) { + for (int i = 0; i < shiftedRanges.length; ++i) { + final ShiftedRange shiftedRange = shiftedRanges[i]; + final long offset = shiftedRange.getDelta(); + if (offset > 0) { + continue; + } + + if (populatedRows != null) { + if (!populatedRows.includesAnyOf(shiftedRange.getRange())) { + // no rows were included, we can skip updating populatedRows and redirectedIndexes + continue; + } + populatedRows.removeRange(shiftedRange.getRange()); + } + final NavigableSet toMove = redirectedIndexes.navigableKeySet() + .subSet(shiftedRange.getRange().getFirst(), true, shiftedRange.getRange().getLast(), true); + // iterate forward and move them backward + for (Long key : toMove) { + long shiftedKey = key + offset; + Long oldValue = redirectedIndexes.put(shiftedKey, redirectedIndexes.remove(key)); + assert oldValue == null : shiftedKey + " already has a value, " + oldValue; + if (populatedRowsetShifter != null) { + populatedRowsetShifter.append(shiftedKey); + } + } + } + } + if (populatedRowsetShifter != null) { + populatedRowsetShifter.flush(); + } + + currentRowSet.addRangeSet(message.rowsAdded); + + RangeSet totalMods = new RangeSet(); + for (int i = 0; i < message.modColumnData.length; i++) { + WebBarrageMessage.ModColumnData column = message.modColumnData[i]; + totalMods.addRangeSet(column.rowsModified); + } + + if (!message.rowsIncluded.isEmpty()) { + if (mightBeInitialSnapshot) { + capacity = message.rowsIncluded.size(); + Arrays.stream(destSources).forEach(s -> s.ensureCapacity(capacity)); + freeset.addRange(new Range(0, capacity - 1)); + } + + RangeSet destinationRowSet = getFreeRows(message.rowsIncluded.size()); + + for (int ii = 0; ii < message.addColumnData.length; ii++) { + if (isSubscribedColumn(ii)) { + WebBarrageMessage.AddColumnData column = message.addColumnData[ii]; + PrimitiveIterator.OfLong destIterator = destinationRowSet.indexIterator(); + + for (int j = 0; j < column.data.size(); j++) { + Chunk chunk = column.data.get(j); + destSources[ii].fillChunk(chunk, destIterator); + } + assert !destIterator.hasNext(); + } + } + // Add redirection mappings + PrimitiveIterator.OfLong srcIter = message.rowsIncluded.indexIterator(); + PrimitiveIterator.OfLong destIter = destinationRowSet.indexIterator(); + while (srcIter.hasNext()) { + assert destIter.hasNext(); + redirectedIndexes.put(srcIter.next(), destIter.next()); + } + assert !destIter.hasNext(); + } + + BitSet modifiedColumnSet = new BitSet(numColumns()); + for (int ii = 0; ii < message.modColumnData.length; ii++) { + WebBarrageMessage.ModColumnData column = message.modColumnData[ii]; + if (column.rowsModified.isEmpty()) { + continue; + } + + modifiedColumnSet.set(ii); + + PrimitiveIterator.OfLong destIterator = column.rowsModified.indexIterator(); + for (int j = 0; j < column.data.size(); j++) { + Chunk chunk = column.data.get(j); + destSources[ii].fillChunk(chunk, destIterator); + } + assert !destIterator.hasNext(); + } + if (serverViewport != null && populatedRows != null) { + RangeSet newPopulated = currentRowSet.subsetForPositions(serverViewport, serverReverseViewport); + populatedRows.removeRangeSet(newPopulated); + freeRows(populatedRows); + } + + state.setSize(currentRowSet.size()); + dataChangedHandler.onDataChanged(message.rowsAdded, removed, totalMods, message.shifted, + modifiedColumnSet); + } + + @Override + public Any getData(long key, int col) { + if (!isSubscribedColumn(col)) { + throw new NoSuchElementException("No column at index " + col); + } + return this.destSources[col].get(redirectedIndexes.get(key)); + } + + private RangeSet getFreeRows(long size) { + if (size <= 0) { + return RangeSet.empty(); + } + boolean needsResizing = false; + final RangeSet result; + if (capacity == 0) { + capacity = Long.highestOneBit(Math.max(size * 2, 8)); + freeset.addRange(new Range(0, capacity - 1)); + needsResizing = true; + } else { + if (freeset.size() < size) { + long usedSlots = capacity - freeset.size(); + long prevCapacity = capacity; + + do { + capacity *= 2; + } while ((capacity - usedSlots) < size); + freeset.addRange(new Range(prevCapacity, capacity - 1)); + needsResizing = true; + } + } + if (needsResizing) { + Arrays.stream(destSources).forEach(s -> s.ensureCapacity(capacity)); + } + result = freeset.subsetForPositions(RangeSet.ofRange(0, size - 1), false); + freeset.removeRange(new Range(0, result.getLastRow())); + assert result.size() == size : result.size() + " == " + size; + return result; + } + + private void freeRows(RangeSet removed) { + RangeSetBulkHelper reusableHelper = new RangeSetBulkHelper(freeset, RangeSetBulkHelper.Operation.APPEND); + removed.indexIterator().forEachRemaining((long index) -> { + Long dest = redirectedIndexes.remove(index); + if (dest != null) { + reusableHelper.append(dest); + } + }); + reusableHelper.flush(); + } + } + + /** + * Helper to avoid appending many times when modifying indexes. The append() method should be called for each key + * in order to ensure that addRange/removeRange isn't called excessively. When no more items will be added, + * flush() must be called. + */ + private static class RangeSetBulkHelper { + enum Operation { + APPEND, REMOVE + } + + private final RangeSet rangeSet; + private final Operation operation; + + private long currentFirst = -1; + private long currentLast; + + public RangeSetBulkHelper(final RangeSet rangeSet, Operation operation) { + this.rangeSet = rangeSet; + this.operation = operation; + } + + public void append(long key) { + assert key >= 0; + + if (currentFirst == -1) { + // first key to be added, move both first and last + currentFirst = key; + currentLast = key; + } else if (key == currentLast + 1) { + // key appends to our current range + currentLast = key; + } else if (key == currentFirst - 1) { + // key appends to our current range + currentFirst = key; + } else { + // existing range doesn't match the new item, finish the old range and start a new one + if (operation == Operation.APPEND) { + rangeSet.addRange(new Range(currentFirst, currentLast)); + } else { + rangeSet.removeRange(new Range(currentFirst, currentLast)); + } + currentFirst = key; + currentLast = key; + } + } + + public void appendRange(Range range) { + if (currentFirst == -1) { + currentFirst = range.getFirst(); + currentLast = range.getLast(); + } else if (range.getFirst() == currentLast + 1) { + currentLast = range.getLast(); + } else if (range.getLast() == currentFirst - 1) { + currentFirst = range.getFirst(); + } else { + if (operation == Operation.APPEND) { + rangeSet.addRange(new Range(currentFirst, currentLast)); + } else { + rangeSet.removeRange(new Range(currentFirst, currentLast)); + } + currentFirst = range.getFirst(); + currentLast = range.getLast(); + } + } + + public void flush() { + if (currentFirst != -1) { + if (operation == Operation.APPEND) { + rangeSet.addRange(new Range(currentFirst, currentLast)); + } else { + rangeSet.removeRange(new Range(currentFirst, currentLast)); + } + currentFirst = -1; + } + } + } + +} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebByteColumnData.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebByteColumnData.java new file mode 100644 index 00000000000..4f0593d05a9 --- /dev/null +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebByteColumnData.java @@ -0,0 +1,27 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +// ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY +// ****** Edit WebCharColumnData and run "./gradlew replicateBarrageUtils" to regenerate +// +// @formatter:off +package io.deephaven.web.client.api.barrage.data; + +import io.deephaven.chunk.ByteChunk; +import io.deephaven.chunk.Chunk; +import io.deephaven.util.QueryConstants; +import jsinterop.base.Js; + +import java.util.PrimitiveIterator; + +public class WebByteColumnData extends WebColumnData { + @Override + public void fillChunk(Chunk data, PrimitiveIterator.OfLong destIterator) { + ByteChunk byteChunk = data.asByteChunk(); + int i = 0; + while (destIterator.hasNext()) { + byte value = byteChunk.get(i++); + arr.setAt((int) destIterator.nextLong(), value == QueryConstants.NULL_BYTE ? null : Js.asAny(value)); + } + } +} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebCharColumnData.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebCharColumnData.java new file mode 100644 index 00000000000..dfe561d90df --- /dev/null +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebCharColumnData.java @@ -0,0 +1,23 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.web.client.api.barrage.data; + +import io.deephaven.chunk.CharChunk; +import io.deephaven.chunk.Chunk; +import io.deephaven.util.QueryConstants; +import jsinterop.base.Js; + +import java.util.PrimitiveIterator; + +public class WebCharColumnData extends WebColumnData { + @Override + public void fillChunk(Chunk data, PrimitiveIterator.OfLong destIterator) { + CharChunk charChunk = data.asCharChunk(); + int i = 0; + while (destIterator.hasNext()) { + char value = charChunk.get(i++); + arr.setAt((int) destIterator.nextLong(), value == QueryConstants.NULL_CHAR ? null : Js.asAny(value)); + } + } +} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebColumnData.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebColumnData.java new file mode 100644 index 00000000000..3c8fee323b4 --- /dev/null +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebColumnData.java @@ -0,0 +1,27 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.web.client.api.barrage.data; + +import elemental2.core.JsArray; +import io.deephaven.chunk.Chunk; +import jsinterop.base.Any; + +import java.util.PrimitiveIterator; + +/** + * Holds data from or intended for web clients, normalizing over nulls, with helpers to handle typed chunks. + */ +public abstract class WebColumnData { + protected final JsArray arr = new JsArray<>(); + + public abstract void fillChunk(Chunk data, PrimitiveIterator.OfLong destIterator); + + public void ensureCapacity(long size) { + // Current impl does nothing, js arrays don't behave better when told the size up front + } + + public Any get(long position) { + return arr.getAt((int) position); + } +} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebDoubleColumnData.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebDoubleColumnData.java new file mode 100644 index 00000000000..d2c8e764ce7 --- /dev/null +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebDoubleColumnData.java @@ -0,0 +1,27 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +// ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY +// ****** Edit WebCharColumnData and run "./gradlew replicateBarrageUtils" to regenerate +// +// @formatter:off +package io.deephaven.web.client.api.barrage.data; + +import io.deephaven.chunk.DoubleChunk; +import io.deephaven.chunk.Chunk; +import io.deephaven.util.QueryConstants; +import jsinterop.base.Js; + +import java.util.PrimitiveIterator; + +public class WebDoubleColumnData extends WebColumnData { + @Override + public void fillChunk(Chunk data, PrimitiveIterator.OfLong destIterator) { + DoubleChunk doubleChunk = data.asDoubleChunk(); + int i = 0; + while (destIterator.hasNext()) { + double value = doubleChunk.get(i++); + arr.setAt((int) destIterator.nextLong(), value == QueryConstants.NULL_DOUBLE ? null : Js.asAny(value)); + } + } +} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebFloatColumnData.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebFloatColumnData.java new file mode 100644 index 00000000000..a624affbda6 --- /dev/null +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebFloatColumnData.java @@ -0,0 +1,27 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +// ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY +// ****** Edit WebCharColumnData and run "./gradlew replicateBarrageUtils" to regenerate +// +// @formatter:off +package io.deephaven.web.client.api.barrage.data; + +import io.deephaven.chunk.FloatChunk; +import io.deephaven.chunk.Chunk; +import io.deephaven.util.QueryConstants; +import jsinterop.base.Js; + +import java.util.PrimitiveIterator; + +public class WebFloatColumnData extends WebColumnData { + @Override + public void fillChunk(Chunk data, PrimitiveIterator.OfLong destIterator) { + FloatChunk floatChunk = data.asFloatChunk(); + int i = 0; + while (destIterator.hasNext()) { + float value = floatChunk.get(i++); + arr.setAt((int) destIterator.nextLong(), value == QueryConstants.NULL_FLOAT ? null : Js.asAny(value)); + } + } +} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebIntColumnData.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebIntColumnData.java new file mode 100644 index 00000000000..996cf43c6a8 --- /dev/null +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebIntColumnData.java @@ -0,0 +1,27 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +// ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY +// ****** Edit WebCharColumnData and run "./gradlew replicateBarrageUtils" to regenerate +// +// @formatter:off +package io.deephaven.web.client.api.barrage.data; + +import io.deephaven.chunk.IntChunk; +import io.deephaven.chunk.Chunk; +import io.deephaven.util.QueryConstants; +import jsinterop.base.Js; + +import java.util.PrimitiveIterator; + +public class WebIntColumnData extends WebColumnData { + @Override + public void fillChunk(Chunk data, PrimitiveIterator.OfLong destIterator) { + IntChunk intChunk = data.asIntChunk(); + int i = 0; + while (destIterator.hasNext()) { + int value = intChunk.get(i++); + arr.setAt((int) destIterator.nextLong(), value == QueryConstants.NULL_INT ? null : Js.asAny(value)); + } + } +} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebLongColumnData.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebLongColumnData.java new file mode 100644 index 00000000000..080c05e6034 --- /dev/null +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebLongColumnData.java @@ -0,0 +1,27 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +// ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY +// ****** Edit WebCharColumnData and run "./gradlew replicateBarrageUtils" to regenerate +// +// @formatter:off +package io.deephaven.web.client.api.barrage.data; + +import io.deephaven.chunk.LongChunk; +import io.deephaven.chunk.Chunk; +import io.deephaven.util.QueryConstants; +import jsinterop.base.Js; + +import java.util.PrimitiveIterator; + +public class WebLongColumnData extends WebColumnData { + @Override + public void fillChunk(Chunk data, PrimitiveIterator.OfLong destIterator) { + LongChunk longChunk = data.asLongChunk(); + int i = 0; + while (destIterator.hasNext()) { + long value = longChunk.get(i++); + arr.setAt((int) destIterator.nextLong(), value == QueryConstants.NULL_LONG ? null : Js.asAny(value)); + } + } +} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebObjectColumnData.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebObjectColumnData.java new file mode 100644 index 00000000000..251bca22e67 --- /dev/null +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebObjectColumnData.java @@ -0,0 +1,22 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.web.client.api.barrage.data; + +import io.deephaven.chunk.Chunk; +import io.deephaven.chunk.ObjectChunk; +import jsinterop.base.Js; + +import java.util.PrimitiveIterator; + +public class WebObjectColumnData extends WebColumnData { + @Override + public void fillChunk(Chunk data, PrimitiveIterator.OfLong destIterator) { + ObjectChunk objectChunk = data.asObjectChunk(); + int i = 0; + while (destIterator.hasNext()) { + Object value = objectChunk.get(i++); + arr.setAt((int) destIterator.nextLong(), Js.asAny(value)); + } + } +} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebShortColumnData.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebShortColumnData.java new file mode 100644 index 00000000000..328a0f654a4 --- /dev/null +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/data/WebShortColumnData.java @@ -0,0 +1,27 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +// ****** AUTO-GENERATED CLASS - DO NOT EDIT MANUALLY +// ****** Edit WebCharColumnData and run "./gradlew replicateBarrageUtils" to regenerate +// +// @formatter:off +package io.deephaven.web.client.api.barrage.data; + +import io.deephaven.chunk.ShortChunk; +import io.deephaven.chunk.Chunk; +import io.deephaven.util.QueryConstants; +import jsinterop.base.Js; + +import java.util.PrimitiveIterator; + +public class WebShortColumnData extends WebColumnData { + @Override + public void fillChunk(Chunk data, PrimitiveIterator.OfLong destIterator) { + ShortChunk shortChunk = data.asShortChunk(); + int i = 0; + while (destIterator.hasNext()) { + short value = shortChunk.get(i++); + arr.setAt((int) destIterator.nextLong(), value == QueryConstants.NULL_SHORT ? null : Js.asAny(value)); + } + } +} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/def/ColumnDefinition.java b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/def/ColumnDefinition.java index 604f80fcd77..377c09d840d 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/def/ColumnDefinition.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/barrage/def/ColumnDefinition.java @@ -4,108 +4,101 @@ package io.deephaven.web.client.api.barrage.def; import io.deephaven.web.client.api.Column; +import org.apache.arrow.flatbuf.Field; import java.util.Map; +import static io.deephaven.web.client.api.barrage.WebBarrageUtils.keyValuePairs; + public class ColumnDefinition { - private int columnIndex; - private String name; - private String type; - - private boolean isSortable; - - private String styleColumn; - private String formatColumn; - - private boolean isStyleColumn; - private boolean isFormatColumn; - private boolean isNumberFormatColumn; - private boolean isPartitionColumn; - private boolean isHierarchicalExpandByColumn; - private boolean isHierarchicalRowDepthColumn; - private boolean isHierarchicalRowExpandedColumn; - private boolean isRollupAggregatedNodeColumn; - private boolean isRollupConstituentNodeColumn; - private boolean isRollupGroupByColumn; - private String rollupAggregationInputColumn; - - // Indicates that this is a style column for the row - private boolean forRow; - private boolean isInputTableKeyColumn; - private String description; + private final Field field; + private final int columnIndex; + private final String type; + + private final boolean isSortable; + + private final String styleColumn; + private final String formatColumn; + + private final boolean isStyleColumn; + private final boolean isFormatColumn; + private final boolean isPartitionColumn; + private final boolean isHierarchicalExpandByColumn; + private final boolean isHierarchicalRowDepthColumn; + private final boolean isHierarchicalRowExpandedColumn; + private final boolean isRollupAggregatedNodeColumn; + private final boolean isRollupConstituentNodeColumn; + private final boolean isRollupGroupByColumn; + private final String rollupAggregationInputColumn; + + // Indicates that this is a style column for the whole row + private final boolean forRow; + private final boolean isInputTableKeyColumn; + private final String description; + + public ColumnDefinition(int index, Field field) { + Map fieldMetadata = + keyValuePairs("deephaven:", field.customMetadataLength(), field::customMetadata); + this.field = field; + columnIndex = index; + type = fieldMetadata.get("type"); + isSortable = "true".equals(fieldMetadata.get("isSortable")); + isStyleColumn = "true".equals(fieldMetadata.get("isStyle")); + isFormatColumn = "true".equals(fieldMetadata.get("isDateFormat")) + || "true".equals(fieldMetadata.get("isNumberFormat")); + forRow = "true".equals(fieldMetadata.get("isRowStyle")); + + String formatColumnName = fieldMetadata.get("dateFormatColumn"); + if (formatColumnName == null) { + formatColumnName = fieldMetadata.get("numberFormatColumn"); + } + formatColumn = formatColumnName; - public String getName() { - return name; - } + styleColumn = fieldMetadata.get("styleColumn"); - public int getColumnIndex() { - return columnIndex; + isInputTableKeyColumn = "true".equals(fieldMetadata.get("inputtable.isKey")); + + this.description = fieldMetadata.get("description"); + + isPartitionColumn = "true".equals(fieldMetadata.get("isPartitioning")); + + isHierarchicalExpandByColumn = "true".equals(fieldMetadata.get("hierarchicalTable.isExpandByColumn")); + isHierarchicalRowDepthColumn = "true".equals(fieldMetadata.get("hierarchicalTable.isRowDepthColumn")); + isHierarchicalRowExpandedColumn = "true".equals(fieldMetadata.get("hierarchicalTable.isRowExpandedColumn")); + isRollupAggregatedNodeColumn = "true".equals(fieldMetadata.get("rollupTable.isAggregatedNodeColumn")); + isRollupConstituentNodeColumn = "true".equals(fieldMetadata.get("rollupTable.isConstituentNodeColumn")); + isRollupGroupByColumn = "true".equals(fieldMetadata.get("rollupTable.isGroupByColumn")); + rollupAggregationInputColumn = fieldMetadata.get("rollupTable.aggregationInputColumnName"); } - public void setColumnIndex(int columnIndex) { - this.columnIndex = columnIndex; + public String getName() { + return field.name(); } - public void setName(String name) { - this.name = name; + public int getColumnIndex() { + return columnIndex; } public String getType() { return type; } - public void setType(String type) { - this.type = type; - } - public boolean isSortable() { return isSortable; } - public void setIsSortable(boolean sortable) { - isSortable = sortable; - } - public boolean isStyleColumn() { return isStyleColumn; } - public void setStyleColumn(boolean styleColumn) { - isStyleColumn = styleColumn; - } - public boolean isFormatColumn() { return isFormatColumn; } - public void setFormatColumn(boolean formatColumn) { - isFormatColumn = formatColumn; - } - - /** - * @deprecated Use {@link #isFormatColumn()} - */ - @Deprecated - public boolean isNumberFormatColumn() { - return isNumberFormatColumn; - } - - /** - * @deprecated Use {@link #setFormatColumn(boolean)} - */ - @Deprecated - public void setNumberFormatColumn(boolean numberFormatColumn) { - isNumberFormatColumn = numberFormatColumn; - } - public boolean isPartitionColumn() { return isPartitionColumn; } - public void setPartitionColumn(boolean partitionColumn) { - isPartitionColumn = partitionColumn; - } - public boolean isVisible() { return !isStyleColumn() && !isFormatColumn() && !isRollupConstituentNodeColumn() && !isHierarchicalRowDepthColumn() && !isHierarchicalRowExpandedColumn(); @@ -115,38 +108,18 @@ public boolean isForRow() { return forRow; } - public void setForRow(boolean forRow) { - this.forRow = forRow; - } - public String getFormatColumnName() { return formatColumn; } - public void setFormatColumnName(String formatColumn) { - this.formatColumn = formatColumn; - } - public String getStyleColumnName() { return styleColumn; } - public void setStyleColumnName(String styleColumn) { - this.styleColumn = styleColumn; - } - - public void setInputTableKeyColumn(boolean inputTableKeyColumn) { - this.isInputTableKeyColumn = inputTableKeyColumn; - } - public boolean isInputTableKeyColumn() { return isInputTableKeyColumn; } - public void setDescription(String description) { - this.description = description; - } - public String getDescription() { return description; } @@ -161,10 +134,10 @@ public Column makeJsColumn(int index, Map return makeColumn(index, this, - format == null || !format.isNumberFormatColumn() ? null : format.getColumnIndex(), + style == null ? null : style.getColumnIndex(), style == null ? null : style.getColumnIndex(), isPartitionColumn(), - format == null || format.isNumberFormatColumn() ? null : format.getColumnIndex(), + format == null || format.isFormatColumn() ? null : format.getColumnIndex(), getDescription(), isInputTableKeyColumn()); } @@ -181,55 +154,28 @@ public boolean isHierarchicalExpandByColumn() { return isHierarchicalExpandByColumn; } - public void setHierarchicalExpandByColumn(boolean hierarchicalExpandByColumn) { - isHierarchicalExpandByColumn = hierarchicalExpandByColumn; - } - public boolean isHierarchicalRowDepthColumn() { return isHierarchicalRowDepthColumn; } - public void setHierarchicalRowDepthColumn(boolean hierarchicalRowDepthColumn) { - isHierarchicalRowDepthColumn = hierarchicalRowDepthColumn; - } - public boolean isHierarchicalRowExpandedColumn() { return isHierarchicalRowExpandedColumn; } - public void setHierarchicalRowExpandedColumn(boolean hierarchicalRowExpandedColumn) { - isHierarchicalRowExpandedColumn = hierarchicalRowExpandedColumn; - } - public boolean isRollupAggregatedNodeColumn() { return isRollupAggregatedNodeColumn; } - public void setRollupAggregatedNodeColumn(boolean rollupAggregatedNodeColumn) { - isRollupAggregatedNodeColumn = rollupAggregatedNodeColumn; - } - public boolean isRollupConstituentNodeColumn() { return isRollupConstituentNodeColumn; } - public void setRollupConstituentNodeColumn(boolean rollupConstituentNodeColumn) { - isRollupConstituentNodeColumn = rollupConstituentNodeColumn; - } - public boolean isRollupGroupByColumn() { return isRollupGroupByColumn; } - public void setRollupGroupByColumn(boolean rollupGroupByColumn) { - isRollupGroupByColumn = rollupGroupByColumn; - } - public String getRollupAggregationInputColumn() { return rollupAggregationInputColumn; } - public void setRollupAggregationInputColumn(String rollupAggregationInputColumn) { - this.rollupAggregationInputColumn = rollupAggregationInputColumn; - } } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/parse/JsDataHandler.java b/web/client-api/src/main/java/io/deephaven/web/client/api/parse/JsDataHandler.java index d3edf0e03f4..4bb583cd86f 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/parse/JsDataHandler.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/parse/JsDataHandler.java @@ -3,6 +3,7 @@ // package io.deephaven.web.client.api.parse; +import com.google.flatbuffers.FlatBufferBuilder; import com.google.gwt.i18n.client.TimeZone; import elemental2.core.ArrayBuffer; import elemental2.core.Float32Array; @@ -14,14 +15,6 @@ import elemental2.core.TypedArray; import elemental2.core.Uint16Array; import elemental2.core.Uint8Array; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Binary; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.FixedSizeBinary; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.FloatingPoint; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Int; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Precision; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Type; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Utf8; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; import io.deephaven.web.client.api.LongWrapper; import io.deephaven.web.client.api.i18n.JsDateTimeFormat; import io.deephaven.web.client.api.i18n.JsTimeZone; @@ -29,6 +22,13 @@ import io.deephaven.web.shared.fu.JsFunction; import jsinterop.base.Js; import jsinterop.base.JsArrayLike; +import org.apache.arrow.flatbuf.Binary; +import org.apache.arrow.flatbuf.FixedSizeBinary; +import org.apache.arrow.flatbuf.FloatingPoint; +import org.apache.arrow.flatbuf.Int; +import org.apache.arrow.flatbuf.Precision; +import org.apache.arrow.flatbuf.Type; +import org.apache.arrow.flatbuf.Utf8; import org.gwtproject.nio.TypedArrayHelper; import java.nio.ByteBuffer; @@ -40,16 +40,16 @@ import java.util.List; import java.util.Map; -import static io.deephaven.web.client.api.subscription.QueryConstants.FALSE_BOOLEAN_AS_BYTE; -import static io.deephaven.web.client.api.subscription.QueryConstants.NULL_BOOLEAN_AS_BYTE; -import static io.deephaven.web.client.api.subscription.QueryConstants.NULL_BYTE; -import static io.deephaven.web.client.api.subscription.QueryConstants.NULL_CHAR; -import static io.deephaven.web.client.api.subscription.QueryConstants.NULL_DOUBLE; -import static io.deephaven.web.client.api.subscription.QueryConstants.NULL_FLOAT; -import static io.deephaven.web.client.api.subscription.QueryConstants.NULL_INT; -import static io.deephaven.web.client.api.subscription.QueryConstants.NULL_LONG; -import static io.deephaven.web.client.api.subscription.QueryConstants.NULL_SHORT; -import static io.deephaven.web.client.api.subscription.QueryConstants.TRUE_BOOLEAN_AS_BYTE; +import static io.deephaven.util.BooleanUtils.FALSE_BOOLEAN_AS_BYTE; +import static io.deephaven.util.BooleanUtils.NULL_BOOLEAN_AS_BYTE; +import static io.deephaven.util.BooleanUtils.TRUE_BOOLEAN_AS_BYTE; +import static io.deephaven.util.QueryConstants.NULL_BYTE; +import static io.deephaven.util.QueryConstants.NULL_CHAR; +import static io.deephaven.util.QueryConstants.NULL_DOUBLE; +import static io.deephaven.util.QueryConstants.NULL_FLOAT; +import static io.deephaven.util.QueryConstants.NULL_INT; +import static io.deephaven.util.QueryConstants.NULL_LONG; +import static io.deephaven.util.QueryConstants.NULL_SHORT; /** * Given the expected type of a column, pick one of the enum entries and use that to read the data into arrow buffers. @@ -101,8 +101,9 @@ public Uint8Array build() { } @Override - public double writeType(Builder builder) { - return Utf8.createUtf8(builder); + public int writeType(FlatBufferBuilder builder) { + Utf8.startUtf8(builder); + return Utf8.endUtf8(builder); } @Override @@ -201,7 +202,7 @@ private long parseDateString(String str, ParseContext context) { } @Override - public double writeType(Builder builder) { + public int writeType(FlatBufferBuilder builder) { return Int.createInt(builder, 64, true); } @@ -249,7 +250,7 @@ public void write(Object[] data, ParseContext context, JsConsumer addNode, }, INTEGER(Type.Int, "int") { @Override - public double writeType(Builder builder) { + public int writeType(FlatBufferBuilder builder) { return Int.createInt(builder, 32, true); } @@ -261,7 +262,7 @@ public void write(Object[] data, ParseContext context, JsConsumer addNode, }, SHORT(Type.Int, "short") { @Override - public double writeType(Builder builder) { + public int writeType(FlatBufferBuilder builder) { return Int.createInt(builder, 16, true); } @@ -273,7 +274,7 @@ public void write(Object[] data, ParseContext context, JsConsumer addNode, }, LONG(Type.Int, "long") { @Override - public double writeType(Builder builder) { + public int writeType(FlatBufferBuilder builder) { return Int.createInt(builder, 64, true); } @@ -319,7 +320,7 @@ public void write(Object[] data, ParseContext context, JsConsumer addNode, }, BYTE(Type.Int, "byte") { @Override - public double writeType(Builder builder) { + public int writeType(FlatBufferBuilder builder) { return Int.createInt(builder, 8, true); } @@ -331,7 +332,7 @@ public void write(Object[] data, ParseContext context, JsConsumer addNode, }, CHAR(Type.Int, "char") { @Override - public double writeType(Builder builder) { + public int writeType(FlatBufferBuilder builder) { return Int.createInt(builder, 16, false); } @@ -343,7 +344,7 @@ public void write(Object[] data, ParseContext context, JsConsumer addNode, }, FLOAT(Type.FloatingPoint, "float") { @Override - public double writeType(Builder builder) { + public int writeType(FlatBufferBuilder builder) { return FloatingPoint.createFloatingPoint(builder, Precision.SINGLE); } @@ -355,7 +356,7 @@ public void write(Object[] data, ParseContext context, JsConsumer addNode, }, DOUBLE(Type.FloatingPoint, "double") { @Override - public double writeType(Builder builder) { + public int writeType(FlatBufferBuilder builder) { return FloatingPoint.createFloatingPoint(builder, Precision.DOUBLE); } @@ -368,7 +369,7 @@ public void write(Object[] data, ParseContext context, JsConsumer addNode, }, BOOLEAN(Type.Bool, "boolean", "bool", "java.lang.Boolean") { @Override - public double writeType(Builder builder) { + public int writeType(FlatBufferBuilder builder) { return Int.createInt(builder, 8, true); } @@ -440,25 +441,27 @@ public void write(Object[] data, ParseContext context, JsConsumer addNode, }, BIG_DECIMAL(Type.Binary, "java.util.BigDecimal") { @Override - public double writeType(Builder builder) { - return Binary.createBinary(builder); + public int writeType(FlatBufferBuilder builder) { + Binary.startBinary(builder); + return Binary.endBinary(builder); } }, BIG_INTEGER(Type.Binary, "java.util.BigInteger") { @Override - public double writeType(Builder builder) { - return Binary.createBinary(builder); + public int writeType(FlatBufferBuilder builder) { + Binary.startBinary(builder); + return Binary.endBinary(builder); } }, LOCAL_DATE(Type.FixedSizeBinary, "java.time.LocalDate", "localdate") { @Override - public double writeType(Builder builder) { + public int writeType(FlatBufferBuilder builder) { return FixedSizeBinary.createFixedSizeBinary(builder, 6); } }, LOCAL_TIME(Type.FixedSizeBinary, "java.time.LocalTime", "localtime") { @Override - public double writeType(Builder builder) { + public int writeType(FlatBufferBuilder builder) { return FixedSizeBinary.createFixedSizeBinary(builder, 7); } }, @@ -540,10 +543,10 @@ private static class HandlersHolder { private static final int SEPARATOR_INDEX = DEFAULT_DATE_TIME_PATTERN.indexOf('T'); - private final int arrowTypeType; + private final byte arrowTypeType; private final String deephavenType; - JsDataHandler(int arrowTypeType, String... typeNames) { + JsDataHandler(byte arrowTypeType, String... typeNames) { this.arrowTypeType = arrowTypeType; assert typeNames.length > 0 : "Must have at least one name"; this.deephavenType = typeNames[0]; @@ -553,7 +556,7 @@ private static class HandlersHolder { } } - public int typeType() { + public byte typeType() { return arrowTypeType; } @@ -561,7 +564,7 @@ public String deephavenType() { return deephavenType; } - public abstract double writeType(Builder builder); + public abstract int writeType(FlatBufferBuilder builder); public void write(Object[] data, ParseContext context, JsConsumer addNode, JsConsumer addBuffer) { throw new UnsupportedOperationException("Can't parse " + name()); diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/AbstractTableSubscription.java b/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/AbstractTableSubscription.java new file mode 100644 index 00000000000..155dbb8271a --- /dev/null +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/AbstractTableSubscription.java @@ -0,0 +1,524 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.web.client.api.subscription; + +import com.google.flatbuffers.FlatBufferBuilder; +import com.vertispan.tsdefs.annotations.TsIgnore; +import elemental2.core.JsArray; +import elemental2.dom.CustomEventInit; +import io.deephaven.barrage.flatbuf.BarrageMessageType; +import io.deephaven.barrage.flatbuf.BarrageSubscriptionRequest; +import io.deephaven.extensions.barrage.BarrageSubscriptionOptions; +import io.deephaven.extensions.barrage.ColumnConversionMode; +import io.deephaven.javascript.proto.dhinternal.arrow.flight.protocol.flight_pb.FlightData; +import io.deephaven.web.client.api.Column; +import io.deephaven.web.client.api.Format; +import io.deephaven.web.client.api.HasEventHandling; +import io.deephaven.web.client.api.JsRangeSet; +import io.deephaven.web.client.api.LongWrapper; +import io.deephaven.web.client.api.TableData; +import io.deephaven.web.client.api.WorkerConnection; +import io.deephaven.web.client.api.barrage.CompressedRangeSetReader; +import io.deephaven.web.client.api.barrage.WebBarrageMessage; +import io.deephaven.web.client.api.barrage.WebBarrageStreamReader; +import io.deephaven.web.client.api.barrage.WebBarrageUtils; +import io.deephaven.web.client.api.barrage.data.WebBarrageSubscription; +import io.deephaven.web.client.api.barrage.stream.BiDiStream; +import io.deephaven.web.client.api.barrage.stream.ResponseStreamWrapper; +import io.deephaven.web.client.fu.JsSettings; +import io.deephaven.web.client.state.ClientTableState; +import io.deephaven.web.shared.data.RangeSet; +import io.deephaven.web.shared.data.ShiftedRange; +import io.deephaven.web.shared.fu.JsRunnable; +import jsinterop.annotations.JsProperty; +import jsinterop.base.Any; +import jsinterop.base.Js; +import org.jetbrains.annotations.Nullable; + +import java.io.IOException; +import java.util.BitSet; + +/** + * Superclass of various subscription types, allowing specific implementations to customize behavior for their needs. + *

+ * Instances are not ready to use right away, owing to the fact that we need to wait both for the provided state to + * resolve (so that we have the table schema, know what kind of subscription we will make, and know what column types + * will be resolves), and because until the subscription has finished being set up, we will not have received the size + * of the table. When closed, it cannot be reused again. + *

+ * This is also a base class for types exposed to JS. + *

+ * This is a rough analog of the JVM's {@code BarrageSubscriptionImpl} class. In contrast to the JVM code, this is + * exposed to api consumers, rather than wrapping in a Table type, as it handles the barrage stream and provides events + * that client code can listen to. + */ +public abstract class AbstractTableSubscription extends HasEventHandling { + /** + * Indicates that some new data is available on the client, either an initial snapshot or a delta update. The + * detail field of the event will contain a TableSubscriptionEventData detailing what has changed, or + * allowing access to the entire range of items currently in the subscribed columns. + */ + public static final String EVENT_UPDATED = "updated"; + + public enum Status { + /** Waiting for some prerequisite before we can use it for the first time. */ + STARTING, + /** Successfully created, not waiting for any messages to be accurate. */ + ACTIVE, + /** Waiting for an update to return from being active to being active again. */ + PENDING_UPDATE, + /** Closed or otherwise stopped, cannot be used again. */ + DONE; + } + + private final ClientTableState state; + private final WorkerConnection connection; + protected final int rowStyleColumn; + private JsArray columns; + private BitSet columnBitSet; + protected RangeSet viewportRowSet; + private boolean isReverseViewport; + private BarrageSubscriptionOptions options; + + private BiDiStream doExchange; + protected WebBarrageSubscription barrageSubscription; + + protected Status status = Status.STARTING; + + private String failMsg; + + public AbstractTableSubscription(ClientTableState state, WorkerConnection connection) { + state.retain(this); + this.state = state; + this.connection = connection; + rowStyleColumn = state.getRowFormatColumn() == null ? TableData.NO_ROW_FORMAT_COLUMN + : state.getRowFormatColumn().getIndex(); + + revive(); + } + + /** + * Creates the connection to the server. Used on initial connection, and for viewport reconnects. + */ + protected void revive() { + // Once the state is running, set up the actual subscription + // Don't let subscription be used again, table failed and user will have already gotten an error elsewhere + state.onRunning(s -> { + if (status != Status.STARTING) { + // already closed + return; + } + WebBarrageSubscription.ViewportChangedHandler viewportChangedHandler = this::onViewportChange; + WebBarrageSubscription.DataChangedHandler dataChangedHandler = this::onDataChanged; + + status = Status.ACTIVE; + this.barrageSubscription = + WebBarrageSubscription.subscribe(state, viewportChangedHandler, dataChangedHandler); + + doExchange = + connection.streamFactory().create( + headers -> connection.flightServiceClient().doExchange(headers), + (first, headers) -> connection.browserFlightServiceClient().openDoExchange(first, headers), + (next, headers, c) -> connection.browserFlightServiceClient().nextDoExchange(next, headers, + c::apply), + new FlightData()); + + doExchange.onData(this::onFlightData); + doExchange.onEnd(this::onStreamEnd); + + sendFirstSubscriptionRequest(); + }, + // If the upstream table fails, kill the subscription + this::fail, + // If the upstream table is closed, its because this subscription released it, do nothing + JsRunnable.doNothing()); + } + + public Status getStatus() { + return status; + } + + protected static FlatBufferBuilder subscriptionRequest(byte[] tableTicket, BitSet columns, + @Nullable RangeSet viewport, + BarrageSubscriptionOptions options, boolean isReverseViewport) { + FlatBufferBuilder sub = new FlatBufferBuilder(1024); + int colOffset = BarrageSubscriptionRequest.createColumnsVector(sub, columns.toByteArray()); + int viewportOffset = 0; + if (viewport != null) { + viewportOffset = + BarrageSubscriptionRequest.createViewportVector(sub, CompressedRangeSetReader.writeRange(viewport)); + } + int optionsOffset = options.appendTo(sub); + int tableTicketOffset = BarrageSubscriptionRequest.createTicketVector(sub, tableTicket); + BarrageSubscriptionRequest.startBarrageSubscriptionRequest(sub); + BarrageSubscriptionRequest.addColumns(sub, colOffset); + BarrageSubscriptionRequest.addViewport(sub, viewportOffset); + BarrageSubscriptionRequest.addSubscriptionOptions(sub, optionsOffset); + BarrageSubscriptionRequest.addTicket(sub, tableTicketOffset); + BarrageSubscriptionRequest.addReverseViewport(sub, isReverseViewport); + sub.finish(BarrageSubscriptionRequest.endBarrageSubscriptionRequest(sub)); + + return sub; + } + + protected abstract void sendFirstSubscriptionRequest(); + + protected void sendBarrageSubscriptionRequest(RangeSet viewport, JsArray columns, Double updateIntervalMs, + boolean isReverseViewport) { + if (status == Status.DONE) { + if (failMsg == null) { + throw new IllegalStateException("Can't change subscription, already closed"); + } else { + throw new IllegalStateException("Can't change subscription, already failed: " + failMsg); + } + } + status = Status.PENDING_UPDATE; + this.columns = columns; + this.viewportRowSet = viewport; + this.columnBitSet = makeColumnBitset(columns); + this.isReverseViewport = isReverseViewport; + this.options = BarrageSubscriptionOptions.builder() + .batchSize(WebBarrageSubscription.BATCH_SIZE) + .maxMessageSize(WebBarrageSubscription.MAX_MESSAGE_SIZE) + .columnConversionMode(ColumnConversionMode.Stringify) + .minUpdateIntervalMs(updateIntervalMs == null ? 0 : (int) (double) updateIntervalMs) + .columnsAsList(false)// TODO(deephaven-core#5927) flip this to true + .useDeephavenNulls(true) + .build(); + FlatBufferBuilder request = subscriptionRequest( + Js.uncheckedCast(state.getHandle().getTicket()), + columnBitSet, + viewport, + options, + isReverseViewport); + FlightData subscriptionRequest = new FlightData(); + subscriptionRequest + .setAppMetadata(WebBarrageUtils.wrapMessage(request, BarrageMessageType.BarrageSubscriptionRequest)); + doExchange.send(subscriptionRequest); + } + + protected BitSet makeColumnBitset(JsArray columns) { + return state.makeBitset(Js.uncheckedCast(columns)); + } + + public ClientTableState state() { + return state; + } + + protected WorkerConnection connection() { + return connection; + } + + protected boolean isSubscriptionReady() { + return status == Status.ACTIVE; + } + + public double size() { + if (status == Status.ACTIVE) { + return barrageSubscription.getCurrentRowSet().size(); + } + if (status == Status.DONE) { + throw new IllegalStateException("Can't read size when already closed"); + } + return state.getSize(); + } + + private void onDataChanged(RangeSet rowsAdded, RangeSet rowsRemoved, RangeSet totalMods, ShiftedRange[] shifted, + BitSet modifiedColumnSet) { + if (!isSubscriptionReady()) { + return; + } + + notifyUpdate(rowsAdded, rowsRemoved, totalMods, shifted); + } + + protected void notifyUpdate(RangeSet rowsAdded, RangeSet rowsRemoved, RangeSet totalMods, ShiftedRange[] shifted) { + // TODO (deephaven-core#2435) Rewrite shifts as adds/removed/modifies + UpdateEventData detail = new SubscriptionEventData( + barrageSubscription, + rowStyleColumn, + columns, + rowsAdded, + rowsRemoved, + totalMods, + shifted); + CustomEventInit event = CustomEventInit.create(); + event.setDetail(detail); + fireEvent(TableSubscription.EVENT_UPDATED, event); + } + + public static class SubscriptionRow implements TableData.Row { + private final WebBarrageSubscription subscription; + private final int rowStyleColumn; + protected final long index; + public LongWrapper indexCached; + + public SubscriptionRow(WebBarrageSubscription subscription, int rowStyleColumn, long index) { + this.subscription = subscription; + this.rowStyleColumn = rowStyleColumn; + this.index = index; + } + + @Override + public LongWrapper getIndex() { + if (indexCached == null) { + indexCached = LongWrapper.of(index); + } + return indexCached; + } + + @Override + public Any get(Column column) { + return subscription.getData(index, column.getIndex()); + } + + @Override + public Format getFormat(Column column) { + long cellColors = 0; + long rowColors = 0; + String numberFormat = null; + String formatString = null; + if (column.getStyleColumnIndex() != null) { + LongWrapper wrapper = subscription.getData(index, column.getStyleColumnIndex()).uncheckedCast(); + cellColors = wrapper == null ? 0 : wrapper.getWrapped(); + } + if (rowStyleColumn != TableData.NO_ROW_FORMAT_COLUMN) { + LongWrapper wrapper = subscription.getData(index, rowStyleColumn).uncheckedCast(); + rowColors = wrapper == null ? 0 : wrapper.getWrapped(); + } + if (column.getFormatStringColumnIndex() != null) { + numberFormat = subscription.getData(index, column.getFormatStringColumnIndex()).uncheckedCast(); + } + if (column.getFormatStringColumnIndex() != null) { + formatString = subscription.getData(index, column.getFormatStringColumnIndex()).uncheckedCast(); + } + return new Format(cellColors, rowColors, numberFormat, formatString); + } + } + + /** + * TableData type for both viewports and full table subscriptions. + */ + @TsIgnore + public static class SubscriptionEventData extends UpdateEventData implements ViewportData, SubscriptionTableData { + public SubscriptionEventData(WebBarrageSubscription subscription, int rowStyleColumn, JsArray columns, + RangeSet added, RangeSet removed, RangeSet modified, ShiftedRange[] shifted) { + super(subscription, rowStyleColumn, columns, added, removed, modified, shifted); + } + + @Override + public JsRangeSet getAdded() { + return added; + } + + @Override + public JsRangeSet getRemoved() { + return removed; + } + + @Override + public JsRangeSet getModified() { + return modified; + } + + @Override + public JsRangeSet getFullIndex() { + return fullRowSet; + } + } + + /** + * Base type to allow trees to extend from here separately from tables. + */ + @TsIgnore + public abstract static class UpdateEventData implements TableData { + protected final WebBarrageSubscription subscription; + private final int rowStyleColumn; + private final JsArray columns; + protected final JsRangeSet added; + protected final JsRangeSet removed; + protected final JsRangeSet modified; + protected final JsRangeSet fullRowSet; + + // cached copy in case it was requested, could be requested again + private JsArray allRows; + + private double offset; + + public UpdateEventData(WebBarrageSubscription subscription, int rowStyleColumn, JsArray columns, + RangeSet added, RangeSet removed, RangeSet modified, ShiftedRange[] shifted) { + this.subscription = subscription; + this.rowStyleColumn = rowStyleColumn; + this.columns = columns; + this.added = new JsRangeSet(added); + this.removed = new JsRangeSet(removed); + this.modified = new JsRangeSet(modified); + this.fullRowSet = new JsRangeSet(transformRowsetForConsumer(subscription.getCurrentRowSet(), + subscription.getServerViewport(), subscription.isReversed())); + } + + // for ViewportData + @JsProperty + public Double getOffset() { + return offset; + } + + public void setOffset(double offset) { + this.offset = offset; + } + + @Override + public JsArray getRows() { + if (allRows == null) { + allRows = new JsArray<>(); + fullRowSet.getRange().indexIterator().forEachRemaining((long index) -> { + allRows.push(makeRow(index)); + }); + if (JsSettings.isDevMode()) { + assert allRows.length == fullRowSet.getSize(); + } + } + return (JsArray) (JsArray) allRows; + } + + protected SubscriptionRow makeRow(long index) { + return new SubscriptionRow(subscription, rowStyleColumn, index); + } + + @Override + public Row get(int index) { + return this.get((long) index); + } + + @Override + public Row get(long index) { + return makeRow(index); + } + + @Override + public Any getData(int index, Column column) { + return getData((long) index, column); + } + + @Override + public Any getData(long key, Column column) { + return subscription.getData(fullRowSet.getRange().get(key), column.getIndex()); + } + + @Override + public Format getFormat(int index, Column column) { + return getFormat((long) index, column); + } + + @Override + public Format getFormat(long index, Column column) { + long key = fullRowSet.getRange().get(index); + long cellColors = 0; + long rowColors = 0; + String numberFormat = null; + String formatString = null; + if (column.getStyleColumnIndex() != null) { + LongWrapper wrapper = subscription.getData(key, column.getStyleColumnIndex()).uncheckedCast(); + cellColors = wrapper == null ? 0 : wrapper.getWrapped(); + } + if (rowStyleColumn != NO_ROW_FORMAT_COLUMN) { + LongWrapper wrapper = subscription.getData(key, column.getStyleColumnIndex()).uncheckedCast(); + rowColors = wrapper == null ? 0 : wrapper.getWrapped(); + } + if (column.getFormatStringColumnIndex() != null) { + numberFormat = subscription.getData(key, column.getFormatStringColumnIndex()).uncheckedCast(); + } + if (column.getFormatStringColumnIndex() != null) { + formatString = subscription.getData(key, column.getFormatStringColumnIndex()).uncheckedCast(); + } + return new Format(cellColors, rowColors, numberFormat, formatString); + } + + @Override + public JsArray getColumns() { + return columns; + } + } + + /** + * If a viewport is in use, transforms the given rowset to position space based on that viewport. + * + * @param rowSet the rowset to possibly transform + * @return a transformed rowset + */ + private static RangeSet transformRowsetForConsumer(RangeSet rowSet, @Nullable RangeSet viewport, boolean reversed) { + if (viewport != null) { + return rowSet.subsetForPositions(viewport, reversed); + } + return rowSet; + } + + private void onViewportChange(RangeSet serverViewport, BitSet serverColumns, boolean serverReverseViewport) { + boolean subscriptionReady = ((serverColumns == null && columnBitSet == null) + || (serverColumns == null && columnBitSet.cardinality() == state.getTableDef().getColumns().length) + || (serverColumns != null && serverColumns.equals(this.columnBitSet))) + && (serverViewport == null && this.viewportRowSet == null + || (serverViewport != null && serverViewport.equals(this.viewportRowSet))) + && serverReverseViewport == isReverseViewport; + if (subscriptionReady) { + status = Status.ACTIVE; + } + } + + private final WebBarrageStreamReader reader = new WebBarrageStreamReader(); + + private void onFlightData(FlightData data) { + WebBarrageMessage message; + try { + message = reader.parseFrom(options, state.chunkTypes(), state.columnTypes(), state.componentTypes(), data); + } catch (IOException e) { + throw new RuntimeException(e); + } + if (message != null) { + // This payload resulted in an update to the table's contents, inform the subscription + barrageSubscription.applyUpdates(message); + } + } + + protected void onStreamEnd(ResponseStreamWrapper.Status status) { + if (this.status == Status.DONE) { + return; + } + if (status.isTransportError()) { + // If the subscription isn't closed and we hit a transport error, allow it to restart + this.status = Status.STARTING; + } else { + // Subscription failed somehow, fire an event + fail(status.getDetails()); + } + } + + private void fail(String message) { + failureHandled(message); + this.status = Status.DONE; + doExchange = null; + failMsg = message; + } + + /** + * The columns that were subscribed to when this subscription was created + * + * @return {@link Column} + */ + public JsArray getColumns() { + return columns; + } + + /** + * Stops the subscription on the server. + */ + public void close() { + state.unretain(this); + if (doExchange != null) { + doExchange.end(); + doExchange.cancel(); + } + status = Status.DONE; + } +} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/QueryConstants.java b/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/QueryConstants.java deleted file mode 100644 index e49eb7c2846..00000000000 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/QueryConstants.java +++ /dev/null @@ -1,21 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.client.api.subscription; - - -/** - * Constants for null values within the Deephaven engine From io.deephaven.util.QueryConstants - */ -public interface QueryConstants { - char NULL_CHAR = Character.MAX_VALUE; - byte NULL_BYTE = Byte.MIN_VALUE; - short NULL_SHORT = Short.MIN_VALUE; - int NULL_INT = Integer.MIN_VALUE; - long NULL_LONG = Long.MIN_VALUE; - float NULL_FLOAT = -Float.MAX_VALUE; - double NULL_DOUBLE = -Double.MAX_VALUE; - byte NULL_BOOLEAN_AS_BYTE = NULL_BYTE; - byte TRUE_BOOLEAN_AS_BYTE = (byte) 1; - byte FALSE_BOOLEAN_AS_BYTE = (byte) 0; -} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/SubscriptionTableData.java b/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/SubscriptionTableData.java index 7c08d330e91..2067e9068db 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/SubscriptionTableData.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/SubscriptionTableData.java @@ -5,672 +5,53 @@ import com.vertispan.tsdefs.annotations.TsInterface; import com.vertispan.tsdefs.annotations.TsName; -import elemental2.core.JsArray; -import elemental2.dom.CustomEventInit; -import io.deephaven.web.client.api.*; -import io.deephaven.web.client.fu.JsSettings; -import io.deephaven.web.shared.data.*; -import io.deephaven.web.shared.data.columns.ColumnData; -import jsinterop.annotations.JsFunction; -import jsinterop.annotations.JsIgnore; -import jsinterop.annotations.JsMethod; +import io.deephaven.web.client.api.JsRangeSet; +import io.deephaven.web.client.api.TableData; import jsinterop.annotations.JsProperty; -import jsinterop.annotations.JsType; -import jsinterop.base.Any; -import jsinterop.base.Js; -import jsinterop.base.JsArrayLike; -import javax.annotation.Nullable; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.NavigableSet; -import java.util.PrimitiveIterator; -import java.util.TreeMap; -import static io.deephaven.web.client.api.subscription.ViewportData.NO_ROW_FORMAT_COLUMN; - -public class SubscriptionTableData { - @JsFunction - private interface ArrayCopy { - @SuppressWarnings("unusable-by-js") - void copyTo(Object destArray, long destPos, Object srcArray, int srcPos); - } - - private final JsArray columns; - private final int rowStyleColumn; - private final HasEventHandling evented; - - // the actual rows present on the client, in their correct order - private RangeSet index; - - // mappings from the index to the position of a row in the data array - private TreeMap redirectedIndexes; - - // rows in the data columns that no longer contain data and can be reused - private RangeSet reusableDestinations; - - // array of data columns, cast each to a jsarray to read rows - private Object[] data; - - public SubscriptionTableData(JsArray columns, int rowStyleColumn, HasEventHandling evented) { - this.columns = columns; - this.rowStyleColumn = rowStyleColumn; - this.evented = evented; - } - - // TODO support this being called multiple times so we can keep viewports going without clearing the data - public TableData handleSnapshot(TableSnapshot snapshot) { - // when changing snapshots we should actually rewrite the columns, possibly emulate ViewportData more? - ColumnData[] dataColumns = snapshot.getDataColumns(); - data = new Object[dataColumns.length]; - reusableDestinations = RangeSet.empty(); - redirectedIndexes = new TreeMap<>(); - index = snapshot.getIncludedRows(); - - long includedRowCount = snapshot.getIncludedRows().size(); - RangeSet destination = freeRows(includedRowCount); - boolean indexUpdated = false; - - for (int index = 0; index < dataColumns.length; index++) { - ColumnData dataColumn = dataColumns[index]; - if (dataColumn == null) { - // no data in this column, wasn't requested - continue; - } - - final int i = index; - Column column = columns.find((c, i1, i2) -> c.getIndex() == i); - - ArrayCopy arrayCopy = arrayCopyFuncForColumn(column); - - Object[] localCopy = new Object[(int) includedRowCount]; - data[index] = localCopy; - PrimitiveIterator.OfLong destIter = destination.indexIterator(); - PrimitiveIterator.OfLong indexIter = snapshot.getIncludedRows().indexIterator(); - int j = 0; - while (indexIter.hasNext()) { - assert destIter.hasNext(); - long dest = destIter.nextLong(); - long nextIndex = indexIter.nextLong(); - if (!indexUpdated) { - redirectedIndexes.put(nextIndex, dest); - } - arrayCopy.copyTo(localCopy, dest, dataColumn.getData(), j++); - } - assert !destIter.hasNext(); - indexUpdated = true; - } - - return notifyUpdates(index, RangeSet.empty(), RangeSet.empty()); - } +/** + * Event data, describing the indexes that were added/removed/updated, and providing access to Rows (and thus data in + * columns) either by index, or scanning the complete present index. + *

+ * This class supports two ways of reading the table - checking the changes made since the last update, and reading all + * data currently in the table. While it is more expensive to always iterate over every single row in the table, it may + * in some cases actually be cheaper than maintaining state separately and updating only the changes, though both + * options should be considered. + *

+ * The RangeSet objects allow iterating over the LongWrapper indexes in the table. Note that these "indexes" are not + * necessarily contiguous and may be negative, and represent some internal state on the server, allowing it to keep + * track of data efficiently. Those LongWrapper objects can be passed to the various methods on this instance to read + * specific rows or cells out of the table. + */ +@TsInterface +@TsName(name = "SubscriptionTableData", namespace = "dh") +public interface SubscriptionTableData extends TableData { + + + @JsProperty + JsRangeSet getFullIndex(); /** - * Helper to avoid appending many times when modifying indexes. The append() method should be called for each key - * _in order_ to ensure that RangeSet.addRange isn't called excessively. When no more items will be added, flush() - * must be called. + * The ordered set of row indexes added since the last update. + * + * @return the rangeset of rows added */ - private static class RangeSetAppendHelper { - private final RangeSet rangeSet; - - private long currentFirst = -1; - private long currentLast; - - public RangeSetAppendHelper(final RangeSet rangeSet) { - this.rangeSet = rangeSet; - } - - public void append(long key) { - assert key >= 0; - - if (currentFirst == -1) { - // first key to be added, move both first and last - currentFirst = key; - currentLast = key; - - return; - } - - if (key == currentLast + 1) { - // key appends to our current range - currentLast = key; - } else if (key == currentFirst - 1) { - // key appends to our current range - currentFirst = key; - } else { - // existing range doesn't match the new item, finish the old range and start a new one - rangeSet.addRange(new Range(currentFirst, currentLast)); - currentFirst = key; - currentLast = key; - } - } - - public void flush() { - if (currentFirst != -1) { - rangeSet.addRange(new Range(currentFirst, currentLast)); - currentFirst = -1; - } - } - } - - public TableData handleDelta(DeltaUpdates delta) { - // delete old data, track slots freed up. we do this by row since they might be non-contiguous or out of order - RangeSetAppendHelper reusableHelper = new RangeSetAppendHelper(reusableDestinations); - delta.getRemoved().indexIterator().forEachRemaining((long index) -> { - long dest = redirectedIndexes.remove(index); - reusableHelper.append(dest); - // TODO consider trimming the columns down too, and truncating the reusable slots at the end - }); - reusableHelper.flush(); - // clean up index by ranges, not by row - delta.getRemoved().rangeIterator().forEachRemaining(index::removeRange); - - // Shift moved rows in the redir index - boolean hasReverseShift = false; - final ShiftedRange[] shiftedRanges = delta.getShiftedRanges(); - RangeSetAppendHelper shifter = new RangeSetAppendHelper(index); - for (int i = shiftedRanges.length - 1; i >= 0; --i) { - final ShiftedRange shiftedRange = shiftedRanges[i]; - final long offset = shiftedRange.getDelta(); - if (offset < 0) { - hasReverseShift = true; - continue; - } - index.removeRange(shiftedRange.getRange()); - final NavigableSet toMove = redirectedIndexes.navigableKeySet() - .subSet(shiftedRange.getRange().getFirst(), true, shiftedRange.getRange().getLast(), true); - // iterate backward and move them forward - for (Long key : toMove.descendingSet()) { - long shiftedKey = key + offset; - Long oldValue = redirectedIndexes.put(shiftedKey, redirectedIndexes.remove(key)); - assert oldValue == null : shiftedKey + " already has a value, " + oldValue; - shifter.append(shiftedKey); - } - } - if (hasReverseShift) { - for (int i = 0; i < shiftedRanges.length; ++i) { - final ShiftedRange shiftedRange = shiftedRanges[i]; - final long offset = shiftedRange.getDelta(); - if (offset > 0) { - continue; - } - index.removeRange(shiftedRange.getRange()); - final NavigableSet toMove = redirectedIndexes.navigableKeySet() - .subSet(shiftedRange.getRange().getFirst(), true, shiftedRange.getRange().getLast(), true); - // iterate forward and move them backward - for (Long key : toMove) { - long shiftedKey = key + offset; - Long oldValue = redirectedIndexes.put(shiftedKey, redirectedIndexes.remove(key)); - assert oldValue == null : shiftedKey + " already has a value, " + oldValue; - shifter.append(shiftedKey); - } - } - } - shifter.flush(); - - // Find space for the rows we're about to add. We must not adjust the index until this is done, it is used - // to see where the end of the data is - RangeSet addedDestination = freeRows(delta.getAdded().size()); - // Within each column, append additions - DeltaUpdates.ColumnAdditions[] additions = delta.getSerializedAdditions(); - for (int i = 0; i < additions.length; i++) { - DeltaUpdates.ColumnAdditions addedColumn = delta.getSerializedAdditions()[i]; - Column column = columns.find((c, i1, i2) -> c.getIndex() == addedColumn.getColumnIndex()); - - ArrayCopy arrayCopy = arrayCopyFuncForColumn(column); - - PrimitiveIterator.OfLong addedIndexes = delta.getAdded().indexIterator(); - PrimitiveIterator.OfLong destIter = addedDestination.indexIterator(); - int j = 0; - while (addedIndexes.hasNext()) { - long origIndex = addedIndexes.nextLong(); - assert delta.getIncludedAdditions().contains(origIndex); - assert destIter.hasNext(); - long dest = destIter.nextLong(); - Long old = redirectedIndexes.put(origIndex, dest); - assert old == null || old == dest; - arrayCopy.copyTo(data[addedColumn.getColumnIndex()], dest, addedColumn.getValues().getData(), j++); - } - } - - // Update the index to reflect the added items - delta.getAdded().rangeIterator().forEachRemaining(index::addRange); - - // Within each column, apply modifications - DeltaUpdates.ColumnModifications[] modifications = delta.getSerializedModifications(); - RangeSet allModified = new RangeSet(); - for (int i = 0; i < modifications.length; ++i) { - final DeltaUpdates.ColumnModifications modifiedColumn = modifications[i]; - if (modifiedColumn == null) { - continue; - } - - modifiedColumn.getRowsIncluded().rangeIterator().forEachRemaining(allModified::addRange); - Column column = columns.find((c, i1, i2) -> c.getIndex() == modifiedColumn.getColumnIndex()); - - ArrayCopy arrayCopy = arrayCopyFuncForColumn(column); - - PrimitiveIterator.OfLong modifiedIndexes = modifiedColumn.getRowsIncluded().indexIterator(); - int j = 0; - while (modifiedIndexes.hasNext()) { - long origIndex = modifiedIndexes.nextLong(); - arrayCopy.copyTo(data[modifiedColumn.getColumnIndex()], redirectedIndexes.get(origIndex), - modifiedColumn.getValues().getData(), j++); - } - } - - // Check that the index sizes make sense - assert redirectedIndexes.size() == index.size(); - // Note that we can't do this assert, since we don't truncate arrays, we just leave nulls at the end - // assert Js.asArrayLike(data[0]).getLength() == redirectedIndexes.size(); - - return notifyUpdates(delta.getAdded(), delta.getRemoved(), allModified); - } - - private TableData notifyUpdates(RangeSet added, RangeSet removed, RangeSet modified) { - UpdateEventData detail = new UpdateEventData(added, removed, modified); - if (evented != null) { - CustomEventInit event = CustomEventInit.create(); - event.setDetail(detail); - evented.fireEvent(TableSubscription.EVENT_UPDATED, event); - } - return detail; - } - - private ArrayCopy arrayCopyFuncForColumn(@Nullable Column column) { - final String type = column != null ? column.getType() : ""; - switch (type) { - case "long": - return (destArray, destPos, srcArray, srcPos) -> { - final long value = Js.asArrayLike(srcArray).getAtAsAny(srcPos).asLong(); - if (value == QueryConstants.NULL_LONG) { - Js.asArrayLike(destArray).setAt((int) destPos, null); - } else { - Js.asArrayLike(destArray).setAt((int) destPos, LongWrapper.of(value)); - } - }; - case "java.time.Instant": - case "java.time.ZonedDateTime": - return (destArray, destPos, srcArray, srcPos) -> { - long value = Js.asArrayLike(srcArray).getAtAsAny(srcPos).asLong(); - if (value == QueryConstants.NULL_LONG) { - Js.asArrayLike(destArray).setAt((int) destPos, null); - } else { - Js.asArrayLike(destArray).setAt((int) destPos, new DateWrapper(value)); - } - }; - case "java.math.BigDecimal": - return (destArray, destPos, srcArray, srcPos) -> { - final BigDecimal value = Js.cast(Js.asArrayLike(srcArray).getAt(srcPos)); - if (value == null) { - Js.asArrayLike(destArray).setAt((int) destPos, null); - } else { - Js.asArrayLike(destArray).setAt((int) destPos, new BigDecimalWrapper(value)); - } - }; - case "java.math.BigInteger": - return (destArray, destPos, srcArray, srcPos) -> { - final BigInteger value = Js.cast(Js.asArrayLike(srcArray).getAt(srcPos)); - if (value == null) { - Js.asArrayLike(destArray).setAt((int) destPos, null); - } else { - Js.asArrayLike(destArray).setAt((int) destPos, new BigIntegerWrapper(value)); - } - }; - case "java.time.LocalDate": - return (destArray, destPos, srcArray, srcPos) -> { - final LocalDate value = Js.cast(Js.asArrayLike(srcArray).getAt(srcPos)); - if (value == null) { - Js.asArrayLike(destArray).setAt((int) destPos, null); - } else { - Js.asArrayLike(destArray).setAt((int) destPos, new LocalDateWrapper(value)); - } - }; - case "java.time.LocalTime": - return (destArray, destPos, srcArray, srcPos) -> { - final LocalTime value = Js.cast(Js.asArrayLike(srcArray).getAt(srcPos)); - if (value == null) { - Js.asArrayLike(destArray).setAt((int) destPos, null); - } else { - Js.asArrayLike(destArray).setAt((int) destPos, new LocalTimeWrapper(value)); - } - }; - case "java.lang.Boolean": - return (destArray, destPos, srcArray, srcPos) -> { - final Any value = Js.asArrayLike(srcArray).getAtAsAny(srcPos); - - if (value == null) { - Js.asArrayLike(destArray).setAt((int) destPos, null); - } else if (value.asBoolean()) { - Js.asArrayLike(destArray).setAt((int) destPos, true); - } else { - Js.asArrayLike(destArray).setAt((int) destPos, false); - } - }; - case "int": - return (destArray, destPos, srcArray, srcPos) -> { - final int value = Js.asArrayLike(srcArray).getAtAsAny(srcPos).asInt(); - if (value == QueryConstants.NULL_INT) { - Js.asArrayLike(destArray).setAt((int) destPos, null); - } else { - Js.asArrayLike(destArray).setAt((int) destPos, value); - } - }; - case "byte": - return (destArray, destPos, srcArray, srcPos) -> { - final byte value = Js.asArrayLike(srcArray).getAtAsAny(srcPos).asByte(); - if (value == QueryConstants.NULL_BYTE) { - Js.asArrayLike(destArray).setAt((int) destPos, null); - } else { - Js.asArrayLike(destArray).setAt((int) destPos, value); - } - }; - case "short": - return (destArray, destPos, srcArray, srcPos) -> { - final short value = Js.asArrayLike(srcArray).getAtAsAny(srcPos).asShort(); - if (value == QueryConstants.NULL_SHORT) { - Js.asArrayLike(destArray).setAt((int) destPos, null); - } else { - Js.asArrayLike(destArray).setAt((int) destPos, value); - } - }; - case "double": - return (destArray, destPos, srcArray, srcPos) -> { - final double value = Js.asArrayLike(srcArray).getAtAsAny(srcPos).asDouble(); - if (value == QueryConstants.NULL_DOUBLE) { - Js.asArrayLike(destArray).setAt((int) destPos, null); - } else { - Js.asArrayLike(destArray).setAt((int) destPos, value); - } - }; - case "float": - return (destArray, destPos, srcArray, srcPos) -> { - final float value = Js.asArrayLike(srcArray).getAtAsAny(srcPos).asFloat(); - if (value == QueryConstants.NULL_FLOAT) { - Js.asArrayLike(destArray).setAt((int) destPos, null); - } else { - Js.asArrayLike(destArray).setAt((int) destPos, value); - } - }; - case "char": - return (destArray, destPos, srcArray, srcPos) -> { - final char value = Js.asArrayLike(srcArray).getAtAsAny(srcPos).asChar(); - if (value == QueryConstants.NULL_CHAR) { - Js.asArrayLike(destArray).setAt((int) destPos, null); - } else { - Js.asArrayLike(destArray).setAt((int) destPos, value); - } - }; - default: - // exit so we can handle null also in the method's final return - } - return (destArray, destPos, srcArray, srcPos) -> { - // boring column or format data, just copy it - Js.asArrayLike(destArray).setAt((int) destPos, Js.asArrayLike(srcArray).getAt(srcPos)); - }; - } - - private RangeSet freeRows(long required) { - if (required == 0) { - return RangeSet.empty(); - } - long existingSlotsToReuse = reusableDestinations.size(); - if (existingSlotsToReuse > required) { - // only take some of the ranges from the reusable list - RangeSet reused = RangeSet.empty(); - long taken = 0; - RangeSet stillUnused = RangeSet.empty(); - // TODO this could be more efficient, iterating entire ranges until we only need a partial range - PrimitiveIterator.OfLong iterator = reusableDestinations.indexIterator(); - while (taken < required) { - assert iterator.hasNext(); - long value = iterator.nextLong(); - reused.addRange(new Range(value, value)); - taken++; - } - assert taken == required; - while (iterator.hasNext()) { - long value = iterator.nextLong(); - stillUnused.addRange(new Range(value, value)); - } - reusableDestinations = stillUnused; - assert required == reused.size(); - return reused; - } - // take all ranges from the reusable list (plus make more if needed) - RangeSet created = reusableDestinations; - if (existingSlotsToReuse < required) { - long nextIndex; - if (created.isEmpty()) { - if (index.isEmpty()) { - nextIndex = 0; - } else { - nextIndex = redirectedIndexes.size(); - } - } else if (index.isEmpty()) { - nextIndex = created.getLastRow() + 1; - } else { - nextIndex = Math.max(created.getLastRow(), index.getLastRow()) + 1; - } - created.addRange(new Range(nextIndex, nextIndex + required - existingSlotsToReuse - 1)); - } - - reusableDestinations = RangeSet.empty(); - assert required == created.size(); - return created; - } - - @TsInterface - @TsName(namespace = "dh") - public class SubscriptionRow implements TableData.Row { - private final long index; - public LongWrapper indexCached; - - public SubscriptionRow(long index) { - this.index = index; - } - - @Override - public LongWrapper getIndex() { - if (indexCached == null) { - indexCached = LongWrapper.of(index); - } - return indexCached; - } - - @Override - public Any get(Column column) { - int redirectedIndex = (int) (long) redirectedIndexes.get(this.index); - JsArrayLike columnData = Js.asArrayLike(data[column.getIndex()]); - return columnData.getAtAsAny(redirectedIndex); - } - - @Override - public Format getFormat(Column column) { - long cellColors = 0; - long rowColors = 0; - String numberFormat = null; - String formatString = null; - int redirectedIndex = (int) (long) redirectedIndexes.get(this.index); - if (column.getStyleColumnIndex() != null) { - JsArray colors = Js.uncheckedCast(data[column.getStyleColumnIndex()]); - cellColors = colors.getAtAsAny(redirectedIndex).asLong(); - } - if (rowStyleColumn != NO_ROW_FORMAT_COLUMN) { - JsArray rowStyle = Js.uncheckedCast(data[rowStyleColumn]); - rowColors = rowStyle.getAtAsAny(redirectedIndex).asLong(); - } - if (column.getFormatColumnIndex() != null) { - JsArray formatStrings = Js.uncheckedCast(data[column.getFormatColumnIndex()]); - numberFormat = formatStrings.getAtAsAny(redirectedIndex).asString(); - } - if (column.getFormatStringColumnIndex() != null) { - JsArray formatStrings = Js.uncheckedCast(data[column.getFormatStringColumnIndex()]); - formatString = formatStrings.getAtAsAny(redirectedIndex).asString(); - } - return new Format(cellColors, rowColors, numberFormat, formatString); - } - } - + @JsProperty + JsRangeSet getAdded(); /** - * Event data, describing the indexes that were added/removed/updated, and providing access to Rows (and thus data - * in columns) either by index, or scanning the complete present index. + * The ordered set of row indexes removed since the last update * - * This class supports two ways of reading the table - checking the changes made since the last update, and reading - * all data currently in the table. While it is more expensive to always iterate over every single row in the table, - * it may in some cases actually be cheaper than maintaining state separately and updating only the changes, though - * both options should be considered. - * - * The RangeSet objects allow iterating over the LongWrapper indexes in the table. Note that these "indexes" are not - * necessarily contiguous and may be negative, and represent some internal state on the server, allowing it to keep - * track of data efficiently. Those LongWrapper objects can be passed to the various methods on this instance to - * read specific rows or cells out of the table. + * @return the rangeset of removed rows */ - @TsInterface - @TsName(name = "SubscriptionTableData", namespace = "dh") - public class UpdateEventData implements TableData { - private JsRangeSet added; - private JsRangeSet removed; - private JsRangeSet modified; - - // cached copy in case it was requested, could be requested again - private JsArray allRows; + @JsProperty + JsRangeSet getRemoved(); - public UpdateEventData(RangeSet added, RangeSet removed, RangeSet modified) { - this.added = new JsRangeSet(added); - this.removed = new JsRangeSet(removed); - this.modified = new JsRangeSet(modified); - } - - /** - * A lazily computed array of all rows in the entire table - * - * @return {@link SubscriptionRow} array. - */ - @Override - public JsArray getRows() { - if (allRows == null) { - allRows = new JsArray<>(); - index.indexIterator().forEachRemaining((long index) -> { - allRows.push(new SubscriptionRow(index)); - }); - if (JsSettings.isDevMode()) { - assert allRows.length == index.size(); - } - } - return allRows; - } - - @Override - public Row get(int index) { - return this.get((long) index); - } - - /** - * Reads a row object from the table, from which any subscribed column can be read - * - * @param index - * @return {@link SubscriptionRow} - */ - @Override - public SubscriptionRow get(long index) { - return new SubscriptionRow(index); - } - - @Override - public Any getData(int index, Column column) { - return getData((long) index, column); - } - - /** - * a specific cell from the table, from the specified row and column - * - * @param index - * @param column - * @return Any - */ - @Override - public Any getData(long index, Column column) { - int redirectedIndex = (int) (long) redirectedIndexes.get(index); - JsArrayLike columnData = Js.asArrayLike(data[column.getIndex()]); - return columnData.getAtAsAny(redirectedIndex); - } - - /** - * the Format to use for a cell from the specified row and column - * - * @param index - * @param column - * @return {@link Format} - */ - @Override - public Format getFormat(int index, Column column) { - return getFormat((long) index, column); - } - - @Override - public Format getFormat(long index, Column column) { - long cellColors = 0; - long rowColors = 0; - String numberFormat = null; - String formatString = null; - int redirectedIndex = (int) (long) redirectedIndexes.get(index); - if (column.getStyleColumnIndex() != null) { - JsArray colors = Js.uncheckedCast(data[column.getStyleColumnIndex()]); - cellColors = colors.getAtAsAny(redirectedIndex).asLong(); - } - if (rowStyleColumn != NO_ROW_FORMAT_COLUMN) { - JsArray rowStyle = Js.uncheckedCast(data[rowStyleColumn]); - rowColors = rowStyle.getAtAsAny(redirectedIndex).asLong(); - } - if (column.getFormatColumnIndex() != null) { - JsArray formatStrings = Js.uncheckedCast(data[column.getFormatColumnIndex()]); - numberFormat = formatStrings.getAtAsAny(redirectedIndex).asString(); - } - if (column.getFormatStringColumnIndex() != null) { - JsArray formatStrings = Js.uncheckedCast(data[column.getFormatStringColumnIndex()]); - formatString = formatStrings.getAtAsAny(redirectedIndex).asString(); - } - return new Format(cellColors, rowColors, numberFormat, formatString); - } - - @Override - public JsArray getColumns() { - return columns; - } - - /** - * The ordered set of row indexes added since the last update - * - * @return dh.RangeSet - */ - @JsProperty - public JsRangeSet getAdded() { - return added; - } - - /** - * The ordered set of row indexes removed since the last update - * - * @return dh.RangeSet - */ - @JsProperty - public JsRangeSet getRemoved() { - return removed; - } - - /** - * The ordered set of row indexes updated since the last update - * - * @return dh.RangeSet - */ - @JsProperty - public JsRangeSet getModified() { - return modified; - } - - @JsProperty - public JsRangeSet getFullIndex() { - return new JsRangeSet(index); - } - } + /** + * The ordered set of row indexes updated since the last update + * + * @return the rnageset of modified rows + */ + @JsProperty + JsRangeSet getModified(); } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/TableSubscription.java b/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/TableSubscription.java index f94aa9a5775..e8399666d9c 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/TableSubscription.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/TableSubscription.java @@ -3,21 +3,14 @@ // package io.deephaven.web.client.api.subscription; -import com.vertispan.tsdefs.annotations.TsName; import elemental2.core.JsArray; -import elemental2.promise.Promise; import io.deephaven.web.client.api.Column; -import io.deephaven.web.client.api.HasEventHandling; import io.deephaven.web.client.api.JsTable; -import io.deephaven.web.shared.data.DeltaUpdates; -import io.deephaven.web.shared.data.TableSnapshot; import jsinterop.annotations.JsIgnore; -import jsinterop.annotations.JsMethod; +import jsinterop.annotations.JsNullable; import jsinterop.annotations.JsProperty; import jsinterop.annotations.JsType; -import static io.deephaven.web.client.api.subscription.ViewportData.NO_ROW_FORMAT_COLUMN; - /** * Represents a non-viewport subscription to a table, and all data currently known to be present in the subscribed * columns. This class handles incoming snapshots and deltas, and fires events to consumers to notify of data changes. @@ -31,80 +24,40 @@ * viewports to make it less expensive to compute for large tables. */ @JsType(namespace = "dh") -public class TableSubscription extends HasEventHandling { - - /** - * Indicates that some new data is available on the client, either an initial snapshot or a delta update. The - * detail field of the event will contain a TableSubscriptionEventData detailing what has changed, or - * allowing access to the entire range of items currently in the subscribed columns. - */ - public static final String EVENT_UPDATED = "updated"; - - - // column defs in this subscription - private JsArray columns; - // holder for data - private SubscriptionTableData data; +public final class TableSubscription extends AbstractTableSubscription { - // table created for this subscription - private Promise copy; + private final JsArray columns; + private final Double updateIntervalMs; - // copy from the initially given table so we don't need to way @JsIgnore public TableSubscription(JsArray columns, JsTable existingTable, Double updateIntervalMs) { - - copy = existingTable.copy(false).then(table -> new Promise<>((resolve, reject) -> { - table.state().onRunning(newState -> { - // TODO handle updateInterval core#188 - table.internalSubscribe(columns, this); - - resolve.onInvoke(table); - }, table::close); - })); - + super(existingTable.state(), existingTable.getConnection()); this.columns = columns; - Integer rowStyleColumn = existingTable.state().getRowFormatColumn() == null ? NO_ROW_FORMAT_COLUMN - : existingTable.state().getRowFormatColumn().getIndex(); - this.data = new SubscriptionTableData(columns, rowStyleColumn, this); - - } - - // public void changeSubscription(JsArray columns) { - // copy.then(t ->{ - // t.internalSubscribe(columns, this); - // return Promise.resolve(t); - // }); - // this.columns = columns; - // } - - - @JsIgnore - public void handleSnapshot(TableSnapshot snapshot) { - data.handleSnapshot(snapshot); + this.updateIntervalMs = updateIntervalMs; } - @JsIgnore - public void handleDelta(DeltaUpdates delta) { - data.handleDelta(delta); + @Override + protected void sendFirstSubscriptionRequest() { + changeSubscription(columns, updateIntervalMs); } /** - * The columns that were subscribed to when this subscription was created + * Updates the subscription to use the given columns and update interval. * - * @return {@link Column} + * @param columns the new columns to subscribe to + * @param updateIntervalMs the new update interval, or null/omit to use the default of one second */ - @JsProperty - public JsArray getColumns() { - return columns; + public void changeSubscription(JsArray columns, @JsNullable Double updateIntervalMs) { + if (updateIntervalMs != null && !updateIntervalMs.equals(this.updateIntervalMs)) { + throw new IllegalArgumentException( + "Can't change refreshIntervalMs on a later call to setViewport, it must be consistent or omitted"); + } + sendBarrageSubscriptionRequest(null, columns, updateIntervalMs, false); } - /** - * Stops the subscription on the server. - */ - public void close() { - copy.then(table -> { - table.close(); - return Promise.resolve(table); - }); + @JsProperty + @Override + public JsArray getColumns() { + return super.getColumns(); } } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/TableViewportSubscription.java b/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/TableViewportSubscription.java index d567fbd3094..203dc0c7890 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/TableViewportSubscription.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/TableViewportSubscription.java @@ -3,188 +3,240 @@ // package io.deephaven.web.client.api.subscription; -import com.vertispan.tsdefs.annotations.TsInterface; +import com.google.flatbuffers.FlatBufferBuilder; import com.vertispan.tsdefs.annotations.TsName; -import elemental2.core.Uint8Array; +import com.vertispan.tsdefs.annotations.TsTypeRef; +import elemental2.core.JsArray; import elemental2.dom.CustomEvent; import elemental2.dom.CustomEventInit; -import elemental2.dom.DomGlobal; -import elemental2.promise.IThenable; import elemental2.promise.Promise; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.Message; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.MessageHeader; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.RecordBatch; +import io.deephaven.barrage.flatbuf.BarrageMessageType; +import io.deephaven.barrage.flatbuf.BarrageSnapshotRequest; +import io.deephaven.extensions.barrage.BarrageSnapshotOptions; +import io.deephaven.extensions.barrage.ColumnConversionMode; import io.deephaven.javascript.proto.dhinternal.arrow.flight.protocol.flight_pb.FlightData; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageMessageType; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageMessageWrapper; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageSnapshotOptions; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageSnapshotRequest; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageUpdateMetadata; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.ColumnConversionMode; -import io.deephaven.web.client.api.Callbacks; +import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.config_pb.ConfigValue; +import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.FlattenRequest; +import io.deephaven.util.mutable.MutableLong; import io.deephaven.web.client.api.Column; -import io.deephaven.web.client.api.HasEventHandling; import io.deephaven.web.client.api.JsRangeSet; import io.deephaven.web.client.api.JsTable; import io.deephaven.web.client.api.TableData; import io.deephaven.web.client.api.WorkerConnection; +import io.deephaven.web.client.api.barrage.WebBarrageMessage; +import io.deephaven.web.client.api.barrage.WebBarrageStreamReader; import io.deephaven.web.client.api.barrage.WebBarrageUtils; -import io.deephaven.web.client.api.barrage.def.ColumnDefinition; +import io.deephaven.web.client.api.barrage.data.WebBarrageSubscription; import io.deephaven.web.client.api.barrage.stream.BiDiStream; import io.deephaven.web.client.fu.JsLog; +import io.deephaven.web.client.fu.LazyPromise; import io.deephaven.web.client.state.ClientTableState; import io.deephaven.web.shared.data.Range; -import io.deephaven.web.shared.data.TableSnapshot; +import io.deephaven.web.shared.data.RangeSet; +import io.deephaven.web.shared.data.ShiftedRange; +import io.deephaven.web.shared.fu.RemoverFn; import jsinterop.annotations.JsMethod; import jsinterop.annotations.JsNullable; import jsinterop.annotations.JsOptional; import jsinterop.base.Js; +import jsinterop.base.JsPropertyMap; +import java.io.IOException; import java.util.Arrays; -import java.util.BitSet; import java.util.Collections; -import java.util.Iterator; +import java.util.Comparator; +import java.util.PrimitiveIterator; -import static io.deephaven.web.client.api.barrage.WebBarrageUtils.makeUint8ArrayFromBitset; +import static io.deephaven.web.client.api.JsTable.EVENT_ROWADDED; +import static io.deephaven.web.client.api.JsTable.EVENT_ROWREMOVED; +import static io.deephaven.web.client.api.JsTable.EVENT_ROWUPDATED; import static io.deephaven.web.client.api.barrage.WebBarrageUtils.serializeRanges; -import static io.deephaven.web.client.api.subscription.ViewportData.NO_ROW_FORMAT_COLUMN; /** - * Encapsulates event handling around table subscriptions by "cheating" and wrapping up a JsTable instance to do the - * real dirty work. This allows a viewport to stay open on the old table if desired, while this one remains open. - *

- * As this just wraps a JsTable (and thus a CTS), it holds its own flattened, pUT'd handle to get deltas from the - * server. The setViewport method can be used to adjust this table instead of creating a new one. - *

- * Existing methods on JsTable like setViewport and getViewportData are intended to proxy to this, which then will talk - * to the underlying handle and accumulated data. - *

- * As long as we keep the existing methods/events on JsTable, close() is not required if no other method is called, with - * the idea then that the caller did not actually use this type. This means that for every exported method (which then - * will mark the instance of "actually being used, please don't automatically close me"), there must be an internal - * version called by those existing JsTable method, which will allow this instance to be cleaned up once the JsTable - * deems it no longer in use. - *

- * Note that if the caller does close an instance, this shuts down the JsTable's use of this (while the converse is not - * true), providing a way to stop the server from streaming updates to the client. - * * This object serves as a "handle" to a subscription, allowing it to be acted on directly or canceled outright. If you * retain an instance of this, you have two choices - either only use it to call `close()` on it to stop the table's * viewport without creating a new one, or listen directly to this object instead of the table for data events, and * always call `close()` when finished. Calling any method on this object other than close() will result in it * continuing to live on after `setViewport` is called on the original table, or after the table is modified. */ -@TsInterface @TsName(namespace = "dh") -public class TableViewportSubscription extends HasEventHandling { - /** - * Describes the possible lifecycle of the viewport as far as anything external cares about it - */ - public enum Status { - /** - * Waiting for some prerequisite before we can begin, usually waiting to make sure the original table is ready - * to be subscribed to. Once the original table is ready, we will enter the ACTIVE state, even if the first - * update hasn't yet arrived. - */ - STARTING, - /** - * Successfully created, viewport is at least begun on the server, updates are subscribed and if changes happen - * on the server, we will be notified. - */ - ACTIVE, - /** - * Closed or otherwise dead, can not be used again. - */ - DONE - } +public class TableViewportSubscription extends AbstractTableSubscription { - private final double refresh; + private double firstRow; + private double lastRow; + private Column[] columns; + private double refresh; private final JsTable original; - private final ClientTableState originalState; - private final Promise copy; - private JsTable realized; + private final RemoverFn reconnectSubscription; - private boolean retained;// if the sub is set up to not close the underlying table once the original table is done - // with it + /** The initial state of the provided table, before flattening. */ + private final ClientTableState initialState; + + /** + * true if the sub is set up to not close the underlying table once the original table is done with it, otherwise + * false. + */ private boolean originalActive = true; + /** + * true if the developer has called methods directly on the subscription, otherwise false. + */ + private boolean retained; + + private UpdateEventData viewportData; + + public static TableViewportSubscription make(double firstRow, double lastRow, Column[] columns, + Double updateIntervalMs, JsTable existingTable) { + ClientTableState tableState = existingTable.state(); + WorkerConnection connection = existingTable.getConnection(); + + final ClientTableState stateToSubscribe; + ConfigValue flattenViewport = connection.getServerConfigValue("web.flattenViewports"); + if (flattenViewport != null && flattenViewport.hasStringValue() + && "true".equalsIgnoreCase(flattenViewport.getStringValue())) { + stateToSubscribe = connection.newState((callback, newState, metadata) -> { + FlattenRequest flatten = new FlattenRequest(); + flatten.setSourceId(tableState.getHandle().makeTableReference()); + flatten.setResultId(newState.getHandle().makeTicket()); + connection.tableServiceClient().flatten(flatten, metadata, callback::apply); + }, "flatten"); + stateToSubscribe.refetch(null, connection.metadata()).then(result -> null, err -> null); + } else { + stateToSubscribe = tableState; + } - private Status status = Status.STARTING; + TableViewportSubscription sub = new TableViewportSubscription(stateToSubscribe, connection, existingTable); + sub.setInternalViewport(firstRow, lastRow, columns, updateIntervalMs, false); + return sub; + } - public TableViewportSubscription(double firstRow, double lastRow, Column[] columns, Double updateIntervalMs, - JsTable existingTable) { - refresh = updateIntervalMs == null ? 1000.0 : updateIntervalMs; - // first off, copy the table, and flatten/pUT it, then apply the new viewport to that + public TableViewportSubscription(ClientTableState state, WorkerConnection connection, JsTable existingTable) { + super(state, connection); this.original = existingTable; - this.originalState = original.state(); - copy = existingTable.copy(false).then(table -> new Promise<>((resolve, reject) -> { - // Wait until the state is running to copy it - originalState.onRunning(newState -> { - if (this.status == Status.DONE) { - JsLog.debug("TableViewportSubscription closed before originalState.onRunning completed, ignoring"); - table.close(); - return; - } - table.batch(batcher -> { - batcher.customColumns(newState.getCustomColumns()); - batcher.filter(newState.getFilters()); - batcher.sort(newState.getSorts()); - batcher.setFlat(true); - }); - // TODO handle updateInterval core#188 - Column[] columnsToSub = table.isBlinkTable() ? Js.uncheckedCast(table.getColumns()) : columns; - table.setInternalViewport(firstRow, lastRow, columnsToSub); - - // Listen for events and refire them on ourselves, optionally on the original table - table.addEventListener(JsTable.EVENT_UPDATED, this::refire); - table.addEventListener(JsTable.EVENT_ROWADDED, this::refire); - table.addEventListener(JsTable.EVENT_ROWREMOVED, this::refire); - table.addEventListener(JsTable.EVENT_ROWUPDATED, this::refire); - table.addEventListener(JsTable.EVENT_SIZECHANGED, this::refire); - // TODO (core#1181): fix this hack that enables barrage errors to propagate to the UI widget - table.addEventListener(JsTable.EVENT_REQUEST_FAILED, this::refire); - - // Take over for the "parent" table - // Cache original table size so we can tell if we need to notify about a change - double originalSize = newState.getSize(); - realized = table; - status = Status.ACTIVE; - // At this point we're now responsible for notifying of size changes, since we will shortly have a - // viewport, - // a more precise way to track the table size (at least w.r.t. the range of the viewport), so if there - // is any difference in size between "realized" and "original", notify now to finish the transition. - if (realized.getSize() != originalSize) { - JsLog.debug( - "firing size changed to transition between table managing its own size changes and viewport sub taking over", - realized.getSize()); - CustomEventInit init = CustomEventInit.create(); - init.setDetail(realized.getSize()); - refire(new CustomEvent(JsTable.EVENT_SIZECHANGED, init)); + initialState = existingTable.state(); + this.reconnectSubscription = existingTable.addEventListener(JsTable.EVENT_RECONNECT, e -> { + if (existingTable.state() == initialState) { + revive(); + } + }); + } + + // Expose this as public + @Override + public void revive() { + super.revive(); + } + + @Override + protected void sendFirstSubscriptionRequest() { + setInternalViewport(firstRow, lastRow, columns, refresh, null); + } + + @Override + protected void notifyUpdate(RangeSet rowsAdded, RangeSet rowsRemoved, RangeSet totalMods, ShiftedRange[] shifted) { + // viewport subscriptions are sometimes required to notify of size change events + if (rowsAdded.size() != rowsRemoved.size() && originalActive) { + fireEventWithDetail(JsTable.EVENT_SIZECHANGED, size()); + } + UpdateEventData detail = new SubscriptionEventData(barrageSubscription, rowStyleColumn, getColumns(), rowsAdded, + rowsRemoved, totalMods, shifted); + + detail.setOffset(this.viewportRowSet.getFirstRow()); + this.viewportData = detail; + CustomEventInit event = CustomEventInit.create(); + event.setDetail(detail); + refire(new CustomEvent<>(EVENT_UPDATED, event)); + + if (hasListeners(EVENT_ROWADDED) || hasListeners(EVENT_ROWREMOVED) || hasListeners(EVENT_ROWUPDATED)) { + RangeSet modifiedCopy = totalMods.copy(); + // exclude added items from being marked as modified, since we're hiding shifts from api consumers + modifiedCopy.removeRangeSet(rowsAdded); + RangeSet removedCopy = rowsRemoved.copy(); + RangeSet addedCopy = rowsAdded.copy(); + + // Any position which was both added and removed should instead be marked as modified, this cleans + // up anything excluded above that didn't otherwise make sense + for (PrimitiveIterator.OfLong it = removedCopy.indexIterator(); it.hasNext();) { + long index = it.nextLong(); + if (addedCopy.contains(index)) { + addedCopy.removeRange(new Range(index, index)); + it.remove(); + modifiedCopy.addRange(new Range(index, index)); } + } - resolve.onInvoke(table); - }, table::close); - })); + fireLegacyEventOnRowsetEntries(EVENT_ROWADDED, detail, rowsAdded); + fireLegacyEventOnRowsetEntries(EVENT_ROWUPDATED, detail, totalMods); + fireLegacyEventOnRowsetEntries(EVENT_ROWREMOVED, detail, rowsRemoved); + } } - /** - * Reflects the state of the original table, before being flattened. - */ - public ClientTableState state() { - return originalState; + private void fireLegacyEventOnRowsetEntries(String eventName, UpdateEventData updateEventData, RangeSet rowset) { + if (hasListeners(eventName)) { + rowset.indexIterator().forEachRemaining((long row) -> { + CustomEventInit> addedEvent = CustomEventInit.create(); + addedEvent.setDetail(wrap((SubscriptionRow) updateEventData.getRows().getAt((int) row), (int) row)); + fireEvent(eventName, addedEvent); + }); + } } + private static JsPropertyMap wrap(SubscriptionRow rowObj, int row) { + return JsPropertyMap.of("row", rowObj, "index", (double) row); + } + + @Override + public void fireEvent(String type) { + refire(new CustomEvent<>(type)); + } + + @Override + public void fireEventWithDetail(String type, T detail) { + CustomEventInit init = CustomEventInit.create(); + init.setDetail(detail); + refire(new CustomEvent(type, init)); + } + + @Override + public void fireEvent(String type, CustomEventInit init) { + refire(new CustomEvent(type, init)); + } + + @Override + public void fireEvent(String type, CustomEvent e) { + if (!type.equals(e.type)) { + throw new IllegalArgumentException(type + " != " + e.type); + } + refire(e); + } + + @Override + public boolean hasListeners(String name) { + if (originalActive && initialState == original.state()) { + if (original.hasListeners(name)) { + return true; + } + } + return super.hasListeners(name); + } + + /** + * Utility to fire an event on this object and also optionally on the parent if still active. All {@code fireEvent} + * overloads dispatch to this. + * + * @param e the event to fire + * @param the type of the custom event data + */ private void refire(CustomEvent e) { - this.fireEvent(e.type, e); - if (originalActive && state() == original.state()) { + // explicitly calling super.fireEvent to avoid calling ourselves recursively + super.fireEvent(e.type, e); + if (originalActive && initialState == original.state()) { // When these fail to match, it probably means that the original's state was paused, but we're still // holding on to it. Since we haven't been internalClose()d yet, that means we're still waiting for // the new state to resolve or fail, so we can be restored, or stopped. In theory, we should put this // assert back, and make the pause code also tell us to pause. - // assert state() == original.state() : "Table owning this viewport subscription forgot to release it"; + // assert initialState == original.state() : "Table owning this viewport subscription forgot to release it"; original.fireEvent(e.type, e); } } @@ -203,23 +255,40 @@ private void retainForExternalUse() { */ @JsMethod public void setViewport(double firstRow, double lastRow, @JsOptional @JsNullable Column[] columns, - @JsOptional @JsNullable Double updateIntervalMs) { + @JsOptional @JsNullable Double updateIntervalMs, + @JsOptional @JsNullable Boolean isReverseViewport) { retainForExternalUse(); - setInternalViewport(firstRow, lastRow, columns, updateIntervalMs); + setInternalViewport(firstRow, lastRow, columns, updateIntervalMs, isReverseViewport); } - public void setInternalViewport(double firstRow, double lastRow, Column[] columns, Double updateIntervalMs) { + public void setInternalViewport(double firstRow, double lastRow, Column[] columns, Double updateIntervalMs, + Boolean isReverseViewport) { + if (status == Status.STARTING) { + this.firstRow = firstRow; + this.lastRow = lastRow; + this.columns = columns; + this.refresh = updateIntervalMs == null ? 1000.0 : updateIntervalMs; + return; + } + if (columns == null) { + // Null columns means the user wants all columns, only supported on viewports. This can't be done until the + // CTS has resolved + columns = state().getColumns(); + } else { + // If columns were provided, sort a copy so that we have them in the expected order + columns = Js.>uncheckedCast(columns).slice().asArray(new Column[0]); + Arrays.sort(columns, Comparator.comparing(Column::getIndex)); + } if (updateIntervalMs != null && refresh != updateIntervalMs) { throw new IllegalArgumentException( "Can't change refreshIntervalMs on a later call to setViewport, it must be consistent or omitted"); } - copy.then(table -> { - if (!table.isBlinkTable()) { - // we only set blink table viewports once; and that's in the constructor - table.setInternalViewport(firstRow, lastRow, columns); - } - return Promise.resolve(table); - }); + if (isReverseViewport == null) { + isReverseViewport = false; + } + RangeSet viewport = RangeSet.ofRange((long) firstRow, (long) lastRow); + this.sendBarrageSubscriptionRequest(viewport, Js.uncheckedCast(columns), updateIntervalMs, + isReverseViewport); } /** @@ -231,6 +300,8 @@ public void close() { JsLog.warn("TableViewportSubscription.close called on subscription that's already done."); } retained = false; + + // Instead of calling super.close(), we delegate to internalClose() internalClose(); } @@ -242,6 +313,8 @@ public void internalClose() { // indicate that the base table shouldn't get events anymore, even if it is still retained elsewhere originalActive = false; + reconnectSubscription.remove(); + if (retained || status == Status.DONE) { // the JsTable has indicated it is no longer interested in this viewport, but other calling // code has retained it, keep it open for now. @@ -250,13 +323,7 @@ public void internalClose() { status = Status.DONE; - // not retained externally, and the original is inactive, mark as "not realized" - realized = null; - - copy.then(table -> { - table.close(); - return Promise.resolve(table); - }); + super.close(); } /** @@ -265,149 +332,107 @@ public void internalClose() { * @return Promise of {@link TableData}. */ @JsMethod - public Promise getViewportData() { + public Promise<@TsTypeRef(ViewportData.class) UpdateEventData> getViewportData() { retainForExternalUse(); return getInternalViewportData(); } - public Promise getInternalViewportData() { - return copy.then(JsTable::getInternalViewportData); - } - - public Status getStatus() { - if (realized == null) { - assert status != Status.ACTIVE - : "when the realized table is null, status should only be DONE or STARTING, instead is " + status; - } else { - if (realized.isAlive()) { - assert status == Status.ACTIVE - : "realized table is alive, expected status ACTIVE, instead is " + status; - } else { - assert status == Status.DONE : "realized table is closed, expected status DONE, instead is " + status; - } + public Promise<@TsTypeRef(ViewportData.class) UpdateEventData> getInternalViewportData() { + if (isSubscriptionReady()) { + return Promise.resolve(viewportData); } - - return status; - } - - public double size() { - assert getStatus() == Status.ACTIVE; - return realized.getSize(); - } - - public double totalSize() { - assert getStatus() == Status.ACTIVE; - return realized.getTotalSize(); + final LazyPromise promise = new LazyPromise<>(); + addEventListenerOneShot(EVENT_UPDATED, ignored -> promise.succeed(viewportData)); + return promise.asPromise(); } @JsMethod public Promise snapshot(JsRangeSet rows, Column[] columns) { retainForExternalUse(); // TODO #1039 slice rows and drop columns - return copy.then(table -> { - final ClientTableState state = table.lastVisibleState(); - String[] columnTypes = Arrays.stream(state.getTableDef().getColumns()) - .map(ColumnDefinition::getType) - .toArray(String[]::new); - - final BitSet columnBitset = table.lastVisibleState().makeBitset(columns); - return Callbacks.promise(this, callback -> { - WorkerConnection connection = table.getConnection(); - BiDiStream stream = connection.streamFactory().create( - headers -> connection.flightServiceClient().doExchange(headers), - (first, headers) -> connection.browserFlightServiceClient().openDoExchange(first, headers), - (next, headers, c) -> connection.browserFlightServiceClient().nextDoExchange(next, headers, - c::apply), - new FlightData()); - - Builder doGetRequest = new Builder(1024); - double columnsOffset = BarrageSnapshotRequest.createColumnsVector(doGetRequest, - makeUint8ArrayFromBitset(columnBitset)); - double viewportOffset = BarrageSnapshotRequest.createViewportVector(doGetRequest, serializeRanges( - Collections.singleton(rows.getRange()))); - double serializationOptionsOffset = BarrageSnapshotOptions - .createBarrageSnapshotOptions(doGetRequest, ColumnConversionMode.Stringify, true, 0, 0); - double tableTicketOffset = - BarrageSnapshotRequest.createTicketVector(doGetRequest, state.getHandle().getTicket()); - BarrageSnapshotRequest.startBarrageSnapshotRequest(doGetRequest); - BarrageSnapshotRequest.addTicket(doGetRequest, tableTicketOffset); - BarrageSnapshotRequest.addColumns(doGetRequest, columnsOffset); - BarrageSnapshotRequest.addSnapshotOptions(doGetRequest, serializationOptionsOffset); - BarrageSnapshotRequest.addViewport(doGetRequest, viewportOffset); - doGetRequest.finish(BarrageSnapshotRequest.endBarrageSnapshotRequest(doGetRequest)); - - FlightData request = new FlightData(); - request.setAppMetadata( - WebBarrageUtils.wrapMessage(doGetRequest, BarrageMessageType.BarrageSnapshotRequest)); - stream.send(request); - stream.end(); - stream.onData(flightData -> { - - Message message = Message.getRootAsMessage(new ByteBuffer(flightData.getDataHeader_asU8())); - if (message.headerType() == MessageHeader.Schema) { - // ignore for now, we'll handle this later - return; - } - assert message.headerType() == MessageHeader.RecordBatch; - RecordBatch header = message.header(new RecordBatch()); - Uint8Array appMetadataBytes = flightData.getAppMetadata_asU8(); - BarrageUpdateMetadata update = null; - if (appMetadataBytes.length != 0) { - BarrageMessageWrapper barrageMessageWrapper = - BarrageMessageWrapper.getRootAsBarrageMessageWrapper( - new io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer( - appMetadataBytes)); - - update = BarrageUpdateMetadata.getRootAsBarrageUpdateMetadata( - new ByteBuffer( - new Uint8Array(barrageMessageWrapper.msgPayloadArray()))); - } - TableSnapshot snapshot = WebBarrageUtils.createSnapshot(header, - WebBarrageUtils.typedArrayToLittleEndianByteBuffer(flightData.getDataBody_asU8()), update, - true, - columnTypes); - - // TODO deephaven-core(#188) this check no longer makes sense - Iterator rangeIterator = rows.getRange().rangeIterator(); - long expectedCount = 0; - while (rangeIterator.hasNext()) { - Range range = rangeIterator.next(); - if (range.getFirst() >= snapshot.getTableSize()) { - break; - } - long end = Math.min(range.getLast(), snapshot.getTableSize()); - expectedCount += end - range.getFirst() + 1; - } - if (expectedCount != snapshot.getIncludedRows().size()) { - callback.onFailure("Server did not send expected number of rows, expected " + expectedCount - + ", actual " + snapshot.getIncludedRows().size()); - } else { - callback.onSuccess(snapshot); - } - }); - stream.onStatus(status -> { - if (!status.isOk()) { - callback.onFailure(status.getDetails()); - } + BarrageSnapshotOptions options = BarrageSnapshotOptions.builder() + .batchSize(WebBarrageSubscription.BATCH_SIZE) + .maxMessageSize(WebBarrageSubscription.MAX_MESSAGE_SIZE) + .columnConversionMode(ColumnConversionMode.Stringify) + .useDeephavenNulls(true) + .build(); + + WebBarrageSubscription snapshot = + WebBarrageSubscription.subscribe(state(), (serverViewport1, serverColumns, serverReverseViewport) -> { + }, (rowsAdded, rowsRemoved, totalMods, shifted, modifiedColumnSet) -> { }); - }).then(defer()).then(snapshot -> { - SubscriptionTableData pretendSubscription = new SubscriptionTableData(Js.uncheckedCast(columns), - state.getRowFormatColumn() == null ? NO_ROW_FORMAT_COLUMN - : state.getRowFormatColumn().getIndex(), - null); - TableData data = pretendSubscription.handleSnapshot(snapshot); - return Promise.resolve(data); - }).then(defer()); - }); - } - /** - * Instead of a micro-task between chained promises, insert a regular task so that control is returned to the - * browser long enough to prevent the UI hanging. - */ - private IThenable.ThenOnFulfilledCallbackFn defer() { - return val -> new Promise<>((resolve, reject) -> { - DomGlobal.setTimeout(ignoreArgs -> resolve.onInvoke(val), 0); + WebBarrageStreamReader reader = new WebBarrageStreamReader(); + return new Promise<>((resolve, reject) -> { + + BiDiStream doExchange = connection().streamFactory().create( + headers -> connection().flightServiceClient().doExchange(headers), + (first, headers) -> connection().browserFlightServiceClient().openDoExchange(first, headers), + (next, headers, c) -> connection().browserFlightServiceClient().nextDoExchange(next, headers, + c::apply), + new FlightData()); + MutableLong rowsReceived = new MutableLong(0); + doExchange.onData(data -> { + WebBarrageMessage message; + try { + message = reader.parseFrom(options, state().chunkTypes(), state().columnTypes(), + state().componentTypes(), data); + } catch (IOException e) { + throw new RuntimeException(e); + } + if (message != null) { + // Replace rowsets with flat versions + long resultSize = message.rowsIncluded.size(); + message.rowsAdded = RangeSet.ofRange(rowsReceived.get(), rowsReceived.get() + resultSize - 1); + message.rowsIncluded = message.rowsAdded; + rowsReceived.add(resultSize); + + // Update our table data with the complete message + snapshot.applyUpdates(message); + } + }); + FlightData payload = new FlightData(); + final FlatBufferBuilder metadata = new FlatBufferBuilder(); + + int colOffset = 0; + if (columns != null) { + colOffset = + BarrageSnapshotRequest.createColumnsVector(metadata, state().makeBitset(columns).toByteArray()); + } + int vpOffset = BarrageSnapshotRequest.createViewportVector(metadata, + serializeRanges(Collections.singleton(rows.getRange()))); + int optOffset = 0; + if (options != null) { + optOffset = options.appendTo(metadata); + } + + final int ticOffset = BarrageSnapshotRequest.createTicketVector(metadata, + Js.uncheckedCast(state().getHandle().getTicket())); + BarrageSnapshotRequest.startBarrageSnapshotRequest(metadata); + BarrageSnapshotRequest.addColumns(metadata, colOffset); + BarrageSnapshotRequest.addViewport(metadata, vpOffset); + BarrageSnapshotRequest.addSnapshotOptions(metadata, optOffset); + BarrageSnapshotRequest.addTicket(metadata, ticOffset); + BarrageSnapshotRequest.addReverseViewport(metadata, false); + metadata.finish(BarrageSnapshotRequest.endBarrageSnapshotRequest(metadata)); + + payload.setAppMetadata(WebBarrageUtils.wrapMessage(metadata, BarrageMessageType.BarrageSnapshotRequest)); + doExchange.onEnd(status -> { + if (status.isOk()) { + // notify the caller that the snapshot is finished + resolve.onInvoke(new SubscriptionEventData(snapshot, rowStyleColumn, Js.uncheckedCast(columns), + RangeSet.ofRange(0, rowsReceived.get() - 1), + RangeSet.empty(), + RangeSet.empty(), + null)); + } else { + reject.onInvoke(status); + } + }); + + doExchange.send(payload); + doExchange.end(); + }); } } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/ViewportData.java b/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/ViewportData.java index 3ca96d1ed2e..04831819539 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/ViewportData.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/ViewportData.java @@ -3,558 +3,48 @@ // package io.deephaven.web.client.api.subscription; -import com.vertispan.tsdefs.annotations.TsInterface; -import com.vertispan.tsdefs.annotations.TsName; +import com.vertispan.tsdefs.annotations.TsTypeRef; import elemental2.core.JsArray; -import elemental2.core.JsObject; -import io.deephaven.web.client.api.*; -import io.deephaven.web.shared.data.*; -import jsinterop.annotations.JsFunction; +import io.deephaven.web.client.api.TableData; import jsinterop.annotations.JsProperty; -import jsinterop.base.Any; -import jsinterop.base.Js; -import jsinterop.base.JsArrayLike; - -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.HashSet; -import java.util.Iterator; -import java.util.PrimitiveIterator.OfLong; -import java.util.Set; +import jsinterop.annotations.JsType; /** - * Contains data in the current viewport. Also contains the offset to this data, so that the actual row number may be - * determined. Do not assume that the first row in `rows` is the first visible row, because extra rows may be provided - * for easier scrolling without going to the server. + * Extends {@link TableData}, but only contains data in the current viewport. The only API change from TableData is that + * ViewportData also contains the offset to this data, so that the actual row number may be determined. + *

+ * For viewport subscriptions, it is not necessary to read with the key, only with the position. + *

+ * Do not assume that the first row in `rows` is the first visible row, because extra rows may be provided for easier + * scrolling without going to the server. */ -@TsInterface -@TsName(namespace = "dh") -public class ViewportData implements TableData { - private static final Any NULL_SENTINEL = Js.asAny(new JsObject()); +@JsType(namespace = "dh") +public interface ViewportData extends TableData { /** - * Clean the data at the provided index - */ - @JsFunction - private interface DataCleaner { - void clean(JsArray data, int index); - } - - public static final int NO_ROW_FORMAT_COLUMN = -1; - - public class MergeResults { - public Set added = new HashSet<>(); - public Set modified = new HashSet<>(); - public Set removed = new HashSet<>(); - } - - private long offset; - private int length; - private final int maxLength; - private JsArray rows; - private final JsArray columns; - - private final Object[] data; - - private final int rowFormatColumn; - - public ViewportData(RangeSet includedRows, Object[] dataColumns, JsArray columns, int rowFormatColumn, - long maxLength) { - assert maxLength <= Integer.MAX_VALUE; - this.maxLength = (int) maxLength; - - Iterator rangeIterator = includedRows.rangeIterator(); - data = new Object[dataColumns.length]; - if (rangeIterator.hasNext()) { - Range range = rangeIterator.next(); - assert !rangeIterator.hasNext() : "Snapshot only supports one range"; - - offset = range.getFirst(); - length = (int) (range.getLast() - range.getFirst() + 1); - assert length == range.size(); - } else { - offset = -1; - } - - // Clean data for requested columns, and provide format column data as well, if any - for (int i = 0; i < columns.length; i++) { - Column c = columns.getAt(i); - int index = c.getIndex(); - if (dataColumns[index] == null) { - // no data for this column, not requested in viewport - continue; - } - data[index] = cleanData(dataColumns[index], c); - if (c.getStyleColumnIndex() != null) { - data[c.getStyleColumnIndex()] = dataColumns[c.getStyleColumnIndex()]; - } - if (c.getFormatStringColumnIndex() != null) { - data[c.getFormatStringColumnIndex()] = dataColumns[c.getFormatStringColumnIndex()]; - } - } - - // Handle row format column, if any - this.rowFormatColumn = rowFormatColumn; - if (rowFormatColumn != NO_ROW_FORMAT_COLUMN) { - data[rowFormatColumn] = dataColumns[rowFormatColumn]; - } - - // Grow all columns to match the size of the viewport, if necessary - if (length < maxLength) { - for (int i = 0; i < data.length; i++) { - if (data[i] != null) { - JsArray existingColumnData = Js.uncheckedCast(data[i]); - existingColumnData.length = this.maxLength; - existingColumnData.fill(NULL_SENTINEL, length, this.maxLength); - } - } - } - - rows = new JsArray<>(); - for (int i = 0; i < length; i++) { - rows.push(new ViewportRow(i, data, data[rowFormatColumn])); - } - this.columns = JsObject.freeze(Js.uncheckedCast(columns.slice())); - } - - private static DataCleaner getDataCleanerForColumnType(String columnType) { - switch (columnType) { - case "int": - return (data, i) -> { - int value = data.getAtAsAny(i).asInt(); - if (value == QueryConstants.NULL_INT) { - data.setAt(i, null); - } - }; - case "byte": - return (data, i) -> { - byte value = data.getAtAsAny(i).asByte(); - if (value == QueryConstants.NULL_BYTE) { - data.setAt(i, null); - } - }; - case "short": - return (data, i) -> { - short value = data.getAtAsAny(i).asShort(); - if (value == QueryConstants.NULL_SHORT) { - data.setAt(i, null); - } - }; - case "double": - return (data, i) -> { - double value = data.getAtAsAny(i).asDouble(); - if (value == QueryConstants.NULL_DOUBLE) { - data.setAt(i, null); - } - }; - case "float": - return (data, i) -> { - float value = data.getAtAsAny(i).asFloat(); - if (value == QueryConstants.NULL_FLOAT) { - data.setAt(i, null); - } - }; - case "char": - return (data, i) -> { - char value = data.getAtAsAny(i).asChar(); - if (value == QueryConstants.NULL_CHAR) { - data.setAt(i, null); - } - }; - default: - return null; - } - } - - public static Object cleanData(Object dataColumn, Column column) { - if (dataColumn == null) { - return null; - } - if (column == null) { - return dataColumn; - } - - switch (column.getType()) { - case "long": { - JsArray values = Js.uncheckedCast(dataColumn); - LongWrapper[] cleanData = new LongWrapper[values.length]; - for (int i = 0; i < values.length; i++) { - long value = values.getAtAsAny(i).asLong(); - if (value == QueryConstants.NULL_LONG) { - cleanData[i] = null; - } else { - cleanData[i] = LongWrapper.of(value); - } - } - return cleanData; - } - case "java.time.Instant": - case "java.time.ZonedDateTime": { - JsArray values = Js.uncheckedCast(dataColumn); - DateWrapper[] cleanData = new DateWrapper[values.length]; - for (int i = 0; i < values.length; i++) { - long value = values.getAtAsAny(i).asLong(); - if (value == QueryConstants.NULL_LONG) { - cleanData[i] = null; - } else { - cleanData[i] = new DateWrapper(value); - } - } - return cleanData; - } - case "java.math.BigDecimal": { - final JsArray values = Js.uncheckedCast(dataColumn); - final BigDecimalWrapper[] cleanData = new BigDecimalWrapper[values.length]; - for (int i = 0; i < values.length; i++) { - final BigDecimal value = Js.cast(values.getAt(i)); - if (value == null) { - cleanData[i] = null; - } else { - cleanData[i] = new BigDecimalWrapper(value); - } - } - return cleanData; - } - case "java.math.BigInteger": { - final JsArray values = Js.uncheckedCast(dataColumn); - final BigIntegerWrapper[] cleanData = new BigIntegerWrapper[values.length]; - for (int i = 0; i < values.length; i++) { - final BigInteger value = Js.cast(values.getAt(i)); - if (value == null) { - cleanData[i] = null; - } else { - cleanData[i] = new BigIntegerWrapper(value); - } - } - return cleanData; - } - case "java.time.LocalDate": { - final JsArray values = Js.uncheckedCast(dataColumn); - final LocalDateWrapper[] cleanData = new LocalDateWrapper[values.length]; - for (int i = 0; i < values.length; i++) { - final LocalDate value = Js.cast(values.getAt(i)); - if (value == null) { - cleanData[i] = null; - } else { - cleanData[i] = new LocalDateWrapper(value); - } - } - return cleanData; - } - case "java.time.LocalTime": { - final JsArray values = Js.uncheckedCast(dataColumn); - final LocalTimeWrapper[] cleanData = new LocalTimeWrapper[values.length]; - for (int i = 0; i < values.length; i++) { - final LocalTime value = Js.cast(values.getAt(i)); - if (value == null) { - cleanData[i] = null; - } else { - cleanData[i] = new LocalTimeWrapper(value); - } - } - return cleanData; - } - default: - DataCleaner dataCleaner = getDataCleanerForColumnType(column.getType()); - if (dataCleaner != null) { - JsArray values = Js.uncheckedCast(dataColumn); - JsArray cleanData = Js.uncheckedCast(JsArray.from((JsArrayLike) values)); - - for (int i = 0; i < values.length; i++) { - dataCleaner.clean(cleanData, i); - } - - return cleanData; - } else { - return dataColumn; - } - } - } - - /** - * The index of the first returned row - * - * @return double + * The position of the first returned row, null if this data is not for a viewport. */ @JsProperty - public double getOffset() { - return offset; - - } - - @Override - public Row get(long index) { - return getRows().getAt((int) index); - } - - @Override - public Row get(int index) { - return getRows().getAt(index); - } - - @Override - public Any getData(int index, Column column) { - return getRows().getAt(index).get(column); - } - - @Override - public Any getData(long index, Column column) { - return getRows().getAt((int) index).get(column); - } - - @Override - public Format getFormat(int index, Column column) { - return getRows().getAt(index).getFormat(column); - } + Double getOffset(); + @JsProperty @Override - public Format getFormat(long index, Column column) { - return getRows().getAt((int) index).getFormat(column); - } + JsArray getRows(); /** - * An array of rows of data - * - * @return {@link ViewportRow} array. + * Reads a row object from the viewport, based on its position in the table. */ @Override - @JsProperty - public JsArray getRows() { - if (rows.length != length) { - rows = new JsArray<>(); - for (int i = 0; i < length; i++) { - rows.push(new ViewportRow(i, data, data[rowFormatColumn])); - } - JsObject.freeze(rows); - } - return rows; + @TsTypeRef(ViewportRow.class) + default TableData.Row get(RowPositionUnion index) { + return TableData.super.get(index); } /** - * A list of columns describing the data types in each row - * - * @return {@link Column} array. + * This object may be pooled internally or discarded and not updated. Do not retain references to it. Instead, + * request the viewport again. */ - @Override - @JsProperty - public JsArray getColumns() { - return columns; - } - - public MergeResults merge(DeltaUpdates updates) { - if (offset == -1 && updates.getIncludedAdditions().size() > 0) { - offset = updates.getIncludedAdditions().getFirstRow(); - } - final MergeResults updated = new MergeResults(); - - // First we remove rows by nulling them out. - updates.getRemoved().indexIterator().forEachRemaining((long removedIndex) -> { - int internalOffset = (int) (removedIndex - offset); - if (internalOffset < 0 || internalOffset >= length) { - return; - } - for (int i = 0; i < data.length; i++) { - JsArray existingColumnData = Js.uncheckedCast(data[i]); - if (existingColumnData == null) { - continue; - } - existingColumnData.setAt(internalOffset, NULL_SENTINEL); - } - updated.removed.add(internalOffset); - }); - - // Now we shift data around. - boolean hasReverseShift = false; - final ShiftedRange[] shiftedRanges = updates.getShiftedRanges(); - - // must apply shifts in mem-move semantics; so we shift forward from right to left first - for (int si = shiftedRanges.length - 1; si >= 0; --si) { - final ShiftedRange shiftedRange = shiftedRanges[si]; - final long shiftDelta = shiftedRange.getDelta(); - if (shiftDelta < 0) { - hasReverseShift = true; - continue; - } - - final long beginAsLong = Math.max(shiftedRange.getRange().getFirst() - offset, 0); - final int end = (int) Math.min(shiftedRange.getRange().getLast() - offset, length - 1); - if (end < beginAsLong) { - // this range is out of our viewport - continue; - } - - // long math is expensive; so convert to int early/once - final int begin = (int) beginAsLong; - - // iterate backward and move them forward - for (int j = end; j >= begin; --j) { - for (int i = 0; i < data.length; ++i) { - final JsArray existingColumnData = Js.uncheckedCast(data[i]); - if (existingColumnData == null) { - continue; - } - - final long internalOffsetAsLong = (j + shiftDelta); - if (internalOffsetAsLong >= 0 && internalOffsetAsLong < maxLength) { - // because internalOffsetAsLong is less than maxLen; we know it must be fit in an int - final int internalOffset = (int) internalOffsetAsLong; - updated.added.add(internalOffset); - Any toMove = existingColumnData.getAt(j); - existingColumnData.setAt(internalOffset, toMove); - } - - updated.removed.add(j); - existingColumnData.setAt(j, NULL_SENTINEL); - } - } - } - if (hasReverseShift) { - // then we shift in reverse from left to right - for (int si = 0; si < shiftedRanges.length; ++si) { - final ShiftedRange shiftedRange = shiftedRanges[si]; - final long shiftDelta = shiftedRange.getDelta(); - if (shiftDelta > 0) { - continue; - } - - final long begin = Math.max(shiftedRange.getRange().getFirst() - offset, 0); - final int end = (int) Math.min(shiftedRange.getRange().getLast() - offset, length - 1); - if (end < begin) { - // this range is out of our viewport - continue; - } - - // iterate forward and move them backward (note: since begin is <= end, we now know it fits in an int) - for (int j = (int) begin; j <= end; ++j) { - for (int i = 0; i < data.length; ++i) { - final JsArray existingColumnData = Js.uncheckedCast(data[i]); - if (existingColumnData == null) { - continue; - } - - final long internalOffsetAsLong = j + shiftDelta; - if (internalOffsetAsLong >= 0 && internalOffsetAsLong < maxLength) { - // because internalOffsetAsLong is less than maxLen; we know it must be fit in an int - final int internalOffset = (int) internalOffsetAsLong; - updated.added.add(internalOffset); - existingColumnData.setAt(internalOffset, existingColumnData.getAt(j)); - } - - updated.removed.add(j); - existingColumnData.setAt(j, NULL_SENTINEL); - } - } - } - } - - DeltaUpdates.ColumnModifications[] serializedModifications = updates.getSerializedModifications(); - for (int modifiedColIndex = 0; modifiedColIndex < serializedModifications.length; modifiedColIndex++) { - final DeltaUpdates.ColumnModifications modifiedColumn = serializedModifications[modifiedColIndex]; - final OfLong it = modifiedColumn == null ? null : modifiedColumn.getRowsIncluded().indexIterator(); - - if (it == null || !it.hasNext()) { - continue; - } - - // look for a local Column which matches this index so we know how to clean it - final Column column = columns.find((c, i1, i2) -> c.getIndex() == modifiedColumn.getColumnIndex()); - final JsArray updatedColumnData = - Js.uncheckedCast(cleanData(modifiedColumn.getValues().getData(), column)); - final JsArray existingColumnData = Js.uncheckedCast(data[modifiedColumn.getColumnIndex()]); - if (updatedColumnData.length == 0) { - continue; - } - - // for each change provided for this column, replace the values in our store - int i = 0; - while (it.hasNext()) { - long modifiedOffset = it.nextLong(); - int internalOffset = (int) (modifiedOffset - offset); - if (internalOffset < 0 || internalOffset >= maxLength) { - i++; - continue;// data we don't need to see, either meant for another table, or we just sent a viewport - // update - } - existingColumnData.setAt(internalOffset, updatedColumnData.getAtAsAny(i)); - updated.modified.add(internalOffset); - i++; - } - } - - if (!updates.getIncludedAdditions().isEmpty()) { - DeltaUpdates.ColumnAdditions[] serializedAdditions = updates.getSerializedAdditions(); - for (int addedColIndex = 0; addedColIndex < serializedAdditions.length; addedColIndex++) { - DeltaUpdates.ColumnAdditions addedColumn = serializedAdditions[addedColIndex]; - - Column column = columns.find((c, i1, i2) -> c.getIndex() == addedColumn.getColumnIndex()); - final JsArray addedColumnData = - Js.uncheckedCast(cleanData(addedColumn.getValues().getData(), column)); - final JsArray existingColumnData = Js.uncheckedCast(data[addedColumn.getColumnIndex()]); - if (addedColumnData.length == 0) { - continue; - } - - int i = 0; - OfLong it = updates.getIncludedAdditions().indexIterator(); - while (it.hasNext()) { - long addedOffset = it.nextLong(); - int internalOffset = (int) (addedOffset - offset); - if (internalOffset < 0 || internalOffset >= maxLength) { - i++; - continue;// data we don't need to see, either meant for another table, or we just sent a - // viewport update - } - assert internalOffset < existingColumnData.length; - - Any existing = existingColumnData.getAt(internalOffset); - if (existing == NULL_SENTINEL || internalOffset >= length) { - // space was set aside or was left at the end of the array for this value, it is a new addition - updated.added.add(internalOffset); - } else { - // we're overwriting some existing value - updated.modified.add(internalOffset); - } - existingColumnData.setAt(internalOffset, addedColumnData.getAtAsAny(i)); - i++; - } - } - } - - // exclude added items from being marked as modified, since we're hiding shifts from api consumers - updated.modified.removeAll(updated.added); - - // Any position which was both added and removed should instead be marked as modified, this cleans - // up anything excluded above that didn't otherwise make sense - for (Iterator it = updated.removed.iterator(); it.hasNext();) { - int ii = it.next(); - if (updated.added.remove(ii)) { - it.remove(); - updated.modified.add(ii); - } - } - - length = length + updated.added.size() - updated.removed.size(); - assert 0 <= length && length <= maxLength; - - // Viewport footprint should be small enough that we can afford to see if this update corrupted our view of the - // world: - assert !dataContainsNullSentinels(); - - return updated; - } - - private boolean dataContainsNullSentinels() { - for (int i = 0; i < data.length; i++) { - JsArray existingColumnData = Js.uncheckedCast(data[i]); - if (existingColumnData == null) { - continue; - } - for (int j = 0; j < length; ++j) { - if (existingColumnData.getAt(j) == NULL_SENTINEL) { - return true; - } - } - } - return false; + @JsType(namespace = "dh") + interface ViewportRow extends TableData.Row { } } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/ViewportRow.java b/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/ViewportRow.java deleted file mode 100644 index ade086f4503..00000000000 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/subscription/ViewportRow.java +++ /dev/null @@ -1,86 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.client.api.subscription; - -import com.vertispan.tsdefs.annotations.TsInterface; -import com.vertispan.tsdefs.annotations.TsName; -import elemental2.core.JsArray; -import io.deephaven.web.client.api.Column; -import io.deephaven.web.client.api.Format; -import io.deephaven.web.client.api.LongWrapper; -import io.deephaven.web.client.api.TableData; -import jsinterop.annotations.JsMethod; -import jsinterop.base.Any; -import jsinterop.base.Js; - -/** - * This object may be pooled internally or discarded and not updated. Do not retain references to it. Instead, request - * the viewport again. - */ -@TsInterface -@TsName(namespace = "dh") -public class ViewportRow implements TableData.Row { - protected final int offsetInSnapshot; - private final Object[] dataColumns; - private final JsArray rowStyleColumn; - - public ViewportRow(int offsetInSnapshot, Object[] dataColumns, Object rowStyleColumn) { - this.offsetInSnapshot = offsetInSnapshot; - this.dataColumns = dataColumns; - this.rowStyleColumn = Js.uncheckedCast(rowStyleColumn); - } - - @Override - public LongWrapper getIndex() { - throw new UnsupportedOperationException("Viewports don't currently represent their position with an index"); - } - - /** - * the data for the given column's cell - * - * @param column - * @return Any - */ - @Override - @JsMethod - public Any get(Column column) { - JsArray uncheckedData = Js.uncheckedCast(dataColumns[column.getIndex()]); - if (uncheckedData == null) { - throw new java.util.NoSuchElementException( - "Column " + column.getName() + " not found in row, was it specified in the viewport?"); - } - return uncheckedData.getAtAsAny(offsetInSnapshot); - } - - /** - * the format object for the given columns' cell - * - * @param column - * @return {@link Format}. - */ - @Override - @JsMethod - public Format getFormat(Column column) { - long cellColors = 0; - long rowColors = 0; - String numberFormat = null; - String formatString = null; - if (column.getStyleColumnIndex() != null) { - JsArray colors = Js.uncheckedCast(dataColumns[column.getStyleColumnIndex()]); - cellColors = colors.getAtAsAny(offsetInSnapshot).asLong(); - } - if (rowStyleColumn != null) { - rowColors = rowStyleColumn.getAtAsAny(offsetInSnapshot).asLong(); - } - if (column.getFormatColumnIndex() != null) { - JsArray formatStrings = Js.uncheckedCast(dataColumns[column.getFormatColumnIndex()]); - numberFormat = formatStrings.getAtAsAny(offsetInSnapshot).asString(); - } - if (column.getFormatStringColumnIndex() != null) { - JsArray formatStrings = Js.uncheckedCast(dataColumns[column.getFormatStringColumnIndex()]); - formatString = formatStrings.getAtAsAny(offsetInSnapshot).asString(); - } - return new Format(cellColors, rowColors, numberFormat, formatString); - } -} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/tree/JsTreeTable.java b/web/client-api/src/main/java/io/deephaven/web/client/api/tree/JsTreeTable.java index 50808f9776d..7163ae034d9 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/tree/JsTreeTable.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/tree/JsTreeTable.java @@ -3,55 +3,44 @@ // package io.deephaven.web.client.api.tree; -import com.vertispan.tsdefs.annotations.TsInterface; -import com.vertispan.tsdefs.annotations.TsName; +import com.vertispan.tsdefs.annotations.TsIgnore; +import com.vertispan.tsdefs.annotations.TsTypeRef; import com.vertispan.tsdefs.annotations.TsUnion; import com.vertispan.tsdefs.annotations.TsUnionMember; import elemental2.core.JsArray; import elemental2.core.JsObject; import elemental2.core.Uint8Array; +import elemental2.dom.CustomEvent; import elemental2.dom.CustomEventInit; import elemental2.dom.DomGlobal; import elemental2.promise.IThenable; import elemental2.promise.Promise; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.Message; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.MessageHeader; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.RecordBatch; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Schema; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.protocol.flight_pb.FlightData; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageMessageType; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageMessageWrapper; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageSubscriptionOptions; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageSubscriptionRequest; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.BarrageUpdateMetadata; -import io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf.ColumnConversionMode; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.hierarchicaltable_pb.HierarchicalTableApplyRequest; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.hierarchicaltable_pb.HierarchicalTableDescriptor; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.hierarchicaltable_pb.HierarchicalTableSourceExportRequest; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.hierarchicaltable_pb.HierarchicalTableViewKeyTableDescriptor; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.hierarchicaltable_pb.HierarchicalTableViewRequest; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.Condition; +import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.ExportedTableCreationResponse; +import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.TableReference; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.ticket_pb.Ticket; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.ticket_pb.TypedTicket; import io.deephaven.web.client.api.*; import io.deephaven.web.client.api.barrage.WebBarrageUtils; +import io.deephaven.web.client.api.barrage.data.WebBarrageSubscription; import io.deephaven.web.client.api.barrage.def.ColumnDefinition; import io.deephaven.web.client.api.barrage.def.InitialTableDefinition; -import io.deephaven.web.client.api.barrage.stream.BiDiStream; +import io.deephaven.web.client.api.barrage.stream.ResponseStreamWrapper; import io.deephaven.web.client.api.filter.FilterCondition; import io.deephaven.web.client.api.impl.TicketAndPromise; import io.deephaven.web.client.api.lifecycle.HasLifecycle; -import io.deephaven.web.client.api.subscription.ViewportData; -import io.deephaven.web.client.api.subscription.ViewportRow; -import io.deephaven.web.client.api.tree.JsTreeTable.TreeViewportData.TreeRow; +import io.deephaven.web.client.api.subscription.AbstractTableSubscription; import io.deephaven.web.client.api.widget.JsWidget; import io.deephaven.web.client.fu.JsItr; import io.deephaven.web.client.fu.JsLog; import io.deephaven.web.client.fu.LazyPromise; +import io.deephaven.web.client.state.ClientTableState; import io.deephaven.web.shared.data.*; -import io.deephaven.web.shared.data.columns.ColumnData; import javaemul.internal.annotations.DoNotAutobox; import jsinterop.annotations.JsIgnore; import jsinterop.annotations.JsNullable; @@ -67,10 +56,6 @@ import java.util.function.Function; import java.util.stream.Collectors; -import static io.deephaven.web.client.api.barrage.WebBarrageUtils.makeUint8ArrayFromBitset; -import static io.deephaven.web.client.api.barrage.WebBarrageUtils.serializeRanges; -import static io.deephaven.web.client.api.subscription.ViewportData.NO_ROW_FORMAT_COLUMN; - /** * Behaves like a {@link JsTable} externally, but data, state, and viewports are managed by an entirely different * mechanism, and so reimplemented here. @@ -108,7 +93,7 @@ * roll-up table, the totals only include leaf nodes (as non-leaf nodes are generated through grouping the contents of * the original table). Roll-ups also have the {@link JsRollupConfig#includeConstituents} property, indicating that a * {@link Column} in the tree may have a {@link Column#getConstituentType()} property reflecting that the type of cells - * where {@link TreeRow#hasChildren()} is false will be different from usual. + * where {@link TreeSubscription.TreeRowImpl#hasChildren()} is false will be different from usual. * */ @JsType(namespace = "dh", name = "TreeTable") @@ -126,216 +111,6 @@ public class JsTreeTable extends HasLifecycle implements ServerObject { private static final double ACTION_EXPAND_WITH_DESCENDENTS = 0b011; private static final double ACTION_COLLAPSE = 0b100; - @TsInterface - @TsName(namespace = "dh") - public class TreeViewportData implements TableData { - private final Boolean[] expandedColumn; - private final int[] depthColumn; - private final double offset; - private final double treeSize; - - private final JsArray columns; - private final JsArray rows; - - private TreeViewportData(double offset, long viewportSize, double treeSize, ColumnData[] dataColumns, - Column[] columns) { - this.offset = offset; - this.treeSize = treeSize; - this.columns = JsObject.freeze(Js.cast(Js.>uncheckedCast(columns).slice())); - - // Unlike ViewportData, assume that we own this copy of the data and can mutate at will. As such, - // we'll just clean the data that the requested columns know about for now. - // TODO to improve this, we can have synthetic columns to handle data that wasn't requested/expected, - // and then can share code with ViewportData - Object[] data = new Object[dataColumns.length]; - - expandedColumn = Js.uncheckedCast( - ViewportData.cleanData(dataColumns[rowExpandedCol.getIndex()].getData(), rowExpandedCol)); - depthColumn = Js.uncheckedCast( - ViewportData.cleanData(dataColumns[rowDepthCol.getIndex()].getData(), rowDepthCol)); - - int constituentDepth = keyColumns.length + 2; - - // Without modifying this.columns (copied and frozen), make sure our key columns are present - // in the list of columns that we will copy data for the viewport - keyColumns.forEach((col, p1) -> { - if (this.columns.indexOf(col) == -1) { - columns[columns.length] = col; - } - return null; - }); - - for (int i = 0; i < columns.length; i++) { - Column c = columns[i]; - int index = c.getIndex(); - - // clean the data, since it will be exposed to the client - data[index] = ViewportData.cleanData(dataColumns[index].getData(), c); - if (c.getStyleColumnIndex() != null) { - data[c.getStyleColumnIndex()] = dataColumns[c.getStyleColumnIndex()].getData(); - } - if (c.getFormatStringColumnIndex() != null) { - data[c.getFormatStringColumnIndex()] = dataColumns[c.getFormatStringColumnIndex()].getData(); - } - - // if there is a matching constituent column array, clean it and copy from it - Column sourceColumn = sourceColumns.get(c.getName()); - if (sourceColumn != null) { - ColumnData constituentColumn = dataColumns[sourceColumn.getIndex()]; - if (constituentColumn != null) { - JsArray cleanConstituentColumn = - Js.uncheckedCast(ViewportData.cleanData(constituentColumn.getData(), sourceColumn)); - // Overwrite the data with constituent values, if any - // We use cleanConstituentColumn to find max item rather than data[index], since we - // are okay stopping at the last constituent value, in case the server sends shorter - // arrays. - for (int rowIndex = 0; rowIndex < cleanConstituentColumn.length; rowIndex++) { - if (depthColumn[rowIndex] == constituentDepth) - Js.asArrayLike(data[index]).setAt(rowIndex, cleanConstituentColumn.getAt(rowIndex)); - } - - if (sourceColumn.getStyleColumnIndex() != null) { - assert c.getStyleColumnIndex() != null; - ColumnData styleData = dataColumns[sourceColumn.getStyleColumnIndex()]; - if (styleData != null) { - JsArray styleArray = Js.cast(styleData.getData()); - for (int rowIndex = 0; rowIndex < styleArray.length; rowIndex++) { - if (depthColumn[rowIndex] == constituentDepth) - Js.asArrayLike(data[c.getStyleColumnIndex()]).setAt(rowIndex, - styleArray.getAt(rowIndex)); - } - } - } - if (sourceColumn.getFormatStringColumnIndex() != null) { - assert c.getFormatStringColumnIndex() != null; - ColumnData formatData = dataColumns[sourceColumn.getFormatStringColumnIndex()]; - if (formatData != null) { - JsArray formatArray = Js.cast(formatData.getData()); - for (int rowIndex = 0; rowIndex < formatArray.length; rowIndex++) { - if (depthColumn[rowIndex] == constituentDepth) { - Js.asArrayLike(data[c.getFormatStringColumnIndex()]).setAt(rowIndex, - formatArray.getAt(rowIndex)); - } - } - } - } - } - } - } - if (rowFormatColumn != NO_ROW_FORMAT_COLUMN) { - data[rowFormatColumn] = dataColumns[rowFormatColumn].getData(); - } - - rows = new JsArray<>(); - for (int i = 0; i < viewportSize; i++) { - rows.push(new TreeRow(i, data, data[rowFormatColumn])); - } - } - - @Override - public Row get(long index) { - return getRows().getAt((int) index); - } - - @Override - public Row get(int index) { - return getRows().getAt((int) index); - } - - @Override - public Any getData(int index, Column column) { - return getRows().getAt(index).get(column); - } - - @Override - public Any getData(long index, Column column) { - return getRows().getAt((int) index).get(column); - } - - @Override - public Format getFormat(int index, Column column) { - return getRows().getAt(index).getFormat(column); - } - - @Override - public Format getFormat(long index, Column column) { - return getRows().getAt((int) index).getFormat(column); - } - - @JsProperty - public double getOffset() { - return offset; - } - - @JsProperty - public JsArray getColumns() { - return columns; - } - - @JsProperty - public JsArray getRows() { - return rows; - } - - public double getTreeSize() { - return treeSize; - } - - /** - * Row implementation that also provides additional read-only properties. represents visible rows in the table, - * but with additional properties to reflect the tree structure. - */ - @TsInterface - @TsName(namespace = "dh") - public class TreeRow extends ViewportRow { - public TreeRow(int offsetInSnapshot, Object[] dataColumns, Object rowStyleColumn) { - super(offsetInSnapshot, dataColumns, rowStyleColumn); - } - - /** - * True if this node is currently expanded to show its children; false otherwise. Those children will be the - * rows below this one with a greater depth than this one - * - * @return boolean - */ - @JsProperty(name = "isExpanded") - public boolean isExpanded() { - return expandedColumn[offsetInSnapshot] == Boolean.TRUE; - } - - /** - * True if this node has children and can be expanded; false otherwise. Note that this value may change when - * the table updates, depending on the table's configuration - * - * @return boolean - */ - @JsProperty(name = "hasChildren") - public boolean hasChildren() { - return expandedColumn[offsetInSnapshot] != null; - } - - /** - * The number of levels above this node; zero for top level nodes. Generally used by the UI to indent the - * row and its expand/collapse icon - * - * @return int - */ - @JsProperty(name = "depth") - public int depth() { - return depthColumn[offsetInSnapshot]; - } - - public void appendKeyData(Object[][] keyTableData, double action) { - int i; - for (i = 0; i < keyColumns.length; i++) { - Js.>cast(keyTableData[i]).push(keyColumns.getAt(i).get(this)); - } - Js.>cast(keyTableData[i++]).push((double) depth()); - Js.>cast(keyTableData[i++]).push(action); - } - } - } - /** * Ordered series of steps that must be performed when changes are made to the table. When any change is applied, * all subsequent steps must be performed as well. @@ -352,7 +127,6 @@ private enum RebuildStep { private final InitialTableDefinition tableDefinition; private final Column[] visibleColumns; private final Map columnsByName = new HashMap<>(); - private final int rowFormatColumn; private final Map sourceColumns; private final JsArray keyColumns = new JsArray<>(); private Column rowDepthCol; @@ -376,7 +150,7 @@ private enum RebuildStep { private Promise keyTable; private TicketAndPromise viewTicket; - private Promise> stream; + private Promise stream; // the "next" set of filters/sorts that we'll use. these either are "==" to the above fields, or are scheduled // to replace them soon. @@ -389,7 +163,7 @@ private enum RebuildStep { private Column[] columns; private int updateInterval = 1000; - private TreeViewportData currentViewportData; + private TreeSubscription.TreeViewportDataImpl currentViewportData; private boolean alwaysFireNextEvent = false; @@ -408,10 +182,9 @@ public JsTreeTable(WorkerConnection workerConnection, JsWidget widget) { HierarchicalTableDescriptor.deserializeBinary(widget.getDataAsU8()); Uint8Array flightSchemaMessage = treeDescriptor.getSnapshotSchema_asU8(); - Schema schema = WebBarrageUtils.readSchemaMessage(flightSchemaMessage); this.isRefreshing = !treeDescriptor.getIsStatic(); - this.tableDefinition = WebBarrageUtils.readTableDefinition(schema); + this.tableDefinition = WebBarrageUtils.readTableDefinition(flightSchemaMessage); Column[] columns = new Column[0]; Map> columnDefsByName = tableDefinition.getColumnsByName(); int rowFormatColumn = -1; @@ -457,7 +230,6 @@ public JsTreeTable(WorkerConnection workerConnection, JsWidget widget) { columnDefsByName.get(true).get(definition.getRollupAggregationInputColumn()).getType()); } } - this.rowFormatColumn = rowFormatColumn; this.groupedColumns = JsObject.freeze(groupedColumns); sourceColumns = columnDefsByName.get(false).values().stream() @@ -602,6 +374,212 @@ private TicketAndPromise makeView(TicketAndPromise prevTicket) { return viewTicket; } + private int constituentDepth() { + return keyColumns.length + 2; + } + + public class TreeSubscription extends AbstractTableSubscription { + @TsIgnore + public class TreeViewportDataImpl extends AbstractTableSubscription.UpdateEventData + implements TreeViewportData { + private final double treeSize; + + private final JsArray columns; + + private TreeViewportDataImpl(WebBarrageSubscription subscription, int rowStyleColumn, + JsArray columns, + RangeSet added, RangeSet removed, RangeSet modified, ShiftedRange[] shifted) { + super(subscription, rowStyleColumn, columns, added, removed, modified, shifted); + + this.treeSize = barrageSubscription.getCurrentRowSet().size(); + this.columns = JsObject.freeze(Js.cast(Js.>uncheckedCast(columns).slice())); + } + + @Override + public Any getData(int index, Column column) { + Column sourceColumn = sourceColumns.get(column.getName()); + if (sourceColumn == null) { + // no constituent column, call super + return super.getData(index, column); + } + if (barrageSubscription.getData(index, rowDepthCol.getIndex()).asInt() != constituentDepth()) { + // not at constituent depth, call super + return super.getData(index, column); + } + // read source col instead + return super.getData(index, sourceColumn); + } + + @Override + public Any getData(long index, Column column) { + Column sourceColumn = sourceColumns.get(column.getName()); + if (sourceColumn == null) { + // no constituent column, call super + return super.getData(index, column); + } + if (barrageSubscription.getData(index, rowDepthCol.getIndex()).asInt() != constituentDepth()) { + // not at constituent depth, call super + return super.getData(index, column); + } + // read source col instead + return super.getData(index, sourceColumn); + } + + @Override + public Format getFormat(int index, Column column) { + Column sourceColumn = sourceColumns.get(column.getName()); + if (sourceColumn == null) { + // no constituent column, call super + return super.getFormat(index, column); + } + if (barrageSubscription.getData(index, rowDepthCol.getIndex()).asInt() != constituentDepth()) { + // not at constituent depth, call super + return super.getFormat(index, column); + } + // read source col instead + return super.getFormat(index, sourceColumn); + } + + @Override + public Format getFormat(long index, Column column) { + Column sourceColumn = sourceColumns.get(column.getName()); + if (sourceColumn == null) { + // no constituent column, call super + return super.getFormat(index, column); + } + if (barrageSubscription.getData(index, rowDepthCol.getIndex()).asInt() != constituentDepth()) { + // not at constituent depth, call super + return super.getFormat(index, column); + } + // read source col instead + return super.getFormat(index, sourceColumn); + } + + @Override + public JsArray getColumns() { + // This looks like its superclass, but we're actually returning a different field + return columns; + } + + @Override + protected SubscriptionRow makeRow(long index) { + return new TreeRowImpl(subscription, index); + } + + @JsProperty + public double getTreeSize() { + return treeSize; + } + } + + public class TreeRowImpl extends SubscriptionRow implements TreeViewportData.TreeRow { + + public TreeRowImpl(WebBarrageSubscription subscription, long index) { + super(subscription, rowStyleColumn, index); + } + + @Override + public boolean isExpanded() { + return barrageSubscription.getData(index, rowExpandedCol.getIndex()).uncheckedCast() == Boolean.TRUE; + } + + @Override + public boolean hasChildren() { + return barrageSubscription.getData(index, rowExpandedCol.getIndex()).uncheckedCast() != null; + } + + @Override + public int depth() { + return Js.coerceToInt(barrageSubscription.getData(index, rowDepthCol.getIndex())); + } + + public void appendKeyData(Object[][] keyTableData, double action) { + int i; + for (i = 0; i < keyColumns.length; i++) { + Js.>cast(keyTableData[i]).push(keyColumns.getAt(i).get(this)); + } + Js.>cast(keyTableData[i++]).push((double) depth()); + Js.>cast(keyTableData[i++]).push(action); + } + + @Override + public Any get(Column column) { + Column sourceColumn = sourceColumns.get(column.getName()); + if (sourceColumn == null) { + // no constituent column, call super + return super.get(column); + } + if (barrageSubscription.getData(index, rowDepthCol.getIndex()).asInt() != constituentDepth()) { + // not at constituent depth, call super + return super.get(column); + } + // read source col instead + return super.get(sourceColumn); + } + + @Override + public Format getFormat(Column column) { + Column sourceColumn = sourceColumns.get(column.getName()); + if (sourceColumn == null) { + // no constituent column, call super + return super.getFormat(column); + } + if (barrageSubscription.getData(index, rowDepthCol.getIndex()).asInt() != constituentDepth()) { + // not at constituent depth, call super + return super.getFormat(column); + } + // read source col instead + return super.getFormat(sourceColumn); + } + } + + private RangeSet serverViewport; + + public TreeSubscription(ClientTableState state, WorkerConnection connection) { + super(state, connection); + } + + @Override + protected void sendFirstSubscriptionRequest() { + setViewport(firstRow, lastRow, Js.uncheckedCast(columns), (double) updateInterval); + } + + @Override + protected BitSet makeColumnBitset(JsArray columns) { + BitSet requested = super.makeColumnBitset(columns); + requested.or(makeColumnSubscriptionBitset()); + return requested; + } + + @Override + protected void onStreamEnd(ResponseStreamWrapper.Status status) { + super.onStreamEnd(status); + JsTreeTable.this.stream = null; + if (!status.isOk()) { + failureHandled(status.getDetails()); + } + } + + public void setViewport(double firstRow, double lastRow, JsArray columns, Double updateInterval) { + serverViewport = RangeSet.ofRange((long) firstRow, (long) lastRow); + + sendBarrageSubscriptionRequest(RangeSet.ofRange((long) firstRow, (long) lastRow), Js.uncheckedCast(columns), + updateInterval, false); + } + + @Override + protected void notifyUpdate(RangeSet rowsAdded, RangeSet rowsRemoved, RangeSet totalMods, + ShiftedRange[] shifted) { + TreeViewportDataImpl detail = + new TreeViewportDataImpl(barrageSubscription, rowStyleColumn, getColumns(), rowsAdded, + rowsRemoved, totalMods, shifted); + detail.setOffset(this.serverViewport.getFirstRow()); + CustomEventInit event = CustomEventInit.create(); + event.setDetail(detail); + fireEvent(EVENT_UPDATED, event); + } + } + private void replaceSubscription(RebuildStep step) { // Perform steps required to remove the existing intermediate tickets. // Fall-through between steps is deliberate. @@ -624,15 +602,14 @@ private void replaceSubscription(RebuildStep step) { case SUBSCRIPTION: if (stream != null) { stream.then(stream -> { - stream.end(); - stream.cancel(); + stream.close(); return null; }); stream = null; } } - Promise> stream = Promise.resolve(defer()) + Promise stream = Promise.resolve(defer()) .then(ignore -> { makeKeyTable(); TicketAndPromise filter = prepareFilter(); @@ -648,8 +625,6 @@ private void replaceSubscription(RebuildStep step) { BitSet columnsBitset = makeColumnSubscriptionBitset(); RangeSet range = RangeSet.ofRange((long) (double) firstRow, (long) (double) lastRow); - Column[] queryColumns = this.columns; - boolean alwaysFireEvent = this.alwaysFireNextEvent; this.alwaysFireNextEvent = false; @@ -658,91 +633,29 @@ private void replaceSubscription(RebuildStep step) { columnsBitset, range, alwaysFireEvent); - BiDiStream doExchange = - connection.streamFactory().create( - headers -> connection.flightServiceClient().doExchange(headers), - (first, headers) -> connection.browserFlightServiceClient().openDoExchange(first, - headers), - (next, headers, c) -> connection.browserFlightServiceClient().nextDoExchange(next, - headers, - c::apply), - new FlightData()); - - FlightData subscriptionRequestWrapper = new FlightData(); - Builder doGetRequest = new Builder(1024); - double columnsOffset = BarrageSubscriptionRequest.createColumnsVector(doGetRequest, - makeUint8ArrayFromBitset(columnsBitset)); - double viewportOffset = BarrageSubscriptionRequest.createViewportVector(doGetRequest, - serializeRanges( - Collections.singleton( - range))); - double serializationOptionsOffset = BarrageSubscriptionOptions - .createBarrageSubscriptionOptions(doGetRequest, ColumnConversionMode.Stringify, true, - updateInterval, 0, 0); - double tableTicketOffset = - BarrageSubscriptionRequest.createTicketVector(doGetRequest, - viewTicket.ticket().getTicket_asU8()); - BarrageSubscriptionRequest.startBarrageSubscriptionRequest(doGetRequest); - BarrageSubscriptionRequest.addTicket(doGetRequest, tableTicketOffset); - BarrageSubscriptionRequest.addColumns(doGetRequest, columnsOffset); - BarrageSubscriptionRequest.addSubscriptionOptions(doGetRequest, serializationOptionsOffset); - BarrageSubscriptionRequest.addViewport(doGetRequest, viewportOffset); - doGetRequest.finish(BarrageSubscriptionRequest.endBarrageSubscriptionRequest(doGetRequest)); - - subscriptionRequestWrapper.setAppMetadata( - WebBarrageUtils.wrapMessage(doGetRequest, BarrageMessageType.BarrageSubscriptionRequest)); - doExchange.send(subscriptionRequestWrapper); - - String[] columnTypes = Arrays.stream(tableDefinition.getColumns()) - .map(ColumnDefinition::getType) - .toArray(String[]::new); - doExchange.onStatus(status -> { - if (!status.isOk()) { - failureHandled(status.getDetails()); - } - }); - doExchange.onEnd(status -> { - this.stream = null; - }); - doExchange.onData(flightData -> { - Message message = Message.getRootAsMessage(new ByteBuffer(flightData.getDataHeader_asU8())); - if (message.headerType() == MessageHeader.Schema) { - // ignore for now, we'll handle this later - return; - } - assert message.headerType() == MessageHeader.RecordBatch; - RecordBatch header = message.header(new RecordBatch()); - Uint8Array appMetadataBytes = flightData.getAppMetadata_asU8(); - BarrageUpdateMetadata update = null; - if (appMetadataBytes.length != 0) { - BarrageMessageWrapper barrageMessageWrapper = - BarrageMessageWrapper.getRootAsBarrageMessageWrapper( - new ByteBuffer( - appMetadataBytes)); - - update = BarrageUpdateMetadata.getRootAsBarrageUpdateMetadata( - new ByteBuffer( - new Uint8Array(barrageMessageWrapper.msgPayloadArray()))); - } - TableSnapshot snapshot = WebBarrageUtils.createSnapshot(header, - WebBarrageUtils.typedArrayToLittleEndianByteBuffer(flightData.getDataBody_asU8()), - update, - true, - columnTypes); - - final RangeSet includedRows = snapshot.getIncludedRows(); - double offset = firstRow; - assert includedRows.isEmpty() || Js.asInt(offset) == includedRows.getFirstRow(); - TreeViewportData vd = new TreeViewportData( - offset, - includedRows.isEmpty() ? 0 : includedRows.size(), - snapshot.getTableSize(), - snapshot.getDataColumns(), - queryColumns); - - handleUpdate(nextSort, nextFilters, vd, alwaysFireEvent); - }); - return Promise.resolve(doExchange); + + ClientTableState state = new ClientTableState(connection, + new TableTicket(viewTicket.ticket().getTicket_asU8()), (callback, newState, metadata) -> { + callback.apply("fail, trees dont reconnect like this", null); + }, ""); + ExportedTableCreationResponse def = new ExportedTableCreationResponse(); + HierarchicalTableDescriptor treeDescriptor = + HierarchicalTableDescriptor.deserializeBinary(widget.getDataAsU8()); + def.setSchemaHeader(treeDescriptor.getSnapshotSchema_asU8()); + def.setResultId(new TableReference()); + def.getResultId().setTicket(viewTicket.ticket()); + state.applyTableCreationResponse(def); + + TreeSubscription subscription = new TreeSubscription(state, connection); + + subscription.addEventListener(TreeSubscription.EVENT_UPDATED, + (CustomEvent data) -> { + TreeSubscription.TreeViewportDataImpl detail = + (TreeSubscription.TreeViewportDataImpl) data.detail; + + handleUpdate(nextSort, nextFilters, detail, alwaysFireEvent); + }); + return Promise.resolve(subscription); }); stream.catch_(err -> { // if this is the active attempt at a subscription, report the error @@ -765,7 +678,7 @@ private IThenable.ThenOnFulfilledCallbackFn defer() { } private void handleUpdate(List nextSort, List nextFilters, - TreeViewportData viewportData, boolean alwaysFireEvent) { + TreeSubscription.TreeViewportDataImpl viewportData, boolean alwaysFireEvent) { JsLog.debug("tree table response arrived", viewportData); if (closed) { // ignore @@ -781,7 +694,7 @@ private void handleUpdate(List nextSort, List nextFilters this.filters = nextFilters; if (fireEvent) { - CustomEventInit updatedEvent = CustomEventInit.create(); + CustomEventInit updatedEvent = CustomEventInit.create(); updatedEvent.setDetail(viewportData); fireEvent(EVENT_UPDATED, updatedEvent); } @@ -863,7 +776,7 @@ static RowReferenceUnion of(@DoNotAutobox Object o) { @JsOverlay default boolean isTreeRow() { - return this instanceof TreeRow; + return this instanceof TreeSubscription.TreeRowImpl; } @JsOverlay @@ -873,7 +786,7 @@ default boolean isNumber() { @JsOverlay @TsUnionMember - default TreeRow asTreeRow() { + default TreeViewportData.TreeRow asTreeRow() { return Js.cast(this); } @@ -904,11 +817,11 @@ public void setExpanded(RowReferenceUnion row, boolean isExpanded, @JsOptional B action = ACTION_EXPAND; } - final TreeRow r; + final TreeSubscription.TreeRowImpl r; if (row.isNumber()) { - r = currentViewportData.rows.getAt((int) (row.asNumber() - currentViewportData.offset)); + r = (TreeSubscription.TreeRowImpl) currentViewportData.getRows().getAt((int) (row.asNumber())); } else if (row.isTreeRow()) { - r = row.asTreeRow(); + r = (TreeSubscription.TreeRowImpl) row.asTreeRow(); } else { throw new IllegalArgumentException("row parameter must be an index or a row"); } @@ -933,11 +846,11 @@ public void collapseAll() { * @return boolean */ public boolean isExpanded(RowReferenceUnion row) { - final TreeRow r; + final TreeSubscription.TreeRowImpl r; if (row.isNumber()) { - r = currentViewportData.rows.getAt((int) (row.asNumber() - currentViewportData.offset)); + r = (TreeSubscription.TreeRowImpl) currentViewportData.getRows().getAt((int) (row.asNumber())); } else if (row.isTreeRow()) { - r = row.asTreeRow(); + r = (TreeSubscription.TreeRowImpl) row.asTreeRow(); } else { throw new IllegalArgumentException("row parameter must be an index or a row"); } @@ -956,8 +869,8 @@ public void setViewport(double firstRow, double lastRow, @JsOptional @JsNullable replaceSubscription(RebuildStep.SUBSCRIPTION); } - public Promise getViewportData() { - LazyPromise promise = new LazyPromise<>(); + public Promise<@TsTypeRef(TreeViewportData.class) Object> getViewportData() { + LazyPromise promise = new LazyPromise<>(); if (currentViewportData == null) { // only one of these two will fire, and when they do, they'll remove both handlers. @@ -1020,8 +933,7 @@ public void close() { } if (stream != null) { stream.then(stream -> { - stream.end(); - stream.cancel(); + stream.close(); return null; }); stream = null; diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/tree/TreeViewportData.java b/web/client-api/src/main/java/io/deephaven/web/client/api/tree/TreeViewportData.java new file mode 100644 index 00000000000..6e00b17bf39 --- /dev/null +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/tree/TreeViewportData.java @@ -0,0 +1,60 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.web.client.api.tree; + +import com.vertispan.tsdefs.annotations.TsTypeRef; +import elemental2.core.JsArray; +import io.deephaven.web.client.api.TableData; +import jsinterop.annotations.JsProperty; +import jsinterop.annotations.JsType; + +@JsType(namespace = "dh") +public interface TreeViewportData extends TableData { + @JsProperty + double getTreeSize(); + + @Override + @TsTypeRef(TreeRow.class) + default TableData.Row get(RowPositionUnion index) { + return TableData.super.get(index); + } + + @JsProperty + @Override + JsArray getRows(); + + /** + * Row implementation that also provides additional read-only properties. represents visible rows in the table, but + * with additional properties to reflect the tree structure. + */ + @JsType + interface TreeRow extends TableData.Row { + /** + * True if this node is currently expanded to show its children; false otherwise. Those children will be the + * rows below this one with a greater depth than this one. + * + * @return boolean + */ + @JsProperty(name = "isExpanded") + boolean isExpanded(); + + /** + * True if this node has children and can be expanded; false otherwise. Note that this value may change when the + * table updates, depending on the table's configuration. + * + * @return boolean + */ + @JsProperty(name = "hasChildren") + boolean hasChildren(); + + /** + * The number of levels above this node; zero for top level nodes. Generally used by the UI to indent the row + * and its expand/collapse icon. + * + * @return int + */ + @JsProperty(name = "depth") + int depth(); + } +} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/widget/plot/ChartData.java b/web/client-api/src/main/java/io/deephaven/web/client/api/widget/plot/ChartData.java index 8a30411fd33..ac70fd09128 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/widget/plot/ChartData.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/widget/plot/ChartData.java @@ -8,7 +8,8 @@ import io.deephaven.web.client.api.JsRangeSet; import io.deephaven.web.client.api.JsTable; import io.deephaven.web.client.api.TableData; -import io.deephaven.web.client.api.subscription.SubscriptionTableData.UpdateEventData; +import io.deephaven.web.client.api.subscription.AbstractTableSubscription; +import io.deephaven.web.client.api.subscription.SubscriptionTableData; import io.deephaven.web.client.fu.JsSettings; import io.deephaven.web.shared.data.Range; import io.deephaven.web.shared.fu.JsFunction; @@ -35,10 +36,11 @@ public ChartData(JsTable table) { this.table = table; } - public void update(UpdateEventData tableData) { - Iterator addedIterator = tableData.getAdded().getRange().rangeIterator(); - Iterator removedIterator = tableData.getRemoved().getRange().rangeIterator(); - Iterator modifiedIterator = tableData.getModified().getRange().rangeIterator(); + public void update(AbstractTableSubscription.UpdateEventData tableData) { + SubscriptionTableData data = (SubscriptionTableData) tableData; + Iterator addedIterator = data.getAdded().getRange().rangeIterator(); + Iterator removedIterator = data.getRemoved().getRange().rangeIterator(); + Iterator modifiedIterator = data.getModified().getRange().rangeIterator(); Range nextAdded = addedIterator.hasNext() ? addedIterator.next() : null; Range nextRemoved = removedIterator.hasNext() ? removedIterator.next() : null; @@ -130,7 +132,7 @@ public void update(UpdateEventData tableData) { assert cachedData.values().stream().flatMap(m -> m.values().stream()).allMatch(arr -> arr .reduce((Object val, Any p1, int p2) -> ((Integer) val) + 1, 0) == indexes.length); - JsRangeSet fullIndex = tableData.getFullIndex(); + JsRangeSet fullIndex = ((SubscriptionTableData) tableData).getFullIndex(); PrimitiveIterator.OfLong iter = fullIndex.getRange().indexIterator(); for (int j = 0; j < indexes.length; j++) { assert indexes[j] == iter.nextLong(); @@ -138,7 +140,7 @@ public void update(UpdateEventData tableData) { } } - private void replaceDataRange(UpdateEventData tableData, Range range, int offset) { + private void replaceDataRange(AbstractTableSubscription.UpdateEventData tableData, Range range, int offset) { // we don't touch the indexes at all, only need to walk each column and replace values in this range for (Entry, JsArray>> columnMap : cachedData.entrySet()) { Column col = table.findColumn(columnMap.getKey()); @@ -160,7 +162,7 @@ private void replaceDataRange(UpdateEventData tableData, Range range, int offset } } - private void insertDataRange(UpdateEventData tableData, Range range, int offset) { + private void insertDataRange(AbstractTableSubscription.UpdateEventData tableData, Range range, int offset) { // splice in the new indexes batchSplice(offset, asArray(indexes), longs(range)); @@ -195,7 +197,8 @@ private Any[] batchSplice(int offset, JsArray existingData, Any[] dataToIns return Js.uncheckedCast(existingData); } - private Any[] values(UpdateEventData tableData, JsFunction mapFunc, Column col, Range insertedRange) { + private Any[] values(AbstractTableSubscription.UpdateEventData tableData, JsFunction mapFunc, Column col, + Range insertedRange) { JsArray result = new JsArray<>(); if (mapFunc == null) { diff --git a/web/client-api/src/main/java/io/deephaven/web/client/api/widget/plot/FigureSubscription.java b/web/client-api/src/main/java/io/deephaven/web/client/api/widget/plot/FigureSubscription.java index 2b1ed636861..bb3d6e0817d 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/api/widget/plot/FigureSubscription.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/api/widget/plot/FigureSubscription.java @@ -3,13 +3,12 @@ // package io.deephaven.web.client.api.widget.plot; -import elemental2.dom.CustomEvent; import elemental2.dom.CustomEventInit; import elemental2.promise.Promise; import io.deephaven.web.client.api.DateWrapper; import io.deephaven.web.client.api.JsTable; import io.deephaven.web.client.api.LongWrapper; -import io.deephaven.web.client.api.subscription.SubscriptionTableData; +import io.deephaven.web.client.api.subscription.AbstractTableSubscription; import io.deephaven.web.client.api.subscription.TableSubscription; import io.deephaven.web.client.fu.JsLog; @@ -259,8 +258,8 @@ private Promise subscribe(final Promise tablePromise this.currentData = new ChartData(table); sub.addEventListener(TableSubscription.EVENT_UPDATED, e -> { // refire with specifics for the columns that we're watching here, after updating data arrays - SubscriptionTableData.UpdateEventData subscriptionUpdateData = - (SubscriptionTableData.UpdateEventData) ((CustomEvent) e).detail; + AbstractTableSubscription.UpdateEventData subscriptionUpdateData = + (AbstractTableSubscription.UpdateEventData) e.detail; currentData.update(subscriptionUpdateData); CustomEventInit event = CustomEventInit.create(); diff --git a/web/client-api/src/main/java/io/deephaven/web/client/fu/JsWeakRef.java b/web/client-api/src/main/java/io/deephaven/web/client/fu/JsWeakRef.java new file mode 100644 index 00000000000..35de0ed3e11 --- /dev/null +++ b/web/client-api/src/main/java/io/deephaven/web/client/fu/JsWeakRef.java @@ -0,0 +1,16 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.web.client.fu; + +import jsinterop.annotations.JsPackage; +import jsinterop.annotations.JsType; + +@JsType(namespace = JsPackage.GLOBAL, name = "WeakRef", isNative = true) +public class JsWeakRef { + public JsWeakRef(T target) { + + } + + public native T deref(); +} diff --git a/web/client-api/src/main/java/io/deephaven/web/client/state/ActiveTableBinding.java b/web/client-api/src/main/java/io/deephaven/web/client/state/ActiveTableBinding.java index 5aed4d5c121..722daed1b95 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/state/ActiveTableBinding.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/state/ActiveTableBinding.java @@ -3,11 +3,8 @@ // package io.deephaven.web.client.state; -import io.deephaven.web.client.api.Column; import io.deephaven.web.client.api.JsTable; import io.deephaven.web.client.api.state.HasTableState; -import io.deephaven.web.shared.data.RangeSet; -import io.deephaven.web.shared.data.Viewport; /** * An active binding describes the link between a {@link JsTable} and the {@link ClientTableState} it is currently @@ -60,10 +57,6 @@ public class ActiveTableBinding implements HasTableState { * new table must copy all bindings to the new table. */ private PausedTableBinding rollback; - private Viewport viewport; - private RangeSet rows; - private Column[] columns; - private boolean subscriptionPending; private ActiveTableBinding( JsTable table, @@ -234,51 +227,4 @@ private void copyRollbacks(ActiveTableBinding sub) { public PausedTableBinding getPaused() { return paused; } - - public Viewport getSubscription() { - return viewport; - } - - public void setViewport(Viewport viewport) { - this.viewport = viewport; - } - - public RangeSet setDesiredViewport(long firstRow, long lastRow, Column[] columns) { - this.rows = RangeSet.ofRange(firstRow, lastRow); - this.columns = columns; - subscriptionPending = true; - return rows; - } - - public void setDesiredSubscription(Column[] columns) { - assert this.rows == null; - this.columns = columns; - subscriptionPending = true; - } - - public RangeSet getRows() { - return rows; - } - - public Column[] getColumns() { - return columns; - } - - public void setSubscriptionPending(boolean subscriptionPending) { - this.subscriptionPending = subscriptionPending; - } - - public boolean isSubscriptionPending() { - return subscriptionPending; - } - - public void maybeReviveSubscription() { - if (subscriptionPending || viewport != null) { - if (rows != null) { - state.setDesiredViewport(table, rows.getFirstRow(), rows.getLastRow(), columns); - } else { - state.subscribe(table, columns); - } - } - } } diff --git a/web/client-api/src/main/java/io/deephaven/web/client/state/ClientTableState.java b/web/client-api/src/main/java/io/deephaven/web/client/state/ClientTableState.java index 8a8be5f1dfc..7eff8266775 100644 --- a/web/client-api/src/main/java/io/deephaven/web/client/state/ClientTableState.java +++ b/web/client-api/src/main/java/io/deephaven/web/client/state/ClientTableState.java @@ -8,7 +8,7 @@ import elemental2.core.JsSet; import elemental2.core.Uint8Array; import elemental2.promise.Promise; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Schema; +import io.deephaven.chunk.ChunkType; import io.deephaven.javascript.proto.dhinternal.browserheaders.BrowserHeaders; import io.deephaven.javascript.proto.dhinternal.io.deephaven.proto.table_pb.ExportedTableCreationResponse; import io.deephaven.web.client.api.*; @@ -57,6 +57,7 @@ * Consider making this a js type with restricted, read-only property access. */ public final class ClientTableState extends TableConfig { + public enum ResolutionState { /** * Table has been created on the client, but client does not yet have a handle ID referring to the table on the @@ -121,7 +122,6 @@ public enum ResolutionState { // A bit of state management private String failMsg; - private boolean subscribed; private Double queuedSize; // Leftovers from Table.StackEntry @@ -233,6 +233,89 @@ public TableTicket getHandle() { return handle; } + /** + * Returns the ChunkType to use for each column in the table. This is roughly + * {@link io.deephaven.engine.table.impl.sources.ReinterpretUtils#maybeConvertToWritablePrimitiveChunkType(Class)} + * but without the trip through Class. Note also that effectively all types are stored as Objects except non-long + * primitives, so that they can be appropriately wrapped before storing (though the storage process will handle DH + * nulls). + */ + public ChunkType[] chunkTypes() { + return Arrays.stream(columnTypes()).map(dataType -> { + if (dataType == Boolean.class || dataType == boolean.class) { + return ChunkType.Object; + } + if (dataType == Long.class || dataType == long.class) { + // JS client holds longs as LongWrappers + return ChunkType.Object; + } + return ChunkType.fromElementType(dataType); + }).toArray(ChunkType[]::new); + } + + /** + * Returns the Java Class to represent each column in the table. This lets the client replace certain JVM-only + * classes with alternative implementations, but still use the simple + * {@link io.deephaven.extensions.barrage.chunk.ChunkReader.TypeInfo} wrapper. + */ + public Class[] columnTypes() { + return Arrays.stream(tableDef.getColumns()) + .map(ColumnDefinition::getType) + .map(t -> { + switch (t) { + case "boolean": + case "java.lang.Boolean": + return boolean.class; + case "char": + case "java.lang.Character": + return char.class; + case "byte": + case "java.lang.Byte": + return byte.class; + case "int": + case "java.lang.Integer": + return int.class; + case "short": + case "java.lang.Short": + return short.class; + case "long": + case "java.lang.Long": + return long.class; + case "java.lang.Float": + case "float": + return float.class; + case "java.lang.Double": + case "double": + return double.class; + case "java.time.Instant": + return DateWrapper.class; + case "java.math.BigInteger": + return BigIntegerWrapper.class; + case "java.math.BigDecimal": + return BigDecimalWrapper.class; + default: + return Object.class; + } + }) + .toArray(Class[]::new); + } + + /** + * Returns the Java Class to represent the component type in any list/array type. At this time, this value is not + * used by the chunk reading implementation. + */ + public Class[] componentTypes() { + return Arrays.stream(tableDef.getColumns()).map(ColumnDefinition::getType).map(t -> { + // All arrays and vectors will be handled as objects for now. + // TODO (deephaven-core#2102) clarify if we need to handle these cases at all + if (t.endsWith("[]") || t.endsWith("Vector")) { + return Object.class; + } + // Non-arrays or vectors should return null + return null; + }).toArray(Class[]::new); + } + public ClientTableState newState(TableTicket newHandle, TableConfig config) { if (config == null) { config = this; @@ -349,27 +432,18 @@ public void setSize(long size) { } this.size = size; - JsConsumer doSetSize = table -> { - long localSize = size; - final ActiveTableBinding binding = getActiveBinding(table); - if (binding != null && table.isBlinkTable() && binding.getRows() != null) { - localSize = Math.min(size, binding.getRows().size()); - } - table.setSize(localSize); - }; - if (isRunning()) { if (log) { JsLog.debug("CTS immediate size update ", this.size, " actives: ", active); } - forActiveTables(doSetSize); + forActiveTables(t -> t.setSize(size)); } else { if (queuedSize == null) { JsLog.debug("Queuing size changed until RUNNING STATE; ", size); onRunning(self -> { JsLog.debug("Firing queued size change event (", queuedSize, ")"); forActiveTables(table -> { - doSetSize.apply(table); + table.setSize(size); queuedSize = null; }); }, JsRunnable.doNothing()); @@ -390,7 +464,6 @@ private void setTableDef(InitialTableDefinition tableDef) { // iterate through the columns, combine format columns into the normal model Map> byNameMap = tableDef.getColumnsByName(); - assert byNameMap.get(true).isEmpty() : "Unexpected constituent columns in table " + byNameMap.get(true); Column[] columns = new Column[0]; allColumns = new Column[0]; for (ColumnDefinition definition : columnDefinitions) { @@ -630,12 +703,10 @@ public Column findColumn(String key) { } /** - * @return true if there are no tables bound to this state. - * - * If a table that had a subscription for this state was orphaned by a pending request, we want to clear the - * subscription immediately so it becomes inert (immediately remove the subscription), but we may need to - * rollback the request, and we don't want to release the handle until the pending request is finished - * (whereupon we will remove the binding). + * @return true if there are no tables bound to this state. If a table that had a subscription for this state was + * orphaned by a pending request, we want to clear the subscription immediately so it becomes inert + * (immediately remove the subscription), but we may need to rollback the request, and we don't want to + * release the handle until the pending request is finished (whereupon we will remove the binding). */ public boolean isEmpty() { return active.size == 0 && paused.size == 0 && retainers.size == 0; @@ -658,14 +729,6 @@ public void unretain(Object retainer) { connection.scheduleCheck(this); } - public boolean isActiveEmpty() { - return active.size == 0; - } - - public boolean hasNoSubscriptions() { - return JsItr.iterate(active.values()).allMatch(binding -> binding.getSubscription() == null); - } - public boolean hasSort(Sort candidate) { return getSorts().contains(candidate); } @@ -715,59 +778,6 @@ public boolean releaseTable(JsTable table) { return had; } - public void setDesiredViewport(JsTable table, long firstRow, long lastRow, Column[] columns) { - touch(); - final ActiveTableBinding sub = active.get(table); - assert sub != null : "You cannot set the desired viewport on a non-active state + table combination"; - final RangeSet rows = sub.setDesiredViewport(firstRow, lastRow, columns); - // let event loop eat multiple viewport sets and only apply the last one (winner of who gets spot in map) - LazyPromise.runLater(() -> { - if (sub.getRows() == rows) { - // winner! now, on to the next hurdle... ensuring we have columns. - // TODO: have an onColumnsReady callback, for cases when we know we're only waiting on - // non-column-modifying operations - onRunning(self -> { - if (sub.getRows() == rows) { - // winner again! - applyViewport(sub); - } - }, JsRunnable.doNothing()); - } - }); - } - - public void subscribe(JsTable table, Column[] columns) { - touch(); - ActiveTableBinding binding = active.get(table); - assert binding != null : "No active binding found for table " + table; - - onRunning(self -> { - binding.setSubscriptionPending(true); - - if (getHandle().equals(table.getHandle())) { - binding.setViewport(new Viewport(null, makeBitset(columns))); - table.getConnection().scheduleCheck(this); - } - }, JsRunnable.doNothing()); - } - - private void applyViewport(ActiveTableBinding sub) { - sub.setSubscriptionPending(false); - final JsTable table = sub.getTable(); - // make sure we're still the tail entry before trying to apply viewport - assert isRunning() : "Do not call this method unless you are in a running state! " + this; - if (getHandle().equals(table.getHandle())) { - final RangeSet rows = sub.getRows(); - Column[] desired = sub.getColumns(); - if (Js.isFalsy(desired)) { - desired = getColumns(); - } - Viewport vp = new Viewport(rows, makeBitset(desired)); - sub.setViewport(vp); - table.refreshViewport(this, vp); - } - } - public BitSet makeBitset(Column[] columns) { BitSet bitSet = new BitSet(getTableDef().getColumns().length); Arrays.stream(columns).flatMapToInt(Column::getRequiredColumns).forEach(bitSet::set); @@ -784,16 +794,6 @@ public MappedIterable getBoundTables() { return iterate(active.keys()).plus(iterate(paused.keys())); } - public void forActiveSubscriptions(JsBiConsumer callback) { - JsItr.forEach(active, (table, binding) -> { - if (binding.getSubscription() != null) { - assert binding.getTable() == table - : "Corrupt binding between " + table + " and " + binding + " in " + active; - callback.apply((JsTable) table, binding.getSubscription()); - } - }); - } - public void forActiveTables(JsConsumer callback) { JsItr.forEach(active, (table, sub) -> { callback.apply(table); @@ -818,24 +818,6 @@ public void forActiveLifecycles(JsConsumer callback) { } } - public void handleDelta(DeltaUpdates updates) { - assert size != SIZE_UNINITIALIZED : "Received delta before receiving initial size"; - setSize(size + updates.getAdded().size() - updates.getRemoved().size()); - forActiveSubscriptions((table, subscription) -> { - assert table.getHandle().equals(handle); - // we are the active state of this table, so forward along the delta. - table.handleDelta(this, updates); - }); - } - - public void setSubscribed(boolean subscribed) { - this.subscribed = subscribed; - } - - public boolean isSubscribed() { - return subscribed; - } - @Override public String toString() { return "ClientTableState{" + @@ -905,15 +887,9 @@ public void unpause(JsTable table) { assert was != null : "Cannot unpause a table that is not paused " + this; paused.delete(table); active.set(table, was.getActiveBinding()); - // Now, we want to put back the viewport, if any. - refreshSubscription(was.getActiveBinding()); - } - - private void refreshSubscription(ActiveTableBinding sub) { - assert active.get(sub.getTable()) == sub; - if (!sub.isSubscriptionPending()) { - sub.maybeReviveSubscription(); - } + // Now, we want to put back the viewport, if any, since those may be still used by the original table + ActiveTableBinding sub = was.getActiveBinding(); + table.maybeReviveSubscription(); } public MappedIterable ancestors() { @@ -925,7 +901,7 @@ public MappedIterable reversed() { } /** - * Look through paused tables to see if any of them have been + * Look through paused tables to see if any of them have been closed. */ public void cleanup() { assert JsItr.iterate(active.keys()).allMatch(t -> !t.isAlive() || t.state() == this) @@ -1011,9 +987,7 @@ public void applyTableCreationResponse(ExportedTableCreationResponse def) { Uint8Array flightSchemaMessage = def.getSchemaHeader_asU8(); isStatic = def.getIsStatic(); - Schema schema = WebBarrageUtils.readSchemaMessage(flightSchemaMessage); - - setTableDef(WebBarrageUtils.readTableDefinition(schema)); + setTableDef(WebBarrageUtils.readTableDefinition(WebBarrageUtils.readSchemaMessage(flightSchemaMessage))); setResolution(ResolutionState.RUNNING); setSize(Long.parseLong(def.getSize())); diff --git a/web/client-api/src/main/resources/io/deephaven/barrage/flatbuf/BarrageFlatbufFormat.gwt.xml b/web/client-api/src/main/resources/io/deephaven/barrage/flatbuf/BarrageFlatbufFormat.gwt.xml new file mode 100644 index 00000000000..9fd0a379083 --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/barrage/flatbuf/BarrageFlatbufFormat.gwt.xml @@ -0,0 +1,4 @@ + + + + diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/com/google/common/io/LittleEndianDataInputStream.java b/web/client-api/src/main/resources/io/deephaven/web/super/com/google/common/io/LittleEndianDataInputStream.java new file mode 100644 index 00000000000..e1f587ac72e --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/com/google/common/io/LittleEndianDataInputStream.java @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2007 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ + +package com.google.common.io; + +import org.gwtproject.nio.Numbers; + +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.EOFException; +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.Objects; + +/** + * An implementation of {@link DataInput} that uses little-endian byte ordering for reading {@code + * short}, {@code int}, {@code float}, {@code double}, and {@code long} values. + * + *

Note: This class intentionally violates the specification of its supertype {@code + * DataInput}, which explicitly requires big-endian byte order. + * + * @author Chris Nokleberg + * @author Keith Bottner + * @since 8.0 + */ +public final class LittleEndianDataInputStream extends FilterInputStream implements DataInput { + + public LittleEndianDataInputStream(InputStream in) { + super(Objects.requireNonNull(in)); + } + + /** This method will throw an {@link UnsupportedOperationException}. */ + @Override + public String readLine() { + throw new UnsupportedOperationException("readLine is not supported"); + } + + @Override + public void readFully(byte[] b) throws IOException { + int total = 0; + while (total < b.length) { + int result = read(b, total, b.length - total); + if (result == -1) { + break; + } + total += result; + } + } + + @Override + public void readFully(byte[] b, int off, int len) throws IOException { + int total = 0; + while (total < len) { + int result = read(b, off + total, len - total); + if (result == -1) { + break; + } + total += result; + } + } + + @Override + public int skipBytes(int n) throws IOException { + return (int) in.skip(n); + } + + @Override + public int readUnsignedByte() throws IOException { + int b1 = in.read(); + if (0 > b1) { + throw new EOFException(); + } + + return b1; + } + + @Override + public int readUnsignedShort() throws IOException { + byte b1 = readAndCheckByte(); + byte b2 = readAndCheckByte(); + + int result = b2; + result = (result << 8) | (b1 & 0xFF); + + return result; + } + + @Override + public int readInt() throws IOException { + byte b1 = readAndCheckByte(); + byte b2 = readAndCheckByte(); + byte b3 = readAndCheckByte(); + byte b4 = readAndCheckByte(); + + int result = b4; + result = (result << 8) | (b3 & 0xFF); + result = (result << 8) | (b2 & 0xFF); + result = (result << 8) | (b1 & 0xFF); + + return result; + } + + @Override + public long readLong() throws IOException { + byte b1 = readAndCheckByte(); + byte b2 = readAndCheckByte(); + byte b3 = readAndCheckByte(); + byte b4 = readAndCheckByte(); + byte b5 = readAndCheckByte(); + byte b6 = readAndCheckByte(); + byte b7 = readAndCheckByte(); + byte b8 = readAndCheckByte(); + + long result = b8; + result = (result << 8) | (b7 & 0xFF); + result = (result << 8) | (b6 & 0xFF); + result = (result << 8) | (b5 & 0xFF); + result = (result << 8) | (b4 & 0xFF); + result = (result << 8) | (b3 & 0xFF); + result = (result << 8) | (b2 & 0xFF); + result = (result << 8) | (b1 & 0xFF); + + return result; + } + + /** + * Reads a {@code float} as specified by {@link DataInputStream#readFloat()}, except using + * little-endian byte order. + * + * @return the next four bytes of the input stream, interpreted as a {@code float} in + * little-endian byte order + * @throws IOException if an I/O error occurs + */ + @Override + public float readFloat() throws IOException { + return Numbers.intBitsToFloat(readInt()); + } + + /** + * Reads a {@code double} as specified by {@link DataInputStream#readDouble()}, except using + * little-endian byte order. + * + * @return the next eight bytes of the input stream, interpreted as a {@code double} in + * little-endian byte order + * @throws IOException if an I/O error occurs + */ + @Override + public double readDouble() throws IOException { + return Numbers.longBitsToDouble(readLong()); + } + + @Override + public String readUTF() throws IOException { + throw new UnsupportedOperationException("readUTF"); + } + + @Override + public short readShort() throws IOException { + return (short) readUnsignedShort(); + } + + @Override + public char readChar() throws IOException { + return (char) readUnsignedShort(); + } + + @Override + public byte readByte() throws IOException { + return (byte) readUnsignedByte(); + } + + @Override + public boolean readBoolean() throws IOException { + return readUnsignedByte() != 0; + } + + private byte readAndCheckByte() throws IOException, EOFException { + int b1 = in.read(); + + if (-1 == b1) { + throw new EOFException(); + } + + return (byte) b1; + } +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/com/google/common/io/LittleEndianDataOutputStream.java b/web/client-api/src/main/resources/io/deephaven/web/super/com/google/common/io/LittleEndianDataOutputStream.java new file mode 100644 index 00000000000..12651d83ddf --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/com/google/common/io/LittleEndianDataOutputStream.java @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2007 The Guava Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License + * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing permissions and limitations under + * the License. + */ +package com.google.common.io; + +import org.gwtproject.nio.Numbers; + +import java.io.DataOutput; +import java.io.DataOutputStream; +import java.io.FilterOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Objects; + +/** + * An implementation of {@link DataOutput} that uses little-endian byte ordering for writing {@code + * char}, {@code short}, {@code int}, {@code float}, {@code double}, and {@code long} values. + * + *

Note: This class intentionally violates the specification of its supertype {@code + * DataOutput}, which explicitly requires big-endian byte order. + * + * @author Chris Nokleberg + * @author Keith Bottner + * @since 8.0 + */ +public final class LittleEndianDataOutputStream extends FilterOutputStream implements DataOutput { + + /** + * Creates a {@code LittleEndianDataOutputStream} that wraps the given stream. + * + * @param out the stream to delegate to + */ + public LittleEndianDataOutputStream(OutputStream out) { + super(new DataOutputStream(Objects.requireNonNull(out))); + } + + @Override + public void write(byte[] b, int off, int len) throws IOException { + // Override slow FilterOutputStream impl + out.write(b, off, len); + } + + @Override + public void writeBoolean(boolean v) throws IOException { + ((DataOutputStream) out).writeBoolean(v); + } + + @Override + public void writeByte(int v) throws IOException { + ((DataOutputStream) out).writeByte(v); + } + + /** + * @deprecated The semantics of {@code writeBytes(String s)} are considered dangerous. Please use + * {@link #writeUTF(String s)}, {@link #writeChars(String s)} or another write method instead. + */ + @Deprecated + @Override + public void writeBytes(String s) throws IOException { + ((DataOutputStream) out).writeBytes(s); + } + + /** + * Writes a char as specified by {@link DataOutputStream#writeChar(int)}, except using + * little-endian byte order. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void writeChar(int v) throws IOException { + writeShort(v); + } + + /** + * Writes a {@code String} as specified by {@link DataOutputStream#writeChars(String)}, except + * each character is written using little-endian byte order. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void writeChars(String s) throws IOException { + for (int i = 0; i < s.length(); i++) { + writeChar(s.charAt(i)); + } + } + + /** + * Writes a {@code double} as specified by {@link DataOutputStream#writeDouble(double)}, except + * using little-endian byte order. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void writeDouble(double v) throws IOException { + writeLong(Double.doubleToLongBits(v)); + } + + /** + * Writes a {@code float} as specified by {@link DataOutputStream#writeFloat(float)}, except using + * little-endian byte order. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void writeFloat(float v) throws IOException { + writeInt(Numbers.floatToIntBits(v)); + } + + /** + * Writes an {@code int} as specified by {@link DataOutputStream#writeInt(int)}, except using + * little-endian byte order. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void writeInt(int v) throws IOException { + out.write(0xFF & v); + out.write(0xFF & (v >> 8)); + out.write(0xFF & (v >> 16)); + out.write(0xFF & (v >> 24)); + } + + /** + * Writes a {@code long} as specified by {@link DataOutputStream#writeLong(long)}, except using + * little-endian byte order. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void writeLong(long v) throws IOException { + out.write(0xFF & (int) v); + out.write(0xFF & (int) (v >> 8)); + out.write(0xFF & (int) (v >> 16)); + out.write(0xFF & (int) (v >> 24)); + out.write(0xFF & (int) (v >> 32)); + out.write(0xFF & (int) (v >> 40)); + out.write(0xFF & (int) (v >> 48)); + out.write(0xFF & (int) (v >> 56)); + } + + /** + * Writes a {@code short} as specified by {@link DataOutputStream#writeShort(int)}, except using + * little-endian byte order. + * + * @throws IOException if an I/O error occurs + */ + @Override + public void writeShort(int v) throws IOException { + out.write(0xFF & v); + out.write(0xFF & (v >> 8)); + } + + @Override + public void writeUTF(String s) throws IOException { + throw new UnsupportedOperationException("modified utf-8"); + } +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/chunk/util/pools/ChunkPoolReleaseTracking.java b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/chunk/util/pools/ChunkPoolReleaseTracking.java new file mode 100644 index 00000000000..c6e26966d4e --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/chunk/util/pools/ChunkPoolReleaseTracking.java @@ -0,0 +1,41 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.chunk.util.pools; + +/** + * Support for release tracking, in order to detect chunk release errors. + */ +public final class ChunkPoolReleaseTracking { + + public static void enableStrict() { + } + + public static void enable() { + } + + private static void enable(final Object factory, boolean preCheck) { + + } + + public static void disable() { + } + + static CHUNK_TYPE onTake(CHUNK_TYPE chunk) { + return chunk; + } + + static CHUNK_TYPE onGive(CHUNK_TYPE chunk) { + return chunk; + } + + public static void check() { + + } + + public static void checkAndDisable() { + + } + + private ChunkPoolReleaseTracking() {} +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/RowSequence.java b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/RowSequence.java new file mode 100644 index 00000000000..1ba218f9a73 --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/RowSequence.java @@ -0,0 +1,24 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.engine.rowset; + +import io.deephaven.util.SafeCloseable; +import io.deephaven.util.datastructures.LongAbortableConsumer; +import io.deephaven.util.datastructures.LongRangeConsumer; +import io.deephaven.util.datastructures.LongSizedDataStructure; + +public interface RowSequence extends SafeCloseable, LongSizedDataStructure { + long NULL_ROW_KEY = -1L; + boolean isEmpty(); + long lastRowKey(); + boolean forEachRowKey(LongAbortableConsumer lac); + default void forAllRowKeys(java.util.function.LongConsumer lc) { + forEachRowKey((final long v) -> { + lc.accept(v); + return true; + }); + } + + void forAllRowKeyRanges(LongRangeConsumer lrc); +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/RowSequenceFactory.java b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/RowSequenceFactory.java new file mode 100644 index 00000000000..9175bd144c4 --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/RowSequenceFactory.java @@ -0,0 +1,14 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.engine.rowset; + +import io.deephaven.engine.rowset.impl.WritableRowSetImpl; +import io.deephaven.web.shared.data.RangeSet; + +public class RowSequenceFactory { + public static final RowSequence EMPTY = new WebRowSetImpl(RangeSet.empty()); + public static RowSequence forRange(final long firstRowKey, final long lastRowKey) { + return new WebRowSetImpl(RangeSet.ofRange(firstRowKey, lastRowKey)); + } +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/RowSet.java b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/RowSet.java new file mode 100644 index 00000000000..a86d285d230 --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/RowSet.java @@ -0,0 +1,14 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.engine.rowset; + +import io.deephaven.util.SafeCloseable; +import io.deephaven.util.datastructures.LongSizedDataStructure; + +public interface RowSet extends RowSequence, LongSizedDataStructure, SafeCloseable { + RowSet copy(); + long get(long rowPosition); + + WritableRowSet intersect(RowSet rowSet); +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/RowSetBuilderSequential.java b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/RowSetBuilderSequential.java new file mode 100644 index 00000000000..e14ffa21d9f --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/RowSetBuilderSequential.java @@ -0,0 +1,11 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.engine.rowset; + +import io.deephaven.util.datastructures.LongRangeConsumer; + +public interface RowSetBuilderSequential extends LongRangeConsumer { + void appendRange(long rangeFirstRowKey, long rangeLastRowKey); + RowSet build(); +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/RowSetFactory.java b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/RowSetFactory.java new file mode 100644 index 00000000000..4dfe25e44e6 --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/RowSetFactory.java @@ -0,0 +1,23 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.engine.rowset; + +import io.deephaven.engine.rowset.RowSetBuilderSequential; +import io.deephaven.web.shared.data.RangeSet; + +public class RowSetFactory { + + public static RowSet empty() { + return new WebRowSetImpl(RangeSet.empty()); + } + public static RowSetBuilderSequential builderSequential() { + return new WebRowSetBuilderSequentialImpl(); + } + public static RowSet fromRange(long first, long last) { + return new WebRowSetImpl(RangeSet.ofRange(first, last)); + } + public static RowSet flat(long size) { + return size <= 0 ? empty() : new WebRowSetImpl(RangeSet.ofRange(0, size - 1)); + } +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/WebRowSetBuilderSequentialImpl.java b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/WebRowSetBuilderSequentialImpl.java new file mode 100644 index 00000000000..7b2673269d0 --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/WebRowSetBuilderSequentialImpl.java @@ -0,0 +1,21 @@ +package io.deephaven.engine.rowset; + +import io.deephaven.web.shared.data.Range; +import io.deephaven.web.shared.data.RangeSet; + +final class WebRowSetBuilderSequentialImpl implements RowSetBuilderSequential { + private final RangeSet rangeSet = new RangeSet(); + @Override + public void appendRange(long rangeFirstRowKey, long rangeLastRowKey) { + rangeSet.addRange(new Range(rangeFirstRowKey, rangeLastRowKey)); + } + + @Override + public void accept(long first, long last) { + appendRange(first, last); + } + @Override + public RowSet build() { + return new WebRowSetImpl(rangeSet); + } +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/WebRowSetImpl.java b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/WebRowSetImpl.java new file mode 100644 index 00000000000..abd578086a6 --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/WebRowSetImpl.java @@ -0,0 +1,89 @@ +package io.deephaven.engine.rowset; + +import io.deephaven.util.datastructures.LongAbortableConsumer; +import io.deephaven.util.datastructures.LongRangeConsumer; +import io.deephaven.web.shared.data.RangeSet; + +import java.util.PrimitiveIterator; + +final class WebRowSetImpl implements RowSet, WritableRowSet { + private final RangeSet rangeSet; + + WebRowSetImpl(RangeSet rangeSet) { + this.rangeSet = rangeSet; + } + + @Override + public boolean isEmpty() { + return rangeSet.isEmpty(); + } + + @Override + public long lastRowKey() { + return rangeSet.getLastRow(); + } + + @Override + public boolean forEachRowKey(LongAbortableConsumer lac) { + PrimitiveIterator.OfLong iter = rangeSet.indexIterator(); + while (iter.hasNext()) { + long key = iter.nextLong(); + if (!lac.accept(key)) { + return false; + } + } + return true; + } + + @Override + public void forAllRowKeyRanges(LongRangeConsumer lrc) { + rangeSet.rangeIterator().forEachRemaining(r -> { + lrc.accept(r.getFirst(), r.getLast()); + }); + } + + @Override + public long get(long position) { + return rangeSet.get(position); + } + @Override + public WritableRowSet intersect(RowSet rowSet) { + throw new UnsupportedOperationException("intersect"); + } + @Override + public WritableRowSet shift(long shiftAmount) { + throw new UnsupportedOperationException("shift"); + } + + + @Override + public long size() { + return rangeSet.size(); + } + + @Override + public void close() { + + } + + @Override + public RowSet copy() { + return new WebRowSetImpl(rangeSet.copy()); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof WebRowSetImpl)) { + return false; + } + return rangeSet.equals(((WebRowSetImpl) obj).rangeSet); + } + + @Override + public int hashCode() { + return rangeSet.hashCode(); + } +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/WritableRowSet.java b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/WritableRowSet.java new file mode 100644 index 00000000000..85572b5939c --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/engine/rowset/WritableRowSet.java @@ -0,0 +1,8 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.engine.rowset; + +public interface WritableRowSet extends RowSet { + WritableRowSet shift(long shiftAmount); +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/extensions/barrage/chunk/array/ArrayReflectUtil.java b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/extensions/barrage/chunk/array/ArrayReflectUtil.java new file mode 100644 index 00000000000..4b0dd298944 --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/extensions/barrage/chunk/array/ArrayReflectUtil.java @@ -0,0 +1,18 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.extensions.barrage.chunk.array; + +import java.lang.reflect.Array; + +/** + * Browser impl, that only returns a plain Object[]. + */ +class ArrayReflectUtil { + /** + * Always returns a plain Object[]. + */ + static Object newInstance(Class componentType, int length) { + return new Object[length]; + } +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/util/MultiException.java b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/util/MultiException.java new file mode 100644 index 00000000000..25c80ae422b --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/util/MultiException.java @@ -0,0 +1,74 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.util; + +import java.util.List; + +/** + * Simplified version of MultiException, which doesn't require PrintWriter. + */ +public class MultiException extends Exception { + + public static final Throwable[] ZERO_LENGTH_THROWABLE_ARRAY = new Throwable[0]; + private final Throwable[] causes; + + /** + * Create a MultiException from an array of Throwable causes. + * + * @param description the message to use + * @param causes a list of causes + */ + public MultiException(String description, Throwable... causes) { + super(description, getFirstCause(causes)); + this.causes = causes == null ? ZERO_LENGTH_THROWABLE_ARRAY : causes; + } + + + /** + * If there is a single exception, return that exception; otherwise wrap the causes into a MultiException. + * + * @param description the description for the MultiException + * @param causes the list of causes + * @return a MultiException or the single Throwable + */ + public static Throwable maybeWrapInMultiException(String description, List causes) { + if (causes.size() == 1) { + return causes.get(0); + } + return new MultiException(description, causes.toArray(ZERO_LENGTH_THROWABLE_ARRAY)); + } + + private static Throwable getFirstCause(Throwable[] causes) { + if (causes == null || causes.length == 0) { + return null; + } + + return causes[0]; + } + + /** + * @return all of the exceptions that resulted in this one. + */ + public Throwable[] getCauses() { + return causes; + } + + @Override + public String getMessage() { + StringBuilder sb = new StringBuilder(); + sb.append(super.getMessage()).append(":\n"); + for (int i = 0; i < causes.length; i++) { + sb.append("Cause ").append(i).append(": "); + sb.append(causes[i].toString()); + sb.append('\n'); + } + + return sb.toString(); + } + + @Override + public String toString() { + return getMessage(); + } +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/util/referencecounting/ReferenceCounted.java b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/util/referencecounting/ReferenceCounted.java new file mode 100644 index 00000000000..f33bd8c6483 --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/io/deephaven/util/referencecounting/ReferenceCounted.java @@ -0,0 +1,193 @@ +// +// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending +// +package io.deephaven.util.referencecounting; + +import org.jetbrains.annotations.NotNull; + +/** + * Implements a recurring reference counting pattern - a concurrent reference count that should refuse to go below zero, + * and invokes {@link #onReferenceCountAtZero()} exactly once when the count returns to zero. + */ +public abstract class ReferenceCounted { + /** + * This constant represents a "zero" reference count value that doesn't prevent increasing the reference count. + */ + private static final int INITIAL_ZERO_VALUE = -1; + + /** + * Since we've reserved -1 as our initial reference count value, our maximum is really one less. + */ + private static final int MAXIMUM_VALUE = -3; + + /** + * This is our "one" reference count value. + */ + private static final int ONE_VALUE = 1; + + /** + * This is our normal "zero" reference count value (terminal state). + */ + private static final int NORMAL_TERMINAL_ZERO_VALUE = 0; + + /** + * This is a marker "zero" reference count value (terminal state), signifying that a reference count was set to zero + * under exceptional circumstances, and additional attempts to drop the reference count should be treated as + * successful so as not to violate constraints. + */ + private static final int FORCED_TERMINAL_ZERO_VALUE = -2; + + /** + * The actual value of our reference count. + */ + private int referenceCount; + + protected ReferenceCounted() { + this(0); + } + + /** + * @param initialValue The initial value for the reference count, taken as an unsigned integer. Must not be one of + * the reserved values {@value #INITIAL_ZERO_VALUE} or {@value #FORCED_TERMINAL_ZERO_VALUE}. + */ + @SuppressWarnings("WeakerAccess") + protected ReferenceCounted(final int initialValue) { + initializeReferenceCount(initialValue); + } + + private void initializeReferenceCount(final int initialValue) { + if (initialValue == INITIAL_ZERO_VALUE || initialValue == FORCED_TERMINAL_ZERO_VALUE) { + throw new IllegalArgumentException("Invalid initial reference count " + initialValue); + } + referenceCount = initialValue == 0 ? INITIAL_ZERO_VALUE : initialValue; + } + + public static String getReferenceCountDebug(Object maybeReferenceCounted) { + return maybeReferenceCounted instanceof ReferenceCounted + ? Integer.toString(((ReferenceCounted) maybeReferenceCounted).getCurrentReferenceCount()) + : "not reference counted"; + } + + private int getCurrentReferenceCount() { + return referenceCount; + } + + private boolean tryUpdateReferenceCount(final int expected, final int update) { + if (referenceCount != expected) { + return false; + } + referenceCount = update; + return true; + } + + /** + * Reset this reference count to its initial state for reuse. + */ + public final void resetReferenceCount() { + if (!tryUpdateReferenceCount(NORMAL_TERMINAL_ZERO_VALUE, INITIAL_ZERO_VALUE) + && !tryUpdateReferenceCount(FORCED_TERMINAL_ZERO_VALUE, INITIAL_ZERO_VALUE)) { + throw new IllegalStateException("reference count is non-zero and cannot be reset"); + } + } + + private static boolean isInitialZero(final int countValue) { + return countValue == INITIAL_ZERO_VALUE; + } + + private static boolean isTerminalZero(final int countValue) { + return countValue == NORMAL_TERMINAL_ZERO_VALUE || countValue == FORCED_TERMINAL_ZERO_VALUE; + } + + private static boolean isZero(final int countValue) { + return isInitialZero(countValue) || isTerminalZero(countValue); + } + + /** + * Increment the reference count by 1, if it has not already been decreased to 0. + * + * @return Whether the reference count was successfully incremented + * @throws IllegalStateException If the reference count is already at its maximum referenceCount + */ + public final boolean tryIncrementReferenceCount() { + int currentReferenceCount; + while (!isTerminalZero(currentReferenceCount = getCurrentReferenceCount())) { + if (currentReferenceCount == MAXIMUM_VALUE) { + throw new IllegalStateException("reference count cannot exceed maximum value"); + } + if (tryUpdateReferenceCount(currentReferenceCount, + isInitialZero(currentReferenceCount) ? ONE_VALUE : currentReferenceCount + 1)) { + return true; + } + } + return false; + } + + /** + * Increment the reference count by one, if it has not already been decreased to zero. + * + * @throws IllegalStateException If the reference count was not successfully incremented + */ + public final void incrementReferenceCount() { + if (!tryIncrementReferenceCount()) { + throw new IllegalStateException("reference count has already reached zero"); + } + } + + /** + * Decrement the reference count by one, if it has ever been increased and has not already been decreased to zero. + * Invokes the implementation's {@link #onReferenceCountAtZero()} method if decrementing to zero. + * + * @return Whether the reference count was successfully decremented + */ + @SuppressWarnings({"WeakerAccess", "BooleanMethodIsAlwaysInverted"}) + public final boolean tryDecrementReferenceCount() { + int currentReferenceCount; + while (!isZero(currentReferenceCount = getCurrentReferenceCount())) { + if (tryUpdateReferenceCount(currentReferenceCount, currentReferenceCount - 1)) { + if (currentReferenceCount == ONE_VALUE) { // Did we just CAS from 1 to 0? + onReferenceCountAtZero(); + } + return true; + } + } + return currentReferenceCount == FORCED_TERMINAL_ZERO_VALUE; + } + + /** + * Force the reference count to zero. If it was non-zero, this will have the same side effects as returning to zero + * normally, but subsequent invocations of {@link #decrementReferenceCount()} and + * {@link #tryDecrementReferenceCount()} will act as if the reference count was successfully decremented until + * {@link #resetReferenceCount()} is invoked. + * + * @return Whether this invocation actually forced the reference count to zero (and invoked + * {@link #onReferenceCountAtZero()}. {@code false} means that this ReferenceCounted reached a zero through + * other means. + */ + public final boolean forceReferenceCountToZero() { + int currentReferenceCount; + while (!isZero(currentReferenceCount = getCurrentReferenceCount())) { + if (tryUpdateReferenceCount(currentReferenceCount, FORCED_TERMINAL_ZERO_VALUE)) { + onReferenceCountAtZero(); + return true; + } + } + return false; + } + + /** + * Decrement the reference count by one, if it has ever been increased and has not already been decreased to zero. + * Invokes the implementation's {@link #onReferenceCountAtZero()} method if decrementing to zero. + * + * @throws IllegalStateException If the reference count was not successfully decremented + */ + public final void decrementReferenceCount() { + if (!tryDecrementReferenceCount()) { + throw new IllegalStateException("reference count has been decreased more than increased"); + } + } + + /** + * Callback method that will be invoked when the reference count returns to zero. + */ + protected abstract void onReferenceCountAtZero(); +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/java/io/DataInput.java b/web/client-api/src/main/resources/io/deephaven/web/super/java/io/DataInput.java new file mode 100644 index 00000000000..8b8eb52520e --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/java/io/DataInput.java @@ -0,0 +1,19 @@ +package java.io; + +public interface DataInput { + boolean readBoolean() throws IOException; + byte readByte() throws IOException; + char readChar() throws IOException; + double readDouble() throws IOException; + float readFloat() throws IOException; + void readFully(byte[] b) throws IOException; + void readFully(byte[] b, int off, int len) throws IOException; + int readInt() throws IOException; + String readLine() throws IOException; + long readLong() throws IOException; + short readShort() throws IOException; + int readUnsignedByte() throws IOException; + int readUnsignedShort() throws IOException; + String readUTF() throws IOException; + int skipBytes(int n) throws IOException; +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/java/io/DataOutput.java b/web/client-api/src/main/resources/io/deephaven/web/super/java/io/DataOutput.java new file mode 100644 index 00000000000..0534189f69a --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/java/io/DataOutput.java @@ -0,0 +1,18 @@ +package java.io; + +public interface DataOutput { + void write(byte[] b) throws IOException; + void write(byte[] b, int off, int len) throws IOException; + void write(int b) throws IOException; + void writeBoolean(boolean v) throws IOException; + void writeByte(int v) throws IOException; + void writeBytes(String s) throws IOException; + void writeChar(int v) throws IOException; + void writeChars(String s) throws IOException; + void writeDouble(double v) throws IOException; + void writeFloat(float v) throws IOException; + void writeInt(int v) throws IOException; + void writeLong(long v) throws IOException; + void writeShort(int v) throws IOException; + void writeUTF(String s) throws IOException; +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/java/io/DataOutputStream.java b/web/client-api/src/main/resources/io/deephaven/web/super/java/io/DataOutputStream.java new file mode 100644 index 00000000000..29f380a4a12 --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/java/io/DataOutputStream.java @@ -0,0 +1,104 @@ +package java.io; + +import org.gwtproject.nio.Numbers; + +import java.nio.charset.StandardCharsets; + +public class DataOutputStream extends FilterOutputStream implements DataOutput { + protected int written; + + public DataOutputStream(OutputStream out) { + super(out); + } + + @Override + public void write(int b) throws IOException { + super.write(b); + written++; + } + + @Override + public void write(byte[] b, int off, int len) throws IOException { + super.write(b, off, len); + written += len; + } + + @Override + public void writeBoolean(boolean b) throws IOException { + write(b ? 1 : 0); + } + + @Override + public void writeByte(int i) throws IOException { + write(i); + } + + @Override + public void writeShort(int i) throws IOException { + super.write((i >> 8) & 0xFF); + super.write((i >> 0) & 0xFF); + written += 2; + } + + @Override + public void writeChar(int i) throws IOException { + super.write((i >> 8) & 0xFF); + super.write((i >> 0) & 0xFF); + written += 2; + } + + @Override + public void writeInt(int i) throws IOException { + super.write((i >> 24) & 0xFF); + super.write((i >> 16) & 0xFF); + super.write((i >> 8) & 0xFF); + super.write((i >> 0) & 0xFF); + written += 4; + } + + @Override + public void writeLong(long l) throws IOException { + super.write((int) (l >> 56) & 0xFF); + super.write((int) (l >> 48) & 0xFF); + super.write((int) (l >> 40) & 0xFF); + super.write((int) (l >> 32) & 0xFF); + super.write((int) (l >> 24) & 0xFF); + super.write((int) (l >> 16) & 0xFF); + super.write((int) (l >> 8) & 0xFF); + super.write((int) (l >> 0) & 0xFF); + written += 8; + } + + @Override + public void writeFloat(float v) throws IOException { + writeInt(Numbers.floatToIntBits(v)); + } + + @Override + public void writeDouble(double v) throws IOException { + writeLong(Numbers.doubleToRawLongBits(v)); + } + + @Override + public void writeBytes(String s) throws IOException { + for (int i = 0; i < s.length(); i++) { + super.write(s.charAt(i) & 0xFF); + } + written += s.length(); + } + + @Override + public void writeChars(String s) throws IOException { + for (int i = 0; i < s.length(); i++) { + char c = s.charAt(i); + super.write((c >> 8) & 0xFF); + super.write(c & 0xFF); + } + written += s.length() * 2; + } + + @Override + public void writeUTF(String s) throws IOException { + throw new UnsupportedOperationException("modified utf-8"); + } +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/java/io/EOFException.java b/web/client-api/src/main/resources/io/deephaven/web/super/java/io/EOFException.java new file mode 100644 index 00000000000..ac8a7959205 --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/java/io/EOFException.java @@ -0,0 +1,10 @@ +package java.io; + +public class EOFException extends IOException { + public EOFException() { + } + + public EOFException(String s) { + super(s); + } +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/java/io/UTFDataFormatException.java b/web/client-api/src/main/resources/io/deephaven/web/super/java/io/UTFDataFormatException.java new file mode 100644 index 00000000000..e2c6a3d3bd8 --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/java/io/UTFDataFormatException.java @@ -0,0 +1,11 @@ +package java.io; + +public class UTFDataFormatException extends IOException { + public UTFDataFormatException() { + super(); + } + + public UTFDataFormatException(String message) { + super(message); + } +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/java/lang/ref/Reference.java b/web/client-api/src/main/resources/io/deephaven/web/super/java/lang/ref/Reference.java new file mode 100644 index 00000000000..2f9dc276b00 --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/java/lang/ref/Reference.java @@ -0,0 +1,44 @@ +package java.lang.ref; + +import io.deephaven.web.client.fu.JsWeakRef; + +public abstract class Reference { + + private JsWeakRef jsWeakRef; + + Reference(T referent) { + this(referent, (ReferenceQueue) null); + } + + Reference(T referent, ReferenceQueue queue) { + if (referent != null) { + jsWeakRef = new JsWeakRef<>(referent); + } + } + + public T get() { + if (jsWeakRef == null) { + return null; + } + return jsWeakRef.deref(); + } + + public void clear() { + if (jsWeakRef != null) { + jsWeakRef = null; + } + } + + public boolean isEnqueued() { + return false; + } + + public boolean enqueue() { + throw new IllegalStateException("never called when emulated"); + } + + protected Object clone() throws CloneNotSupportedException { + throw new CloneNotSupportedException(); + } + +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/java/lang/ref/ReferenceQueue.java b/web/client-api/src/main/resources/io/deephaven/web/super/java/lang/ref/ReferenceQueue.java new file mode 100644 index 00000000000..1e2dfd25483 --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/java/lang/ref/ReferenceQueue.java @@ -0,0 +1,5 @@ +package java.lang.ref; + +public class ReferenceQueue { + +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/java/lang/ref/SoftReference.java b/web/client-api/src/main/resources/io/deephaven/web/super/java/lang/ref/SoftReference.java new file mode 100644 index 00000000000..f18650366ea --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/java/lang/ref/SoftReference.java @@ -0,0 +1,10 @@ +package java.lang.ref; + +public class SoftReference extends Reference { + public SoftReference(T referent) { + super(referent); + } + public SoftReference(T referent, ReferenceQueue q) { + super(referent, q); + } +} diff --git a/web/client-api/src/main/resources/io/deephaven/web/super/java/math/BigInteger.java b/web/client-api/src/main/resources/io/deephaven/web/super/java/math/BigInteger.java new file mode 100644 index 00000000000..500451f2f96 --- /dev/null +++ b/web/client-api/src/main/resources/io/deephaven/web/super/java/math/BigInteger.java @@ -0,0 +1,1599 @@ +/* + * Copyright 2009 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to You under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + * + * INCLUDES MODIFICATIONS BY RICHARD ZSCHECH AS WELL AS GOOGLE. + */ +package java.math; + +import static javaemul.internal.Coercions.ensureInt; +import static javaemul.internal.InternalPreconditions.checkCriticalArgument; +import static javaemul.internal.InternalPreconditions.checkNotNull; + +import java.io.Serializable; +import java.util.Random; +import javaemul.internal.LongUtils; + +/** + * This class represents immutable integer numbers of arbitrary length. Large + * numbers are typically used in security applications and therefore BigIntegers + * offer dedicated functionality like the generation of large prime numbers or + * the computation of modular inverse. + *

+ * Since the class was modeled to offer all the functionality as the + * {@link Integer} class does, it provides even methods that operate bitwise on + * a two's complement representation of large integers. Note however that the + * implementations favors an internal representation where magnitude and sign + * are treated separately. Hence such operations are inefficient and should be + * discouraged. In simple words: Do NOT implement any bit fields based on + * BigInteger. + */ +public class BigInteger extends Number implements Comparable, + Serializable { + + /** + * The {@code BigInteger} constant 1. + */ + public static final BigInteger ONE = new BigInteger(1, 1); + + /* Fields used for the internal representation. */ + + /** + * The {@code BigInteger} constant 10. + */ + public static final BigInteger TEN = new BigInteger(1, 10); + + /** + * The {@code BigInteger} constant 0. + */ + public static final BigInteger ZERO = new BigInteger(0, 0); + + /** + * The {@code BigInteger} constant 0 used for comparison. + */ + static final int EQUALS = 0; + + /** + * The {@code BigInteger} constant 1 used for comparison. + */ + static final int GREATER = 1; + + /** + * The {@code BigInteger} constant -1 used for comparison. + */ + static final int LESS = -1; + + /** + * The {@code BigInteger} constant -1. + */ + static final BigInteger MINUS_ONE = new BigInteger(-1, 1); + + /** + * All the {@code BigInteger} numbers in the range [0,10] are cached. + */ + static final BigInteger[] SMALL_VALUES = { + ZERO, ONE, new BigInteger(1, 2), new BigInteger(1, 3), + new BigInteger(1, 4), new BigInteger(1, 5), new BigInteger(1, 6), + new BigInteger(1, 7), new BigInteger(1, 8), new BigInteger(1, 9), TEN}; + + static final BigInteger[] TWO_POWS; + + /** + * This is the serialVersionUID used by the sun implementation. + */ + private static final long serialVersionUID = -8287574255936472291L; + + static { + TWO_POWS = new BigInteger[32]; + for (int i = 0; i < TWO_POWS.length; i++) { + TWO_POWS[i] = BigInteger.valueOf(1L << i); + } + } + + /** + * Returns a random positive {@code BigInteger} instance in the range [0, + * 2^(bitLength)-1] which is probably prime. The probability that the returned + * {@code BigInteger} is prime is beyond (1-1/2^80). + *

+ * Implementation Note: Currently {@code rnd} is ignored. + * + * @param bitLength length of the new {@code BigInteger} in bits. + * @param rnd random generator used to generate the new {@code BigInteger}. + * @return probably prime random {@code BigInteger} instance. + * @throws ArithmeticException if {@code bitLength < 2}. + */ + public static BigInteger probablePrime(int bitLength, Random rnd) { + return new BigInteger(bitLength, 100, rnd); + } + + public static BigInteger valueOf(long val) { + return val >= 0 ? BigInteger.fromBits(val) : BigInteger.fromBits(-val).negate(); + } + + private static BigInteger fromBits(long bits) { + int lowBits = (int) bits; + int highBits = LongUtils.getHighBits(bits); + if (highBits != 0) { + return new BigInteger(1, lowBits, highBits); + } + if (lowBits > 10 || lowBits < 0) { + return new BigInteger(1, lowBits); + } + return SMALL_VALUES[lowBits]; + } + + static BigInteger getPowerOfTwo(int exp) { + if (exp < TWO_POWS.length) { + return TWO_POWS[exp]; + } + int intCount = exp >> 5; + int bitN = exp & 31; + int resDigits[] = new int[intCount + 1]; + resDigits[intCount] = 1 << bitN; + return new BigInteger(1, intCount + 1, resDigits); + } + + /** + * @see BigInteger#BigInteger(String, int) + */ + private static void setFromString(BigInteger bi, String val, int radix) { + int sign; + int[] digits; + int numberLength; + int stringLength = val.length(); + int startChar; + int endChar = stringLength; + + if (val.charAt(0) == '-') { + sign = -1; + startChar = 1; + stringLength--; + } else { + sign = 1; + startChar = 0; + } + /* + * We use the following algorithm: split a string into portions of n + * characters and convert each portion to an integer according to the radix. + * Then convert an exp(radix, n) based number to binary using the + * multiplication method. See D. Knuth, The Art of Computer Programming, + * vol. 2. + */ + + int charsPerInt = Conversion.digitFitInInt[radix]; + int bigRadixDigitsLength = stringLength / charsPerInt; + int topChars = stringLength % charsPerInt; + + if (topChars != 0) { + bigRadixDigitsLength++; + } + digits = new int[bigRadixDigitsLength]; + // Get the maximal power of radix that fits in int + int bigRadix = Conversion.bigRadices[radix - 2]; + // Parse an input string and accumulate the BigInteger's magnitude + int digitIndex = 0; // index of digits array + int substrEnd = startChar + ((topChars == 0) ? charsPerInt : topChars); + int newDigit; + + for (int substrStart = startChar; substrStart < endChar; substrStart = substrEnd, substrEnd = substrStart + + charsPerInt) { + int bigRadixDigit = Integer.parseInt( + val.substring(substrStart, substrEnd), radix); + newDigit = Multiplication.multiplyByInt(digits, digitIndex, bigRadix); + newDigit += Elementary.inplaceAdd(digits, digitIndex, bigRadixDigit); + digits[digitIndex++] = newDigit; + } + numberLength = digitIndex; + bi.sign = sign; + bi.numberLength = numberLength; + bi.digits = digits; + bi.cutOffLeadingZeroes(); + } + + /** + * The magnitude of this big integer. This array is in little endian order and + * each "digit" is a 32-bit unsigned integer. For example: {@code 13} is + * represented as [ 13 ] {@code -13} is represented as [ 13 ] {@code 2^32 + + * 13} is represented as [ 13, 1 ] {@code 2^64 + 13} is represented as [ 13, + * 0, 1 ] {@code 2^31} is represented as [ Integer.MIN_VALUE ] The magnitude + * array may be longer than strictly necessary, which results in additional + * trailing zeros. + * + *

TODO(jat): consider changing to 24-bit integers for better performance + * in browsers. + */ + transient int digits[]; + + /** + * The length of this in measured in ints. Can be less than digits.length(). + */ + transient int numberLength; + + /** + * The sign of this. + */ + transient int sign; + + private transient int firstNonzeroDigit = -2; + + /** + * Cache for the hash code. + */ + private transient int hashCode = 0; + + /** + * Constructs a new {@code BigInteger} from the given two's complement + * representation. The most significant byte is the entry at index 0. The most + * significant bit of this entry determines the sign of the new {@code + * BigInteger} instance. The given array must not be empty. + * + * @param val two's complement representation of the new {@code BigInteger}. + * @throws NullPointerException if {@code val == null}. + * @throws NumberFormatException if the length of {@code val} is zero. + */ + public BigInteger(byte[] val) { + this(val, 0, val.length); + } + + /** + * Constructs a new {@code BigInteger} from the given two's complement + * representation. The most significant byte is the entry at index 0. The most + * significant bit of this entry determines the sign of the new {@code + * BigInteger} instance. The given array must not be empty. + * + * @param val two's complement representation of the new {@code BigInteger}. + * @param offset the start offset of the binary representation. + * @param length the number of bytes to use. + * @throws NullPointerException if {@code val == null}. + * @throws NumberFormatException if the length of {@code val} is zero. + */ + public BigInteger(byte[] val, int offset, int length) { + if (val.length == 0) { + // math.12=Zero length BigInteger + throw new NumberFormatException("Zero length BigInteger"); //$NON-NLS-1$ + } + if (length < 0 || offset < 0 || length > val.length - offset) { + throw new IndexOutOfBoundsException("Range check failed: offset=" + offset + ", length=" + + length + ", val.length=" + val.length); + } + if (length == 0) { + sign = 0; + numberLength = 1; + digits = new int[] {0}; + return; + } + if (val[offset] < 0) { + sign = -1; + putBytesNegativeToIntegers(val, offset, length); + } else { + sign = 1; + putBytesPositiveToIntegers(val, offset, length); + } + cutOffLeadingZeroes(); + } + + /** + * Constructs a new {@code BigInteger} instance with the given sign and the + * given magnitude. The sign is given as an integer (-1 for negative, 0 for + * zero, 1 for positive). The magnitude is specified as a byte array. The most + * significant byte is the entry at index 0. + * + * @param signum sign of the new {@code BigInteger} (-1 for negative, 0 for + * zero, 1 for positive). + * @param magnitude magnitude of the new {@code BigInteger} with the most + * significant byte first. + * @throws NullPointerException if {@code magnitude == null}. + * @throws NumberFormatException if the sign is not one of -1, 0, 1 or if the + * sign is zero and the magnitude contains non-zero entries. + */ + public BigInteger(int signum, byte[] magnitude) { + this(signum, magnitude, 0, magnitude.length); + } + + /** + * Constructs a new {@code BigInteger} instance with the given sign and the + * given magnitude. The sign is given as an integer (-1 for negative, 0 for + * zero, 1 for positive). The magnitude is specified as a byte array. The most + * significant byte is the entry at index 0. + * + * @param signum sign of the new {@code BigInteger} (-1 for negative, 0 for + * zero, 1 for positive). + * @param magnitude magnitude of the new {@code BigInteger} with the most + * significant byte first. + * @param offset the start offset of the binary representation. + * @param length the number of bytes to use. + * @throws NullPointerException if {@code magnitude == null}. + * @throws NumberFormatException if the sign is not one of -1, 0, 1 or if the + * sign is zero and the magnitude contains non-zero entries. + */ + public BigInteger(int signum, byte[] magnitude, int offset, int length) { + checkNotNull(magnitude); + + if (length < 0 || offset < 0 || length > magnitude.length - offset) { + throw new IndexOutOfBoundsException("Range check failed: offset=" + offset + ", length=" + + length + ", val.length=" + magnitude.length); + } + + if ((signum < -1) || (signum > 1)) { + // math.13=Invalid signum value + throw new NumberFormatException("Invalid signum value"); //$NON-NLS-1$ + } + if (signum == 0) { + for (int index = offset; index < offset + length; index++) { + byte element = magnitude[index]; + if (element != 0) { + // math.14=signum-magnitude mismatch + throw new NumberFormatException("signum-magnitude mismatch"); //$NON-NLS-1$ + } + } + } + if (length == 0) { + sign = 0; + numberLength = 1; + digits = new int[] {0}; + } else { + sign = signum; + putBytesPositiveToIntegers(magnitude, offset, length); + cutOffLeadingZeroes(); + } + } + + /** + * Constructs a random {@code BigInteger} instance in the range [0, + * 2^(bitLength)-1] which is probably prime. The probability that the returned + * {@code BigInteger} is prime is beyond (1-1/2^certainty). + * + * @param bitLength length of the new {@code BigInteger} in bits. + * @param certainty tolerated primality uncertainty. + * @param rnd is an optional random generator to be used. + * @throws ArithmeticException if {@code bitLength} < 2. + */ + public BigInteger(int bitLength, int certainty, Random rnd) { + if (bitLength < 2) { + // math.1C=bitLength < 2 + throw new ArithmeticException("bitLength < 2"); //$NON-NLS-1$ + } + BigInteger me = Primality.consBigInteger(bitLength, certainty, rnd); + sign = me.sign; + numberLength = me.numberLength; + digits = me.digits; + } + + /** + * Constructs a random non-negative {@code BigInteger} instance in the range + * [0, 2^(numBits)-1]. + * + * @param numBits maximum length of the new {@code BigInteger} in bits. + * @param rnd is an optional random generator to be used. + * @throws IllegalArgumentException if {@code numBits} < 0. + */ + public BigInteger(int numBits, Random rnd) { + checkCriticalArgument(numBits >= 0, "numBits must be non-negative"); + + if (numBits == 0) { + sign = 0; + numberLength = 1; + digits = new int[] {0}; + } else { + sign = 1; + numberLength = (numBits + 31) >> 5; + digits = new int[numberLength]; + for (int i = 0; i < numberLength; i++) { + digits[i] = rnd.nextInt(); + } + // Using only the necessary bits + digits[numberLength - 1] >>>= (-numBits) & 31; + cutOffLeadingZeroes(); + } + } + + /** + * Constructs a new {@code BigInteger} instance from the string + * representation. The string representation consists of an optional minus + * sign followed by a non-empty sequence of decimal digits. + * + * @param val string representation of the new {@code BigInteger}. + * @throws NullPointerException if {@code val == null}. + * @throws NumberFormatException if {@code val} is not a valid representation + * of a {@code BigInteger}. + */ + public BigInteger(String val) { + this(val, 10); + } + + /** + * Constructs a new {@code BigInteger} instance from the string + * representation. The string representation consists of an optional minus + * sign followed by a non-empty sequence of digits in the specified radix. For + * the conversion the method {@code Character.digit(char, radix)} is used. + * + * @param val string representation of the new {@code BigInteger}. + * @param radix the base to be used for the conversion. + * @throws NullPointerException if {@code val == null}. + * @throws NumberFormatException if {@code val} is not a valid representation + * of a {@code BigInteger} or if {@code radix < Character.MIN_RADIX} + * or {@code radix > Character.MAX_RADIX}. + */ + public BigInteger(String val, int radix) { + checkNotNull(val); + + if ((radix < Character.MIN_RADIX) || (radix > Character.MAX_RADIX)) { + // math.11=Radix out of range + throw new NumberFormatException("Radix out of range"); //$NON-NLS-1$ + } + if (val.isEmpty()) { + // math.12=Zero length BigInteger + throw new NumberFormatException("Zero length BigInteger"); //$NON-NLS-1$ + } + setFromString(this, val, radix); + } + + /** + * Constructs a number which array is of size 1. + * + * @param sign the sign of the number + * @param value the only one digit of array + */ + BigInteger(int sign, int bits) { + this(sign, 1, new int[] {bits}); + } + + BigInteger(int sign, int lowBits, int highBits) { + this(sign, 2, new int[] {lowBits, highBits}); + } + + /** + * Creates a new {@code BigInteger} with the given sign and magnitude. This constructor does not + * create a copy, so any changes to the reference will affect the new number. + * + * @param signum The sign of the number represented by {@code digits} + * @param digits The magnitude of the number + */ + BigInteger(int signum, int digits[]) { + if (digits.length == 0) { + sign = 0; + numberLength = 1; + this.digits = new int[] {0}; + } else { + sign = signum; + numberLength = digits.length; + this.digits = digits; + cutOffLeadingZeroes(); + } + } + + /** + * Constructs a number without to create new space. This construct should be used only if the + * three fields of representation are known. + * + * @param sign the sign of the number + * @param numberLength the length of the internal array + * @param digits a reference of some array created before + */ + BigInteger(int sign, int numberLength, int[] digits) { + this.sign = sign; + this.numberLength = numberLength; + this.digits = digits; + } + + /** + * Returns a (new) {@code BigInteger} whose value is the absolute value of + * {@code this}. + * + * @return {@code abs(this)}. + */ + public BigInteger abs() { + return sign < 0 ? negate() : this; + } + + /** + * Returns a new {@code BigInteger} whose value is {@code this + val}. + * + * @param val value to be added to {@code this}. + * @return {@code this + val}. + * @throws NullPointerException if {@code val == null}. + */ + public BigInteger add(BigInteger val) { + return Elementary.add(this, val); + } + + /** + * Returns a new {@code BigInteger} whose value is {@code this & val}. + *

+ * Implementation Note: Usage of this method is not recommended as the + * current implementation is not efficient. + * + * @param val value to be and'ed with {@code this}. + * @return {@code this & val}. + * @throws NullPointerException if {@code val == null}. + */ + public BigInteger and(BigInteger val) { + return Logical.and(this, val); + } + + /** + * Returns a new {@code BigInteger} whose value is {@code this & ~val}. + * Evaluating {@code x.andNot(val)} returns the same result as {@code + * x.and(val.not())}. + *

+ * Implementation Note: Usage of this method is not recommended as the + * current implementation is not efficient. + * + * @param val value to be not'ed and then and'ed with {@code this}. + * @return {@code this & ~val}. + * @throws NullPointerException if {@code val == null}. + */ + public BigInteger andNot(BigInteger val) { + return Logical.andNot(this, val); + } + + /** + * Use {@code bitLength(0)} if you want to know the length of the binary value + * in bits. + *

+ * Returns the number of bits in the binary representation of {@code this} + * which differ from the sign bit. If {@code this} is positive the result is + * equivalent to the number of bits set in the binary representation of + * {@code this}. If {@code this} is negative the result is equivalent to the + * number of bits set in the binary representation of {@code -this-1}. + *

+ * Implementation Note: Usage of this method is not recommended as the + * current implementation is not efficient. + * + * @return number of bits in the binary representation of {@code this} which + * differ from the sign bit + */ + public int bitCount() { + return BitLevel.bitCount(this); + } + + /** + * Returns the length of the value's two's complement representation without + * leading zeros for positive numbers / without leading ones for negative + * values. + *

+ * The two's complement representation of {@code this} will be at least + * {@code bitLength() + 1} bits long. + *

+ * The value will fit into an {@code int} if {@code bitLength() < 32} or into + * a {@code long} if {@code bitLength() < 64}. + * + * @return the length of the minimal two's complement representation for + * {@code this} without the sign bit. + */ + public int bitLength() { + return BitLevel.bitLength(this); + } + + /** + * Converts value of this {@code BigInteger} to a {@code byte} if it fits it, + * otherwise {@code ArithmeticException} is thrown. + * + * @return this {@code BigInteger} converted to a {@code byte}. + * @throws ArithmeticException if the value of this {@code BigInteger} + * does not fit in a {@code byte}. + */ + public byte byteValueExact() { + if (numberLength <= 1 && bitLength() < Byte.SIZE) { + return byteValue(); + } + throw new ArithmeticException("out of byte range"); + } + + /** + * Returns a new {@code BigInteger} which has the same binary representation + * as {@code this} but with the bit at position n cleared. The result is + * equivalent to {@code this & ~(2^n)}. + *

+ * Implementation Note: Usage of this method is not recommended as the + * current implementation is not efficient. + * + * @param n position where the bit in {@code this} has to be cleared. + * @return {@code this & ~(2^n)}. + * @throws ArithmeticException if {@code n < 0}. + */ + public BigInteger clearBit(int n) { + if (testBit(n)) { + return BitLevel.flipBit(this, n); + } + return this; + } + + /** + * Compares this {@code BigInteger} with {@code val}. Returns one of the three + * values 1, 0, or -1. + * + * @param val value to be compared with {@code this}. + * @return {@code 1} if {@code this > val}, {@code -1} if {@code this < val} , + * {@code 0} if {@code this == val}. + * @throws NullPointerException if {@code val == null}. + */ + @Override + public int compareTo(BigInteger val) { + if (sign > val.sign) { + return GREATER; + } + if (sign < val.sign) { + return LESS; + } + if (numberLength > val.numberLength) { + return sign; + } + if (numberLength < val.numberLength) { + return -val.sign; + } + // Equal sign and equal numberLength + return (sign * Elementary.compareArrays(digits, val.digits, numberLength)); + } + + /** + * Returns a new {@code BigInteger} whose value is {@code this / divisor}. + * + * @param divisor value by which {@code this} is divided. + * @return {@code this / divisor}. + * @throws NullPointerException if {@code divisor == null}. + * @throws ArithmeticException if {@code divisor == 0}. + */ + public BigInteger divide(BigInteger divisor) { + if (divisor.sign == 0) { + // math.17=BigInteger divide by zero + throw new ArithmeticException("BigInteger divide by zero"); //$NON-NLS-1$ + } + int divisorSign = divisor.sign; + if (divisor.isOne()) { + return ((divisor.sign > 0) ? this : this.negate()); + } + int thisSign = sign; + int thisLen = numberLength; + int divisorLen = divisor.numberLength; + if (thisLen + divisorLen == 2) { + long val = (digits[0] & 0xFFFFFFFFL) / (divisor.digits[0] & 0xFFFFFFFFL); + if (thisSign != divisorSign) { + val = -val; + } + return valueOf(val); + } + int cmp = ((thisLen != divisorLen) ? ((thisLen > divisorLen) ? 1 : -1) + : Elementary.compareArrays(digits, divisor.digits, thisLen)); + if (cmp == EQUALS) { + return ((thisSign == divisorSign) ? ONE : MINUS_ONE); + } + if (cmp == LESS) { + return ZERO; + } + int resLength = thisLen - divisorLen + 1; + int resDigits[] = new int[resLength]; + int resSign = ((thisSign == divisorSign) ? 1 : -1); + if (divisorLen == 1) { + Division.divideArrayByInt(resDigits, digits, thisLen, divisor.digits[0]); + } else { + Division.divide(resDigits, resLength, digits, thisLen, divisor.digits, + divisorLen); + } + BigInteger result = new BigInteger(resSign, resLength, resDigits); + result.cutOffLeadingZeroes(); + return result; + } + + /** + * Returns a {@code BigInteger} array which contains {@code this / divisor} at + * index 0 and {@code this % divisor} at index 1. + * + * @param divisor value by which {@code this} is divided. + * @return {@code [this / divisor, this % divisor]}. + * @throws NullPointerException if {@code divisor == null}. + * @throws ArithmeticException if {@code divisor == 0}. + * @see #divide + * @see #remainder + */ + public BigInteger[] divideAndRemainder(BigInteger divisor) { + int divisorSign = divisor.sign; + if (divisorSign == 0) { + // math.17=BigInteger divide by zero + throw new ArithmeticException("BigInteger divide by zero"); //$NON-NLS-1$ + } + int divisorLen = divisor.numberLength; + int[] divisorDigits = divisor.digits; + if (divisorLen == 1) { + return Division.divideAndRemainderByInteger(this, divisorDigits[0], + divisorSign); + } + // res[0] is a quotient and res[1] is a remainder: + int[] thisDigits = digits; + int thisLen = numberLength; + int cmp = (thisLen != divisorLen) ? ((thisLen > divisorLen) ? 1 : -1) + : Elementary.compareArrays(thisDigits, divisorDigits, thisLen); + if (cmp < 0) { + return new BigInteger[] {ZERO, this}; + } + int thisSign = sign; + int quotientLength = thisLen - divisorLen + 1; + int remainderLength = divisorLen; + int quotientSign = ((thisSign == divisorSign) ? 1 : -1); + int quotientDigits[] = new int[quotientLength]; + int remainderDigits[] = Division.divide(quotientDigits, quotientLength, + thisDigits, thisLen, divisorDigits, divisorLen); + BigInteger result0 = new BigInteger(quotientSign, quotientLength, + quotientDigits); + BigInteger result1 = new BigInteger(thisSign, remainderLength, + remainderDigits); + result0.cutOffLeadingZeroes(); + result1.cutOffLeadingZeroes(); + return new BigInteger[] {result0, result1}; + } + + /** + * Returns this {@code BigInteger} as an double value. If {@code this} is too + * big to be represented as an double, then {@code Double.POSITIVE_INFINITY} + * or {@code Double.NEGATIVE_INFINITY} is returned. Note, that not all + * integers x in the range [-Double.MAX_VALUE, Double.MAX_VALUE] can be + * represented as a double. The double representation has a mantissa of length + * 53. For example, 2^53+1 = 9007199254740993 is returned as double + * 9007199254740992.0. + * + * @return this {@code BigInteger} as a double value + */ + @Override + public double doubleValue() { + return Double.parseDouble(this.toString()); + } + + /** + * Returns {@code true} if {@code x} is a BigInteger instance and if this + * instance is equal to this {@code BigInteger}. + * + * @param x object to be compared with {@code this}. + * @return true if {@code x} is a BigInteger and {@code this == x}, {@code + * false} otherwise. + */ + @Override + public boolean equals(Object x) { + if (this == x) { + return true; + } + if (x instanceof BigInteger) { + BigInteger x1 = (BigInteger) x; + return sign == x1.sign && numberLength == x1.numberLength + && equalsArrays(x1.digits); + } + return false; + } + + /** + * Returns a new {@code BigInteger} which has the same binary representation + * as {@code this} but with the bit at position n flipped. The result is + * equivalent to {@code this ^ 2^n}. + *

+ * Implementation Note: Usage of this method is not recommended as the + * current implementation is not efficient. + * + * @param n position where the bit in {@code this} has to be flipped. + * @return {@code this ^ 2^n}. + * @throws ArithmeticException if {@code n < 0}. + */ + public BigInteger flipBit(int n) { + if (n < 0) { + // math.15=Negative bit address + throw new ArithmeticException("Negative bit address"); //$NON-NLS-1$ + } + return BitLevel.flipBit(this, n); + } + + /** + * Returns this {@code BigInteger} as an float value. If {@code this} is too + * big to be represented as an float, then {@code Float.POSITIVE_INFINITY} or + * {@code Float.NEGATIVE_INFINITY} is returned. Note, that not all integers x + * in the range [-Float.MAX_VALUE, Float.MAX_VALUE] can be represented as a + * float. The float representation has a mantissa of length 24. For example, + * 2^24+1 = 16777217 is returned as float 16777216.0. + * + * @return this {@code BigInteger} as a float value. + */ + @Override + public float floatValue() { + return Float.parseFloat(this.toString()); + } + + /** + * Returns a new {@code BigInteger} whose value is greatest common divisor of + * {@code this} and {@code val}. If {@code this==0} and {@code val==0} then + * zero is returned, otherwise the result is positive. + * + * @param val value with which the greatest common divisor is computed. + * @return {@code gcd(this, val)}. + * @throws NullPointerException if {@code val == null}. + */ + public BigInteger gcd(BigInteger val) { + BigInteger val1 = this.abs(); + BigInteger val2 = val.abs(); + // To avoid a possible division by zero + if (val1.signum() == 0) { + return val2; + } else if (val2.signum() == 0) { + return val1; + } + + // Optimization for small operands + // (op2.bitLength() < 64) and (op1.bitLength() < 64) + if (((val1.numberLength == 1) || ((val1.numberLength == 2) && (val1.digits[1] > 0))) + && (val2.numberLength == 1 || (val2.numberLength == 2 && val2.digits[1] > 0))) { + return BigInteger.valueOf(Division.gcdBinary(val1.longValue(), + val2.longValue())); + } + + return Division.gcdBinary(val1.copy(), val2.copy()); + } + + /** + * Returns the position of the lowest set bit in the two's complement + * representation of this {@code BigInteger}. If all bits are zero (this=0) + * then -1 is returned as result. + *

+ * Implementation Note: Usage of this method is not recommended as the + * current implementation is not efficient. + * + * @return position of lowest bit if {@code this != 0}, {@code -1} otherwise + */ + public int getLowestSetBit() { + if (sign == 0) { + return -1; + } + // (sign != 0) implies that exists some non zero digit + int i = getFirstNonzeroDigit(); + return ((i << 5) + Integer.numberOfTrailingZeros(digits[i])); + } + + /** + * Returns a hash code for this {@code BigInteger}. + * + * @return hash code for {@code this}. + */ + @Override + public int hashCode() { + if (hashCode != 0) { + return hashCode; + } + for (int i = 0; i < digits.length; i++) { + hashCode = (hashCode * 33 + (digits[i] & 0xffffffff)); + } + hashCode = hashCode * sign; + return hashCode; + } + + /** + * Returns this {@code BigInteger} as an int value. If {@code this} is too big + * to be represented as an int, then {@code this} % 2^32 is returned. + * + * @return this {@code BigInteger} as an int value. + */ + @Override + public int intValue() { + int i = digits[0]; + // i is always positive except for Integer.MIN_VALUE because of int overflow + return sign > 0 ? i : ensureInt(-i); + } + + /** + * Converts value of this {@code BigInteger} to an {@code int} if it fits it, + * otherwise {@code ArithmeticException} is thrown. + * + * @return this {@code BigInteger} converted to an {@code int}. + * @throws ArithmeticException if the value of this {@code BigInteger} + * does not fit in an {@code int}. + */ + public int intValueExact() { + if (numberLength <= 1 && bitLength() < Integer.SIZE) { + return intValue(); + } + throw new ArithmeticException("out of int range"); + } + + /** + * Tests whether this {@code BigInteger} is probably prime. If {@code true} is + * returned, then this is prime with a probability beyond (1-1/2^certainty). + * If {@code false} is returned, then this is definitely composite. If the + * argument {@code certainty} <= 0, then this method returns true. + * + * @param certainty tolerated primality uncertainty. + * @return {@code true}, if {@code this} is probably prime, {@code false} + * otherwise. + */ + public boolean isProbablePrime(int certainty) { + return Primality.isProbablePrime(abs(), certainty); + } + + /** + * Returns this {@code BigInteger} as an long value. If {@code this} is too + * big to be represented as an long, then {@code this} % 2^64 is returned. + * + * @return this {@code BigInteger} as a long value. + */ + @Override + public long longValue() { + long value = + numberLength > 1 + ? LongUtils.fromBits(digits[0], digits[1]) + : LongUtils.fromBits(digits[0], 0); + return sign > 0 ? value : -value; + } + + /** + * Converts value of this {@code BigInteger} to a {@code long} if it fits it, + * otherwise {@code ArithmeticException} is thrown. + * + * @return this {@code BigInteger} converted to a {@code long}. + * @throws ArithmeticException if the value of this {@code BigInteger} + * does not fit in a {@code long}. + */ + public long longValueExact() { + if (numberLength <= 2 && bitLength() < Long.SIZE) { + return longValue(); + } + throw new ArithmeticException("out of long range"); + } + + /** + * Returns the maximum of this {@code BigInteger} and {@code val}. + * + * @param val value to be used to compute the maximum with {@code this} + * @return {@code max(this, val)} + * @throws NullPointerException if {@code val == null} + */ + public BigInteger max(BigInteger val) { + return ((this.compareTo(val) == GREATER) ? this : val); + } + + /** + * Returns the minimum of this {@code BigInteger} and {@code val}. + * + * @param val value to be used to compute the minimum with {@code this}. + * @return {@code min(this, val)}. + * @throws NullPointerException if {@code val == null}. + */ + public BigInteger min(BigInteger val) { + return ((this.compareTo(val) == LESS) ? this : val); + } + + /** + * Returns a new {@code BigInteger} whose value is {@code this mod m}. The + * modulus {@code m} must be positive. The result is guaranteed to be in the + * interval {@code [0, m)} (0 inclusive, m exclusive). The behavior of this + * function is not equivalent to the behavior of the % operator defined for + * the built-in {@code int}'s. + * + * @param m the modulus. + * @return {@code this mod m}. + * @throws NullPointerException if {@code m == null}. + * @throws ArithmeticException if {@code m < 0}. + */ + public BigInteger mod(BigInteger m) { + if (m.sign <= 0) { + // math.18=BigInteger: modulus not positive + throw new ArithmeticException("BigInteger: modulus not positive"); //$NON-NLS-1$ + } + BigInteger rem = remainder(m); + return ((rem.sign < 0) ? rem.add(m) : rem); + } + + // @Override + // public double doubleValue() { + // return Conversion.bigInteger2Double(this); + // } + + /** + * Returns a new {@code BigInteger} whose value is {@code 1/this mod m}. The + * modulus {@code m} must be positive. The result is guaranteed to be in the + * interval {@code [0, m)} (0 inclusive, m exclusive). If {@code this} is not + * relatively prime to m, then an exception is thrown. + * + * @param m the modulus. + * @return {@code 1/this mod m}. + * @throws NullPointerException if {@code m == null} + * @throws ArithmeticException if {@code m < 0 or} if {@code this} is not + * relatively prime to {@code m} + */ + public BigInteger modInverse(BigInteger m) { + if (m.sign <= 0) { + // math.18=BigInteger: modulus not positive + throw new ArithmeticException("BigInteger: modulus not positive"); //$NON-NLS-1$ + } + // If both are even, no inverse exists + if (!(testBit(0) || m.testBit(0))) { + // math.19=BigInteger not invertible. + throw new ArithmeticException("BigInteger not invertible."); //$NON-NLS-1$ + } + if (m.isOne()) { + return ZERO; + } + + // From now on: (m > 1) + BigInteger res = Division.modInverseMontgomery(abs().mod(m), m); + if (res.sign == 0) { + // math.19=BigInteger not invertible. + throw new ArithmeticException("BigInteger not invertible."); //$NON-NLS-1$ + } + + res = ((sign < 0) ? m.subtract(res) : res); + return res; + } + + /** + * Returns a new {@code BigInteger} whose value is {@code this^exponent mod m} + * . The modulus {@code m} must be positive. The result is guaranteed to be in + * the interval {@code [0, m)} (0 inclusive, m exclusive). If the exponent is + * negative, then {@code this.modInverse(m)^(-exponent) mod m)} is computed. + * The inverse of this only exists if {@code this} is relatively prime to m, + * otherwise an exception is thrown. + * + * @param exponent the exponent. + * @param m the modulus. + * @return {@code this^exponent mod val}. + * @throws NullPointerException if {@code m == null} or {@code exponent == + * null}. + * @throws ArithmeticException if {@code m < 0} or if {@code exponent<0} and + * this is not relatively prime to {@code m}. + */ + public BigInteger modPow(BigInteger exponent, BigInteger m) { + if (m.sign <= 0) { + // math.18=BigInteger: modulus not positive + throw new ArithmeticException("BigInteger: modulus not positive"); //$NON-NLS-1$ + } + BigInteger base = this; + + if (m.isOne() | (exponent.sign > 0 & base.sign == 0)) { + return BigInteger.ZERO; + } + if (base.sign == 0 && exponent.sign == 0) { + return BigInteger.ONE; + } + if (exponent.sign < 0) { + base = modInverse(m); + exponent = exponent.negate(); + } + // From now on: (m > 0) and (exponent >= 0) + BigInteger res = (m.testBit(0)) ? Division.oddModPow(base.abs(), exponent, + m) : Division.evenModPow(base.abs(), exponent, m); + if ((base.sign < 0) && exponent.testBit(0)) { + // -b^e mod m == ((-1 mod m) * (b^e mod m)) mod m + res = m.subtract(BigInteger.ONE).multiply(res).mod(m); + } + // else exponent is even, so base^exp is positive + return res; + } + + /** + * Returns a new {@code BigInteger} whose value is {@code this * val}. + * + * @param val value to be multiplied with {@code this}. + * @return {@code this * val}. + * @throws NullPointerException if {@code val == null}. + */ + public BigInteger multiply(BigInteger val) { + // This let us to throw NullPointerException when val == null + if (val.sign == 0 || sign == 0) { + return ZERO; + } + return Multiplication.multiply(this, val); + } + + /** + * Returns a new {@code BigInteger} whose value is the {@code -this}. + * + * @return {@code -this}. + */ + public BigInteger negate() { + return sign == 0 ? this : new BigInteger(-sign, numberLength, digits); + } + + /** + * Returns the smallest integer x > {@code this} which is probably prime as a + * {@code BigInteger} instance. The probability that the returned {@code + * BigInteger} is prime is beyond (1-1/2^80). + * + * @return smallest integer > {@code this} which is robably prime. + * @throws ArithmeticException if {@code this < 0}. + */ + public BigInteger nextProbablePrime() { + if (sign < 0) { + // math.1A=start < 0: {0} + throw new ArithmeticException("start < 0: " + this); //$NON-NLS-1$ + } + return Primality.nextProbablePrime(this); + } + + /** + * Returns a new {@code BigInteger} whose value is {@code ~this}. The result + * of this operation is {@code -this-1}. + *

+ * Implementation Note: Usage of this method is not recommended as the + * current implementation is not efficient. + * + * @return {@code ~this}. + */ + public BigInteger not() { + return Logical.not(this); + } + + /** + * Returns a new {@code BigInteger} whose value is {@code this | val}. + *

+ * Implementation Note: Usage of this method is not recommended as the + * current implementation is not efficient. + * + * @param val value to be or'ed with {@code this}. + * @return {@code this | val}. + * @throws NullPointerException if {@code val == null}. + */ + public BigInteger or(BigInteger val) { + return Logical.or(this, val); + } + + /** + * Returns a new {@code BigInteger} whose value is {@code this ^ exp}. + * + * @param exp exponent to which {@code this} is raised. + * @return {@code this ^ exp}. + * @throws ArithmeticException if {@code exp < 0}. + */ + public BigInteger pow(int exp) { + if (exp < 0) { + // math.16=Negative exponent + throw new ArithmeticException("Negative exponent"); //$NON-NLS-1$ + } + if (exp == 0) { + return ONE; + } else if (exp == 1 || equals(ONE) || equals(ZERO)) { + return this; + } + + // if even take out 2^x factor which we can + // calculate by shifting. + if (!testBit(0)) { + int x = 1; + while (!testBit(x)) { + x++; + } + return getPowerOfTwo(x * exp).multiply(this.shiftRight(x).pow(exp)); + } + return Multiplication.pow(this, exp); + } + + /** + * Returns a new {@code BigInteger} whose value is {@code this % divisor}. + * Regarding signs this methods has the same behavior as the % operator on + * int's, i.e. the sign of the remainder is the same as the sign of this. + * + * @param divisor value by which {@code this} is divided. + * @return {@code this % divisor}. + * @throws NullPointerException if {@code divisor == null}. + * @throws ArithmeticException if {@code divisor == 0}. + */ + public BigInteger remainder(BigInteger divisor) { + if (divisor.sign == 0) { + // math.17=BigInteger divide by zero + throw new ArithmeticException("BigInteger divide by zero"); //$NON-NLS-1$ + } + int thisLen = numberLength; + int divisorLen = divisor.numberLength; + if (((thisLen != divisorLen) ? ((thisLen > divisorLen) ? 1 : -1) + : Elementary.compareArrays(digits, divisor.digits, thisLen)) == LESS) { + return this; + } + int resLength = divisorLen; + int resDigits[] = new int[resLength]; + if (resLength == 1) { + resDigits[0] = Division.remainderArrayByInt(digits, thisLen, + divisor.digits[0]); + } else { + int qLen = thisLen - divisorLen + 1; + resDigits = Division.divide(null, qLen, digits, thisLen, divisor.digits, + divisorLen); + } + BigInteger result = new BigInteger(sign, resLength, resDigits); + result.cutOffLeadingZeroes(); + return result; + } + + /** + * Returns a new {@code BigInteger} which has the same binary representation + * as {@code this} but with the bit at position n set. The result is + * equivalent to {@code this | 2^n}. + *

+ * Implementation Note: Usage of this method is not recommended as the + * current implementation is not efficient. + * + * @param n position where the bit in {@code this} has to be set. + * @return {@code this | 2^n}. + * @throws ArithmeticException if {@code n < 0}. + */ + public BigInteger setBit(int n) { + if (!testBit(n)) { + return BitLevel.flipBit(this, n); + } + return this; + } + + /** + * Returns a new {@code BigInteger} whose value is {@code this << n}. The + * result is equivalent to {@code this * 2^n} if n >= 0. The shift distance + * may be negative which means that {@code this} is shifted right. The result + * then corresponds to {@code floor(this / 2^(-n))}. + *

+ * Implementation Note: Usage of this method on negative values is not + * recommended as the current implementation is not efficient. + * + * @param n shift distance. + * @return {@code this << n} if {@code n >= 0}; {@code this >> (-n)}. + * otherwise + */ + public BigInteger shiftLeft(int n) { + if ((n == 0) || (sign == 0)) { + return this; + } + return ((n > 0) ? BitLevel.shiftLeft(this, n) : BitLevel.shiftRight(this, + -n)); + } + + /** + * Returns a new {@code BigInteger} whose value is {@code this >> n}. For + * negative arguments, the result is also negative. The shift distance may be + * negative which means that {@code this} is shifted left. + *

+ * Implementation Note: Usage of this method on negative values is not + * recommended as the current implementation is not efficient. + * + * @param n shift distance + * @return {@code this >> n} if {@code n >= 0}; {@code this << (-n)} otherwise + */ + public BigInteger shiftRight(int n) { + if ((n == 0) || (sign == 0)) { + return this; + } + return ((n > 0) ? BitLevel.shiftRight(this, n) : BitLevel.shiftLeft(this, + -n)); + } + + /** + * Converts value of this {@code BigInteger} to a {@code short} if it fits it, + * otherwise {@code ArithmeticException} is thrown. + * + * @return this {@code BigInteger} converted to a {@code short}. + * @throws ArithmeticException if the value of this {@code BigInteger} + * does not fit in a {@code short}. + */ + public short shortValueExact() { + if (numberLength <= 1 && bitLength() < Short.SIZE) { + return shortValue(); + } + throw new ArithmeticException("out of short range"); + } + + /** + * Returns the sign of this {@code BigInteger}. + * + * @return {@code -1} if {@code this < 0}, {@code 0} if {@code this == 0}, + * {@code 1} if {@code this > 0}. + */ + public int signum() { + return sign; + } + + /** + * Returns a new {@code BigInteger} whose value is {@code this - val}. + * + * @param val value to be subtracted from {@code this}. + * @return {@code this - val}. + * @throws NullPointerException if {@code val == null}. + */ + public BigInteger subtract(BigInteger val) { + return Elementary.subtract(this, val); + } + + /** + * Tests whether the bit at position n in {@code this} is set. The result is + * equivalent to {@code this & (2^n) != 0}. + *

+ * Implementation Note: Usage of this method is not recommended as the + * current implementation is not efficient. + * + * @param n position where the bit in {@code this} has to be inspected. + * @return {@code this & (2^n) != 0}. + * @throws ArithmeticException if {@code n < 0}. + */ + public boolean testBit(int n) { + if (n == 0) { + return ((digits[0] & 1) != 0); + } + if (n < 0) { + // math.15=Negative bit address + throw new ArithmeticException("Negative bit address"); //$NON-NLS-1$ + } + int intCount = n >> 5; + if (intCount >= numberLength) { + return (sign < 0); + } + int digit = digits[intCount]; + n = (1 << (n & 31)); // int with 1 set to the needed position + if (sign < 0) { + int firstNonZeroDigit = getFirstNonzeroDigit(); + if (intCount < firstNonZeroDigit) { + return false; + } else if (firstNonZeroDigit == intCount) { + digit = -digit; + } else { + digit = ~digit; + } + } + return ((digit & n) != 0); + } + + /** + * Returns the two's complement representation of this BigInteger in a byte + * array. + * + * @return two's complement representation of {@code this}. + */ + public byte[] toByteArray() { + if (this.sign == 0) { + return new byte[] {0}; + } + BigInteger temp = this; + int bitLen = bitLength(); + int iThis = getFirstNonzeroDigit(); + int bytesLen = (bitLen >> 3) + 1; + /* + * Puts the little-endian int array representing the magnitude of this + * BigInteger into the big-endian byte array. + */ + byte[] bytes = new byte[bytesLen]; + int firstByteNumber = 0; + int highBytes; + int digitIndex = 0; + int bytesInInteger = 4; + int digit; + int hB; + + if (bytesLen - (numberLength << 2) == 1) { + bytes[0] = (byte) ((sign < 0) ? -1 : 0); + highBytes = 4; + firstByteNumber++; + } else { + hB = bytesLen & 3; + highBytes = (hB == 0) ? 4 : hB; + } + + digitIndex = iThis; + bytesLen -= iThis << 2; + + if (sign < 0) { + digit = -temp.digits[digitIndex]; + digitIndex++; + if (digitIndex == numberLength) { + bytesInInteger = highBytes; + } + for (int i = 0; i < bytesInInteger; i++, digit >>= 8) { + bytes[--bytesLen] = (byte) digit; + } + while (bytesLen > firstByteNumber) { + digit = ~temp.digits[digitIndex]; + digitIndex++; + if (digitIndex == numberLength) { + bytesInInteger = highBytes; + } + for (int i = 0; i < bytesInInteger; i++, digit >>= 8) { + bytes[--bytesLen] = (byte) digit; + } + } + } else { + while (bytesLen > firstByteNumber) { + digit = temp.digits[digitIndex]; + digitIndex++; + if (digitIndex == numberLength) { + bytesInInteger = highBytes; + } + for (int i = 0; i < bytesInInteger; i++, digit >>= 8) { + bytes[--bytesLen] = (byte) digit; + } + } + } + return bytes; + } + + /** + * Returns a string representation of this {@code BigInteger} in decimal form. + * + * @return a string representation of {@code this} in decimal form. + */ + @Override + public String toString() { + return Conversion.toDecimalScaledString(this, 0); + } + + /** + * Returns a string containing a string representation of this {@code + * BigInteger} with base radix. If {@code radix} is less than + * {@link Character#MIN_RADIX} or greater than {@link Character#MAX_RADIX} + * then a decimal representation is returned. The characters of the string + * representation are generated with method {@link Character#forDigit}. + * + * @param radix base to be used for the string representation. + * @return a string representation of this with radix 10. + */ + public String toString(int radix) { + return Conversion.bigInteger2String(this, radix); + } + + /** + * Returns a new {@code BigInteger} whose value is {@code this ^ val}. + *

+ * Implementation Note: Usage of this method is not recommended as the + * current implementation is not efficient. + * + * @param val value to be xor'ed with {@code this} + * @return {@code this ^ val} + * @throws NullPointerException if {@code val == null} + */ + public BigInteger xor(BigInteger val) { + return Logical.xor(this, val); + } + + /* + * Returns a copy of the current instance to achieve immutability + */ + BigInteger copy() { + int[] copyDigits = new int[numberLength]; + System.arraycopy(digits, 0, copyDigits, 0, numberLength); + return new BigInteger(sign, numberLength, copyDigits); + } + + /* Private Methods */ + + /** + * Decreases {@code numberLength} if there are zero high elements. + */ + final void cutOffLeadingZeroes() { + while ((numberLength > 0) && (digits[--numberLength] == 0)) { + // Empty + } + if (digits[numberLength++] == 0) { + sign = 0; + } + } + + boolean equalsArrays(final int[] b) { + int i; + for (i = numberLength - 1; (i >= 0) && (digits[i] == b[i]); i--) { + // Empty + } + return i < 0; + } + + int getFirstNonzeroDigit() { + if (firstNonzeroDigit == -2) { + int i; + if (this.sign == 0) { + i = -1; + } else { + for (i = 0; digits[i] == 0; i++) { + // Empty + } + } + firstNonzeroDigit = i; + } + return firstNonzeroDigit; + } + + /** + * Tests if {@code this.abs()} is equals to {@code ONE}. + */ + boolean isOne() { + return ((numberLength == 1) && (digits[0] == 1)); + } + + BigInteger shiftLeftOneBit() { + return (sign == 0) ? this : BitLevel.shiftLeftOneBit(this); + } + + void unCache() { + firstNonzeroDigit = -2; + } + + /** + * Puts a big-endian byte array into a little-endian applying two complement. + */ + private void putBytesNegativeToIntegers(byte[] byteValues, int offset, int length) { + int bytesLen = length; + int highBytes = bytesLen & 3; + numberLength = (bytesLen >> 2) + ((highBytes == 0) ? 0 : 1); + digits = new int[numberLength]; + int i = 0; + // Setting the sign + digits[numberLength - 1] = -1; + // Put bytes to the int array starting from the end of the byte array + while (bytesLen > highBytes) { + digits[i] = (byteValues[--bytesLen + offset] & 0xFF) + | (byteValues[--bytesLen + offset] & 0xFF) << 8 + | (byteValues[--bytesLen + offset] & 0xFF) << 16 + | (byteValues[--bytesLen + offset] & 0xFF) << 24; + if (digits[i] != 0) { + digits[i] = -digits[i]; + firstNonzeroDigit = i; + i++; + while (bytesLen > highBytes) { + digits[i] = (byteValues[--bytesLen + offset] & 0xFF) + | (byteValues[--bytesLen + offset] & 0xFF) << 8 + | (byteValues[--bytesLen + offset] & 0xFF) << 16 + | (byteValues[--bytesLen + offset] & 0xFF) << 24; + digits[i] = ~digits[i]; + i++; + } + break; + } + i++; + } + if (highBytes != 0) { + // Put the first bytes in the highest element of the int array + if (firstNonzeroDigit != -2) { + for (int j = offset; j < bytesLen + offset; j++) { + digits[i] = (digits[i] << 8) | (byteValues[j] & 0xFF); + } + digits[i] = ~digits[i]; + } else { + for (int j = offset; j < bytesLen + offset; j++) { + digits[i] = (digits[i] << 8) | (byteValues[j] & 0xFF); + } + digits[i] = -digits[i]; + } + } + } + + /** + * Puts a big-endian byte array into a little-endian int array. + */ + private void putBytesPositiveToIntegers(byte[] byteValues, int offset, int length) { + int bytesLen = length; + int highBytes = bytesLen & 3; + numberLength = (bytesLen >> 2) + ((highBytes == 0) ? 0 : 1); + digits = new int[numberLength]; + int i = 0; + // Put bytes to the int array starting from the end of the byte array + while (bytesLen > highBytes) { + digits[i++] = (byteValues[--bytesLen + offset] & 0xFF) + | (byteValues[--bytesLen + offset] & 0xFF) << 8 + | (byteValues[--bytesLen + offset] & 0xFF) << 16 + | (byteValues[--bytesLen + offset] & 0xFF) << 24; + } + // Put the first bytes in the highest element of the int array + for (int j = offset; j < bytesLen + offset; j++) { + digits[i] = (digits[i] << 8) | (byteValues[j] & 0xFF); + } + } +} diff --git a/web/client-api/src/main/resources/io/grpc/Grpc.gwt.xml b/web/client-api/src/main/resources/io/grpc/Grpc.gwt.xml new file mode 100644 index 00000000000..187ac264524 --- /dev/null +++ b/web/client-api/src/main/resources/io/grpc/Grpc.gwt.xml @@ -0,0 +1,3 @@ + + + diff --git a/web/client-api/src/main/resources/org/apache/arrow/flatbuf/FlightFlatbufFormat.gwt.xml b/web/client-api/src/main/resources/org/apache/arrow/flatbuf/FlightFlatbufFormat.gwt.xml new file mode 100644 index 00000000000..9fd0a379083 --- /dev/null +++ b/web/client-api/src/main/resources/org/apache/arrow/flatbuf/FlightFlatbufFormat.gwt.xml @@ -0,0 +1,4 @@ + + + + diff --git a/web/client-api/src/main/resources/org/immutables/value/Immutables.gwt.xml b/web/client-api/src/main/resources/org/immutables/value/Immutables.gwt.xml new file mode 100644 index 00000000000..c78151ef021 --- /dev/null +++ b/web/client-api/src/main/resources/org/immutables/value/Immutables.gwt.xml @@ -0,0 +1,3 @@ + + + diff --git a/web/client-api/src/test/java/io/deephaven/web/client/api/HierarchicalTableTestGwt.java b/web/client-api/src/test/java/io/deephaven/web/client/api/HierarchicalTableTestGwt.java index 3e244ba9cd8..54ace6db598 100644 --- a/web/client-api/src/test/java/io/deephaven/web/client/api/HierarchicalTableTestGwt.java +++ b/web/client-api/src/test/java/io/deephaven/web/client/api/HierarchicalTableTestGwt.java @@ -4,20 +4,27 @@ package io.deephaven.web.client.api; import elemental2.dom.CustomEvent; +import elemental2.promise.Promise; import io.deephaven.web.client.api.tree.JsTreeTable; +import io.deephaven.web.client.api.tree.TreeViewportData; public class HierarchicalTableTestGwt extends AbstractAsyncGwtTestCase { + private static final Format red = new Format(0x1ff000001e0e0e0L, 0, null, null); + private static final Format green = new Format(0x100800001e0e0e0L, 0, null, null); + @Override public String getModuleName() { return "io.deephaven.web.DeephavenIntegrationTest"; } private final TableSourceBuilder tables = new TableSourceBuilder() - .script("from deephaven import empty_table, time_table") + .script("from deephaven import empty_table, time_table, agg") .script("static_tree", - "empty_table(1000).update(['ID=i', 'Parent=i == 0 ? null : (int)(i/10)']).tree('ID', 'Parent')") + "empty_table(1000).update(['ID=i', 'Parent=i == 0 ? null : (int)(i/10)']).format_columns(['ID=ID>0 ? GREEN : RED']).tree('ID', 'Parent')") .script("ticking_tree", - "time_table('PT0.1s').update(['ID=i', 'Parent=i == 0 ? null : (int)(i/10)']).tree('ID', 'Parent')"); + "time_table('PT0.1s').update(['ID=i', 'Parent=i == 0 ? null : (int)(i/10)']).format_columns(['ID=ID>0 ? GREEN : RED']).tree('ID', 'Parent')") + .script("ticking_rollup", + "time_table('PT0.1s').update(['Y=Math.sin(i/3)', 'X=i%3']).format_columns(['Y=Y>0 ? GREEN : RED']).rollup(aggs=[agg.first('Y')],by=['X'],include_constituents=True)"); public void testStaticTreeTable() { connect(tables) @@ -33,19 +40,22 @@ public void testStaticTreeTable() { assertEquals("Parent", treeTable.getColumns().getAt(1).getName()); treeTable.setViewport(0, 99, treeTable.getColumns(), null); - return treeTable.getViewportData().then(data -> { - assertEquals(1d, data.getTreeSize()); + return treeTable.getViewportData() + .then(data -> Promise.resolve((TreeViewportData) data)) + .then(data -> { + assertEquals(1d, data.getTreeSize()); - treeTable.expand(JsTreeTable.RowReferenceUnion.of(0), null); - return treeTable.nextEvent(JsTreeTable.EVENT_UPDATED, 2001d); - }).then(event -> { - assertEquals(10d, event.detail.getTreeSize()); + treeTable.expand(JsTreeTable.RowReferenceUnion.of(0), null); + return treeTable.nextEvent( + JsTreeTable.EVENT_UPDATED, 2001d); + }).then(event -> { + assertEquals(10d, event.detail.getTreeSize()); - treeTable.close(); + treeTable.close(); - assertTrue(treeTable.isClosed()); - return null; - }); + assertTrue(treeTable.isClosed()); + return null; + }); }) .then(this::finish).catch_(this::report); } @@ -68,17 +78,64 @@ public void testRefreshingTreeTable() { treeTable.setViewport(0, 99, treeTable.getColumns(), null); // Wait for the table to tick such that the first row has children + // Read values from the one returned row return waitForEventWhere(treeTable, JsTreeTable.EVENT_UPDATED, - (CustomEvent d) -> d.detail.getTreeSize() == 1 - && d.detail.getRows().getAt(0).hasChildren(), - 10001).then(data -> { + (CustomEvent d) -> d.detail + .getTreeSize() == 1 + && d.detail.getRows().getAtAsAny(0).cast() + .hasChildren(), + 10001) + .then(JsTreeTable::getViewportData) + .then(data -> Promise.resolve((TreeViewportData) data)) + .then(data -> { + assertEquals(1.0, data.getTreeSize()); + TreeViewportData.TreeRow row1 = (TreeViewportData.TreeRow) data.getRows().getAt(0); + Column timestampCol = treeTable.findColumn("Timestamp"); + assertEquals(Format.EMPTY, data.getFormat(0, timestampCol)); + assertEquals(Format.EMPTY, row1.getFormat(timestampCol)); + assertEquals(Format.EMPTY, timestampCol.getFormat(row1)); + + Column idCol = treeTable.findColumn("ID"); + assertEquals(0, data.getData(0, idCol).asInt()); + assertEquals(0, row1.get(idCol).asInt()); + assertEquals(0, idCol.get(row1).asInt()); + + assertEquals(red, data.getFormat(0, idCol)); + assertEquals(red, row1.getFormat(idCol)); + assertEquals(red, idCol.getFormat(row1)); + + assertNotNull(data.getData(0, timestampCol)); + assertNotNull(row1.get(timestampCol)); + assertNotNull(timestampCol.get(row1)); + treeTable.expand(JsTreeTable.RowReferenceUnion.of(0), null); // Wait for the expand to occur and table to show all 10 rows return waitForEventWhere(treeTable, JsTreeTable.EVENT_UPDATED, - (CustomEvent d) -> d.detail.getTreeSize() == 10, + (CustomEvent d) -> d.detail.getTreeSize() == 10, 14004); - }).then(event -> { + }) + .then(JsTreeTable::getViewportData) + .then(data -> Promise.resolve((TreeViewportData) data)) + .then(data -> { + TreeViewportData.TreeRow row2 = (TreeViewportData.TreeRow) data.getRows().getAt(1); + + Column timestampCol = treeTable.findColumn("Timestamp"); + assertEquals(Format.EMPTY, data.getFormat(1, timestampCol)); + assertEquals(Format.EMPTY, row2.getFormat(timestampCol)); + assertEquals(Format.EMPTY, timestampCol.getFormat(row2)); + + Column idCol = treeTable.findColumn("ID"); + assertEquals(1, data.getData(1, idCol).asInt()); + assertEquals(1, row2.get(idCol).asInt()); + assertEquals(1, idCol.get(row2).asInt()); + + assertEquals(green, data.getFormat(1, idCol)); + assertEquals(green, row2.getFormat(idCol)); + assertEquals(green, idCol.getFormat(row2)); + return Promise.resolve(treeTable); + }) + .then(event -> { treeTable.close(); assertTrue(treeTable.isClosed()); return null; @@ -86,4 +143,110 @@ public void testRefreshingTreeTable() { }) .then(this::finish).catch_(this::report); } + + public void testTickingRollup() { + connect(tables) + .then(treeTable("ticking_rollup")) + .then(rollup -> { + // Very large timeout, 3.5s is enough that we see failures on this regularly + delayTestFinish(20_001); + assertTrue(rollup.isRefreshing()); + assertFalse(rollup.isClosed()); + assertTrue(rollup.isIncludeConstituents()); + + assertEquals(2, rollup.getColumns().length); + assertEquals("X", rollup.getColumns().getAt(0).getName()); + assertEquals("Y", rollup.getColumns().getAt(1).getName()); + + rollup.setViewport(0, 99, rollup.getColumns(), null); + + Column xCol = rollup.findColumn("X"); + Column yCol = rollup.findColumn("Y"); + + // Wait for the table to tick such that we have at least 4 rows (root, three children) + return waitForEventWhere(rollup, JsTreeTable.EVENT_UPDATED, + (CustomEvent d) -> d.detail.getTreeSize() == 4, + 10002) + .then(JsTreeTable::getViewportData) + .then(data -> Promise.resolve((TreeViewportData) data)) + .then(data -> { + TreeViewportData.TreeRow row1 = (TreeViewportData.TreeRow) data.getRows().getAt(0); + + assertEquals(Format.EMPTY, data.getFormat(0, xCol)); + assertEquals(Format.EMPTY, row1.getFormat(xCol)); + assertEquals(Format.EMPTY, xCol.getFormat(row1)); + + assertNull(data.getData(0, xCol)); + assertNull(row1.get(xCol)); + assertNull(xCol.get(row1)); + + assertEquals(Format.EMPTY, data.getFormat(0, yCol)); + assertEquals(Format.EMPTY, row1.getFormat(yCol)); + assertEquals(Format.EMPTY, yCol.getFormat(row1)); + + assertEquals(0d, data.getData(0, yCol).asDouble()); + assertEquals(0d, row1.get(yCol).asDouble()); + assertEquals(0d, yCol.get(row1).asDouble()); + + TreeViewportData.TreeRow row2 = (TreeViewportData.TreeRow) data.getRows().getAt(1); + assertEquals(Format.EMPTY, data.getFormat(1, xCol)); + assertEquals(Format.EMPTY, row2.getFormat(xCol)); + assertEquals(Format.EMPTY, xCol.getFormat(row2)); + + assertEquals(0d, data.getData(1, xCol).asDouble()); + assertEquals(0d, row2.get(xCol).asDouble()); + assertEquals(0d, xCol.get(row2).asDouble()); + + assertEquals(Format.EMPTY, data.getFormat(1, yCol)); + assertEquals(Format.EMPTY, row2.getFormat(yCol)); + assertEquals(Format.EMPTY, yCol.getFormat(row2)); + + assertEquals(0d, data.getData(1, yCol).asDouble()); + assertEquals(0d, row2.get(yCol).asDouble()); + assertEquals(0d, yCol.get(row2).asDouble()); + + // Expand row 2 + rollup.expand(JsTreeTable.RowReferenceUnion.of(1), null); + + // Wait for the expand to occur and table to show all 10 rows + return waitForEventWhere(rollup, JsTreeTable.EVENT_UPDATED, + (CustomEvent d) -> d.detail.getTreeSize() > 4, + 14008); + }) + .then(JsTreeTable::getViewportData) + .then(data -> Promise.resolve((TreeViewportData) data)) + .then(data -> { + TreeViewportData.TreeRow row3 = (TreeViewportData.TreeRow) data.getRows().getAt(2); + + assertEquals(Format.EMPTY, data.getFormat(2, xCol)); + assertEquals(Format.EMPTY, row3.getFormat(xCol)); + assertEquals(Format.EMPTY, xCol.getFormat(row3)); + + assertEquals(0d, data.getData(2, yCol).asDouble()); + assertEquals(0d, row3.get(yCol).asDouble()); + assertEquals(0d, yCol.get(row3).asDouble()); + + assertEquals(red, data.getFormat(2, yCol)); + assertEquals(red, row3.getFormat(yCol)); + assertEquals(red, yCol.getFormat(row3)); + + assertEquals(0d, data.getData(2, yCol).asDouble()); + assertEquals(0d, row3.get(yCol).asDouble()); + assertEquals(0d, yCol.get(row3).asDouble()); + + // Collapse row 2, wait until back to 4 rows + rollup.collapse(JsTreeTable.RowReferenceUnion.of(1)); + return waitForEventWhere(rollup, JsTreeTable.EVENT_UPDATED, + (CustomEvent d) -> d.detail.getTreeSize() == 4, + 14009); + }) + .then(event -> { + rollup.close(); + assertTrue(rollup.isClosed()); + return null; + }); + }) + .then(this::finish).catch_(this::report); + } + } diff --git a/web/client-api/src/test/java/io/deephaven/web/client/api/NullValueTestGwt.java b/web/client-api/src/test/java/io/deephaven/web/client/api/NullValueTestGwt.java index 4699a9f3de5..03ec2a2382b 100644 --- a/web/client-api/src/test/java/io/deephaven/web/client/api/NullValueTestGwt.java +++ b/web/client-api/src/test/java/io/deephaven/web/client/api/NullValueTestGwt.java @@ -7,7 +7,6 @@ import com.google.gwt.junit.Platform; import elemental2.core.JsArray; import elemental2.promise.Promise; -import io.deephaven.web.client.api.subscription.ViewportRow; import jsinterop.base.Js; import java.math.BigDecimal; @@ -86,8 +85,8 @@ public void testTableWithSomeNulls() { .then(table -> { table.setViewport(0, 1, null); return assertUpdateReceived(table, viewport -> { - JsArray rows = viewport.getRows(); - ViewportRow nullRow = rows.getAt(0); + JsArray rows = viewport.getRows(); + TableData.Row nullRow = rows.getAt(0); JsArray columns = table.getColumns(); for (int i = 0; i < columns.length; i++) { @@ -95,7 +94,7 @@ public void testTableWithSomeNulls() { assertNull(nullRow.get(columns.getAt(i))); } - ViewportRow valueRow = rows.getAt(1); + TableData.Row valueRow = rows.getAt(1); assertEquals(1, valueRow.get(table.findColumn("MyInt")).asInt()); assertEquals((long) 1, valueRow.get(table.findColumn("MyLong")).cast().getWrapped()); @@ -157,12 +156,12 @@ public void testTableWithAllNulls() { .then(table -> { table.setViewport(0, 1, null); return assertUpdateReceived(table, viewport -> { - JsArray rows = viewport.getRows(); + JsArray rows = viewport.getRows(); JsArray columns = table.getColumns(); for (int i = 0; i < columns.length; i++) { for (int j = 0; j < rows.length; j++) { - ViewportRow row = rows.getAt(j); + TableData.Row row = rows.getAt(j); assertFalse(Js.isTripleEqual(Js.undefined(), row.get(columns.getAt(i)))); assertNull(columns.getAt(i).getName(), row.get(columns.getAt(i))); } diff --git a/web/client-api/src/test/java/io/deephaven/web/client/api/PartitionedTableTestGwt.java b/web/client-api/src/test/java/io/deephaven/web/client/api/PartitionedTableTestGwt.java index 0d3cf8edbb3..d0b9c4fcc40 100644 --- a/web/client-api/src/test/java/io/deephaven/web/client/api/PartitionedTableTestGwt.java +++ b/web/client-api/src/test/java/io/deephaven/web/client/api/PartitionedTableTestGwt.java @@ -5,8 +5,6 @@ import elemental2.core.JsArray; import elemental2.dom.CustomEvent; -import io.deephaven.web.client.api.subscription.ViewportData; -import io.deephaven.web.client.api.tree.JsTreeTable; public class PartitionedTableTestGwt extends AbstractAsyncGwtTestCase { @Override diff --git a/web/client-api/src/test/java/io/deephaven/web/client/api/TotalsTableTestGwt.java b/web/client-api/src/test/java/io/deephaven/web/client/api/TotalsTableTestGwt.java index 6a6c2d3e706..857cad855c5 100644 --- a/web/client-api/src/test/java/io/deephaven/web/client/api/TotalsTableTestGwt.java +++ b/web/client-api/src/test/java/io/deephaven/web/client/api/TotalsTableTestGwt.java @@ -72,7 +72,7 @@ public void testQueryDefinedConfigs() { .then(totals -> { assertEquals(3, totals.getColumns().length); assertEquals(1, totals.getSize(), DELTA); - totals.setViewport(0, 100, null, null); + totals.setViewport(0, 100, null, null, null); return waitForEvent(totals, JsTable.EVENT_UPDATED, checkTotals(totals, 5, 6., 0, "a1"), 2508); @@ -81,7 +81,7 @@ public void testQueryDefinedConfigs() { .then(totals -> { assertEquals(3, totals.getColumns().length); assertEquals(1, totals.getSize(), DELTA); - totals.setViewport(0, 100, null, null); + totals.setViewport(0, 100, null, null, null); return waitForEvent(totals, JsTable.EVENT_UPDATED, checkTotals(totals, 5, 6.0, 0., "a2"), 2509); @@ -112,7 +112,7 @@ public void ignore_testTotalsOnFilteredTable() { totalTables[0] = totals; assertEquals(3, totals.getColumns().length); assertEquals(1, totals.getSize(), DELTA); - totals.setViewport(0, 100, null, null); + totals.setViewport(0, 100, null, null, null); // confirm the normal totals match the filtered data return waitForEvent(totals, JsTable.EVENT_UPDATED, @@ -123,7 +123,7 @@ public void ignore_testTotalsOnFilteredTable() { totalTables[1] = totals; assertEquals(3, totals.getColumns().length); assertEquals(1, totals.getSize(), DELTA); - totals.setViewport(0, 100, null, null); + totals.setViewport(0, 100, null, null, null); // confirm the grand totals are unchanged return waitForEvent(totals, JsTable.EVENT_UPDATED, @@ -238,7 +238,7 @@ public void ignore_testFilteringTotalsTable() { totalTables[0] = totals; assertEquals(4, totals.getColumns().length); assertEquals(2, totals.getSize(), DELTA); - totals.setViewport(0, 100, null, null); + totals.setViewport(0, 100, null, null, null); // confirm the normal totals match the filtered data return waitForEvent(totals, JsTable.EVENT_UPDATED, checkTotals(totals, "a1", @@ -250,7 +250,7 @@ public void ignore_testFilteringTotalsTable() { totalTables[1] = totals; assertEquals(4, totals.getColumns().length); assertEquals(2, totals.getSize(), DELTA); - totals.setViewport(0, 100, null, null); + totals.setViewport(0, 100, null, null, null); // confirm the grand totals include the missing row... return waitForEvent(totals, JsTable.EVENT_UPDATED, checkTotals(totals, "a2", @@ -269,8 +269,8 @@ public void ignore_testFilteringTotalsTable() { totalTables[1].applyFilter(new FilterCondition[] { totalTables[1].findColumn("J__Avg").filter().eq(FilterValue.ofNumber(5.0)) }); - totalTables[0].setViewport(0, 100, null, null); - totalTables[1].setViewport(0, 100, null, null); + totalTables[0].setViewport(0, 100, null, null, null); + totalTables[1].setViewport(0, 100, null, null, null); return promiseAllThen(table, totalPromises[0] = waitForEvent(totalTables[0], JsTable.EVENT_UPDATED, @@ -327,7 +327,7 @@ public void testGroupedTotals() { (JsTotalsTable totals) -> { assertEquals(4, totals.getColumns().length); assertEquals(2, totals.getSize(), DELTA); - totals.setViewport(0, 100, null, null); + totals.setViewport(0, 100, null, null, null); // confirm the grand totals are unchanged return waitForEvent(totals, JsTable.EVENT_UPDATED, update -> { diff --git a/web/client-api/src/test/java/io/deephaven/web/client/api/subscription/ViewportTestGwt.java b/web/client-api/src/test/java/io/deephaven/web/client/api/subscription/ViewportTestGwt.java index 19e1a1ddf4f..2d9648c7b08 100644 --- a/web/client-api/src/test/java/io/deephaven/web/client/api/subscription/ViewportTestGwt.java +++ b/web/client-api/src/test/java/io/deephaven/web/client/api/subscription/ViewportTestGwt.java @@ -12,6 +12,7 @@ import io.deephaven.web.client.api.Column; import io.deephaven.web.client.api.HasEventHandling; import io.deephaven.web.client.api.JsTable; +import io.deephaven.web.client.api.TableData; import io.deephaven.web.client.api.filter.FilterCondition; import io.deephaven.web.client.api.filter.FilterValue; import io.deephaven.web.shared.fu.RemoverFn; @@ -40,7 +41,8 @@ public class ViewportTestGwt extends AbstractAsyncGwtTestCase { .script("from datetime import datetime, timedelta") .script("growingForward", "time_table(period=\"PT00:00:01\", start_time=datetime.now() - timedelta(minutes=1)).update([\"I=i\", \"J=i*i\", \"K=0\"])") - .script("growingBackward", "growingForward.sort_descending(\"Timestamp\")") + .script("growingBackward", + "growingForward.sort_descending(\"Timestamp\").format_columns(['I=I>2 ? GREEN : RED'])") .script("blinkOne", "time_table(\"PT00:00:01\").update([\"I=i\", \"J=1\"]).last_by(by=\"J\").where(\"I%2 != 0\")"); @@ -59,28 +61,28 @@ public void testViewportOnStaticTable() { // table has 100 rows, go through each page of 25, make sure the offset and length is sane table.setViewport(0, 24, null); return assertUpdateReceived(table, viewport -> { - assertEquals(0, (long) viewport.getOffset()); + assertEquals(0d, viewport.getOffset()); assertEquals(25, viewport.getRows().length); }, 2100); }) .then(table -> { table.setViewport(25, 49, null); return assertUpdateReceived(table, viewport -> { - assertEquals(25, (long) viewport.getOffset()); + assertEquals(25d, viewport.getOffset()); assertEquals(25, viewport.getRows().length); }, 2101); }) .then(table -> { table.setViewport(50, 74, null); return assertUpdateReceived(table, viewport -> { - assertEquals(50, (long) viewport.getOffset()); + assertEquals(50d, viewport.getOffset()); assertEquals(25, viewport.getRows().length); }, 2102); }) .then(table -> { table.setViewport(75, 99, null); return assertUpdateReceived(table, viewport -> { - assertEquals(75, (long) viewport.getOffset()); + assertEquals(75d, viewport.getOffset()); assertEquals(25, viewport.getRows().length); }, 2103); }) @@ -179,10 +181,16 @@ public void testViewportSubsetOfColumns() { assertEquals(0, indexOf(viewport.getColumns(), table.findColumn("I"))); assertEquals(1, viewport.getRows().length); - assertNotNull(viewport.getRows().getAt(0).get(table.findColumn("I"))); - assertThrowsException(() -> viewport.getRows().getAt(0).get(table.findColumn("J"))); - assertThrowsException(() -> viewport.getRows().getAt(0).get(table.findColumn("K"))); - + TableData.Row row1 = viewport.getRows().getAt(0); + assertNotNull(viewport.getData(0, table.findColumn("I"))); + assertNotNull(row1.get(table.findColumn("I"))); + assertNotNull(table.findColumn("I").get(row1)); + assertNotNull(row1.getFormat(table.findColumn("I"))); + assertNotNull(table.findColumn("I").getFormat(row1)); + assertNotNull(viewport.getFormat(0, table.findColumn("I"))); + + assertThrowsException(() -> row1.get(table.findColumn("J"))); + assertThrowsException(() -> row1.get(table.findColumn("K"))); }, 2501); }) .then(table -> { @@ -361,7 +369,7 @@ public void testRapidChangingViewport() { table.setViewport(0, 10, null); table.setViewport(5, 14, null); return assertUpdateReceived(table, viewport -> { - assertEquals(5, (int) viewport.getOffset()); + assertEquals(5d, viewport.getOffset()); assertEquals(10, (int) viewport.getRows().length); }, 1008); }) @@ -373,8 +381,8 @@ public void testRapidChangingViewport() { .then(table -> { table.setViewport(6, 14, null); return assertUpdateReceived(table, viewport -> { - assertEquals(6, (int) viewport.getOffset()); - assertEquals(9, (int) viewport.getRows().length); + assertEquals(6d, viewport.getOffset()); + assertEquals(9, viewport.getRows().length); }, 1009); }) .then(table -> { @@ -387,12 +395,9 @@ public void testRapidChangingViewport() { table.setViewport(7, 17, null); return assertUpdateReceived(table, ignored -> { }, 1010) - .then(waitFor(JsTable.DEBOUNCE_TIME * 2)) .then(t -> { - // force the debounce to be processed - t.processSnapshot(); t.getViewportData().then(vp -> { - // assertEquals(7, (int) vp.getOffset()); + assertEquals(7d, vp.getOffset()); assertEquals(11, (int) vp.getRows().length); return Promise.resolve(vp); }); diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/Flatbuf.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/Flatbuf.java deleted file mode 100644 index d32b397e89b..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/Flatbuf.java +++ /dev/null @@ -1,300 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow; - -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.DictionaryBatch; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf.RecordBatch; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Schema; -import jsinterop.annotations.JsFunction; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Message_generated.org.apache.arrow.flatbuf", - namespace = JsPackage.GLOBAL) -public class Flatbuf { - @JsFunction - public interface UnionListToMessageHeaderAccessorFn { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface P1UnionType { - @JsOverlay - static Flatbuf.UnionListToMessageHeaderAccessorFn.P1UnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default DictionaryBatch asDictionaryBatch() { - return Js.cast(this); - } - - @JsOverlay - default RecordBatch asRecordBatch() { - return Js.cast(this); - } - - @JsOverlay - default Schema asSchema() { - return Js.cast(this); - } - - @JsOverlay - default boolean isDictionaryBatch() { - return (Object) this instanceof DictionaryBatch; - } - - @JsOverlay - default boolean isRecordBatch() { - return (Object) this instanceof RecordBatch; - } - - @JsOverlay - default boolean isSchema() { - return (Object) this instanceof Schema; - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface UnionType { - @JsOverlay - static Flatbuf.UnionListToMessageHeaderAccessorFn.UnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default DictionaryBatch asDictionaryBatch() { - return Js.cast(this); - } - - @JsOverlay - default RecordBatch asRecordBatch() { - return Js.cast(this); - } - - @JsOverlay - default Schema asSchema() { - return Js.cast(this); - } - - @JsOverlay - default boolean isDictionaryBatch() { - return (Object) this instanceof DictionaryBatch; - } - - @JsOverlay - default boolean isRecordBatch() { - return (Object) this instanceof RecordBatch; - } - - @JsOverlay - default boolean isSchema() { - return (Object) this instanceof Schema; - } - } - - @JsOverlay - default Flatbuf.UnionListToMessageHeaderAccessorFn.UnionType onInvoke( - double p0, DictionaryBatch p1) { - return onInvoke( - p0, Js.uncheckedCast(p1)); - } - - Flatbuf.UnionListToMessageHeaderAccessorFn.UnionType onInvoke( - double p0, Flatbuf.UnionListToMessageHeaderAccessorFn.P1UnionType p1); - - @JsOverlay - default Flatbuf.UnionListToMessageHeaderAccessorFn.UnionType onInvoke( - double p0, RecordBatch p1) { - return onInvoke( - p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToMessageHeaderAccessorFn.UnionType onInvoke(double p0, Schema p1) { - return onInvoke( - p0, Js.uncheckedCast(p1)); - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface UnionListToMessageHeaderUnionType { - @JsOverlay - static Flatbuf.UnionListToMessageHeaderUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default DictionaryBatch asDictionaryBatch() { - return Js.cast(this); - } - - @JsOverlay - default RecordBatch asRecordBatch() { - return Js.cast(this); - } - - @JsOverlay - default Schema asSchema() { - return Js.cast(this); - } - - @JsOverlay - default boolean isDictionaryBatch() { - return (Object) this instanceof DictionaryBatch; - } - - @JsOverlay - default boolean isRecordBatch() { - return (Object) this instanceof RecordBatch; - } - - @JsOverlay - default boolean isSchema() { - return (Object) this instanceof Schema; - } - } - - @JsFunction - public interface UnionToMessageHeaderAccessorFn { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface P0UnionType { - @JsOverlay - static Flatbuf.UnionToMessageHeaderAccessorFn.P0UnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default DictionaryBatch asDictionaryBatch() { - return Js.cast(this); - } - - @JsOverlay - default RecordBatch asRecordBatch() { - return Js.cast(this); - } - - @JsOverlay - default Schema asSchema() { - return Js.cast(this); - } - - @JsOverlay - default boolean isDictionaryBatch() { - return (Object) this instanceof DictionaryBatch; - } - - @JsOverlay - default boolean isRecordBatch() { - return (Object) this instanceof RecordBatch; - } - - @JsOverlay - default boolean isSchema() { - return (Object) this instanceof Schema; - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface UnionType { - @JsOverlay - static Flatbuf.UnionToMessageHeaderAccessorFn.UnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default DictionaryBatch asDictionaryBatch() { - return Js.cast(this); - } - - @JsOverlay - default RecordBatch asRecordBatch() { - return Js.cast(this); - } - - @JsOverlay - default Schema asSchema() { - return Js.cast(this); - } - - @JsOverlay - default boolean isDictionaryBatch() { - return (Object) this instanceof DictionaryBatch; - } - - @JsOverlay - default boolean isRecordBatch() { - return (Object) this instanceof RecordBatch; - } - - @JsOverlay - default boolean isSchema() { - return (Object) this instanceof Schema; - } - } - - @JsOverlay - default Flatbuf.UnionToMessageHeaderAccessorFn.UnionType onInvoke(DictionaryBatch p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - Flatbuf.UnionToMessageHeaderAccessorFn.UnionType onInvoke( - Flatbuf.UnionToMessageHeaderAccessorFn.P0UnionType p0); - - @JsOverlay - default Flatbuf.UnionToMessageHeaderAccessorFn.UnionType onInvoke(RecordBatch p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToMessageHeaderAccessorFn.UnionType onInvoke(Schema p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface UnionToMessageHeaderUnionType { - @JsOverlay - static Flatbuf.UnionToMessageHeaderUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default DictionaryBatch asDictionaryBatch() { - return Js.cast(this); - } - - @JsOverlay - default RecordBatch asRecordBatch() { - return Js.cast(this); - } - - @JsOverlay - default Schema asSchema() { - return Js.cast(this); - } - - @JsOverlay - default boolean isDictionaryBatch() { - return (Object) this instanceof DictionaryBatch; - } - - @JsOverlay - default boolean isRecordBatch() { - return (Object) this instanceof RecordBatch; - } - - @JsOverlay - default boolean isSchema() { - return (Object) this instanceof Schema; - } - } - - public static native Flatbuf.UnionListToMessageHeaderUnionType unionListToMessageHeader( - int type, Flatbuf.UnionListToMessageHeaderAccessorFn accessor, double index); - - public static native Flatbuf.UnionToMessageHeaderUnionType unionToMessageHeader( - int type, Flatbuf.UnionToMessageHeaderAccessorFn accessor); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/BodyCompression.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/BodyCompression.java deleted file mode 100644 index 77a91516d9c..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/BodyCompression.java +++ /dev/null @@ -1,44 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Message_generated.org.apache.arrow.flatbuf.BodyCompression", - namespace = JsPackage.GLOBAL) -public class BodyCompression { - public static native void addCodec(Builder builder, int codec); - - public static native void addMethod(Builder builder, int method); - - public static native double createBodyCompression( - Builder builder, int codec, int method); - - public static native double endBodyCompression(Builder builder); - - public static native BodyCompression getRootAsBodyCompression(ByteBuffer bb, BodyCompression obj); - - public static native BodyCompression getRootAsBodyCompression(ByteBuffer bb); - - public static native BodyCompression getSizePrefixedRootAsBodyCompression( - ByteBuffer bb, BodyCompression obj); - - public static native BodyCompression getSizePrefixedRootAsBodyCompression(ByteBuffer bb); - - public static native void startBodyCompression(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native BodyCompression __init(double i, ByteBuffer bb); - - public native int codec(); - - public native int method(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/BodyCompressionMethod.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/BodyCompressionMethod.java deleted file mode 100644 index 0fa3c6919e4..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/BodyCompressionMethod.java +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Message_generated.org.apache.arrow.flatbuf.BodyCompressionMethod", - namespace = JsPackage.GLOBAL) -public class BodyCompressionMethod { - public static int BUFFER; -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/CompressionType.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/CompressionType.java deleted file mode 100644 index a395a0317e3..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/CompressionType.java +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Message_generated.org.apache.arrow.flatbuf.CompressionType", - namespace = JsPackage.GLOBAL) -public class CompressionType { - public static int LZ4_FRAME, - ZSTD; -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/DictionaryBatch.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/DictionaryBatch.java deleted file mode 100644 index b063716b3c4..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/DictionaryBatch.java +++ /dev/null @@ -1,48 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Long; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Message_generated.org.apache.arrow.flatbuf.DictionaryBatch", - namespace = JsPackage.GLOBAL) -public class DictionaryBatch { - public static native void addData(Builder builder, double dataOffset); - - public static native void addId(Builder builder, Long id); - - public static native void addIsDelta(Builder builder, boolean isDelta); - - public static native double endDictionaryBatch(Builder builder); - - public static native DictionaryBatch getRootAsDictionaryBatch(ByteBuffer bb, DictionaryBatch obj); - - public static native DictionaryBatch getRootAsDictionaryBatch(ByteBuffer bb); - - public static native DictionaryBatch getSizePrefixedRootAsDictionaryBatch( - ByteBuffer bb, DictionaryBatch obj); - - public static native DictionaryBatch getSizePrefixedRootAsDictionaryBatch(ByteBuffer bb); - - public static native void startDictionaryBatch(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native DictionaryBatch __init(double i, ByteBuffer bb); - - public native RecordBatch data(); - - public native RecordBatch data(RecordBatch obj); - - public native Long id(); - - public native boolean isDelta(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/FieldNode.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/FieldNode.java deleted file mode 100644 index e3751057417..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/FieldNode.java +++ /dev/null @@ -1,29 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Long; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Message_generated.org.apache.arrow.flatbuf.FieldNode", - namespace = JsPackage.GLOBAL) -public class FieldNode { - public static native double createFieldNode(Builder builder, Long length, Long null_count); - - public static native double sizeOf(); - - public ByteBuffer bb; - public double bb_pos; - - public native FieldNode __init(double i, ByteBuffer bb); - - public native Long length(); - - public native Long nullCount(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/Message.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/Message.java deleted file mode 100644 index 691e7947369..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/Message.java +++ /dev/null @@ -1,82 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf; - -import elemental2.core.JsArray; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.KeyValue; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Long; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Message_generated.org.apache.arrow.flatbuf.Message", - namespace = JsPackage.GLOBAL) -public class Message { - public static native void addBodyLength(Builder builder, Long bodyLength); - - public static native void addCustomMetadata(Builder builder, double customMetadataOffset); - - public static native void addHeader(Builder builder, double headerOffset); - - public static native void addHeaderType(Builder builder, int headerType); - - public static native void addVersion(Builder builder, int version); - - public static native double createCustomMetadataVector(Builder builder, JsArray data); - - @JsOverlay - public static final double createCustomMetadataVector(Builder builder, double[] data) { - return createCustomMetadataVector(builder, Js.>uncheckedCast(data)); - } - - public static native double createMessage( - Builder builder, - int version, - int headerType, - double headerOffset, - Long bodyLength, - double customMetadataOffset); - - public static native double endMessage(Builder builder); - - public static native void finishMessageBuffer(Builder builder, double offset); - - public static native void finishSizePrefixedMessageBuffer(Builder builder, double offset); - - public static native Message getRootAsMessage(ByteBuffer bb, Message obj); - - public static native Message getRootAsMessage(ByteBuffer bb); - - public static native Message getSizePrefixedRootAsMessage(ByteBuffer bb, Message obj); - - public static native Message getSizePrefixedRootAsMessage(ByteBuffer bb); - - public static native void startCustomMetadataVector(Builder builder, double numElems); - - public static native void startMessage(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Message __init(double i, ByteBuffer bb); - - public native Long bodyLength(); - - public native KeyValue customMetadata(double index, KeyValue obj); - - public native KeyValue customMetadata(double index); - - public native double customMetadataLength(); - - public native T header(T obj); - - public native int headerType(); - - public native int version(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/MessageHeader.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/MessageHeader.java deleted file mode 100644 index 48bae3c723d..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/MessageHeader.java +++ /dev/null @@ -1,18 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Message_generated.org.apache.arrow.flatbuf.MessageHeader", - namespace = JsPackage.GLOBAL) -public class MessageHeader { - public static int DictionaryBatch, - NONE, - RecordBatch, - Schema; -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/RecordBatch.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/RecordBatch.java deleted file mode 100644 index 619fbee84cb..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/message_generated/org/apache/arrow/flatbuf/RecordBatch.java +++ /dev/null @@ -1,64 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.message_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Buffer; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Long; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Message_generated.org.apache.arrow.flatbuf.RecordBatch", - namespace = JsPackage.GLOBAL) -public class RecordBatch { - public static native void addBuffers(Builder builder, double buffersOffset); - - public static native void addCompression(Builder builder, double compressionOffset); - - public static native void addLength(Builder builder, Long length); - - public static native void addNodes(Builder builder, double nodesOffset); - - public static native double endRecordBatch(Builder builder); - - public static native RecordBatch getRootAsRecordBatch(ByteBuffer bb, RecordBatch obj); - - public static native RecordBatch getRootAsRecordBatch(ByteBuffer bb); - - public static native RecordBatch getSizePrefixedRootAsRecordBatch(ByteBuffer bb, RecordBatch obj); - - public static native RecordBatch getSizePrefixedRootAsRecordBatch(ByteBuffer bb); - - public static native void startBuffersVector(Builder builder, double numElems); - - public static native void startNodesVector(Builder builder, double numElems); - - public static native void startRecordBatch(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native RecordBatch __init(double i, ByteBuffer bb); - - public native Buffer buffers(double index, Buffer obj); - - public native Buffer buffers(double index); - - public native double buffersLength(); - - public native BodyCompression compression(); - - public native BodyCompression compression(BodyCompression obj); - - public native Long length(); - - public native FieldNode nodes(double index, FieldNode obj); - - public native FieldNode nodes(double index); - - public native double nodesLength(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/Flatbuf.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/Flatbuf.java deleted file mode 100644 index c74661f7d31..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/Flatbuf.java +++ /dev/null @@ -1,1572 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow; - -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Binary; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Bool; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Date; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Decimal; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Duration; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.FixedSizeBinary; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.FixedSizeList; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.FloatingPoint; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Int; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Interval; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.LargeBinary; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.LargeList; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.LargeUtf8; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.List; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Map; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Null; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Struct_; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Time; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Timestamp; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Union; -import io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf.Utf8; -import jsinterop.annotations.JsFunction; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf", - namespace = JsPackage.GLOBAL) -public class Flatbuf { - @JsFunction - public interface UnionListToTypeAccessorFn { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface P1UnionType { - @JsOverlay - static Flatbuf.UnionListToTypeAccessorFn.P1UnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Binary asBinary() { - return Js.cast(this); - } - - @JsOverlay - default Bool asBool() { - return Js.cast(this); - } - - @JsOverlay - default Date asDate() { - return Js.cast(this); - } - - @JsOverlay - default Decimal asDecimal() { - return Js.cast(this); - } - - @JsOverlay - default Duration asDuration() { - return Js.cast(this); - } - - @JsOverlay - default FixedSizeBinary asFixedSizeBinary() { - return Js.cast(this); - } - - @JsOverlay - default FixedSizeList asFixedSizeList() { - return Js.cast(this); - } - - @JsOverlay - default FloatingPoint asFloatingPoint() { - return Js.cast(this); - } - - @JsOverlay - default Int asInt() { - return Js.cast(this); - } - - @JsOverlay - default Interval asInterval() { - return Js.cast(this); - } - - @JsOverlay - default LargeBinary asLargeBinary() { - return Js.cast(this); - } - - @JsOverlay - default LargeList asLargeList() { - return Js.cast(this); - } - - @JsOverlay - default LargeUtf8 asLargeUtf8() { - return Js.cast(this); - } - - @JsOverlay - default List asList() { - return Js.cast(this); - } - - @JsOverlay - default Map asMap() { - return Js.cast(this); - } - - @JsOverlay - default Null asNull() { - return Js.cast(this); - } - - @JsOverlay - default Struct_ asStruct_() { - return Js.cast(this); - } - - @JsOverlay - default Time asTime() { - return Js.cast(this); - } - - @JsOverlay - default Timestamp asTimestamp() { - return Js.cast(this); - } - - @JsOverlay - default Union asUnion() { - return Js.cast(this); - } - - @JsOverlay - default Utf8 asUtf8() { - return Js.cast(this); - } - - @JsOverlay - default boolean isBinary() { - return (Object) this instanceof Binary; - } - - @JsOverlay - default boolean isBool() { - return (Object) this instanceof Bool; - } - - @JsOverlay - default boolean isDate() { - return (Object) this instanceof Date; - } - - @JsOverlay - default boolean isDecimal() { - return (Object) this instanceof Decimal; - } - - @JsOverlay - default boolean isDuration() { - return (Object) this instanceof Duration; - } - - @JsOverlay - default boolean isFixedSizeBinary() { - return (Object) this instanceof FixedSizeBinary; - } - - @JsOverlay - default boolean isFixedSizeList() { - return (Object) this instanceof FixedSizeList; - } - - @JsOverlay - default boolean isFloatingPoint() { - return (Object) this instanceof FloatingPoint; - } - - @JsOverlay - default boolean isInt() { - return (Object) this instanceof Int; - } - - @JsOverlay - default boolean isInterval() { - return (Object) this instanceof Interval; - } - - @JsOverlay - default boolean isLargeBinary() { - return (Object) this instanceof LargeBinary; - } - - @JsOverlay - default boolean isLargeList() { - return (Object) this instanceof LargeList; - } - - @JsOverlay - default boolean isLargeUtf8() { - return (Object) this instanceof LargeUtf8; - } - - @JsOverlay - default boolean isList() { - return (Object) this instanceof List; - } - - @JsOverlay - default boolean isMap() { - return (Object) this instanceof Map; - } - - @JsOverlay - default boolean isNull() { - return (Object) this instanceof Null; - } - - @JsOverlay - default boolean isStruct_() { - return (Object) this instanceof Struct_; - } - - @JsOverlay - default boolean isTime() { - return (Object) this instanceof Time; - } - - @JsOverlay - default boolean isTimestamp() { - return (Object) this instanceof Timestamp; - } - - @JsOverlay - default boolean isUnion() { - return (Object) this instanceof Union; - } - - @JsOverlay - default boolean isUtf8() { - return (Object) this instanceof Utf8; - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface UnionType { - @JsOverlay - static Flatbuf.UnionListToTypeAccessorFn.UnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Binary asBinary() { - return Js.cast(this); - } - - @JsOverlay - default Bool asBool() { - return Js.cast(this); - } - - @JsOverlay - default Date asDate() { - return Js.cast(this); - } - - @JsOverlay - default Decimal asDecimal() { - return Js.cast(this); - } - - @JsOverlay - default Duration asDuration() { - return Js.cast(this); - } - - @JsOverlay - default FixedSizeBinary asFixedSizeBinary() { - return Js.cast(this); - } - - @JsOverlay - default FixedSizeList asFixedSizeList() { - return Js.cast(this); - } - - @JsOverlay - default FloatingPoint asFloatingPoint() { - return Js.cast(this); - } - - @JsOverlay - default Int asInt() { - return Js.cast(this); - } - - @JsOverlay - default Interval asInterval() { - return Js.cast(this); - } - - @JsOverlay - default LargeBinary asLargeBinary() { - return Js.cast(this); - } - - @JsOverlay - default LargeList asLargeList() { - return Js.cast(this); - } - - @JsOverlay - default LargeUtf8 asLargeUtf8() { - return Js.cast(this); - } - - @JsOverlay - default List asList() { - return Js.cast(this); - } - - @JsOverlay - default Map asMap() { - return Js.cast(this); - } - - @JsOverlay - default Null asNull() { - return Js.cast(this); - } - - @JsOverlay - default Struct_ asStruct_() { - return Js.cast(this); - } - - @JsOverlay - default Time asTime() { - return Js.cast(this); - } - - @JsOverlay - default Timestamp asTimestamp() { - return Js.cast(this); - } - - @JsOverlay - default Union asUnion() { - return Js.cast(this); - } - - @JsOverlay - default Utf8 asUtf8() { - return Js.cast(this); - } - - @JsOverlay - default boolean isBinary() { - return (Object) this instanceof Binary; - } - - @JsOverlay - default boolean isBool() { - return (Object) this instanceof Bool; - } - - @JsOverlay - default boolean isDate() { - return (Object) this instanceof Date; - } - - @JsOverlay - default boolean isDecimal() { - return (Object) this instanceof Decimal; - } - - @JsOverlay - default boolean isDuration() { - return (Object) this instanceof Duration; - } - - @JsOverlay - default boolean isFixedSizeBinary() { - return (Object) this instanceof FixedSizeBinary; - } - - @JsOverlay - default boolean isFixedSizeList() { - return (Object) this instanceof FixedSizeList; - } - - @JsOverlay - default boolean isFloatingPoint() { - return (Object) this instanceof FloatingPoint; - } - - @JsOverlay - default boolean isInt() { - return (Object) this instanceof Int; - } - - @JsOverlay - default boolean isInterval() { - return (Object) this instanceof Interval; - } - - @JsOverlay - default boolean isLargeBinary() { - return (Object) this instanceof LargeBinary; - } - - @JsOverlay - default boolean isLargeList() { - return (Object) this instanceof LargeList; - } - - @JsOverlay - default boolean isLargeUtf8() { - return (Object) this instanceof LargeUtf8; - } - - @JsOverlay - default boolean isList() { - return (Object) this instanceof List; - } - - @JsOverlay - default boolean isMap() { - return (Object) this instanceof Map; - } - - @JsOverlay - default boolean isNull() { - return (Object) this instanceof Null; - } - - @JsOverlay - default boolean isStruct_() { - return (Object) this instanceof Struct_; - } - - @JsOverlay - default boolean isTime() { - return (Object) this instanceof Time; - } - - @JsOverlay - default boolean isTimestamp() { - return (Object) this instanceof Timestamp; - } - - @JsOverlay - default boolean isUnion() { - return (Object) this instanceof Union; - } - - @JsOverlay - default boolean isUtf8() { - return (Object) this instanceof Utf8; - } - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, Binary p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, Bool p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, Date p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, Decimal p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, Duration p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, FixedSizeBinary p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, FixedSizeList p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, FloatingPoint p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, Int p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, Interval p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, LargeBinary p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, LargeList p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, LargeUtf8 p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, List p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, Map p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, Null p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke( - double p0, Flatbuf.UnionListToTypeAccessorFn.P1UnionType p1); - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, Struct_ p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, Time p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, Timestamp p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, Union p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - - @JsOverlay - default Flatbuf.UnionListToTypeAccessorFn.UnionType onInvoke(double p0, Utf8 p1) { - return onInvoke(p0, Js.uncheckedCast(p1)); - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface UnionListToTypeUnionType { - @JsOverlay - static Flatbuf.UnionListToTypeUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Binary asBinary() { - return Js.cast(this); - } - - @JsOverlay - default Bool asBool() { - return Js.cast(this); - } - - @JsOverlay - default Date asDate() { - return Js.cast(this); - } - - @JsOverlay - default Decimal asDecimal() { - return Js.cast(this); - } - - @JsOverlay - default Duration asDuration() { - return Js.cast(this); - } - - @JsOverlay - default FixedSizeBinary asFixedSizeBinary() { - return Js.cast(this); - } - - @JsOverlay - default FixedSizeList asFixedSizeList() { - return Js.cast(this); - } - - @JsOverlay - default FloatingPoint asFloatingPoint() { - return Js.cast(this); - } - - @JsOverlay - default Int asInt() { - return Js.cast(this); - } - - @JsOverlay - default Interval asInterval() { - return Js.cast(this); - } - - @JsOverlay - default LargeBinary asLargeBinary() { - return Js.cast(this); - } - - @JsOverlay - default LargeList asLargeList() { - return Js.cast(this); - } - - @JsOverlay - default LargeUtf8 asLargeUtf8() { - return Js.cast(this); - } - - @JsOverlay - default List asList() { - return Js.cast(this); - } - - @JsOverlay - default Map asMap() { - return Js.cast(this); - } - - @JsOverlay - default Null asNull() { - return Js.cast(this); - } - - @JsOverlay - default Struct_ asStruct_() { - return Js.cast(this); - } - - @JsOverlay - default Time asTime() { - return Js.cast(this); - } - - @JsOverlay - default Timestamp asTimestamp() { - return Js.cast(this); - } - - @JsOverlay - default Union asUnion() { - return Js.cast(this); - } - - @JsOverlay - default Utf8 asUtf8() { - return Js.cast(this); - } - - @JsOverlay - default boolean isBinary() { - return (Object) this instanceof Binary; - } - - @JsOverlay - default boolean isBool() { - return (Object) this instanceof Bool; - } - - @JsOverlay - default boolean isDate() { - return (Object) this instanceof Date; - } - - @JsOverlay - default boolean isDecimal() { - return (Object) this instanceof Decimal; - } - - @JsOverlay - default boolean isDuration() { - return (Object) this instanceof Duration; - } - - @JsOverlay - default boolean isFixedSizeBinary() { - return (Object) this instanceof FixedSizeBinary; - } - - @JsOverlay - default boolean isFixedSizeList() { - return (Object) this instanceof FixedSizeList; - } - - @JsOverlay - default boolean isFloatingPoint() { - return (Object) this instanceof FloatingPoint; - } - - @JsOverlay - default boolean isInt() { - return (Object) this instanceof Int; - } - - @JsOverlay - default boolean isInterval() { - return (Object) this instanceof Interval; - } - - @JsOverlay - default boolean isLargeBinary() { - return (Object) this instanceof LargeBinary; - } - - @JsOverlay - default boolean isLargeList() { - return (Object) this instanceof LargeList; - } - - @JsOverlay - default boolean isLargeUtf8() { - return (Object) this instanceof LargeUtf8; - } - - @JsOverlay - default boolean isList() { - return (Object) this instanceof List; - } - - @JsOverlay - default boolean isMap() { - return (Object) this instanceof Map; - } - - @JsOverlay - default boolean isNull() { - return (Object) this instanceof Null; - } - - @JsOverlay - default boolean isStruct_() { - return (Object) this instanceof Struct_; - } - - @JsOverlay - default boolean isTime() { - return (Object) this instanceof Time; - } - - @JsOverlay - default boolean isTimestamp() { - return (Object) this instanceof Timestamp; - } - - @JsOverlay - default boolean isUnion() { - return (Object) this instanceof Union; - } - - @JsOverlay - default boolean isUtf8() { - return (Object) this instanceof Utf8; - } - } - - @JsFunction - public interface UnionToTypeAccessorFn { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface P0UnionType { - @JsOverlay - static Flatbuf.UnionToTypeAccessorFn.P0UnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Binary asBinary() { - return Js.cast(this); - } - - @JsOverlay - default Bool asBool() { - return Js.cast(this); - } - - @JsOverlay - default Date asDate() { - return Js.cast(this); - } - - @JsOverlay - default Decimal asDecimal() { - return Js.cast(this); - } - - @JsOverlay - default Duration asDuration() { - return Js.cast(this); - } - - @JsOverlay - default FixedSizeBinary asFixedSizeBinary() { - return Js.cast(this); - } - - @JsOverlay - default FixedSizeList asFixedSizeList() { - return Js.cast(this); - } - - @JsOverlay - default FloatingPoint asFloatingPoint() { - return Js.cast(this); - } - - @JsOverlay - default Int asInt() { - return Js.cast(this); - } - - @JsOverlay - default Interval asInterval() { - return Js.cast(this); - } - - @JsOverlay - default LargeBinary asLargeBinary() { - return Js.cast(this); - } - - @JsOverlay - default LargeList asLargeList() { - return Js.cast(this); - } - - @JsOverlay - default LargeUtf8 asLargeUtf8() { - return Js.cast(this); - } - - @JsOverlay - default List asList() { - return Js.cast(this); - } - - @JsOverlay - default Map asMap() { - return Js.cast(this); - } - - @JsOverlay - default Null asNull() { - return Js.cast(this); - } - - @JsOverlay - default Struct_ asStruct_() { - return Js.cast(this); - } - - @JsOverlay - default Time asTime() { - return Js.cast(this); - } - - @JsOverlay - default Timestamp asTimestamp() { - return Js.cast(this); - } - - @JsOverlay - default Union asUnion() { - return Js.cast(this); - } - - @JsOverlay - default Utf8 asUtf8() { - return Js.cast(this); - } - - @JsOverlay - default boolean isBinary() { - return (Object) this instanceof Binary; - } - - @JsOverlay - default boolean isBool() { - return (Object) this instanceof Bool; - } - - @JsOverlay - default boolean isDate() { - return (Object) this instanceof Date; - } - - @JsOverlay - default boolean isDecimal() { - return (Object) this instanceof Decimal; - } - - @JsOverlay - default boolean isDuration() { - return (Object) this instanceof Duration; - } - - @JsOverlay - default boolean isFixedSizeBinary() { - return (Object) this instanceof FixedSizeBinary; - } - - @JsOverlay - default boolean isFixedSizeList() { - return (Object) this instanceof FixedSizeList; - } - - @JsOverlay - default boolean isFloatingPoint() { - return (Object) this instanceof FloatingPoint; - } - - @JsOverlay - default boolean isInt() { - return (Object) this instanceof Int; - } - - @JsOverlay - default boolean isInterval() { - return (Object) this instanceof Interval; - } - - @JsOverlay - default boolean isLargeBinary() { - return (Object) this instanceof LargeBinary; - } - - @JsOverlay - default boolean isLargeList() { - return (Object) this instanceof LargeList; - } - - @JsOverlay - default boolean isLargeUtf8() { - return (Object) this instanceof LargeUtf8; - } - - @JsOverlay - default boolean isList() { - return (Object) this instanceof List; - } - - @JsOverlay - default boolean isMap() { - return (Object) this instanceof Map; - } - - @JsOverlay - default boolean isNull() { - return (Object) this instanceof Null; - } - - @JsOverlay - default boolean isStruct_() { - return (Object) this instanceof Struct_; - } - - @JsOverlay - default boolean isTime() { - return (Object) this instanceof Time; - } - - @JsOverlay - default boolean isTimestamp() { - return (Object) this instanceof Timestamp; - } - - @JsOverlay - default boolean isUnion() { - return (Object) this instanceof Union; - } - - @JsOverlay - default boolean isUtf8() { - return (Object) this instanceof Utf8; - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface UnionType { - @JsOverlay - static Flatbuf.UnionToTypeAccessorFn.UnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Binary asBinary() { - return Js.cast(this); - } - - @JsOverlay - default Bool asBool() { - return Js.cast(this); - } - - @JsOverlay - default Date asDate() { - return Js.cast(this); - } - - @JsOverlay - default Decimal asDecimal() { - return Js.cast(this); - } - - @JsOverlay - default Duration asDuration() { - return Js.cast(this); - } - - @JsOverlay - default FixedSizeBinary asFixedSizeBinary() { - return Js.cast(this); - } - - @JsOverlay - default FixedSizeList asFixedSizeList() { - return Js.cast(this); - } - - @JsOverlay - default FloatingPoint asFloatingPoint() { - return Js.cast(this); - } - - @JsOverlay - default Int asInt() { - return Js.cast(this); - } - - @JsOverlay - default Interval asInterval() { - return Js.cast(this); - } - - @JsOverlay - default LargeBinary asLargeBinary() { - return Js.cast(this); - } - - @JsOverlay - default LargeList asLargeList() { - return Js.cast(this); - } - - @JsOverlay - default LargeUtf8 asLargeUtf8() { - return Js.cast(this); - } - - @JsOverlay - default List asList() { - return Js.cast(this); - } - - @JsOverlay - default Map asMap() { - return Js.cast(this); - } - - @JsOverlay - default Null asNull() { - return Js.cast(this); - } - - @JsOverlay - default Struct_ asStruct_() { - return Js.cast(this); - } - - @JsOverlay - default Time asTime() { - return Js.cast(this); - } - - @JsOverlay - default Timestamp asTimestamp() { - return Js.cast(this); - } - - @JsOverlay - default Union asUnion() { - return Js.cast(this); - } - - @JsOverlay - default Utf8 asUtf8() { - return Js.cast(this); - } - - @JsOverlay - default boolean isBinary() { - return (Object) this instanceof Binary; - } - - @JsOverlay - default boolean isBool() { - return (Object) this instanceof Bool; - } - - @JsOverlay - default boolean isDate() { - return (Object) this instanceof Date; - } - - @JsOverlay - default boolean isDecimal() { - return (Object) this instanceof Decimal; - } - - @JsOverlay - default boolean isDuration() { - return (Object) this instanceof Duration; - } - - @JsOverlay - default boolean isFixedSizeBinary() { - return (Object) this instanceof FixedSizeBinary; - } - - @JsOverlay - default boolean isFixedSizeList() { - return (Object) this instanceof FixedSizeList; - } - - @JsOverlay - default boolean isFloatingPoint() { - return (Object) this instanceof FloatingPoint; - } - - @JsOverlay - default boolean isInt() { - return (Object) this instanceof Int; - } - - @JsOverlay - default boolean isInterval() { - return (Object) this instanceof Interval; - } - - @JsOverlay - default boolean isLargeBinary() { - return (Object) this instanceof LargeBinary; - } - - @JsOverlay - default boolean isLargeList() { - return (Object) this instanceof LargeList; - } - - @JsOverlay - default boolean isLargeUtf8() { - return (Object) this instanceof LargeUtf8; - } - - @JsOverlay - default boolean isList() { - return (Object) this instanceof List; - } - - @JsOverlay - default boolean isMap() { - return (Object) this instanceof Map; - } - - @JsOverlay - default boolean isNull() { - return (Object) this instanceof Null; - } - - @JsOverlay - default boolean isStruct_() { - return (Object) this instanceof Struct_; - } - - @JsOverlay - default boolean isTime() { - return (Object) this instanceof Time; - } - - @JsOverlay - default boolean isTimestamp() { - return (Object) this instanceof Timestamp; - } - - @JsOverlay - default boolean isUnion() { - return (Object) this instanceof Union; - } - - @JsOverlay - default boolean isUtf8() { - return (Object) this instanceof Utf8; - } - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(Binary p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(Bool p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(Date p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(Decimal p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(Duration p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(FixedSizeBinary p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(FixedSizeList p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(FloatingPoint p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(Int p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(Interval p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(LargeBinary p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(LargeList p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(LargeUtf8 p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(List p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(Map p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(Null p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(Flatbuf.UnionToTypeAccessorFn.P0UnionType p0); - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(Struct_ p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(Time p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(Timestamp p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(Union p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - - @JsOverlay - default Flatbuf.UnionToTypeAccessorFn.UnionType onInvoke(Utf8 p0) { - return onInvoke(Js.uncheckedCast(p0)); - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface UnionToTypeUnionType { - @JsOverlay - static Flatbuf.UnionToTypeUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Binary asBinary() { - return Js.cast(this); - } - - @JsOverlay - default Bool asBool() { - return Js.cast(this); - } - - @JsOverlay - default Date asDate() { - return Js.cast(this); - } - - @JsOverlay - default Decimal asDecimal() { - return Js.cast(this); - } - - @JsOverlay - default Duration asDuration() { - return Js.cast(this); - } - - @JsOverlay - default FixedSizeBinary asFixedSizeBinary() { - return Js.cast(this); - } - - @JsOverlay - default FixedSizeList asFixedSizeList() { - return Js.cast(this); - } - - @JsOverlay - default FloatingPoint asFloatingPoint() { - return Js.cast(this); - } - - @JsOverlay - default Int asInt() { - return Js.cast(this); - } - - @JsOverlay - default Interval asInterval() { - return Js.cast(this); - } - - @JsOverlay - default LargeBinary asLargeBinary() { - return Js.cast(this); - } - - @JsOverlay - default LargeList asLargeList() { - return Js.cast(this); - } - - @JsOverlay - default LargeUtf8 asLargeUtf8() { - return Js.cast(this); - } - - @JsOverlay - default List asList() { - return Js.cast(this); - } - - @JsOverlay - default Map asMap() { - return Js.cast(this); - } - - @JsOverlay - default Null asNull() { - return Js.cast(this); - } - - @JsOverlay - default Struct_ asStruct_() { - return Js.cast(this); - } - - @JsOverlay - default Time asTime() { - return Js.cast(this); - } - - @JsOverlay - default Timestamp asTimestamp() { - return Js.cast(this); - } - - @JsOverlay - default Union asUnion() { - return Js.cast(this); - } - - @JsOverlay - default Utf8 asUtf8() { - return Js.cast(this); - } - - @JsOverlay - default boolean isBinary() { - return (Object) this instanceof Binary; - } - - @JsOverlay - default boolean isBool() { - return (Object) this instanceof Bool; - } - - @JsOverlay - default boolean isDate() { - return (Object) this instanceof Date; - } - - @JsOverlay - default boolean isDecimal() { - return (Object) this instanceof Decimal; - } - - @JsOverlay - default boolean isDuration() { - return (Object) this instanceof Duration; - } - - @JsOverlay - default boolean isFixedSizeBinary() { - return (Object) this instanceof FixedSizeBinary; - } - - @JsOverlay - default boolean isFixedSizeList() { - return (Object) this instanceof FixedSizeList; - } - - @JsOverlay - default boolean isFloatingPoint() { - return (Object) this instanceof FloatingPoint; - } - - @JsOverlay - default boolean isInt() { - return (Object) this instanceof Int; - } - - @JsOverlay - default boolean isInterval() { - return (Object) this instanceof Interval; - } - - @JsOverlay - default boolean isLargeBinary() { - return (Object) this instanceof LargeBinary; - } - - @JsOverlay - default boolean isLargeList() { - return (Object) this instanceof LargeList; - } - - @JsOverlay - default boolean isLargeUtf8() { - return (Object) this instanceof LargeUtf8; - } - - @JsOverlay - default boolean isList() { - return (Object) this instanceof List; - } - - @JsOverlay - default boolean isMap() { - return (Object) this instanceof Map; - } - - @JsOverlay - default boolean isNull() { - return (Object) this instanceof Null; - } - - @JsOverlay - default boolean isStruct_() { - return (Object) this instanceof Struct_; - } - - @JsOverlay - default boolean isTime() { - return (Object) this instanceof Time; - } - - @JsOverlay - default boolean isTimestamp() { - return (Object) this instanceof Timestamp; - } - - @JsOverlay - default boolean isUnion() { - return (Object) this instanceof Union; - } - - @JsOverlay - default boolean isUtf8() { - return (Object) this instanceof Utf8; - } - } - - public static native Flatbuf.UnionListToTypeUnionType unionListToType( - int type, Flatbuf.UnionListToTypeAccessorFn accessor, double index); - - public static native Flatbuf.UnionToTypeUnionType unionToType( - int type, Flatbuf.UnionToTypeAccessorFn accessor); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Binary.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Binary.java deleted file mode 100644 index 9174b46ad62..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Binary.java +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Binary", - namespace = JsPackage.GLOBAL) -public class Binary { - public static native double createBinary(Builder builder); - - public static native double endBinary(Builder builder); - - public static native Binary getRootAsBinary(ByteBuffer bb, Binary obj); - - public static native Binary getRootAsBinary(ByteBuffer bb); - - public static native Binary getSizePrefixedRootAsBinary(ByteBuffer bb, Binary obj); - - public static native Binary getSizePrefixedRootAsBinary(ByteBuffer bb); - - public static native void startBinary(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Binary __init(double i, ByteBuffer bb); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Bool.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Bool.java deleted file mode 100644 index a995e0e6a1d..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Bool.java +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Bool", - namespace = JsPackage.GLOBAL) -public class Bool { - public static native double createBool(Builder builder); - - public static native double endBool(Builder builder); - - public static native Bool getRootAsBool(ByteBuffer bb, Bool obj); - - public static native Bool getRootAsBool(ByteBuffer bb); - - public static native Bool getSizePrefixedRootAsBool(ByteBuffer bb, Bool obj); - - public static native Bool getSizePrefixedRootAsBool(ByteBuffer bb); - - public static native void startBool(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Bool __init(double i, ByteBuffer bb); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Buffer.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Buffer.java deleted file mode 100644 index 9cb4e6bc3c6..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Buffer.java +++ /dev/null @@ -1,29 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Long; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Buffer", - namespace = JsPackage.GLOBAL) -public class Buffer { - public static native double createBuffer(Builder builder, Long offset, Long length); - - public static native double sizeOf(); - - public ByteBuffer bb; - public double bb_pos; - - public native Buffer __init(double i, ByteBuffer bb); - - public native Long length(); - - public native Long offset(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Date.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Date.java deleted file mode 100644 index 37483e70bcc..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Date.java +++ /dev/null @@ -1,38 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Date", - namespace = JsPackage.GLOBAL) -public class Date { - public static native void addUnit(Builder builder, int unit); - - public static native double createDate(Builder builder, int unit); - - public static native double endDate(Builder builder); - - public static native Date getRootAsDate(ByteBuffer bb, Date obj); - - public static native Date getRootAsDate(ByteBuffer bb); - - public static native Date getSizePrefixedRootAsDate(ByteBuffer bb, Date obj); - - public static native Date getSizePrefixedRootAsDate(ByteBuffer bb); - - public static native void startDate(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Date __init(double i, ByteBuffer bb); - - public native int unit(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/DateUnit.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/DateUnit.java deleted file mode 100644 index b5edb152cb7..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/DateUnit.java +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.DateUnit", - namespace = JsPackage.GLOBAL) -public class DateUnit { - public static int DAY, - MILLISECOND; -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Decimal.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Decimal.java deleted file mode 100644 index fa3ee35026b..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Decimal.java +++ /dev/null @@ -1,47 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Decimal", - namespace = JsPackage.GLOBAL) -public class Decimal { - public static native void addBitWidth(Builder builder, double bitWidth); - - public static native void addPrecision(Builder builder, double precision); - - public static native void addScale(Builder builder, double scale); - - public static native double createDecimal( - Builder builder, double precision, double scale, double bitWidth); - - public static native double endDecimal(Builder builder); - - public static native Decimal getRootAsDecimal(ByteBuffer bb, Decimal obj); - - public static native Decimal getRootAsDecimal(ByteBuffer bb); - - public static native Decimal getSizePrefixedRootAsDecimal(ByteBuffer bb, Decimal obj); - - public static native Decimal getSizePrefixedRootAsDecimal(ByteBuffer bb); - - public static native void startDecimal(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Decimal __init(double i, ByteBuffer bb); - - public native double bitWidth(); - - public native double precision(); - - public native double scale(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/DictionaryEncoding.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/DictionaryEncoding.java deleted file mode 100644 index 9be0497b0ec..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/DictionaryEncoding.java +++ /dev/null @@ -1,53 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Long; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.DictionaryEncoding", - namespace = JsPackage.GLOBAL) -public class DictionaryEncoding { - public static native void addDictionaryKind(Builder builder, int dictionaryKind); - - public static native void addId(Builder builder, Long id); - - public static native void addIndexType(Builder builder, double indexTypeOffset); - - public static native void addIsOrdered(Builder builder, boolean isOrdered); - - public static native double endDictionaryEncoding(Builder builder); - - public static native DictionaryEncoding getRootAsDictionaryEncoding( - ByteBuffer bb, DictionaryEncoding obj); - - public static native DictionaryEncoding getRootAsDictionaryEncoding(ByteBuffer bb); - - public static native DictionaryEncoding getSizePrefixedRootAsDictionaryEncoding( - ByteBuffer bb, DictionaryEncoding obj); - - public static native DictionaryEncoding getSizePrefixedRootAsDictionaryEncoding(ByteBuffer bb); - - public static native void startDictionaryEncoding(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native DictionaryEncoding __init(double i, ByteBuffer bb); - - public native int dictionaryKind(); - - public native Long id(); - - public native Int indexType(); - - public native Int indexType(Int obj); - - public native boolean isOrdered(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/DictionaryKind.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/DictionaryKind.java deleted file mode 100644 index 0a78b7f3036..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/DictionaryKind.java +++ /dev/null @@ -1,15 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.DictionaryKind", - namespace = JsPackage.GLOBAL) -public class DictionaryKind { - public static int DenseArray; -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Duration.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Duration.java deleted file mode 100644 index ae2bc2aee9d..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Duration.java +++ /dev/null @@ -1,38 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Duration", - namespace = JsPackage.GLOBAL) -public class Duration { - public static native void addUnit(Builder builder, int unit); - - public static native double createDuration(Builder builder, int unit); - - public static native double endDuration(Builder builder); - - public static native Duration getRootAsDuration(ByteBuffer bb, Duration obj); - - public static native Duration getRootAsDuration(ByteBuffer bb); - - public static native Duration getSizePrefixedRootAsDuration(ByteBuffer bb, Duration obj); - - public static native Duration getSizePrefixedRootAsDuration(ByteBuffer bb); - - public static native void startDuration(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Duration __init(double i, ByteBuffer bb); - - public native int unit(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Endianness.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Endianness.java deleted file mode 100644 index e29338b855b..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Endianness.java +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Endianness", - namespace = JsPackage.GLOBAL) -public class Endianness { - public static int Big, - Little; -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Feature.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Feature.java deleted file mode 100644 index 5b81178a43e..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Feature.java +++ /dev/null @@ -1,17 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Feature", - namespace = JsPackage.GLOBAL) -public class Feature { - public static int COMPRESSED_BODY, - DICTIONARY_REPLACEMENT, - UNUSED; -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Field.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Field.java deleted file mode 100644 index 6cdc1706df3..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Field.java +++ /dev/null @@ -1,123 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import elemental2.core.JsArray; -import elemental2.core.Uint8Array; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Encoding; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Field", - namespace = JsPackage.GLOBAL) -public class Field { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface NameUnionType { - @JsOverlay - static Field.NameUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default String asString() { - return Js.asString(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isString() { - return (Object) this instanceof String; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - public static native void addChildren(Builder builder, double childrenOffset); - - public static native void addCustomMetadata(Builder builder, double customMetadataOffset); - - public static native void addDictionary(Builder builder, double dictionaryOffset); - - public static native void addName(Builder builder, double nameOffset); - - public static native void addNullable(Builder builder, boolean nullable); - - public static native void addType(Builder builder, double typeOffset); - - public static native void addTypeType(Builder builder, int typeType); - - public static native double createChildrenVector(Builder builder, JsArray data); - - @JsOverlay - public static final double createChildrenVector(Builder builder, double[] data) { - return createChildrenVector(builder, Js.>uncheckedCast(data)); - } - - public static native double createCustomMetadataVector(Builder builder, JsArray data); - - @JsOverlay - public static final double createCustomMetadataVector(Builder builder, double[] data) { - return createCustomMetadataVector(builder, Js.>uncheckedCast(data)); - } - - public static native double endField(Builder builder); - - public static native Field getRootAsField(ByteBuffer bb, Field obj); - - public static native Field getRootAsField(ByteBuffer bb); - - public static native Field getSizePrefixedRootAsField(ByteBuffer bb, Field obj); - - public static native Field getSizePrefixedRootAsField(ByteBuffer bb); - - public static native void startChildrenVector(Builder builder, double numElems); - - public static native void startCustomMetadataVector(Builder builder, double numElems); - - public static native void startField(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Field __init(double i, ByteBuffer bb); - - public native Field children(double index, Field obj); - - public native Field children(double index); - - public native double childrenLength(); - - public native KeyValue customMetadata(double index, KeyValue obj); - - public native KeyValue customMetadata(double index); - - public native double customMetadataLength(); - - public native DictionaryEncoding dictionary(); - - public native DictionaryEncoding dictionary(DictionaryEncoding obj); - - public native Field.NameUnionType name(); - - public native Field.NameUnionType name(Encoding optionalEncoding); - - public native boolean nullable(); - - public native T type(T obj); - - public native int typeType(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/FixedSizeBinary.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/FixedSizeBinary.java deleted file mode 100644 index 701078f258f..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/FixedSizeBinary.java +++ /dev/null @@ -1,39 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.FixedSizeBinary", - namespace = JsPackage.GLOBAL) -public class FixedSizeBinary { - public static native void addByteWidth(Builder builder, double byteWidth); - - public static native double createFixedSizeBinary(Builder builder, double byteWidth); - - public static native double endFixedSizeBinary(Builder builder); - - public static native FixedSizeBinary getRootAsFixedSizeBinary(ByteBuffer bb, FixedSizeBinary obj); - - public static native FixedSizeBinary getRootAsFixedSizeBinary(ByteBuffer bb); - - public static native FixedSizeBinary getSizePrefixedRootAsFixedSizeBinary( - ByteBuffer bb, FixedSizeBinary obj); - - public static native FixedSizeBinary getSizePrefixedRootAsFixedSizeBinary(ByteBuffer bb); - - public static native void startFixedSizeBinary(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native FixedSizeBinary __init(double i, ByteBuffer bb); - - public native double byteWidth(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/FixedSizeList.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/FixedSizeList.java deleted file mode 100644 index 6e7f302b85d..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/FixedSizeList.java +++ /dev/null @@ -1,39 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.FixedSizeList", - namespace = JsPackage.GLOBAL) -public class FixedSizeList { - public static native void addListSize(Builder builder, double listSize); - - public static native double createFixedSizeList(Builder builder, double listSize); - - public static native double endFixedSizeList(Builder builder); - - public static native FixedSizeList getRootAsFixedSizeList(ByteBuffer bb, FixedSizeList obj); - - public static native FixedSizeList getRootAsFixedSizeList(ByteBuffer bb); - - public static native FixedSizeList getSizePrefixedRootAsFixedSizeList( - ByteBuffer bb, FixedSizeList obj); - - public static native FixedSizeList getSizePrefixedRootAsFixedSizeList(ByteBuffer bb); - - public static native void startFixedSizeList(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native FixedSizeList __init(double i, ByteBuffer bb); - - public native double listSize(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/FloatingPoint.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/FloatingPoint.java deleted file mode 100644 index 739c3f455d6..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/FloatingPoint.java +++ /dev/null @@ -1,39 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.FloatingPoint", - namespace = JsPackage.GLOBAL) -public class FloatingPoint { - public static native void addPrecision(Builder builder, int precision); - - public static native double createFloatingPoint(Builder builder, int precision); - - public static native double endFloatingPoint(Builder builder); - - public static native FloatingPoint getRootAsFloatingPoint(ByteBuffer bb, FloatingPoint obj); - - public static native FloatingPoint getRootAsFloatingPoint(ByteBuffer bb); - - public static native FloatingPoint getSizePrefixedRootAsFloatingPoint( - ByteBuffer bb, FloatingPoint obj); - - public static native FloatingPoint getSizePrefixedRootAsFloatingPoint(ByteBuffer bb); - - public static native void startFloatingPoint(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native FloatingPoint __init(double i, ByteBuffer bb); - - public native int precision(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Int.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Int.java deleted file mode 100644 index c1441852b02..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Int.java +++ /dev/null @@ -1,42 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Int", - namespace = JsPackage.GLOBAL) -public class Int { - public static native void addBitWidth(Builder builder, double bitWidth); - - public static native void addIsSigned(Builder builder, boolean isSigned); - - public static native double createInt(Builder builder, double bitWidth, boolean isSigned); - - public static native double endInt(Builder builder); - - public static native Int getRootAsInt(ByteBuffer bb, Int obj); - - public static native Int getRootAsInt(ByteBuffer bb); - - public static native Int getSizePrefixedRootAsInt(ByteBuffer bb, Int obj); - - public static native Int getSizePrefixedRootAsInt(ByteBuffer bb); - - public static native void startInt(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Int __init(double i, ByteBuffer bb); - - public native double bitWidth(); - - public native boolean isSigned(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Interval.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Interval.java deleted file mode 100644 index c844a0f89d2..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Interval.java +++ /dev/null @@ -1,38 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Interval", - namespace = JsPackage.GLOBAL) -public class Interval { - public static native void addUnit(Builder builder, int unit); - - public static native double createInterval(Builder builder, int unit); - - public static native double endInterval(Builder builder); - - public static native Interval getRootAsInterval(ByteBuffer bb, Interval obj); - - public static native Interval getRootAsInterval(ByteBuffer bb); - - public static native Interval getSizePrefixedRootAsInterval(ByteBuffer bb, Interval obj); - - public static native Interval getSizePrefixedRootAsInterval(ByteBuffer bb); - - public static native void startInterval(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Interval __init(double i, ByteBuffer bb); - - public native int unit(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/IntervalUnit.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/IntervalUnit.java deleted file mode 100644 index aee19255211..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/IntervalUnit.java +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.IntervalUnit", - namespace = JsPackage.GLOBAL) -public class IntervalUnit { - public static int DAY_TIME, - YEAR_MONTH; -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/KeyValue.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/KeyValue.java deleted file mode 100644 index 3a7511d91eb..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/KeyValue.java +++ /dev/null @@ -1,106 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import elemental2.core.Uint8Array; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Encoding; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.KeyValue", - namespace = JsPackage.GLOBAL) -public class KeyValue { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface KeyUnionType { - @JsOverlay - static KeyValue.KeyUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default String asString() { - return Js.asString(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isString() { - return (Object) this instanceof String; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface ValueUnionType { - @JsOverlay - static KeyValue.ValueUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default String asString() { - return Js.asString(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isString() { - return (Object) this instanceof String; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - public static native void addKey(Builder builder, double keyOffset); - - public static native void addValue(Builder builder, double valueOffset); - - public static native double createKeyValue(Builder builder, double keyOffset, double valueOffset); - - public static native double endKeyValue(Builder builder); - - public static native KeyValue getRootAsKeyValue(ByteBuffer bb, KeyValue obj); - - public static native KeyValue getRootAsKeyValue(ByteBuffer bb); - - public static native KeyValue getSizePrefixedRootAsKeyValue(ByteBuffer bb, KeyValue obj); - - public static native KeyValue getSizePrefixedRootAsKeyValue(ByteBuffer bb); - - public static native void startKeyValue(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native KeyValue __init(double i, ByteBuffer bb); - - public native KeyValue.KeyUnionType key(); - - public native KeyValue.KeyUnionType key(Encoding optionalEncoding); - - public native KeyValue.ValueUnionType value(); - - public native KeyValue.ValueUnionType value(Encoding optionalEncoding); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/LargeBinary.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/LargeBinary.java deleted file mode 100644 index 98b3ca5480b..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/LargeBinary.java +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.LargeBinary", - namespace = JsPackage.GLOBAL) -public class LargeBinary { - public static native double createLargeBinary(Builder builder); - - public static native double endLargeBinary(Builder builder); - - public static native LargeBinary getRootAsLargeBinary(ByteBuffer bb, LargeBinary obj); - - public static native LargeBinary getRootAsLargeBinary(ByteBuffer bb); - - public static native LargeBinary getSizePrefixedRootAsLargeBinary(ByteBuffer bb, LargeBinary obj); - - public static native LargeBinary getSizePrefixedRootAsLargeBinary(ByteBuffer bb); - - public static native void startLargeBinary(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native LargeBinary __init(double i, ByteBuffer bb); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/LargeList.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/LargeList.java deleted file mode 100644 index c7581db121c..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/LargeList.java +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.LargeList", - namespace = JsPackage.GLOBAL) -public class LargeList { - public static native double createLargeList(Builder builder); - - public static native double endLargeList(Builder builder); - - public static native LargeList getRootAsLargeList(ByteBuffer bb, LargeList obj); - - public static native LargeList getRootAsLargeList(ByteBuffer bb); - - public static native LargeList getSizePrefixedRootAsLargeList(ByteBuffer bb, LargeList obj); - - public static native LargeList getSizePrefixedRootAsLargeList(ByteBuffer bb); - - public static native void startLargeList(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native LargeList __init(double i, ByteBuffer bb); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/LargeUtf8.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/LargeUtf8.java deleted file mode 100644 index 55031aa3e29..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/LargeUtf8.java +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.LargeUtf8", - namespace = JsPackage.GLOBAL) -public class LargeUtf8 { - public static native double createLargeUtf8(Builder builder); - - public static native double endLargeUtf8(Builder builder); - - public static native LargeUtf8 getRootAsLargeUtf8(ByteBuffer bb, LargeUtf8 obj); - - public static native LargeUtf8 getRootAsLargeUtf8(ByteBuffer bb); - - public static native LargeUtf8 getSizePrefixedRootAsLargeUtf8(ByteBuffer bb, LargeUtf8 obj); - - public static native LargeUtf8 getSizePrefixedRootAsLargeUtf8(ByteBuffer bb); - - public static native void startLargeUtf8(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native LargeUtf8 __init(double i, ByteBuffer bb); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/List.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/List.java deleted file mode 100644 index f4a0f64ba0e..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/List.java +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.List", - namespace = JsPackage.GLOBAL) -public class List { - public static native double createList(Builder builder); - - public static native double endList(Builder builder); - - public static native List getRootAsList(ByteBuffer bb, List obj); - - public static native List getRootAsList(ByteBuffer bb); - - public static native List getSizePrefixedRootAsList(ByteBuffer bb, List obj); - - public static native List getSizePrefixedRootAsList(ByteBuffer bb); - - public static native void startList(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native List __init(double i, ByteBuffer bb); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Map.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Map.java deleted file mode 100644 index 1a2e54e0fc6..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Map.java +++ /dev/null @@ -1,38 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Map", - namespace = JsPackage.GLOBAL) -public class Map { - public static native void addKeysSorted(Builder builder, boolean keysSorted); - - public static native double createMap(Builder builder, boolean keysSorted); - - public static native double endMap(Builder builder); - - public static native Map getRootAsMap(ByteBuffer bb, Map obj); - - public static native Map getRootAsMap(ByteBuffer bb); - - public static native Map getSizePrefixedRootAsMap(ByteBuffer bb, Map obj); - - public static native Map getSizePrefixedRootAsMap(ByteBuffer bb); - - public static native void startMap(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Map __init(double i, ByteBuffer bb); - - public native boolean keysSorted(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/MetadataVersion.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/MetadataVersion.java deleted file mode 100644 index 6e26ef3e21b..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/MetadataVersion.java +++ /dev/null @@ -1,19 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.MetadataVersion", - namespace = JsPackage.GLOBAL) -public class MetadataVersion { - public static int V1, - V2, - V3, - V4, - V5; -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Null.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Null.java deleted file mode 100644 index a4c761da693..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Null.java +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Null", - namespace = JsPackage.GLOBAL) -public class Null { - public static native double createNull(Builder builder); - - public static native double endNull(Builder builder); - - public static native Null getRootAsNull(ByteBuffer bb, Null obj); - - public static native Null getRootAsNull(ByteBuffer bb); - - public static native Null getSizePrefixedRootAsNull(ByteBuffer bb, Null obj); - - public static native Null getSizePrefixedRootAsNull(ByteBuffer bb); - - public static native void startNull(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Null __init(double i, ByteBuffer bb); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Precision.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Precision.java deleted file mode 100644 index 0c7f6cad0e3..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Precision.java +++ /dev/null @@ -1,17 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Precision", - namespace = JsPackage.GLOBAL) -public class Precision { - public static int DOUBLE, - HALF, - SINGLE; -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Schema.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Schema.java deleted file mode 100644 index 23ddc811ef7..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Schema.java +++ /dev/null @@ -1,100 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import elemental2.core.JsArray; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Long; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Schema", - namespace = JsPackage.GLOBAL) -public class Schema { - public static native void addCustomMetadata(Builder builder, double customMetadataOffset); - - public static native void addEndianness(Builder builder, int endianness); - - public static native void addFeatures(Builder builder, double featuresOffset); - - public static native void addFields(Builder builder, double fieldsOffset); - - public static native double createCustomMetadataVector(Builder builder, JsArray data); - - @JsOverlay - public static final double createCustomMetadataVector(Builder builder, double[] data) { - return createCustomMetadataVector(builder, Js.>uncheckedCast(data)); - } - - public static native double createFeaturesVector(Builder builder, JsArray data); - - @JsOverlay - public static final double createFeaturesVector(Builder builder, Object[] data) { - return createFeaturesVector(builder, Js.>uncheckedCast(data)); - } - - public static native double createFieldsVector(Builder builder, JsArray data); - - @JsOverlay - public static final double createFieldsVector(Builder builder, double[] data) { - return createFieldsVector(builder, Js.>uncheckedCast(data)); - } - - public static native double createSchema( - Builder builder, - int endianness, - double fieldsOffset, - double customMetadataOffset, - double featuresOffset); - - public static native double endSchema(Builder builder); - - public static native void finishSchemaBuffer(Builder builder, double offset); - - public static native void finishSizePrefixedSchemaBuffer(Builder builder, double offset); - - public static native Schema getRootAsSchema(ByteBuffer bb, Schema obj); - - public static native Schema getRootAsSchema(ByteBuffer bb); - - public static native Schema getSizePrefixedRootAsSchema(ByteBuffer bb, Schema obj); - - public static native Schema getSizePrefixedRootAsSchema(ByteBuffer bb); - - public static native void startCustomMetadataVector(Builder builder, double numElems); - - public static native void startFeaturesVector(Builder builder, double numElems); - - public static native void startFieldsVector(Builder builder, double numElems); - - public static native void startSchema(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Schema __init(double i, ByteBuffer bb); - - public native KeyValue customMetadata(double index, KeyValue obj); - - public native KeyValue customMetadata(double index); - - public native double customMetadataLength(); - - public native int endianness(); - - public native Long features(double index); - - public native double featuresLength(); - - public native Field fields(double index, Field obj); - - public native Field fields(double index); - - public native double fieldsLength(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Struct_.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Struct_.java deleted file mode 100644 index 62c88e3f8ae..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Struct_.java +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Struct_", - namespace = JsPackage.GLOBAL) -public class Struct_ { - public static native double createStruct_(Builder builder); - - public static native double endStruct_(Builder builder); - - public static native Struct_ getRootAsStruct_(ByteBuffer bb, Struct_ obj); - - public static native Struct_ getRootAsStruct_(ByteBuffer bb); - - public static native Struct_ getSizePrefixedRootAsStruct_(ByteBuffer bb, Struct_ obj); - - public static native Struct_ getSizePrefixedRootAsStruct_(ByteBuffer bb); - - public static native void startStruct_(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Struct_ __init(double i, ByteBuffer bb); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Time.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Time.java deleted file mode 100644 index 0f40072c5dd..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Time.java +++ /dev/null @@ -1,42 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Time", - namespace = JsPackage.GLOBAL) -public class Time { - public static native void addBitWidth(Builder builder, double bitWidth); - - public static native void addUnit(Builder builder, int unit); - - public static native double createTime(Builder builder, int unit, double bitWidth); - - public static native double endTime(Builder builder); - - public static native Time getRootAsTime(ByteBuffer bb, Time obj); - - public static native Time getRootAsTime(ByteBuffer bb); - - public static native Time getSizePrefixedRootAsTime(ByteBuffer bb, Time obj); - - public static native Time getSizePrefixedRootAsTime(ByteBuffer bb); - - public static native void startTime(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Time __init(double i, ByteBuffer bb); - - public native double bitWidth(); - - public native int unit(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/TimeUnit.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/TimeUnit.java deleted file mode 100644 index 780d7cc9e08..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/TimeUnit.java +++ /dev/null @@ -1,18 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.TimeUnit", - namespace = JsPackage.GLOBAL) -public class TimeUnit { - public static int MICROSECOND, - MILLISECOND, - NANOSECOND, - SECOND; -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Timestamp.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Timestamp.java deleted file mode 100644 index fa1ef0923ed..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Timestamp.java +++ /dev/null @@ -1,77 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import elemental2.core.Uint8Array; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Encoding; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Timestamp", - namespace = JsPackage.GLOBAL) -public class Timestamp { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface TimezoneUnionType { - @JsOverlay - static Timestamp.TimezoneUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default String asString() { - return Js.asString(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isString() { - return (Object) this instanceof String; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - public static native void addTimezone(Builder builder, double timezoneOffset); - - public static native void addUnit(Builder builder, int unit); - - public static native double createTimestamp( - Builder builder, int unit, double timezoneOffset); - - public static native double endTimestamp(Builder builder); - - public static native Timestamp getRootAsTimestamp(ByteBuffer bb, Timestamp obj); - - public static native Timestamp getRootAsTimestamp(ByteBuffer bb); - - public static native Timestamp getSizePrefixedRootAsTimestamp(ByteBuffer bb, Timestamp obj); - - public static native Timestamp getSizePrefixedRootAsTimestamp(ByteBuffer bb); - - public static native void startTimestamp(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Timestamp __init(double i, ByteBuffer bb); - - public native Timestamp.TimezoneUnionType timezone(); - - public native Timestamp.TimezoneUnionType timezone(Encoding optionalEncoding); - - public native int unit(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Type.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Type.java deleted file mode 100644 index 6336d2a547f..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Type.java +++ /dev/null @@ -1,36 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Type", - namespace = JsPackage.GLOBAL) -public class Type { - public static int Binary, - Bool, - Date, - Decimal, - Duration, - FixedSizeBinary, - FixedSizeList, - FloatingPoint, - Int, - Interval, - LargeBinary, - LargeList, - LargeUtf8, - List, - Map, - NONE, - Null, - Struct_, - Time, - Timestamp, - Union, - Utf8; -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Union.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Union.java deleted file mode 100644 index a3ff98e8975..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Union.java +++ /dev/null @@ -1,122 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import elemental2.core.Int32Array; -import elemental2.core.JsArray; -import elemental2.core.Uint8Array; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Union", - namespace = JsPackage.GLOBAL) -public class Union { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateTypeIdsVectorDataUnionType { - @JsOverlay - static Union.CreateTypeIdsVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int32Array asInt32Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt32Array() { - return (Object) this instanceof Int32Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - public static native void addMode(Builder builder, int mode); - - public static native void addTypeIds(Builder builder, double typeIdsOffset); - - @Deprecated - public static native double createTypeIdsVector( - Builder builder, Union.CreateTypeIdsVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createTypeIdsVector(Builder builder, Int32Array data) { - return createTypeIdsVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createTypeIdsVector(Builder builder, JsArray data) { - return createTypeIdsVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createTypeIdsVector(Builder builder, Uint8Array data) { - return createTypeIdsVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createTypeIdsVector(Builder builder, double[] data) { - return createTypeIdsVector(builder, Js.>uncheckedCast(data)); - } - - public static native double createUnion(Builder builder, int mode, double typeIdsOffset); - - public static native double endUnion(Builder builder); - - public static native Union getRootAsUnion(ByteBuffer bb, Union obj); - - public static native Union getRootAsUnion(ByteBuffer bb); - - public static native Union getSizePrefixedRootAsUnion(ByteBuffer bb, Union obj); - - public static native Union getSizePrefixedRootAsUnion(ByteBuffer bb); - - public static native void startTypeIdsVector(Builder builder, double numElems); - - public static native void startUnion(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Union __init(double i, ByteBuffer bb); - - public native int mode(); - - public native double typeIds(double index); - - public native Int32Array typeIdsArray(); - - public native double typeIdsLength(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/UnionMode.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/UnionMode.java deleted file mode 100644 index 30553887de2..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/UnionMode.java +++ /dev/null @@ -1,16 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.UnionMode", - namespace = JsPackage.GLOBAL) -public class UnionMode { - public static int Dense, - Sparse; -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Utf8.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Utf8.java deleted file mode 100644 index 1149f1f8977..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/arrow/flight/flatbuf/schema_generated/org/apache/arrow/flatbuf/Utf8.java +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.arrow.flight.flatbuf.schema_generated.org.apache.arrow.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.arrow.flight.flatbuf.Schema_generated.org.apache.arrow.flatbuf.Utf8", - namespace = JsPackage.GLOBAL) -public class Utf8 { - public static native double createUtf8(Builder builder); - - public static native double endUtf8(Builder builder); - - public static native Utf8 getRootAsUtf8(ByteBuffer bb, Utf8 obj); - - public static native Utf8 getRootAsUtf8(ByteBuffer bb); - - public static native Utf8 getSizePrefixedRootAsUtf8(ByteBuffer bb, Utf8 obj); - - public static native Utf8 getSizePrefixedRootAsUtf8(ByteBuffer bb); - - public static native void startUtf8(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native Utf8 __init(double i, ByteBuffer bb); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/flatbuffers/Builder.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/flatbuffers/Builder.java deleted file mode 100644 index 0c9118583d8..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/flatbuffers/Builder.java +++ /dev/null @@ -1,143 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.flatbuffers; - -import elemental2.core.Uint8Array; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType(isNative = true, name = "dhinternal.flatbuffers.Builder", namespace = JsPackage.GLOBAL) -public class Builder { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateStringSUnionType { - @JsOverlay - static Builder.CreateStringSUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default String asString() { - return Js.asString(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isString() { - return (Object) this instanceof String; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - public static native ByteBuffer growByteBuffer(ByteBuffer bb); - - public Builder() {} - - public Builder(double initial_size) {} - - public native void addFieldFloat32(double voffset, double value, double defaultValue); - - public native void addFieldFloat64(double voffset, double value, double defaultValue); - - public native void addFieldInt16(double voffset, double value, double defaultValue); - - public native void addFieldInt32(double voffset, double value, double defaultValue); - - public native void addFieldInt64(double voffset, Long value, Long defaultValue); - - public native void addFieldInt8(double voffset, double value, double defaultValue); - - public native void addFieldOffset(double voffset, double value, double defaultValue); - - public native void addFieldStruct(double voffset, double value, double defaultValue); - - public native void addFloat32(double value); - - public native void addFloat64(double value); - - public native void addInt16(double value); - - public native void addInt32(double value); - - public native void addInt64(Long value); - - public native void addInt8(double value); - - public native void addOffset(double offset); - - public native Uint8Array asUint8Array(); - - public native void clear(); - - public native Long createLong(double low, double high); - - public native double createString(Builder.CreateStringSUnionType s); - - @JsOverlay - public final double createString(String s) { - return createString(Js.uncheckedCast(s)); - } - - @JsOverlay - public final double createString(Uint8Array s) { - return createString(Js.uncheckedCast(s)); - } - - public native ByteBuffer dataBuffer(); - - public native double endObject(); - - public native double endVector(); - - public native void finish(double root_table, String file_identifier, boolean size_prefix); - - public native void finish(double root_table, String file_identifier); - - public native void finish(double root_table); - - public native void finishSizePrefixed(double root_table, String file_identifier); - - public native void finishSizePrefixed(double root_table); - - public native void forceDefaults(boolean forceDefaults); - - public native void nested(double obj); - - public native void notNested(); - - public native double offset(); - - public native void pad(double byte_size); - - public native void prep(double size, double additional_bytes); - - public native void requiredField(double table, double field); - - public native void slot(double voffset); - - public native void startObject(double numfields); - - public native void startVector(double elem_size, double num_elems, double alignment); - - public native void writeFloat32(double value); - - public native void writeFloat64(double value); - - public native void writeInt16(double value); - - public native void writeInt32(double value); - - public native void writeInt64(Long value); - - public native void writeInt8(double value); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/flatbuffers/ByteBuffer.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/flatbuffers/ByteBuffer.java deleted file mode 100644 index 85a71935d92..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/flatbuffers/ByteBuffer.java +++ /dev/null @@ -1,115 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.flatbuffers; - -import elemental2.core.Uint8Array; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType(isNative = true, name = "dhinternal.flatbuffers.ByteBuffer", namespace = JsPackage.GLOBAL) -public class ByteBuffer { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface __stringUnionType { - @JsOverlay - static ByteBuffer.__stringUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default String asString() { - return Js.asString(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isString() { - return (Object) this instanceof String; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - public static native ByteBuffer allocate(double byte_size); - - public ByteBuffer(Uint8Array bytes) {} - - public native boolean __has_identifier(String ident); - - public native double __indirect(double offset); - - public native double __offset(double bb_pos, double vtable_offset); - - public native ByteBuffer.__stringUnionType __string(double offset, int optionalEncoding); - - public native ByteBuffer.__stringUnionType __string(double offset); - - public native T __union(T t, double offset); - - public native double __vector(double offset); - - public native double __vector_len(double offset); - - public native Uint8Array bytes(); - - public native double capacity(); - - public native void clear(); - - public native Long createLong(double low, double high); - - public native String getBufferIdentifier(); - - public native double position(); - - public native double readFloat32(double offset); - - public native double readFloat64(double offset); - - public native double readInt16(double offset); - - public native double readInt32(double offset); - - public native Long readInt64(double offset); - - public native double readInt8(double offset); - - public native double readUint16(double offset); - - public native double readUint32(double offset); - - public native Long readUint64(double offset); - - public native double readUint8(double offset); - - public native void setPosition(double position); - - public native void writeFloat32(double offset, double value); - - public native void writeFloat64(double offset, double value); - - public native void writeInt16(double offset, double value); - - public native void writeInt32(double offset, double value); - - public native void writeInt64(double offset, Long value); - - public native void writeInt8(double offset, double value); - - public native void writeUint16(double offset, double value); - - public native void writeUint32(double offset, double value); - - public native void writeUint64(double offset, Long value); - - public native void writeUint8(double offset, double value); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/flatbuffers/Encoding.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/flatbuffers/Encoding.java deleted file mode 100644 index be269d6968a..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/flatbuffers/Encoding.java +++ /dev/null @@ -1,13 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.flatbuffers; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType(isNative = true, name = "dhinternal.flatbuffers.Encoding", namespace = JsPackage.GLOBAL) -public class Encoding { - public static int UTF16_STRING, - UTF8_BYTES; -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/flatbuffers/Long.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/flatbuffers/Long.java deleted file mode 100644 index e7551a82d7d..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/flatbuffers/Long.java +++ /dev/null @@ -1,25 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.flatbuffers; - -import jsinterop.annotations.JsMethod; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType(isNative = true, name = "dhinternal.flatbuffers.Long", namespace = JsPackage.GLOBAL) -public class Long { - public static Long ZERO; - - public static native Long create(double low, double high); - - public double high; - public double low; - - public Long(double low, double high) {} - - @JsMethod(name = "equals") - public native boolean equals_(Object other); - - public native double toFloat64(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/flatbuffers/Table.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/flatbuffers/Table.java deleted file mode 100644 index e2dcada04fb..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/flatbuffers/Table.java +++ /dev/null @@ -1,31 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.flatbuffers; - -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsProperty; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; -import jsinterop.base.JsPropertyMap; - -@JsType(isNative = true, name = "dhinternal.flatbuffers.Table", namespace = JsPackage.GLOBAL) -public interface Table { - @JsOverlay - static Table create() { - return Js.uncheckedCast(JsPropertyMap.of()); - } - - @JsProperty - ByteBuffer getBb(); - - @JsProperty - double getBb_pos(); - - @JsProperty - void setBb(ByteBuffer bb); - - @JsProperty - void setBb_pos(double bb_pos); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageMessageType.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageMessageType.java deleted file mode 100644 index 9dc50f672a7..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageMessageType.java +++ /dev/null @@ -1,23 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.io.deephaven.barrage.flatbuf.Barrage_generated.io.deephaven.barrage.flatbuf.BarrageMessageType", - namespace = JsPackage.GLOBAL) -public class BarrageMessageType { - public static int BarragePublicationRequest, - BarrageSerializationOptions, - BarrageSnapshotRequest, - BarrageSubscriptionRequest, - BarrageUpdateMetadata, - NewSessionRequest, - None, - RefreshSessionRequest, - SessionInfoResponse; -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageMessageWrapper.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageMessageWrapper.java deleted file mode 100644 index 7de97b929cd..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageMessageWrapper.java +++ /dev/null @@ -1,130 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf; - -import elemental2.core.Int8Array; -import elemental2.core.JsArray; -import elemental2.core.Uint8Array; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.io.deephaven.barrage.flatbuf.Barrage_generated.io.deephaven.barrage.flatbuf.BarrageMessageWrapper", - namespace = JsPackage.GLOBAL) -public class BarrageMessageWrapper { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateMsgPayloadVectorDataUnionType { - @JsOverlay - static BarrageMessageWrapper.CreateMsgPayloadVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - public static native void addMagic(Builder builder, double magic); - - public static native void addMsgPayload(Builder builder, double msgPayloadOffset); - - public static native void addMsgType(Builder builder, int msgType); - - public static native double createBarrageMessageWrapper( - Builder builder, double magic, int msgType, double msgPayloadOffset); - - @Deprecated - public static native double createMsgPayloadVector( - Builder builder, BarrageMessageWrapper.CreateMsgPayloadVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createMsgPayloadVector(Builder builder, Int8Array data) { - return createMsgPayloadVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createMsgPayloadVector(Builder builder, JsArray data) { - return createMsgPayloadVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createMsgPayloadVector(Builder builder, Uint8Array data) { - return createMsgPayloadVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createMsgPayloadVector(Builder builder, double[] data) { - return createMsgPayloadVector(builder, Js.>uncheckedCast(data)); - } - - public static native double endBarrageMessageWrapper(Builder builder); - - public static native BarrageMessageWrapper getRootAsBarrageMessageWrapper( - ByteBuffer bb, BarrageMessageWrapper obj); - - public static native BarrageMessageWrapper getRootAsBarrageMessageWrapper(ByteBuffer bb); - - public static native BarrageMessageWrapper getSizePrefixedRootAsBarrageMessageWrapper( - ByteBuffer bb, BarrageMessageWrapper obj); - - public static native BarrageMessageWrapper getSizePrefixedRootAsBarrageMessageWrapper( - ByteBuffer bb); - - public static native void startBarrageMessageWrapper(Builder builder); - - public static native void startMsgPayloadVector(Builder builder, double numElems); - - public ByteBuffer bb; - public double bb_pos; - - public native BarrageMessageWrapper __init(double i, ByteBuffer bb); - - public native double magic(); - - public native double msgPayload(double index); - - public native Int8Array msgPayloadArray(); - - public native double msgPayloadLength(); - - public native int msgType(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageModColumnMetadata.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageModColumnMetadata.java deleted file mode 100644 index 076793a4be2..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageModColumnMetadata.java +++ /dev/null @@ -1,125 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf; - -import elemental2.core.Int8Array; -import elemental2.core.JsArray; -import elemental2.core.Uint8Array; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.io.deephaven.barrage.flatbuf.Barrage_generated.io.deephaven.barrage.flatbuf.BarrageModColumnMetadata", - namespace = JsPackage.GLOBAL) -public class BarrageModColumnMetadata { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateModifiedRowsVectorDataUnionType { - @JsOverlay - static BarrageModColumnMetadata.CreateModifiedRowsVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - public static native void addModifiedRows(Builder builder, double modifiedRowsOffset); - - public static native double createBarrageModColumnMetadata( - Builder builder, double modifiedRowsOffset); - - @Deprecated - public static native double createModifiedRowsVector( - Builder builder, BarrageModColumnMetadata.CreateModifiedRowsVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createModifiedRowsVector(Builder builder, Int8Array data) { - return createModifiedRowsVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createModifiedRowsVector(Builder builder, JsArray data) { - return createModifiedRowsVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createModifiedRowsVector(Builder builder, Uint8Array data) { - return createModifiedRowsVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createModifiedRowsVector(Builder builder, double[] data) { - return createModifiedRowsVector(builder, Js.>uncheckedCast(data)); - } - - public static native double endBarrageModColumnMetadata(Builder builder); - - public static native BarrageModColumnMetadata getRootAsBarrageModColumnMetadata( - ByteBuffer bb, BarrageModColumnMetadata obj); - - public static native BarrageModColumnMetadata getRootAsBarrageModColumnMetadata(ByteBuffer bb); - - public static native BarrageModColumnMetadata getSizePrefixedRootAsBarrageModColumnMetadata( - ByteBuffer bb, BarrageModColumnMetadata obj); - - public static native BarrageModColumnMetadata getSizePrefixedRootAsBarrageModColumnMetadata( - ByteBuffer bb); - - public static native void startBarrageModColumnMetadata(Builder builder); - - public static native void startModifiedRowsVector(Builder builder, double numElems); - - public ByteBuffer bb; - public double bb_pos; - - public native BarrageModColumnMetadata __init(double i, ByteBuffer bb); - - public native double modifiedRows(double index); - - public native Int8Array modifiedRowsArray(); - - public native double modifiedRowsLength(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarragePublicationOptions.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarragePublicationOptions.java deleted file mode 100644 index 0726110f013..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarragePublicationOptions.java +++ /dev/null @@ -1,42 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.io.deephaven.barrage.flatbuf.Barrage_generated.io.deephaven.barrage.flatbuf.BarragePublicationOptions", - namespace = JsPackage.GLOBAL) -public class BarragePublicationOptions { - public static native void addUseDeephavenNulls(Builder builder, boolean useDeephavenNulls); - - public static native double createBarragePublicationOptions( - Builder builder, boolean useDeephavenNulls); - - public static native double endBarragePublicationOptions(Builder builder); - - public static native BarragePublicationOptions getRootAsBarragePublicationOptions( - ByteBuffer bb, BarragePublicationOptions obj); - - public static native BarragePublicationOptions getRootAsBarragePublicationOptions(ByteBuffer bb); - - public static native BarragePublicationOptions getSizePrefixedRootAsBarragePublicationOptions( - ByteBuffer bb, BarragePublicationOptions obj); - - public static native BarragePublicationOptions getSizePrefixedRootAsBarragePublicationOptions( - ByteBuffer bb); - - public static native void startBarragePublicationOptions(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native BarragePublicationOptions __init(double i, ByteBuffer bb); - - public native boolean useDeephavenNulls(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarragePublicationRequest.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarragePublicationRequest.java deleted file mode 100644 index ee5fbe08fcc..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarragePublicationRequest.java +++ /dev/null @@ -1,125 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf; - -import elemental2.core.Int8Array; -import elemental2.core.JsArray; -import elemental2.core.Uint8Array; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.io.deephaven.barrage.flatbuf.Barrage_generated.io.deephaven.barrage.flatbuf.BarragePublicationRequest", - namespace = JsPackage.GLOBAL) -public class BarragePublicationRequest { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateTicketVectorDataUnionType { - @JsOverlay - static BarragePublicationRequest.CreateTicketVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - public static native void addPublishOptions(Builder builder, double publishOptionsOffset); - - public static native void addTicket(Builder builder, double ticketOffset); - - @Deprecated - public static native double createTicketVector( - Builder builder, BarragePublicationRequest.CreateTicketVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createTicketVector(Builder builder, Int8Array data) { - return createTicketVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createTicketVector(Builder builder, JsArray data) { - return createTicketVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createTicketVector(Builder builder, Uint8Array data) { - return createTicketVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createTicketVector(Builder builder, double[] data) { - return createTicketVector(builder, Js.>uncheckedCast(data)); - } - - public static native double endBarragePublicationRequest(Builder builder); - - public static native BarragePublicationRequest getRootAsBarragePublicationRequest( - ByteBuffer bb, BarragePublicationRequest obj); - - public static native BarragePublicationRequest getRootAsBarragePublicationRequest(ByteBuffer bb); - - public static native BarragePublicationRequest getSizePrefixedRootAsBarragePublicationRequest( - ByteBuffer bb, BarragePublicationRequest obj); - - public static native BarragePublicationRequest getSizePrefixedRootAsBarragePublicationRequest( - ByteBuffer bb); - - public static native void startBarragePublicationRequest(Builder builder); - - public static native void startTicketVector(Builder builder, double numElems); - - public ByteBuffer bb; - public double bb_pos; - - public native BarragePublicationRequest __init(double i, ByteBuffer bb); - - public native BarragePublicationOptions publishOptions(); - - public native BarragePublicationOptions publishOptions(BarragePublicationOptions obj); - - public native double ticket(double index); - - public native Int8Array ticketArray(); - - public native double ticketLength(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageSnapshotOptions.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageSnapshotOptions.java deleted file mode 100644 index efedac5d190..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageSnapshotOptions.java +++ /dev/null @@ -1,59 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.io.deephaven.barrage.flatbuf.Barrage_generated.io.deephaven.barrage.flatbuf.BarrageSnapshotOptions", - namespace = JsPackage.GLOBAL) -public class BarrageSnapshotOptions { - public static native void addBatchSize(Builder builder, double batchSize); - - public static native void addColumnConversionMode( - Builder builder, int columnConversionMode); - - public static native void addMaxMessageSize(Builder builder, double maxMessageSize); - - public static native void addUseDeephavenNulls(Builder builder, boolean useDeephavenNulls); - - public static native double createBarrageSnapshotOptions( - Builder builder, - int columnConversionMode, - boolean useDeephavenNulls, - double batchSize, - double maxMessageSize); - - public static native double endBarrageSnapshotOptions(Builder builder); - - public static native BarrageSnapshotOptions getRootAsBarrageSnapshotOptions( - ByteBuffer bb, BarrageSnapshotOptions obj); - - public static native BarrageSnapshotOptions getRootAsBarrageSnapshotOptions(ByteBuffer bb); - - public static native BarrageSnapshotOptions getSizePrefixedRootAsBarrageSnapshotOptions( - ByteBuffer bb, BarrageSnapshotOptions obj); - - public static native BarrageSnapshotOptions getSizePrefixedRootAsBarrageSnapshotOptions( - ByteBuffer bb); - - public static native void startBarrageSnapshotOptions(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native BarrageSnapshotOptions __init(double i, ByteBuffer bb); - - public native double batchSize(); - - public native int columnConversionMode(); - - public native double maxMessageSize(); - - public native boolean useDeephavenNulls(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageSnapshotRequest.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageSnapshotRequest.java deleted file mode 100644 index 8e8d43e6c58..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageSnapshotRequest.java +++ /dev/null @@ -1,287 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf; - -import elemental2.core.Int8Array; -import elemental2.core.JsArray; -import elemental2.core.Uint8Array; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.io.deephaven.barrage.flatbuf.Barrage_generated.io.deephaven.barrage.flatbuf.BarrageSnapshotRequest", - namespace = JsPackage.GLOBAL) -public class BarrageSnapshotRequest { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateColumnsVectorDataUnionType { - @JsOverlay - static BarrageSnapshotRequest.CreateColumnsVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateTicketVectorDataUnionType { - @JsOverlay - static BarrageSnapshotRequest.CreateTicketVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateViewportVectorDataUnionType { - @JsOverlay - static BarrageSnapshotRequest.CreateViewportVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - public static native void addColumns(Builder builder, double columnsOffset); - - public static native void addReverseViewport(Builder builder, boolean reverseViewport); - - public static native void addSnapshotOptions(Builder builder, double snapshotOptionsOffset); - - public static native void addTicket(Builder builder, double ticketOffset); - - public static native void addViewport(Builder builder, double viewportOffset); - - @Deprecated - public static native double createColumnsVector( - Builder builder, BarrageSnapshotRequest.CreateColumnsVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createColumnsVector(Builder builder, Int8Array data) { - return createColumnsVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createColumnsVector(Builder builder, JsArray data) { - return createColumnsVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createColumnsVector(Builder builder, Uint8Array data) { - return createColumnsVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createColumnsVector(Builder builder, double[] data) { - return createColumnsVector(builder, Js.>uncheckedCast(data)); - } - - @Deprecated - public static native double createTicketVector( - Builder builder, BarrageSnapshotRequest.CreateTicketVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createTicketVector(Builder builder, Int8Array data) { - return createTicketVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createTicketVector(Builder builder, JsArray data) { - return createTicketVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createTicketVector(Builder builder, Uint8Array data) { - return createTicketVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createTicketVector(Builder builder, double[] data) { - return createTicketVector(builder, Js.>uncheckedCast(data)); - } - - @Deprecated - public static native double createViewportVector( - Builder builder, BarrageSnapshotRequest.CreateViewportVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createViewportVector(Builder builder, Int8Array data) { - return createViewportVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createViewportVector(Builder builder, JsArray data) { - return createViewportVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createViewportVector(Builder builder, Uint8Array data) { - return createViewportVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createViewportVector(Builder builder, double[] data) { - return createViewportVector(builder, Js.>uncheckedCast(data)); - } - - public static native double endBarrageSnapshotRequest(Builder builder); - - public static native BarrageSnapshotRequest getRootAsBarrageSnapshotRequest( - ByteBuffer bb, BarrageSnapshotRequest obj); - - public static native BarrageSnapshotRequest getRootAsBarrageSnapshotRequest(ByteBuffer bb); - - public static native BarrageSnapshotRequest getSizePrefixedRootAsBarrageSnapshotRequest( - ByteBuffer bb, BarrageSnapshotRequest obj); - - public static native BarrageSnapshotRequest getSizePrefixedRootAsBarrageSnapshotRequest( - ByteBuffer bb); - - public static native void startBarrageSnapshotRequest(Builder builder); - - public static native void startColumnsVector(Builder builder, double numElems); - - public static native void startTicketVector(Builder builder, double numElems); - - public static native void startViewportVector(Builder builder, double numElems); - - public ByteBuffer bb; - public double bb_pos; - - public native BarrageSnapshotRequest __init(double i, ByteBuffer bb); - - public native double columns(double index); - - public native Int8Array columnsArray(); - - public native double columnsLength(); - - public native boolean reverseViewport(); - - public native BarrageSnapshotOptions snapshotOptions(); - - public native BarrageSnapshotOptions snapshotOptions(BarrageSnapshotOptions obj); - - public native double ticket(double index); - - public native Int8Array ticketArray(); - - public native double ticketLength(); - - public native double viewport(double index); - - public native Int8Array viewportArray(); - - public native double viewportLength(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageSubscriptionOptions.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageSubscriptionOptions.java deleted file mode 100644 index 9b6d39b53ec..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageSubscriptionOptions.java +++ /dev/null @@ -1,65 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf; - -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.io.deephaven.barrage.flatbuf.Barrage_generated.io.deephaven.barrage.flatbuf.BarrageSubscriptionOptions", - namespace = JsPackage.GLOBAL) -public class BarrageSubscriptionOptions { - public static native void addBatchSize(Builder builder, double batchSize); - - public static native void addColumnConversionMode( - Builder builder, int columnConversionMode); - - public static native void addMaxMessageSize(Builder builder, double maxMessageSize); - - public static native void addMinUpdateIntervalMs(Builder builder, double minUpdateIntervalMs); - - public static native void addUseDeephavenNulls(Builder builder, boolean useDeephavenNulls); - - public static native double createBarrageSubscriptionOptions( - Builder builder, - int columnConversionMode, - boolean useDeephavenNulls, - double minUpdateIntervalMs, - double batchSize, - double maxMessageSize); - - public static native double endBarrageSubscriptionOptions(Builder builder); - - public static native BarrageSubscriptionOptions getRootAsBarrageSubscriptionOptions( - ByteBuffer bb, BarrageSubscriptionOptions obj); - - public static native BarrageSubscriptionOptions getRootAsBarrageSubscriptionOptions( - ByteBuffer bb); - - public static native BarrageSubscriptionOptions getSizePrefixedRootAsBarrageSubscriptionOptions( - ByteBuffer bb, BarrageSubscriptionOptions obj); - - public static native BarrageSubscriptionOptions getSizePrefixedRootAsBarrageSubscriptionOptions( - ByteBuffer bb); - - public static native void startBarrageSubscriptionOptions(Builder builder); - - public ByteBuffer bb; - public double bb_pos; - - public native BarrageSubscriptionOptions __init(double i, ByteBuffer bb); - - public native double batchSize(); - - public native int columnConversionMode(); - - public native double maxMessageSize(); - - public native double minUpdateIntervalMs(); - - public native boolean useDeephavenNulls(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageSubscriptionRequest.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageSubscriptionRequest.java deleted file mode 100644 index 807184ee34c..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageSubscriptionRequest.java +++ /dev/null @@ -1,298 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf; - -import elemental2.core.Int8Array; -import elemental2.core.JsArray; -import elemental2.core.Uint8Array; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.io.deephaven.barrage.flatbuf.Barrage_generated.io.deephaven.barrage.flatbuf.BarrageSubscriptionRequest", - namespace = JsPackage.GLOBAL) -public class BarrageSubscriptionRequest { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateColumnsVectorDataUnionType { - @JsOverlay - static BarrageSubscriptionRequest.CreateColumnsVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateTicketVectorDataUnionType { - @JsOverlay - static BarrageSubscriptionRequest.CreateTicketVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateViewportVectorDataUnionType { - @JsOverlay - static BarrageSubscriptionRequest.CreateViewportVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - public static native void addColumns(Builder builder, double columnsOffset); - - public static native void addReverseViewport(Builder builder, boolean reverseViewport); - - public static native void addSubscriptionOptions( - Builder builder, double subscriptionOptionsOffset); - - public static native void addTicket(Builder builder, double ticketOffset); - - public static native void addViewport(Builder builder, double viewportOffset); - - @Deprecated - public static native double createColumnsVector( - Builder builder, BarrageSubscriptionRequest.CreateColumnsVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createColumnsVector(Builder builder, Int8Array data) { - return createColumnsVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createColumnsVector(Builder builder, JsArray data) { - return createColumnsVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createColumnsVector(Builder builder, Uint8Array data) { - return createColumnsVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createColumnsVector(Builder builder, double[] data) { - return createColumnsVector(builder, Js.>uncheckedCast(data)); - } - - @Deprecated - public static native double createTicketVector( - Builder builder, BarrageSubscriptionRequest.CreateTicketVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createTicketVector(Builder builder, Int8Array data) { - return createTicketVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createTicketVector(Builder builder, JsArray data) { - return createTicketVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createTicketVector(Builder builder, Uint8Array data) { - return createTicketVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createTicketVector(Builder builder, double[] data) { - return createTicketVector(builder, Js.>uncheckedCast(data)); - } - - @Deprecated - public static native double createViewportVector( - Builder builder, BarrageSubscriptionRequest.CreateViewportVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createViewportVector(Builder builder, Int8Array data) { - return createViewportVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createViewportVector(Builder builder, JsArray data) { - return createViewportVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createViewportVector(Builder builder, Uint8Array data) { - return createViewportVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createViewportVector(Builder builder, double[] data) { - return createViewportVector(builder, Js.>uncheckedCast(data)); - } - - public static native double endBarrageSubscriptionRequest(Builder builder); - - public static native BarrageSubscriptionRequest getRootAsBarrageSubscriptionRequest( - ByteBuffer bb, BarrageSubscriptionRequest obj); - - public static native BarrageSubscriptionRequest getRootAsBarrageSubscriptionRequest( - ByteBuffer bb); - - public static native BarrageSubscriptionRequest getSizePrefixedRootAsBarrageSubscriptionRequest( - ByteBuffer bb, BarrageSubscriptionRequest obj); - - public static native BarrageSubscriptionRequest getSizePrefixedRootAsBarrageSubscriptionRequest( - ByteBuffer bb); - - public static native void startBarrageSubscriptionRequest(Builder builder); - - public static native void startColumnsVector(Builder builder, double numElems); - - public static native void startTicketVector(Builder builder, double numElems); - - public static native void startViewportVector(Builder builder, double numElems); - - public ByteBuffer bb; - public double bb_pos; - - public native BarrageSubscriptionRequest __init(double i, ByteBuffer bb); - - public native double columns(double index); - - public native Int8Array columnsArray(); - - public native double columnsLength(); - - public native boolean reverseViewport(); - - public native BarrageSubscriptionOptions subscriptionOptions(); - - public native BarrageSubscriptionOptions subscriptionOptions(BarrageSubscriptionOptions obj); - - public native double ticket(double index); - - public native Int8Array ticketArray(); - - public native double ticketLength(); - - public native double viewport(double index); - - public native Int8Array viewportArray(); - - public native double viewportLength(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageUpdateMetadata.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageUpdateMetadata.java deleted file mode 100644 index 3d9f4bd51df..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/BarrageUpdateMetadata.java +++ /dev/null @@ -1,575 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf; - -import elemental2.core.Int8Array; -import elemental2.core.JsArray; -import elemental2.core.Uint8Array; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Long; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.io.deephaven.barrage.flatbuf.Barrage_generated.io.deephaven.barrage.flatbuf.BarrageUpdateMetadata", - namespace = JsPackage.GLOBAL) -public class BarrageUpdateMetadata { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateAddedRowsIncludedVectorDataUnionType { - @JsOverlay - static BarrageUpdateMetadata.CreateAddedRowsIncludedVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateAddedRowsVectorDataUnionType { - @JsOverlay - static BarrageUpdateMetadata.CreateAddedRowsVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateEffectiveColumnSetVectorDataUnionType { - @JsOverlay - static BarrageUpdateMetadata.CreateEffectiveColumnSetVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateEffectiveViewportVectorDataUnionType { - @JsOverlay - static BarrageUpdateMetadata.CreateEffectiveViewportVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateRemovedRowsVectorDataUnionType { - @JsOverlay - static BarrageUpdateMetadata.CreateRemovedRowsVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateShiftDataVectorDataUnionType { - @JsOverlay - static BarrageUpdateMetadata.CreateShiftDataVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - public static native void addAddedRows(Builder builder, double addedRowsOffset); - - public static native void addAddedRowsIncluded(Builder builder, double addedRowsIncludedOffset); - - public static native void addEffectiveColumnSet(Builder builder, double effectiveColumnSetOffset); - - public static native void addEffectiveReverseViewport( - Builder builder, boolean effectiveReverseViewport); - - public static native void addEffectiveViewport(Builder builder, double effectiveViewportOffset); - - public static native void addFirstSeq(Builder builder, Long firstSeq); - - public static native void addIsSnapshot(Builder builder, boolean isSnapshot); - - public static native void addLastSeq(Builder builder, Long lastSeq); - - public static native void addModColumnNodes(Builder builder, double modColumnNodesOffset); - - public static native void addRemovedRows(Builder builder, double removedRowsOffset); - - public static native void addShiftData(Builder builder, double shiftDataOffset); - - @Deprecated - public static native double createAddedRowsIncludedVector( - Builder builder, BarrageUpdateMetadata.CreateAddedRowsIncludedVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createAddedRowsIncludedVector(Builder builder, Int8Array data) { - return createAddedRowsIncludedVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createAddedRowsIncludedVector(Builder builder, JsArray data) { - return createAddedRowsIncludedVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createAddedRowsIncludedVector(Builder builder, Uint8Array data) { - return createAddedRowsIncludedVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createAddedRowsIncludedVector(Builder builder, double[] data) { - return createAddedRowsIncludedVector(builder, Js.>uncheckedCast(data)); - } - - @Deprecated - public static native double createAddedRowsVector( - Builder builder, BarrageUpdateMetadata.CreateAddedRowsVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createAddedRowsVector(Builder builder, Int8Array data) { - return createAddedRowsVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createAddedRowsVector(Builder builder, JsArray data) { - return createAddedRowsVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createAddedRowsVector(Builder builder, Uint8Array data) { - return createAddedRowsVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createAddedRowsVector(Builder builder, double[] data) { - return createAddedRowsVector(builder, Js.>uncheckedCast(data)); - } - - public static native double createBarrageUpdateMetadata( - Builder builder, - Long firstSeq, - Long lastSeq, - boolean isSnapshot, - double effectiveViewportOffset, - boolean effectiveReverseViewport, - double effectiveColumnSetOffset, - double addedRowsOffset, - double removedRowsOffset, - double shiftDataOffset, - double addedRowsIncludedOffset, - double modColumnNodesOffset); - - @Deprecated - public static native double createEffectiveColumnSetVector( - Builder builder, BarrageUpdateMetadata.CreateEffectiveColumnSetVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createEffectiveColumnSetVector(Builder builder, Int8Array data) { - return createEffectiveColumnSetVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createEffectiveColumnSetVector(Builder builder, JsArray data) { - return createEffectiveColumnSetVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createEffectiveColumnSetVector(Builder builder, Uint8Array data) { - return createEffectiveColumnSetVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createEffectiveColumnSetVector(Builder builder, double[] data) { - return createEffectiveColumnSetVector(builder, Js.>uncheckedCast(data)); - } - - @Deprecated - public static native double createEffectiveViewportVector( - Builder builder, BarrageUpdateMetadata.CreateEffectiveViewportVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createEffectiveViewportVector(Builder builder, Int8Array data) { - return createEffectiveViewportVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createEffectiveViewportVector(Builder builder, JsArray data) { - return createEffectiveViewportVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createEffectiveViewportVector(Builder builder, Uint8Array data) { - return createEffectiveViewportVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createEffectiveViewportVector(Builder builder, double[] data) { - return createEffectiveViewportVector(builder, Js.>uncheckedCast(data)); - } - - public static native double createModColumnNodesVector(Builder builder, JsArray data); - - @JsOverlay - public static final double createModColumnNodesVector(Builder builder, double[] data) { - return createModColumnNodesVector(builder, Js.>uncheckedCast(data)); - } - - @Deprecated - public static native double createRemovedRowsVector( - Builder builder, BarrageUpdateMetadata.CreateRemovedRowsVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createRemovedRowsVector(Builder builder, Int8Array data) { - return createRemovedRowsVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createRemovedRowsVector(Builder builder, JsArray data) { - return createRemovedRowsVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createRemovedRowsVector(Builder builder, Uint8Array data) { - return createRemovedRowsVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createRemovedRowsVector(Builder builder, double[] data) { - return createRemovedRowsVector(builder, Js.>uncheckedCast(data)); - } - - @Deprecated - public static native double createShiftDataVector( - Builder builder, BarrageUpdateMetadata.CreateShiftDataVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createShiftDataVector(Builder builder, Int8Array data) { - return createShiftDataVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createShiftDataVector(Builder builder, JsArray data) { - return createShiftDataVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createShiftDataVector(Builder builder, Uint8Array data) { - return createShiftDataVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createShiftDataVector(Builder builder, double[] data) { - return createShiftDataVector(builder, Js.>uncheckedCast(data)); - } - - public static native double endBarrageUpdateMetadata(Builder builder); - - public static native BarrageUpdateMetadata getRootAsBarrageUpdateMetadata( - ByteBuffer bb, BarrageUpdateMetadata obj); - - public static native BarrageUpdateMetadata getRootAsBarrageUpdateMetadata(ByteBuffer bb); - - public static native BarrageUpdateMetadata getSizePrefixedRootAsBarrageUpdateMetadata( - ByteBuffer bb, BarrageUpdateMetadata obj); - - public static native BarrageUpdateMetadata getSizePrefixedRootAsBarrageUpdateMetadata( - ByteBuffer bb); - - public static native void startAddedRowsIncludedVector(Builder builder, double numElems); - - public static native void startAddedRowsVector(Builder builder, double numElems); - - public static native void startBarrageUpdateMetadata(Builder builder); - - public static native void startEffectiveColumnSetVector(Builder builder, double numElems); - - public static native void startEffectiveViewportVector(Builder builder, double numElems); - - public static native void startModColumnNodesVector(Builder builder, double numElems); - - public static native void startRemovedRowsVector(Builder builder, double numElems); - - public static native void startShiftDataVector(Builder builder, double numElems); - - public ByteBuffer bb; - public double bb_pos; - - public native BarrageUpdateMetadata __init(double i, ByteBuffer bb); - - public native double addedRows(double index); - - public native Int8Array addedRowsArray(); - - public native double addedRowsIncluded(double index); - - public native Int8Array addedRowsIncludedArray(); - - public native double addedRowsIncludedLength(); - - public native double addedRowsLength(); - - public native double effectiveColumnSet(double index); - - public native Int8Array effectiveColumnSetArray(); - - public native double effectiveColumnSetLength(); - - public native boolean effectiveReverseViewport(); - - public native double effectiveViewport(double index); - - public native Int8Array effectiveViewportArray(); - - public native double effectiveViewportLength(); - - public native Long firstSeq(); - - public native boolean isSnapshot(); - - public native Long lastSeq(); - - public native BarrageModColumnMetadata modColumnNodes(double index, BarrageModColumnMetadata obj); - - public native BarrageModColumnMetadata modColumnNodes(double index); - - public native double modColumnNodesLength(); - - public native double removedRows(double index); - - public native Int8Array removedRowsArray(); - - public native double removedRowsLength(); - - public native double shiftData(double index); - - public native Int8Array shiftDataArray(); - - public native double shiftDataLength(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/ColumnConversionMode.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/ColumnConversionMode.java deleted file mode 100644 index 30a750f44a6..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/ColumnConversionMode.java +++ /dev/null @@ -1,17 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf; - -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; - -@JsType( - isNative = true, - name = "dhinternal.io.deephaven.barrage.flatbuf.Barrage_generated.io.deephaven.barrage.flatbuf.ColumnConversionMode", - namespace = JsPackage.GLOBAL) -public class ColumnConversionMode { - public static int JavaSerialization, - Stringify, - ThrowError; -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/NewSessionRequest.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/NewSessionRequest.java deleted file mode 100644 index a1f002c434a..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/NewSessionRequest.java +++ /dev/null @@ -1,125 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf; - -import elemental2.core.Int8Array; -import elemental2.core.JsArray; -import elemental2.core.Uint8Array; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.io.deephaven.barrage.flatbuf.Barrage_generated.io.deephaven.barrage.flatbuf.NewSessionRequest", - namespace = JsPackage.GLOBAL) -public class NewSessionRequest { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreatePayloadVectorDataUnionType { - @JsOverlay - static NewSessionRequest.CreatePayloadVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - public static native void addPayload(Builder builder, double payloadOffset); - - public static native void addProtocolVersion(Builder builder, double protocolVersion); - - public static native double createNewSessionRequest( - Builder builder, double protocolVersion, double payloadOffset); - - @Deprecated - public static native double createPayloadVector( - Builder builder, NewSessionRequest.CreatePayloadVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createPayloadVector(Builder builder, Int8Array data) { - return createPayloadVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createPayloadVector(Builder builder, JsArray data) { - return createPayloadVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createPayloadVector(Builder builder, Uint8Array data) { - return createPayloadVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createPayloadVector(Builder builder, double[] data) { - return createPayloadVector(builder, Js.>uncheckedCast(data)); - } - - public static native double endNewSessionRequest(Builder builder); - - public static native NewSessionRequest getRootAsNewSessionRequest( - ByteBuffer bb, NewSessionRequest obj); - - public static native NewSessionRequest getRootAsNewSessionRequest(ByteBuffer bb); - - public static native NewSessionRequest getSizePrefixedRootAsNewSessionRequest( - ByteBuffer bb, NewSessionRequest obj); - - public static native NewSessionRequest getSizePrefixedRootAsNewSessionRequest(ByteBuffer bb); - - public static native void startNewSessionRequest(Builder builder); - - public static native void startPayloadVector(Builder builder, double numElems); - - public ByteBuffer bb; - public double bb_pos; - - public native NewSessionRequest __init(double i, ByteBuffer bb); - - public native double payload(double index); - - public native Int8Array payloadArray(); - - public native double payloadLength(); - - public native double protocolVersion(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/RefreshSessionRequest.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/RefreshSessionRequest.java deleted file mode 100644 index 3fcc2501206..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/RefreshSessionRequest.java +++ /dev/null @@ -1,121 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf; - -import elemental2.core.Int8Array; -import elemental2.core.JsArray; -import elemental2.core.Uint8Array; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.io.deephaven.barrage.flatbuf.Barrage_generated.io.deephaven.barrage.flatbuf.RefreshSessionRequest", - namespace = JsPackage.GLOBAL) -public class RefreshSessionRequest { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateSessionVectorDataUnionType { - @JsOverlay - static RefreshSessionRequest.CreateSessionVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - public static native void addSession(Builder builder, double sessionOffset); - - public static native double createRefreshSessionRequest(Builder builder, double sessionOffset); - - @Deprecated - public static native double createSessionVector( - Builder builder, RefreshSessionRequest.CreateSessionVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createSessionVector(Builder builder, Int8Array data) { - return createSessionVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createSessionVector(Builder builder, JsArray data) { - return createSessionVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createSessionVector(Builder builder, Uint8Array data) { - return createSessionVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createSessionVector(Builder builder, double[] data) { - return createSessionVector(builder, Js.>uncheckedCast(data)); - } - - public static native double endRefreshSessionRequest(Builder builder); - - public static native RefreshSessionRequest getRootAsRefreshSessionRequest( - ByteBuffer bb, RefreshSessionRequest obj); - - public static native RefreshSessionRequest getRootAsRefreshSessionRequest(ByteBuffer bb); - - public static native RefreshSessionRequest getSizePrefixedRootAsRefreshSessionRequest( - ByteBuffer bb, RefreshSessionRequest obj); - - public static native RefreshSessionRequest getSizePrefixedRootAsRefreshSessionRequest( - ByteBuffer bb); - - public static native void startRefreshSessionRequest(Builder builder); - - public static native void startSessionVector(Builder builder, double numElems); - - public ByteBuffer bb; - public double bb_pos; - - public native RefreshSessionRequest __init(double i, ByteBuffer bb); - - public native double session(double index); - - public native Int8Array sessionArray(); - - public native double sessionLength(); -} diff --git a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/SessionInfoResponse.java b/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/SessionInfoResponse.java deleted file mode 100644 index 39658a0f27b..00000000000 --- a/web/client-backplane/src/main/java/io/deephaven/javascript/proto/dhinternal/io/deephaven/barrage/flatbuf/barrage_generated/io/deephaven/barrage/flatbuf/SessionInfoResponse.java +++ /dev/null @@ -1,211 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.javascript.proto.dhinternal.io.deephaven.barrage.flatbuf.barrage_generated.io.deephaven.barrage.flatbuf; - -import elemental2.core.Int8Array; -import elemental2.core.JsArray; -import elemental2.core.Uint8Array; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Builder; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.ByteBuffer; -import io.deephaven.javascript.proto.dhinternal.flatbuffers.Long; -import jsinterop.annotations.JsOverlay; -import jsinterop.annotations.JsPackage; -import jsinterop.annotations.JsType; -import jsinterop.base.Js; - -@JsType( - isNative = true, - name = "dhinternal.io.deephaven.barrage.flatbuf.Barrage_generated.io.deephaven.barrage.flatbuf.SessionInfoResponse", - namespace = JsPackage.GLOBAL) -public class SessionInfoResponse { - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateMetadataHeaderVectorDataUnionType { - @JsOverlay - static SessionInfoResponse.CreateMetadataHeaderVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - @JsType(isNative = true, name = "?", namespace = JsPackage.GLOBAL) - public interface CreateSessionTokenVectorDataUnionType { - @JsOverlay - static SessionInfoResponse.CreateSessionTokenVectorDataUnionType of(Object o) { - return Js.cast(o); - } - - @JsOverlay - default Int8Array asInt8Array() { - return Js.cast(this); - } - - @JsOverlay - default JsArray asJsArray() { - return Js.cast(this); - } - - @JsOverlay - default Uint8Array asUint8Array() { - return Js.cast(this); - } - - @JsOverlay - default boolean isInt8Array() { - return (Object) this instanceof Int8Array; - } - - @JsOverlay - default boolean isJsArray() { - return (Object) this instanceof JsArray; - } - - @JsOverlay - default boolean isUint8Array() { - return (Object) this instanceof Uint8Array; - } - } - - public static native void addMetadataHeader(Builder builder, double metadataHeaderOffset); - - public static native void addSessionToken(Builder builder, double sessionTokenOffset); - - public static native void addTokenRefreshDeadlineMs(Builder builder, Long tokenRefreshDeadlineMs); - - @Deprecated - public static native double createMetadataHeaderVector( - Builder builder, SessionInfoResponse.CreateMetadataHeaderVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createMetadataHeaderVector(Builder builder, Int8Array data) { - return createMetadataHeaderVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createMetadataHeaderVector(Builder builder, JsArray data) { - return createMetadataHeaderVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createMetadataHeaderVector(Builder builder, Uint8Array data) { - return createMetadataHeaderVector( - builder, - Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createMetadataHeaderVector(Builder builder, double[] data) { - return createMetadataHeaderVector(builder, Js.>uncheckedCast(data)); - } - - public static native double createSessionInfoResponse( - Builder builder, - double metadataHeaderOffset, - double sessionTokenOffset, - Long tokenRefreshDeadlineMs); - - @Deprecated - public static native double createSessionTokenVector( - Builder builder, SessionInfoResponse.CreateSessionTokenVectorDataUnionType data); - - @JsOverlay - @Deprecated - public static final double createSessionTokenVector(Builder builder, Int8Array data) { - return createSessionTokenVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createSessionTokenVector(Builder builder, JsArray data) { - return createSessionTokenVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createSessionTokenVector(Builder builder, Uint8Array data) { - return createSessionTokenVector( - builder, Js.uncheckedCast(data)); - } - - @JsOverlay - @Deprecated - public static final double createSessionTokenVector(Builder builder, double[] data) { - return createSessionTokenVector(builder, Js.>uncheckedCast(data)); - } - - public static native double endSessionInfoResponse(Builder builder); - - public static native SessionInfoResponse getRootAsSessionInfoResponse( - ByteBuffer bb, SessionInfoResponse obj); - - public static native SessionInfoResponse getRootAsSessionInfoResponse(ByteBuffer bb); - - public static native SessionInfoResponse getSizePrefixedRootAsSessionInfoResponse( - ByteBuffer bb, SessionInfoResponse obj); - - public static native SessionInfoResponse getSizePrefixedRootAsSessionInfoResponse(ByteBuffer bb); - - public static native void startMetadataHeaderVector(Builder builder, double numElems); - - public static native void startSessionInfoResponse(Builder builder); - - public static native void startSessionTokenVector(Builder builder, double numElems); - - public ByteBuffer bb; - public double bb_pos; - - public native SessionInfoResponse __init(double i, ByteBuffer bb); - - public native double metadataHeader(double index); - - public native Int8Array metadataHeaderArray(); - - public native double metadataHeaderLength(); - - public native double sessionToken(double index); - - public native Int8Array sessionTokenArray(); - - public native double sessionTokenLength(); - - public native Long tokenRefreshDeadlineMs(); -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/ColumnStatistics.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/ColumnStatistics.java deleted file mode 100644 index 7a72d3806d5..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/ColumnStatistics.java +++ /dev/null @@ -1,169 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data; - -import java.io.Serializable; -import java.util.Arrays; - -/** - * A DTO containing the result data from a call to GenerateComparableStatsFunction or GenerateNumericalStatsFunction - */ -public class ColumnStatistics implements Serializable { - public enum ColumnType { - NUMERIC, COMPARABLE, DATETIME, NON_COMPARABLE, - } - - private ColumnType type; - private long size; - private long count; - - // Data from a GenerateComparableStatsFunction - private int numUnique; - private String[] uniqueKeys; - private long[] uniqueValues; - - // Data from a GenerateNumericalStatsFunction - private double sum; - private double absSum; - private double min; - private double max; - private double absMin; - private double absMax; - - // Data from a GenerateDateTimeStatsFunction - private long minDateTime; - private long maxDateTime; - - public ColumnType getType() { - return type; - } - - public void setType(ColumnType type) { - this.type = type; - } - - public long getSize() { - return size; - } - - public void setSize(final long size) { - this.size = size; - } - - public long getCount() { - return count; - } - - public void setCount(long count) { - this.count = count; - } - - public int getNumUnique() { - return numUnique; - } - - public void setNumUnique(int numUnique) { - this.numUnique = numUnique; - } - - public String[] getUniqueKeys() { - return uniqueKeys; - } - - public void setUniqueKeys(String[] uniqueKeys) { - this.uniqueKeys = uniqueKeys; - } - - public long[] getUniqueValues() { - return uniqueValues; - } - - public void setUniqueValues(long[] uniqueValues) { - this.uniqueValues = uniqueValues; - } - - public double getSum() { - return sum; - } - - public void setSum(double sum) { - this.sum = sum; - } - - public double getAbsSum() { - return absSum; - } - - public void setAbsSum(double absSum) { - this.absSum = absSum; - } - - public double getMin() { - return min; - } - - public void setMin(double min) { - this.min = min; - } - - public double getMax() { - return max; - } - - public void setMax(double max) { - this.max = max; - } - - public double getAbsMin() { - return absMin; - } - - public void setAbsMin(double absMin) { - this.absMin = absMin; - } - - public double getAbsMax() { - return absMax; - } - - public void setAbsMax(double absMax) { - this.absMax = absMax; - } - - public long getMinDateTime() { - return minDateTime; - } - - public void setMinDateTime(final long minDateTime) { - this.minDateTime = minDateTime; - } - - public long getMaxDateTime() { - return maxDateTime; - } - - public void setMaxDateTime(final long maxDateTime) { - this.maxDateTime = maxDateTime; - } - - @Override - public String toString() { - return "ColumnStatistics{" + - "type=" + type + - ", size=" + size + - ", count=" + count + - ", numUnique=" + numUnique + - ", uniqueKeys=" + Arrays.toString(uniqueKeys) + - ", uniqueValues=" + Arrays.toString(uniqueValues) + - ", sum=" + sum + - ", absSum=" + absSum + - ", min=" + min + - ", max=" + max + - ", absMin=" + absMin + - ", absMax=" + absMax + - ", minDateTime=" + minDateTime + - ", maxDateTime=" + maxDateTime + - '}'; - } -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/DeltaUpdates.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/DeltaUpdates.java deleted file mode 100644 index f6e3e59a753..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/DeltaUpdates.java +++ /dev/null @@ -1,174 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data; - -import io.deephaven.web.shared.data.columns.ColumnData; - -import java.io.Serializable; - -public class DeltaUpdates implements Serializable { - public static class ColumnAdditions implements Serializable { - private int columnIndex; - private ColumnData values; - - public ColumnAdditions() {} - - public ColumnAdditions(int colIndex, ColumnData values) { - setColumnIndex(colIndex); - setValues(values); - } - - public int getColumnIndex() { - return columnIndex; - } - - public void setColumnIndex(final int columnIndex) { - this.columnIndex = columnIndex; - } - - public ColumnData getValues() { - return values; - } - - public void setValues(final ColumnData values) { - this.values = values; - } - } - public static class ColumnModifications implements Serializable { - private int columnIndex; - private RangeSet rowsIncluded; - public ColumnData values; - - public ColumnModifications() {} - - public ColumnModifications(int columnIndex, RangeSet includedModifications, ColumnData columnData) { - setColumnIndex(columnIndex); - setRowsIncluded(includedModifications); - setValues(columnData); - } - - public int getColumnIndex() { - return columnIndex; - } - - public void setColumnIndex(final int columnIndex) { - this.columnIndex = columnIndex; - } - - public RangeSet getRowsIncluded() { - return rowsIncluded; - } - - public void setRowsIncluded(final RangeSet rowsIncluded) { - this.rowsIncluded = rowsIncluded; - } - - public ColumnData getValues() { - return values; - } - - public void setValues(final ColumnData values) { - this.values = values; - } - } - - private long deltaSequence; - private long firstStep; - private long lastStep; - - private RangeSet added; - private RangeSet removed; - - private ShiftedRange[] shiftedRanges; - - private RangeSet includedAdditions; - - private ColumnAdditions[] serializedAdditions; - private ColumnModifications[] serializedModifications; - - public DeltaUpdates() {} - - public DeltaUpdates(RangeSet added, RangeSet removed, ShiftedRange[] shifted, RangeSet includedAdditions, - ColumnAdditions[] addedColumnData, ColumnModifications[] modifiedColumnData) { - setAdded(added); - setRemoved(removed); - setShiftedRanges(shifted); - setIncludedAdditions(includedAdditions); - setSerializedAdditions(addedColumnData); - setSerializedModifications(modifiedColumnData); - } - - - public long getDeltaSequence() { - return deltaSequence; - } - - public void setDeltaSequence(final long deltaSequence) { - this.deltaSequence = deltaSequence; - } - - public long getFirstStep() { - return firstStep; - } - - public void setFirstStep(final long firstStep) { - this.firstStep = firstStep; - } - - public long getLastStep() { - return lastStep; - } - - public void setLastStep(final long lastStep) { - this.lastStep = lastStep; - } - - public RangeSet getAdded() { - return added; - } - - public void setAdded(final RangeSet added) { - this.added = added; - } - - public RangeSet getRemoved() { - return removed; - } - - public void setRemoved(final RangeSet removed) { - this.removed = removed; - } - - public ShiftedRange[] getShiftedRanges() { - return shiftedRanges; - } - - public void setShiftedRanges(final ShiftedRange[] shiftedRanges) { - this.shiftedRanges = shiftedRanges; - } - - public RangeSet getIncludedAdditions() { - return includedAdditions; - } - - public void setIncludedAdditions(final RangeSet includedAdditions) { - this.includedAdditions = includedAdditions; - } - - public ColumnAdditions[] getSerializedAdditions() { - return serializedAdditions; - } - - public void setSerializedAdditions(final ColumnAdditions[] serializedAdditions) { - this.serializedAdditions = serializedAdditions; - } - - public ColumnModifications[] getSerializedModifications() { - return serializedModifications; - } - - public void setSerializedModifications(final ColumnModifications[] serializedModifications) { - this.serializedModifications = serializedModifications; - } -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/Range.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/Range.java index 16ef88a4e60..87144a989f1 100644 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/Range.java +++ b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/Range.java @@ -4,26 +4,17 @@ package io.deephaven.web.shared.data; import javax.annotation.Nonnull; -import java.io.Serializable; /** * Describes a contiguous range of at least one item. Equals/hashcode compare both start and end, but comparing Range * instances will compare only by start - the overlap(Range) method should be used to see if two ranges share at least * one item. */ -public class Range implements Serializable, Comparable { - private long first; - private long last; - - // serialization - Range() { - this(0, 0); - } +public class Range implements Comparable { + private final long first; + private final long last; public Range(long first, long last) { - if (first > last) { - throw new IllegalStateException(first + " > " + last); - } this.first = first; this.last = last; } @@ -36,14 +27,6 @@ public long getLast() { return last; } - void setFirst(long first) { - this.first = first; - } - - void setLast(long last) { - this.last = last; - } - @Override public int compareTo(@Nonnull Range o) { return Long.compare(first, o.first); @@ -78,13 +61,10 @@ public Range[] minus(Range range) { // otherwise either the subtracted section's start is within our range _or_ its end is within our range, // and we can use that to only produce the one range we need to return if (range.first <= first) { - assert range.last >= first : "removed range expected to not end before existing range"; return new Range[] { new Range(range.last + 1, last) }; } else { - assert range.last >= last : "removed range expected to end by the end of the existing range"; - assert range.first <= last : "removed range expected to start before existing range"; return new Range[] { new Range(first, range.first - 1) }; @@ -123,4 +103,8 @@ public String toString() { ", last=" + last + '}'; } + + public Range shift(long delta) { + return new Range(first + delta, last + delta); + } } diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/RangeSet.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/RangeSet.java index c782582a425..3e77c9ccec8 100644 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/RangeSet.java +++ b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/RangeSet.java @@ -3,9 +3,11 @@ // package io.deephaven.web.shared.data; -import java.io.Serializable; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.Iterator; +import java.util.List; import java.util.PrimitiveIterator; import java.util.stream.LongStream; @@ -14,7 +16,7 @@ * Iteration protocol, but for now has one method which returns an iterator, and also supports querying the size. * Additionally, we may add support for creating RangeSet objects to better serve some use cases. */ -public class RangeSet implements Serializable { +public class RangeSet { public static RangeSet empty() { return new RangeSet(); @@ -37,210 +39,356 @@ public static RangeSet ofItems(long... items) { return rangeSet; } - public static RangeSet fromSortedRanges(Range[] sortedRanges) { - assert orderedAndNonOverlapping(sortedRanges) : Arrays.toString(sortedRanges); + public static RangeSet fromSortedRanges(List sortedRanges) { + assertOrderedAndNonOverlapping(sortedRanges.toArray(new Range[0])); RangeSet rangeSet = new RangeSet(); rangeSet.sortedRanges = sortedRanges; return rangeSet; } - private static boolean orderedAndNonOverlapping(Range[] sortedRanges) { + public static RangeSet fromSortedRanges(Range[] sortedRanges) { + assertOrderedAndNonOverlapping(sortedRanges); + RangeSet rangeSet = new RangeSet(); + rangeSet.sortedRanges.addAll(Arrays.asList(sortedRanges)); + return rangeSet; + } + + private static void assertOrderedAndNonOverlapping(Range[] sortedRanges) { long lastSeen = -1; for (int i = 0; i < sortedRanges.length; i++) { - if (lastSeen >= sortedRanges[i].getFirst()) { - return false; - } + assert lastSeen < sortedRanges[i].getFirst() || lastSeen == -1 + : sortedRanges[i - 1] + " came before " + sortedRanges[i] + " (index=" + i + ")"; lastSeen = sortedRanges[i].getLast(); } - return true; } - private Range[] sortedRanges = new Range[0]; + private List sortedRanges = new ArrayList<>(); + + private int firstWrongCacheEntry = 0; + private long[] cardinality = new long[0]; + + public void addRangeSet(RangeSet rangeSet) { + if (isEmpty() && !rangeSet.isEmpty()) { + sortedRanges = new ArrayList<>(rangeSet.sortedRanges); + poisonCache(0); + } else if (!rangeSet.isEmpty()) { + RangeAccumulator newRanges = new RangeAccumulator(); + Iterator rangeIterator = sortedRanges.iterator(); + Iterator addIterator = rangeSet.sortedRanges.iterator(); + + Range toCheck = rangeIterator.next(); + Range toAdd = addIterator.next(); + while (true) { + if (toCheck.getLast() < toAdd.getFirst()) { + newRanges.appendRange(toCheck); + if (!rangeIterator.hasNext()) { + toCheck = null; + break; + } + toCheck = rangeIterator.next(); + } else if (toCheck.getFirst() > toAdd.getLast()) { + newRanges.appendRange(toAdd); + + if (!addIterator.hasNext()) { + toAdd = null; + break; + } + toAdd = addIterator.next(); + } else { + Range overlap = toCheck.overlap(toAdd); + assert overlap != null; + newRanges.appendRange(overlap); + + if (!rangeIterator.hasNext()) { + toCheck = null; + break; + } + toCheck = rangeIterator.next(); + + if (!addIterator.hasNext()) { + toAdd = null; + break; + } + toAdd = addIterator.next(); + } + } - public void addRange(Range range) { - // if empty, add as the only entry - if (sortedRanges.length == 0) { - sortedRanges = new Range[] {range}; - return; - } - // if one other entry, test if before, after, or overlapping - if (sortedRanges.length == 1) { - Range existing = sortedRanges[0]; - Range overlap = range.overlap(existing); - if (overlap != null) { - sortedRanges = new Range[] {overlap}; - } else if (existing.compareTo(range) < 0) { - sortedRanges = new Range[] {existing, range}; + // Grab remaining ranges + if (toCheck != null) { + assert toAdd == null; + newRanges.appendRange(toCheck); + while (rangeIterator.hasNext()) { + newRanges.appendRange(rangeIterator.next()); + } } else { - assert existing.compareTo(range) > 0; - sortedRanges = new Range[] {range, existing}; + assert toAdd != null; + newRanges.appendRange(toAdd); + while (addIterator.hasNext()) { + newRanges.appendRange(addIterator.next()); + } } - return; + + this.sortedRanges = newRanges.build(); + poisonCache(0); } + } - // if more than one other entry, binarySearch to find before and after entry, and test both for overlapping - int index = Arrays.binarySearch(sortedRanges, range); - if (index >= 0) { + public void addRange(Range range) { + addRangeSet(RangeSet.fromSortedRanges(Collections.singletonList(range))); + } - // starting with that item, check to see if each following item is part of the existing range - // we know that no range before it will need to be considered, since the set should previously - // have been broken into non-contiguous ranges - Range merged = range; - int end = sortedRanges.length - 1; - for (int i = index; i < sortedRanges.length; i++) { - Range existing = sortedRanges[i]; - // there is an item with the same start, either new item falls within it, or should replace it - Range overlap = existing.overlap(merged); - - if (overlap == null) { - // index before this one is the last item to be replaced - end = i - 1; + public void removeRangeSet(RangeSet rangeSet) { + if (isEmpty() || rangeSet.isEmpty()) { + return; + } + + RangeAccumulator newRanges = new RangeAccumulator(); + RangeIterator rangeIterator = new RangeIterator(sortedRanges); + Iterator removeIterator = rangeSet.sortedRanges.iterator(); + + Range toCheck = rangeIterator.next(); + Range toRemove = removeIterator.next(); + while (true) { + if (toCheck.getLast() < toRemove.getFirst()) { + newRanges.appendRange(toCheck); + if (!rangeIterator.hasNext()) { + toCheck = null; break; } - if (overlap.equals(existing)) { - // the entire range to be added existed within an existing range, we're done - return; + toCheck = rangeIterator.next(); + } else if (toCheck.getFirst() > toRemove.getLast()) { + if (!removeIterator.hasNext()) { + break; + } + toRemove = removeIterator.next(); + } else { + Range[] remaining = toCheck.minus(toRemove); + if (remaining.length == 0) { + // entire range removed, advance to the next range to check + if (!rangeIterator.hasNext()) { + toCheck = null; + break; + } + toCheck = rangeIterator.next(); + } else if (remaining.length == 1) { + Range remainingRange = remaining[0]; + if (remainingRange.compareTo(toCheck) > 0) { + // unremoved range still needs to be checked + rangeIterator.advanceInCurrentRangeToKey(remainingRange.getFirst()); + toCheck = rangeIterator.next(); + + if (!removeIterator.hasNext()) { + break; + } + toRemove = removeIterator.next(); + } else { + // keep the leading, remaining section + newRanges.appendRange(remainingRange); + + // look at the next range + if (!rangeIterator.hasNext()) { + toCheck = null; + break; + } + toCheck = rangeIterator.next(); + } + } else { + assert remaining.length == 2; + newRanges.appendRange(remaining[0]); + + rangeIterator.advanceInCurrentRangeToKey(remaining[1].getFirst()); + toCheck = rangeIterator.next(); + + if (!removeIterator.hasNext()) { + break; + } + toRemove = removeIterator.next(); } - - // grow the region used for replacing - merged = overlap; - } - // splice out [index, end] items, replacing with the newly grown overlap object (may be the same - // size, and only replacing one item) - int newLength = sortedRanges.length - (end - index); - Range[] newArray = new Range[newLength]; - if (index > 0) { - System.arraycopy(sortedRanges, 0, newArray, 0, index); } - newArray[index] = merged; - if (end < sortedRanges.length - 1) { - System.arraycopy(sortedRanges, end + 1, newArray, index + 1, sortedRanges.length - 1 - end); + } + + // Grab remaining ranges + if (toCheck != null) { + newRanges.appendRange(toCheck); + while (rangeIterator.hasNext()) { + newRanges.appendRange(rangeIterator.next()); } - sortedRanges = newArray; - } else { - int proposedIndex = -(index) - 1; - Range merged = range; - // test the item before the proposed location (if any), try to merge it - if (proposedIndex > 0) { - Range before = sortedRanges[proposedIndex - 1]; - Range overlap = before.overlap(merged); + } + + this.sortedRanges = newRanges.build(); + poisonCache(0); + } + + public void removeRange(Range range) { + removeRangeSet(RangeSet.fromSortedRanges(Collections.singletonList(range))); + } + + public void clear() { + sortedRanges.clear(); + poisonCache(0); + } + + private static class RangeAccumulator { + private final List replacement = new ArrayList<>(); + + public void appendRange(Range range) { + if (!replacement.isEmpty()) { + Range lastSeen = replacement.get(replacement.size() - 1); + Range overlap = lastSeen.overlap(range); if (overlap != null) { - // replace the range that we are merging, and start the slice here instead - merged = overlap; - proposedIndex--; - // TODO this will make the loop start here, considering this item twice. not ideal, but not a big - // deal either - } - } - // "end" represents the last item that needs to be merged in to the newly added item. if no items are to be - // merged in, then end will be proposedIndex-1, meaning nothing gets merged in, and the array will grow - // instead of shrinking. - // if we never find an item we cannot merge with, the end of the replaced range is the last item of the old - // array, which could result in the new array having as little as only 1 item - int end = sortedRanges.length - 1; - // until we quit finding matches, test subsequent items - for (int i = proposedIndex; i < sortedRanges.length; i++) { - Range existing = sortedRanges[i]; - Range overlap = existing.overlap(merged); - if (overlap == null) { - // stop at the item before this one - end = i - 1; - break; + replacement.set(replacement.size() - 1, overlap); + } else { + replacement.add(range); } - merged = overlap; - } - int newLength = sortedRanges.length - (end - proposedIndex); - assert newLength > 0 && newLength <= sortedRanges.length + 1; - Range[] newArray = new Range[newLength]; - if (proposedIndex > 0) { - System.arraycopy(sortedRanges, 0, newArray, 0, proposedIndex); - } - newArray[proposedIndex] = merged; - if (end < sortedRanges.length - 1) { - System.arraycopy(sortedRanges, end + 1, newArray, proposedIndex + 1, sortedRanges.length - (end + 1)); + } else { + replacement.add(range); } - sortedRanges = newArray; + } + + public void appendRanges(List ranges) { + appendRange(ranges.get(0)); + replacement.addAll(ranges.subList(0, ranges.size() - 1)); + } + + public void appendRanges(List ranges, long firstItemSubindex) { + Range first = ranges.get(0); + appendRange(new Range(first.getFirst() + firstItemSubindex, first.getLast())); + replacement.addAll(ranges.subList(0, ranges.size() - 1)); + } + + public List build() { + return replacement; } } - public void removeRange(Range range) { - // if empty, nothing to do - if (sortedRanges.length == 0) { - return; + private static class RangeIterator { + private int index = -1; + private final List ranges; + private long key = 0; + + private RangeIterator(List ranges) { + this.ranges = ranges; } - // search the sorted list of ranges and find where the current range starts. two case here when using - // binarySearch, either the removed range starts in the same place as an existing range starts, or - // it starts before an item (and so we check the item before and the item after) - int index = Arrays.binarySearch(sortedRanges, range); - if (index < 0) { - // adjusted index notes where the item would be if it were added, minus _one more_ to see if - // it overlaps the item before it. To compute "the position where the new item belongs", we - // would do (-index - 1), so to examine one item prior to that we'll subtract one more. Then, - // to confirm that we are inserting in a valid position, take the max of that value and zero. - index = Math.max(0, -index - 2); - } - - int beforeCount = -1; - int toRemove = 0; - for (; index < sortedRanges.length; index++) { - Range toCheck = sortedRanges[index]; - if (toCheck.getFirst() > range.getLast()) { - break;// done, this is entirely after the range we're removing - } - if (toCheck.getLast() < range.getFirst()) { - continue;// skip, we don't overlap at all yet - } - Range[] remaining = toCheck.minus(range); - assert remaining != null : "Only early ranges are allowed to not match at all"; - - if (remaining.length == 2) { - // Removed region is entirely within the range we are checking: - // Splice in the one extra item and we're done - this entry - // both started before and ended after the removed section, - // so we don't even "break", we just return - assert toCheck.getFirst() < range.getFirst() : "Expected " + range + " to start after " + toCheck; - assert toCheck.getLast() > range.getLast() : "Expected " + range + " to end after " + toCheck; - assert toRemove == 0 && beforeCount == -1 - : "Expected that no previous items in the RangeSet had been removed toRemove=" + toRemove - + ", beforeCount=" + beforeCount; - - Range[] replacement = new Range[sortedRanges.length + 1]; - if (index > 0) { - System.arraycopy(sortedRanges, 0, replacement, 0, index); - } - replacement[index] = remaining[0]; - replacement[index + 1] = remaining[1]; - System.arraycopy(sortedRanges, index + 1, replacement, index + 2, sortedRanges.length - (index + 1)); + public void advanceInCurrentRangeToKey(long key) { + assert key != 0; + this.key = key; + } + + public boolean hasNext() { + return key == -1 || index < ranges.size() - 1; + } - sortedRanges = replacement; + public Range next() { + if (key != 0) { + Range r = ranges.get(index); + assert key > r.getFirst() && key <= r.getLast(); + r = new Range(key, r.getLast()); + key = 0; - return; + return r; } - if (remaining.length == 1) { - // swap shortened item and move on - sortedRanges[index] = remaining[0]; - } else { - assert remaining.length == 0 : "Array contains a surprising number of items: " + remaining.length; + return ranges.get(++index); + } + + } - // splice out this item as nothing exists here any more and move on - if (toRemove == 0) { - beforeCount = index; + public void applyShifts(ShiftedRange[] shiftedRanges) { + if (shiftedRanges.length == 0 || isEmpty()) { + return; + } + RangeAccumulator newRanges = new RangeAccumulator(); + RangeIterator rangeIterator = new RangeIterator(sortedRanges); + Iterator shiftIterator = Arrays.asList(shiftedRanges).iterator(); + Range toCheck = rangeIterator.next(); + ShiftedRange shiftedRange = shiftIterator.next(); + do { + if (toCheck.getLast() < shiftedRange.getRange().getFirst()) { + // leave this range alone, the range to shift is after it + newRanges.appendRange(toCheck); + if (!rangeIterator.hasNext()) { + toCheck = null; + break; + } + toCheck = rangeIterator.next(); + } else if (toCheck.getFirst() > shiftedRange.getRange().getLast()) { + // skip the rest of this shift, the next range is after it + if (!shiftIterator.hasNext()) { + break; + } + shiftedRange = shiftIterator.next(); + } else { + Range[] remaining = toCheck.minus(shiftedRange.getRange()); + if (remaining.length == 0) { + // entire range shifted + newRanges.appendRange(toCheck.shift(shiftedRange.getDelta())); + if (!rangeIterator.hasNext()) { + toCheck = null; + break; + } + toCheck = rangeIterator.next(); + } else if (remaining.length == 1) { + Range remainingRange = remaining[0]; + + Range[] complimentArr = toCheck.minus(remainingRange); + assert complimentArr.length == 1; + Range compliment = complimentArr[0]; + if (remainingRange.compareTo(toCheck) > 0) { + // shift the compliment + newRanges.appendRange(compliment.shift(shiftedRange.getDelta())); + + // rest of the range still needs to be checked + rangeIterator.advanceInCurrentRangeToKey(remainingRange.getFirst()); + toCheck = rangeIterator.next(); + + // shift is consumed, move to the next one + if (!shiftIterator.hasNext()) { + break; + } + shiftedRange = shiftIterator.next(); + } else { + // keep the remaining section + newRanges.appendRange(remainingRange); + // leftovers after, shift the compliment + newRanges.appendRange(compliment.shift(shiftedRange.getDelta())); + + // look at the next range + if (!rangeIterator.hasNext()) { + toCheck = null; + break; + } + toCheck = rangeIterator.next(); + } + } else { + assert remaining.length == 2; + // We matched the entire shift range, plus a prefix and suffix + // First append the before section + newRanges.appendRange(remaining[0]); + // Then the entire shift range + newRanges.appendRange(shiftedRange.getResultRange()); + + // Visit the rest of the range next + rangeIterator.advanceInCurrentRangeToKey(remaining[1].getFirst()); + toCheck = rangeIterator.next(); + + if (!shiftIterator.hasNext()) { + break; + } + shiftedRange = shiftIterator.next(); } - toRemove++; } + } while (true); + // Grab remaining ranges + if (toCheck != null) { + newRanges.appendRange(toCheck); + while (rangeIterator.hasNext()) { + newRanges.appendRange(rangeIterator.next()); + } } - if (toRemove > 0) { - Range[] replacement = new Range[sortedRanges.length - toRemove]; - System.arraycopy(sortedRanges, 0, replacement, 0, beforeCount); - System.arraycopy(sortedRanges, beforeCount + toRemove, replacement, beforeCount, - sortedRanges.length - beforeCount - toRemove); - sortedRanges = replacement; - } else { - assert beforeCount == -1 : "No items to remove, but beforeCount set?"; - } + sortedRanges = newRanges.build(); + poisonCache(0); } /** @@ -249,17 +397,42 @@ public void removeRange(Range range) { * @return Iterator of {@link Range} */ public Iterator rangeIterator() { - return Arrays.asList(sortedRanges).iterator(); + return sortedRanges.iterator(); } public PrimitiveIterator.OfLong indexIterator() { - return Arrays.stream(sortedRanges) - .flatMapToLong(range -> LongStream.rangeClosed(range.getFirst(), range.getLast())) - .iterator(); + if (isEmpty()) { + return LongStream.empty().iterator(); + } + return new PrimitiveIterator.OfLong() { + private int rangeIndex = 0; + private Range current = sortedRanges.get(0); + private long offsetInRange = 0; + + @Override + public long nextLong() { + long value = current.getFirst() + offsetInRange; + if (++offsetInRange >= current.size()) { + rangeIndex++; + offsetInRange = 0; + if (rangeIndex < rangeCount()) { + current = sortedRanges.get(rangeIndex); + } else { + current = null; + } + } + return value; + } + + @Override + public boolean hasNext() { + return rangeIndex < rangeCount(); + } + }; } public int rangeCount() { - return sortedRanges.length; + return sortedRanges.size(); } /** @@ -270,11 +443,15 @@ public int rangeCount() { * @return long */ public long size() { - return Arrays.stream(sortedRanges).mapToLong(Range::size).sum(); + if (rangeCount() == 0) { + return 0; + } + ensureCardinalityCache(); + return cardinality[sortedRanges.size() - 1]; } public boolean isEmpty() { - return sortedRanges.length == 0; + return rangeCount() == 0; } public boolean contains(long value) { @@ -319,19 +496,58 @@ public boolean includesAllOf(RangeSet other) { return true; } + public boolean includesAnyOf(Range range) { + if (isEmpty()) { + return false; + } + // search the sorted list of ranges and find where the current range starts. two case here when using + // binarySearch, either the removed range starts in the same place as an existing range starts, or + // it starts before an item (and so we check the item before and the item after) + int index = Collections.binarySearch(sortedRanges, range); + if (index >= 0) { + // matching start position + return true; + } + // adjusted index notes where the item would be if it were added, minus _one more_ to see if + // it overlaps the item before it. To compute "the position where the new item belongs", we + // would do (-index - 1), so to examine one item prior to that we'll subtract one more. Then, + // to confirm that we are inserting in a valid position, take the max of that value and zero. + index = Math.max(0, -index - 2); + + // Check if there is any overlap with the prev item + Range target = sortedRanges.get(index); + if (range.getFirst() <= target.getLast() && range.getLast() >= target.getFirst()) { + return true; + } + + // Check if there is a later item, and if there is an overlap with it + index++; + if (index >= rangeCount()) { + return false; + } + target = sortedRanges.get(index); + return range.getFirst() <= target.getLast() && range.getLast() >= target.getFirst(); + } + @Override public String toString() { return "RangeSet{" + - "sortedRanges=" + Arrays.toString(sortedRanges) + + "sortedRanges=" + sortedRanges + '}'; } public long getFirstRow() { - return sortedRanges[0].getFirst(); + return sortedRanges.get(0).getFirst(); } public long getLastRow() { - return sortedRanges[sortedRanges.length - 1].getLast(); + return sortedRanges.get(rangeCount() - 1).getLast(); + } + + public RangeSet copy() { + RangeSet copy = new RangeSet(); + copy.sortedRanges = new ArrayList<>(sortedRanges); + return copy; } @Override @@ -342,20 +558,142 @@ public boolean equals(Object o) { return false; final RangeSet rangeSet = (RangeSet) o; - return Arrays.equals(sortedRanges, rangeSet.sortedRanges); + return sortedRanges.equals(rangeSet.sortedRanges); } @Override public int hashCode() { - return Arrays.hashCode(sortedRanges); + return sortedRanges.hashCode(); + } + + /** + * Indicates that this item has been changed, and should be recomputed. Stores the earliest offset that should be + * recomputed. + */ + private void poisonCache(int rangeIndex) { + firstWrongCacheEntry = Math.min(rangeIndex, firstWrongCacheEntry); + } + + /** + * Ensures that the cardinality cache is correct, by correcting any values after the first wrong entry. + */ + private void ensureCardinalityCache() { + if (firstWrongCacheEntry == rangeCount()) { + return; + } + if (cardinality.length < rangeCount()) { + long[] replacement = new long[rangeCount()]; + System.arraycopy(cardinality, 0, replacement, 0, cardinality.length); + cardinality = replacement; + } + assert firstWrongCacheEntry >= 0 : this; + long cumulative = firstWrongCacheEntry == 0 ? 0 : cardinality[firstWrongCacheEntry - 1]; + for (int i = firstWrongCacheEntry; i < rangeCount(); i++) { + cumulative += sortedRanges.get(i).size(); + this.cardinality[i] = cumulative; + } + firstWrongCacheEntry = rangeCount(); + assert cardinality.length >= rangeCount() : this; + } + + public RangeSet subsetForPositions(RangeSet positions, boolean reversed) { + if (reversed) { + throw new UnsupportedOperationException("reversed=true"); + } + if (positions.isEmpty() || isEmpty()) { + return empty(); + } + ensureCardinalityCache(); + + List ranges = new ArrayList<>(); + + Iterator positionsIter = positions.rangeIterator(); + + int from = 0; + while (positionsIter.hasNext()) { + Range nextPosRange = positionsIter.next(); + if (nextPosRange.getFirst() > size()) { + // Entire range is past the end - since ranges are sorted, we're done + break; + } else if (nextPosRange.getFirst() == size()) { + ranges.add(new Range(getLastRow(), getLastRow())); + break; + } + long rangeToTake = nextPosRange.size(); + + int pos = Arrays.binarySearch(cardinality, from, rangeCount(), nextPosRange.getFirst() + 1); + + long first; + Range target; + long offset; + if (pos >= 0) { + // Position matches the last item in the current range + target = sortedRanges.get(pos); + offset = 1; + } else { + // Position matches an earlier item in + pos = -pos - 1; + target = sortedRanges.get(pos); + long c = cardinality[pos]; + offset = c - nextPosRange.getFirst();// positive value to offset backwards from the end of target + } + assert target != null : this + ".subsetForPositions(" + positions + ")"; + assert offset >= 0 && offset <= target.size() : offset; + first = target.getLast() - offset + 1; + + while (rangeToTake > 0) { + long count = Math.min(offset, rangeToTake); + Range res = new Range(first, first + count - 1); + assert count == res.size(); + ranges.add(res); + + rangeToTake -= count; + pos++; + if (pos >= rangeCount()) { + break; + } + target = sortedRanges.get(pos); + first = target.getFirst(); + offset = target.size(); + } + + from = pos - 1; + } + RangeSet result = RangeSet.fromSortedRanges(ranges.toArray(new Range[0])); + assert result.size() <= positions.size(); + return result; } + public long get(long key) { + if (key == 0) { + return getFirstRow(); + } + ensureCardinalityCache(); + + int pos = Arrays.binarySearch(cardinality, key); - Range[] getSortedRanges() { - return sortedRanges; + if (pos >= 0) { + return sortedRanges.get(pos + 1).getFirst(); + } + Range target = sortedRanges.get(-pos - 1); + long c = cardinality[-pos - 1]; + long offset = c - key;// positive value to offset backwards from the end of target + assert offset >= 0; + return target.getLast() - offset + 1; } - void setSortedRanges(Range[] sortedRanges) { - this.sortedRanges = sortedRanges; + /** + * Removes all keys in the provided rangeset that are present in this. + * + * @param other the rows to remove + * @return any removed keys + */ + public RangeSet extract(RangeSet other) { + RangeSet populatedCopy = copy(); + populatedCopy.removeRangeSet(other); + RangeSet removed = copy(); + removed.removeRangeSet(populatedCopy); + removeRangeSet(removed); + return removed; } } diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/ShiftedRange.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/ShiftedRange.java index 4b1b587be97..f1d9e4848d6 100644 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/ShiftedRange.java +++ b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/ShiftedRange.java @@ -31,4 +31,16 @@ public long getDelta() { public void setDelta(final long delta) { this.delta = delta; } + + public Range getResultRange() { + return range.shift(delta); + } + + @Override + public String toString() { + return "ShiftedRange{" + + "range=" + range + + ", delta=" + delta + + '}'; + } } diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/TableSnapshot.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/TableSnapshot.java deleted file mode 100644 index ae5f8870184..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/TableSnapshot.java +++ /dev/null @@ -1,60 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data; - -import io.deephaven.web.shared.data.columns.ColumnData; - -import java.io.Serializable; - -public class TableSnapshot implements Serializable { - public enum SnapshotType { - INITIAL_SNAPSHOT, UPDATE_COLUMN_SNAPSHOT, UPDATE_ROW_SNAPSHOT, FORCED_SNAPSHOT, - } - - private SnapshotType snapshotType; - - private ColumnData[] dataColumns; - private RangeSet includedRows; - - private long tableSize; - - public TableSnapshot() {} - - public TableSnapshot(RangeSet includedAdditions, ColumnData[] dataColumns, long tableSize) { - this.snapshotType = SnapshotType.INITIAL_SNAPSHOT; - - this.dataColumns = dataColumns; - this.includedRows = includedAdditions; - - this.tableSize = tableSize; - } - - public SnapshotType getSnapshotType() { - return snapshotType; - } - - public ColumnData[] getDataColumns() { - return dataColumns; - } - - public void setDataColumns(ColumnData[] dataColumns) { - this.dataColumns = dataColumns; - } - - public RangeSet getIncludedRows() { - return includedRows; - } - - public void setIncludedRows(RangeSet includedRows) { - this.includedRows = includedRows; - } - - public void setTableSize(long tableSize) { - this.tableSize = tableSize; - } - - public long getTableSize() { - return tableSize; - } -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/TableSubscriptionRequest.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/TableSubscriptionRequest.java deleted file mode 100644 index 3dc940db123..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/TableSubscriptionRequest.java +++ /dev/null @@ -1,76 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data; - -import javax.annotation.Nullable; -import java.io.Serializable; -import java.util.BitSet; - -/** - * A class to encapsulate updates to a given table's subscription. - * - * Because the server is now managing the creation of a "tail table" to only subscribe to updates after all filters have - * run, we are giving the server a bit more rights w.r.t. subscription state management. - * - * The client will now send an array of ViewportSubscription, each containing a subscriptionId (JsTable id) and a - * {@link Viewport} object. - * - * The server will be responsible for merging ranges and columns to create flattened tables with the desired viewports. - * - * For now, we'll likely preserve "bunch them all together" semantics, but we should do performance testing to identify - * if we'll get better performance from having multiple tables of smaller viewport scope (more messages on the wire, but - * less work to do before sending messages). - * - * The {@link #columns} must be non-null (and almost always non-empty), but {@link #rows} may be null to indicate a - * non-viewport subscription. - */ -public class TableSubscriptionRequest implements Serializable { - - private int subscriptionId; - private RangeSet rows; - private BitSet columns; - - public TableSubscriptionRequest() { - - } - - public TableSubscriptionRequest(int subscriptionId, @Nullable RangeSet rows, BitSet columns) { - this.subscriptionId = subscriptionId; - this.rows = rows; - this.columns = columns; - } - - public int getSubscriptionId() { - return subscriptionId; - } - - public RangeSet getRows() { - return rows; - } - - public BitSet getColumns() { - return columns; - } - - void setSubscriptionId(int subscriptionId) { - this.subscriptionId = subscriptionId; - } - - void setRows(RangeSet rows) { - this.rows = rows; - } - - void setColumns(BitSet columns) { - this.columns = columns; - } - - @Override - public String toString() { - return "TableSubscriptionRequest{" + - "subscriptionId=" + subscriptionId + - ", rows=" + rows + - ", columns=" + columns + - '}'; - } -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/Viewport.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/Viewport.java deleted file mode 100644 index bdc19ce9e39..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/Viewport.java +++ /dev/null @@ -1,75 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data; - -import java.io.Serializable; -import java.util.BitSet; - -public class Viewport implements Serializable { - - private final RangeSet rows; - private final BitSet columns; - - public Viewport() { - this(new RangeSet(), new BitSet()); - } - - public Viewport(RangeSet rows, BitSet columns) { - this.rows = rows; - this.columns = columns; - } - - public Viewport merge(Viewport other) { - RangeSet mergedRows = new RangeSet(); - rows.rangeIterator().forEachRemaining(mergedRows::addRange); - other.rows.rangeIterator().forEachRemaining(mergedRows::addRange); - - BitSet mergedColumns = new BitSet(); - mergedColumns.or(columns); - mergedColumns.or(other.columns); - - return new Viewport(mergedRows, mergedColumns); - } - - public RangeSet getRows() { - return rows; - } - - public BitSet getColumns() { - return columns; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - final Viewport viewport = (Viewport) o; - - if (!rows.equals(viewport.rows)) - return false; - return columns.equals(viewport.columns); - } - - @Override - public int hashCode() { - int result = rows.hashCode(); - result = 31 * result + columns.hashCode(); - return result; - } - - @Override - public String toString() { - return "Viewport{" + - "rows=" + rows + - ", columns=" + columns + - '}'; - } - - public boolean isEmpty() { - return rows.size() == 0 && columns.isEmpty(); - } -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/BigDecimalArrayColumnData.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/BigDecimalArrayColumnData.java deleted file mode 100644 index 9a6bed67823..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/BigDecimalArrayColumnData.java +++ /dev/null @@ -1,44 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data.columns; - -import java.math.BigDecimal; -import java.util.Arrays; - -/** - * Holder for data associated with a column of type java.math.BigDecimal. - */ -public class BigDecimalArrayColumnData extends ColumnData { - private BigDecimal[] data; - - public BigDecimalArrayColumnData() {} - - public BigDecimalArrayColumnData(BigDecimal[] data) { - this.data = data; - } - - public BigDecimal[] getData() { - return data; - } - - public void setData(BigDecimal[] data) { - this.data = data; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - final BigDecimalArrayColumnData that = (BigDecimalArrayColumnData) o; - return Arrays.deepEquals(data, that.data); - } - - @Override - public int hashCode() { - return Arrays.deepHashCode(data); - } -} - diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/BigIntegerArrayColumnData.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/BigIntegerArrayColumnData.java deleted file mode 100644 index b9eb9db11fc..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/BigIntegerArrayColumnData.java +++ /dev/null @@ -1,44 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data.columns; - -import java.math.BigInteger; -import java.util.Arrays; - -/** - * Holder for data associated with a column of type java.math.BigInteger. - */ -public class BigIntegerArrayColumnData extends ColumnData { - private BigInteger[] data; - - public BigIntegerArrayColumnData() {} - - public BigIntegerArrayColumnData(BigInteger[] data) { - this.data = data; - } - - public BigInteger[] getData() { - return data; - } - - public void setData(BigInteger[] data) { - this.data = data; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - final BigIntegerArrayColumnData that = (BigIntegerArrayColumnData) o; - return Arrays.deepEquals(data, that.data); - } - - @Override - public int hashCode() { - return Arrays.deepHashCode(data); - } -} - diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/BooleanArrayColumnData.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/BooleanArrayColumnData.java deleted file mode 100644 index 487c6592ca2..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/BooleanArrayColumnData.java +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data.columns; - -import java.util.Arrays; - -public class BooleanArrayColumnData extends ColumnData { - private Boolean[] data; - - public BooleanArrayColumnData() {} - - public BooleanArrayColumnData(Boolean[] data) { - this.data = data; - } - - public Boolean[] getData() { - return data; - } - - public void setData(Boolean[] data) { - this.data = data; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - BooleanArrayColumnData that = (BooleanArrayColumnData) o; - - return Arrays.equals(data, that.data); - } - - @Override - public int hashCode() { - return Arrays.hashCode(data); - } -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/ByteArrayColumnData.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/ByteArrayColumnData.java deleted file mode 100644 index 7bbe9a1b710..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/ByteArrayColumnData.java +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data.columns; - -import java.util.Arrays; - -public class ByteArrayColumnData extends ColumnData { - private byte[] data; - - public ByteArrayColumnData() {} - - public ByteArrayColumnData(byte[] data) { - this.data = data; - } - - public byte[] getData() { - return data; - } - - public void setData(byte[] data) { - this.data = data; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - ByteArrayColumnData that = (ByteArrayColumnData) o; - - return Arrays.equals(data, that.data); - } - - @Override - public int hashCode() { - return Arrays.hashCode(data); - } -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/CharArrayColumnData.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/CharArrayColumnData.java deleted file mode 100644 index 22aae999562..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/CharArrayColumnData.java +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data.columns; - -import java.util.Arrays; - -public class CharArrayColumnData extends ColumnData { - private char[] data; - - public CharArrayColumnData() {} - - public CharArrayColumnData(char[] data) { - this.data = data; - } - - public char[] getData() { - return data; - } - - public void setData(char[] data) { - this.data = data; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - CharArrayColumnData that = (CharArrayColumnData) o; - - return Arrays.equals(data, that.data); - } - - @Override - public int hashCode() { - return Arrays.hashCode(data); - } -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/ColumnData.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/ColumnData.java deleted file mode 100644 index 20817d4672a..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/ColumnData.java +++ /dev/null @@ -1,11 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data.columns; - -import java.io.Serializable; - -public abstract class ColumnData implements Serializable { - - public abstract Object getData(); -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/DoubleArrayColumnData.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/DoubleArrayColumnData.java deleted file mode 100644 index 6864217cfb4..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/DoubleArrayColumnData.java +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data.columns; - -import java.util.Arrays; - -public class DoubleArrayColumnData extends ColumnData { - private double[] data; - - public DoubleArrayColumnData() {} - - public DoubleArrayColumnData(double[] data) { - this.data = data; - } - - public double[] getData() { - return data; - } - - public void setData(double[] data) { - this.data = data; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - DoubleArrayColumnData that = (DoubleArrayColumnData) o; - - return Arrays.equals(data, that.data); - } - - @Override - public int hashCode() { - return Arrays.hashCode(data); - } -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/FloatArrayColumnData.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/FloatArrayColumnData.java deleted file mode 100644 index 8fd13a5962f..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/FloatArrayColumnData.java +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data.columns; - -import java.util.Arrays; - -public class FloatArrayColumnData extends ColumnData { - private float[] data; - - public FloatArrayColumnData() {} - - public FloatArrayColumnData(float[] data) { - this.data = data; - } - - public float[] getData() { - return data; - } - - public void setData(float[] data) { - this.data = data; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - FloatArrayColumnData that = (FloatArrayColumnData) o; - - return Arrays.equals(data, that.data); - } - - @Override - public int hashCode() { - return Arrays.hashCode(data); - } -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/IntArrayColumnData.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/IntArrayColumnData.java deleted file mode 100644 index 49b1b2e4d86..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/IntArrayColumnData.java +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data.columns; - -import java.util.Arrays; - -public class IntArrayColumnData extends ColumnData { - private int[] data; - - public IntArrayColumnData() {} - - public IntArrayColumnData(int[] data) { - this.data = data; - } - - public int[] getData() { - return data; - } - - public void setData(int[] data) { - this.data = data; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - IntArrayColumnData that = (IntArrayColumnData) o; - - return Arrays.equals(data, that.data); - } - - @Override - public int hashCode() { - return Arrays.hashCode(data); - } -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/LocalDateArrayColumnData.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/LocalDateArrayColumnData.java deleted file mode 100644 index 4fd4226279e..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/LocalDateArrayColumnData.java +++ /dev/null @@ -1,46 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data.columns; - -import io.deephaven.web.shared.data.LocalDate; - -import java.util.Arrays; - -/** - * Holder for data associated with a column of type java.time.LocalDate. This type is serialized with a custom LocalDate - * type for efficiency and GWT compatibility. - */ -public class LocalDateArrayColumnData extends ColumnData { - private LocalDate[] data; - - public LocalDateArrayColumnData() {} - - public LocalDateArrayColumnData(LocalDate[] data) { - this.data = data; - } - - public LocalDate[] getData() { - return data; - } - - public void setData(LocalDate[] data) { - this.data = data; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - final LocalDateArrayColumnData that = (LocalDateArrayColumnData) o; - return Arrays.deepEquals(data, that.data); - } - - @Override - public int hashCode() { - return Arrays.deepHashCode(data); - } -} - diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/LocalTimeArrayColumnData.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/LocalTimeArrayColumnData.java deleted file mode 100644 index 2e8ddc291c3..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/LocalTimeArrayColumnData.java +++ /dev/null @@ -1,45 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data.columns; - -import io.deephaven.web.shared.data.LocalTime; - -import java.util.Arrays; - -/** - * Holder for data associated with a column of type java.time.LocalTime. This type is serialized with a custom LocalTime - * type for efficiency and GWT compatibility. - */ -public class LocalTimeArrayColumnData extends ColumnData { - private LocalTime[] data; - - public LocalTimeArrayColumnData() {} - - public LocalTimeArrayColumnData(LocalTime[] data) { - this.data = data; - } - - public LocalTime[] getData() { - return data; - } - - public void setData(LocalTime[] data) { - this.data = data; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - final LocalTimeArrayColumnData that = (LocalTimeArrayColumnData) o; - return Arrays.deepEquals(data, that.data); - } - - @Override - public int hashCode() { - return Arrays.deepHashCode(data); - } -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/LongArrayColumnData.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/LongArrayColumnData.java deleted file mode 100644 index a9e252568b1..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/LongArrayColumnData.java +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data.columns; - -import java.util.Arrays; - -public class LongArrayColumnData extends ColumnData { - private long[] data; - - public LongArrayColumnData() {} - - public LongArrayColumnData(long[] data) { - this.data = data; - } - - public long[] getData() { - return data; - } - - public void setData(long[] data) { - this.data = data; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - LongArrayColumnData that = (LongArrayColumnData) o; - - return Arrays.equals(data, that.data); - } - - @Override - public int hashCode() { - return Arrays.hashCode(data); - } -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/ShortArrayColumnData.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/ShortArrayColumnData.java deleted file mode 100644 index d8c0540ce96..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/ShortArrayColumnData.java +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data.columns; - -import java.util.Arrays; - -public class ShortArrayColumnData extends ColumnData { - private short[] data; - - public ShortArrayColumnData() {} - - public ShortArrayColumnData(short[] data) { - this.data = data; - } - - public short[] getData() { - return data; - } - - public void setData(short[] data) { - this.data = data; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - ShortArrayColumnData that = (ShortArrayColumnData) o; - - return Arrays.equals(data, that.data); - } - - @Override - public int hashCode() { - return Arrays.hashCode(data); - } -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/StringArrayArrayColumnData.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/StringArrayArrayColumnData.java deleted file mode 100644 index 721e0aabd72..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/StringArrayArrayColumnData.java +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data.columns; - -import java.util.Arrays; - -public class StringArrayArrayColumnData extends ColumnData { - private String[][] data; - - public StringArrayArrayColumnData() {} - - public StringArrayArrayColumnData(String[][] data) { - this.data = data; - } - - public String[][] getData() { - return data; - } - - public void setData(String[][] data) { - this.data = data; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - StringArrayArrayColumnData that = (StringArrayArrayColumnData) o; - - return Arrays.deepEquals(data, that.data); - } - - @Override - public int hashCode() { - return Arrays.deepHashCode(data); - } -} diff --git a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/StringArrayColumnData.java b/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/StringArrayColumnData.java deleted file mode 100644 index 338402855bf..00000000000 --- a/web/shared-beans/src/main/java/io/deephaven/web/shared/data/columns/StringArrayColumnData.java +++ /dev/null @@ -1,41 +0,0 @@ -// -// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending -// -package io.deephaven.web.shared.data.columns; - -import java.util.Arrays; - -public class StringArrayColumnData extends ColumnData { - private String[] data; - - public StringArrayColumnData() {} - - public StringArrayColumnData(String[] data) { - this.data = data; - } - - public String[] getData() { - return data; - } - - public void setData(String[] data) { - this.data = data; - } - - @Override - public boolean equals(Object o) { - if (this == o) - return true; - if (o == null || getClass() != o.getClass()) - return false; - - StringArrayColumnData that = (StringArrayColumnData) o; - - return Arrays.equals(data, that.data); - } - - @Override - public int hashCode() { - return Arrays.hashCode(data); - } -} diff --git a/web/shared-beans/src/test/java/io/deephaven/web/shared/data/RangeSetTest.java b/web/shared-beans/src/test/java/io/deephaven/web/shared/data/RangeSetTest.java index d28a702bbbb..a2c2522b2d9 100644 --- a/web/shared-beans/src/test/java/io/deephaven/web/shared/data/RangeSetTest.java +++ b/web/shared-beans/src/test/java/io/deephaven/web/shared/data/RangeSetTest.java @@ -128,21 +128,24 @@ public void testAddExistingRange() { @Test public void testOverlappingRangesInDifferentOrder() { - // add three items in each possible order to a rangeset, ensure results are always the same + // add five ranges, where some overlap others, in each possible order to a rangeset, ensure results are always + // the same Range rangeA = new Range(100, 108); Range rangeB = new Range(105, 112); Range rangeC = new Range(110, 115); - Collections2.permutations(Arrays.asList(rangeA, rangeB, rangeC)).forEach(list -> { + Range rangeD = new Range(100, 113); + Range rangeE = new Range(101, 115); + Collections2.permutations(Arrays.asList(rangeA, rangeB, rangeC, rangeD, rangeE)).forEach(list -> { RangeSet rangeSet = new RangeSet(); list.forEach(rangeSet::addRange); - assertEquals(16, rangeSet.size()); + assertEquals(list.toString(), 16, rangeSet.size()); assertEquals(list.toString(), Collections.singletonList(new Range(100, 115)), asList(rangeSet)); }); - // same three items, but with another before that will not overlap with them + // same five items, but with another before that will not overlap with them Range before = new Range(0, 4); - Collections2.permutations(Arrays.asList(before, rangeA, rangeB, rangeC)).forEach(list -> { + Collections2.permutations(Arrays.asList(before, rangeA, rangeB, rangeC, rangeD, rangeE)).forEach(list -> { RangeSet rangeSet = new RangeSet(); list.forEach(rangeSet::addRange); @@ -150,9 +153,9 @@ public void testOverlappingRangesInDifferentOrder() { assertEquals(list.toString(), Arrays.asList(new Range(0, 4), new Range(100, 115)), asList(rangeSet)); }); - // same three items, but with another following that will not overlap with them + // same five items, but with another following that will not overlap with them Range after = new Range(200, 204); - Collections2.permutations(Arrays.asList(after, rangeA, rangeB, rangeC)).forEach(list -> { + Collections2.permutations(Arrays.asList(after, rangeA, rangeB, rangeC, rangeD, rangeE)).forEach(list -> { RangeSet rangeSet = new RangeSet(); list.forEach(rangeSet::addRange); @@ -212,6 +215,41 @@ public void testIncludesAllOf() { assertFalse(rangeSet.includesAllOf(RangeSet.ofRange(54, 60))); } + @Test + public void testIncludesAnyOf() { + RangeSet rangeSet = new RangeSet(); + rangeSet.addRange(new Range(0, 19)); + rangeSet.addRange(new Range(50, 54)); + + assertTrue(rangeSet.includesAnyOf(new Range(0, 19))); + assertTrue(rangeSet.includesAnyOf(new Range(50, 54))); + + rangeSet.indexIterator().forEachRemaining((LongConsumer) l -> { + assertTrue(rangeSet.includesAnyOf(new Range(l, l))); + }); + + assertTrue(rangeSet.includesAnyOf(new Range(0, 20))); + assertTrue(rangeSet.includesAnyOf(new Range(10, 20))); + assertTrue(rangeSet.includesAnyOf(new Range(19, 20))); + + assertTrue(rangeSet.includesAnyOf(new Range(19, 30))); + assertFalse(rangeSet.includesAnyOf(new Range(20, 30))); + assertFalse(rangeSet.includesAnyOf(new Range(21, 30))); + + assertFalse(rangeSet.includesAnyOf(new Range(30, 40))); + + assertFalse(rangeSet.includesAnyOf(new Range(40, 49))); + assertTrue(rangeSet.includesAnyOf(new Range(40, 50))); + assertFalse(rangeSet.includesAnyOf(new Range(40, 41))); + assertTrue(rangeSet.includesAnyOf(new Range(40, 54))); + + assertTrue(rangeSet.includesAnyOf(new Range(49, 54))); + assertTrue(rangeSet.includesAnyOf(new Range(50, 55))); + assertTrue(rangeSet.includesAnyOf(new Range(50, 60))); + + assertTrue(rangeSet.includesAnyOf(new Range(54, 60))); + assertFalse(rangeSet.includesAnyOf(new Range(55, 60))); + } @Test public void testRemove() { @@ -475,4 +513,123 @@ public void testLarge() { assertEquals(RangeSet.ofItems(largeA, largeB), rangeSet); } + @Test + public void testSubsetForPostions() { + RangeSet initialRange = RangeSet.ofItems(2, 4, 6, 8); + assertEquals(RangeSet.ofItems(4, 8), initialRange.subsetForPositions(RangeSet.ofItems(1, 3), false)); + assertEquals(RangeSet.ofItems(4, 8), initialRange.subsetForPositions(RangeSet.ofItems(1, 3, 4), false)); + assertEquals(RangeSet.ofItems(4, 8), initialRange.subsetForPositions(RangeSet.ofItems(1, 3, 5), false)); + assertEquals(initialRange, initialRange.subsetForPositions(RangeSet.ofItems(0, 1, 2, 3, 4, 5, 100), false)); + assertEquals(initialRange, initialRange.subsetForPositions(RangeSet.ofItems(0, 1, 2, 3, 100), false)); + + assertEquals(RangeSet.ofItems(4, 6, 8), initialRange.subsetForPositions(RangeSet.ofRange(1, 3), false)); + assertEquals(RangeSet.ofItems(2, 4, 6), initialRange.subsetForPositions(RangeSet.ofRange(0, 2), false)); + assertEquals(initialRange, initialRange.subsetForPositions(RangeSet.ofRange(0, 3), false)); + assertEquals(initialRange, initialRange.subsetForPositions(RangeSet.ofRange(0, 9), false)); + + initialRange = RangeSet.ofRange(10, 109); + assertEquals(RangeSet.ofItems(12, 14), initialRange.subsetForPositions(RangeSet.ofItems(2, 4), false)); + assertEquals(RangeSet.ofItems(12, 14), initialRange.subsetForPositions(RangeSet.ofItems(2, 4, 101), false)); + + assertEquals(RangeSet.empty(), RangeSet.empty().subsetForPositions(RangeSet.ofItems(0), false)); + assertEquals(RangeSet.ofItems(99), + RangeSet.ofRange(0, 99).subsetForPositions(RangeSet.ofRange(100, 104), false)); + + initialRange = RangeSet.empty(); + assertEquals(0, initialRange.size()); + initialRange.addRange(new Range(0, 1)); + assertEquals(2, initialRange.size()); + initialRange.addRange(new Range(2, 3)); + assertEquals(4, initialRange.size()); + initialRange.removeRange(new Range(0, 3)); + assertEquals(0, initialRange.size()); + initialRange.addRange(new Range(0, 1)); + assertEquals(2, initialRange.size()); + + initialRange = RangeSet.ofItems(1, 4, 5, 6); + assertEquals(RangeSet.ofItems(1, 4, 5, 6), initialRange.subsetForPositions(RangeSet.ofRange(0, 3), false)); + assertEquals(RangeSet.ofItems(1, 5, 6), initialRange.subsetForPositions(RangeSet.ofItems(0, 2, 3), false)); + assertEquals(RangeSet.ofItems(1, 4, 6), initialRange.subsetForPositions(RangeSet.ofItems(0, 1, 3), false)); + assertEquals(RangeSet.ofItems(1, 4, 5), initialRange.subsetForPositions(RangeSet.ofItems(0, 1, 2), false)); + assertEquals(RangeSet.ofItems(1, 5), initialRange.subsetForPositions(RangeSet.ofItems(0, 2), false)); + assertEquals(RangeSet.ofItems(4, 5), initialRange.subsetForPositions(RangeSet.ofRange(1, 2), false)); + assertEquals(RangeSet.ofItems(4, 5, 6), initialRange.subsetForPositions(RangeSet.ofRange(1, 3), false)); + assertEquals(RangeSet.ofItems(5, 6), initialRange.subsetForPositions(RangeSet.ofRange(2, 3), false)); + } + + @Test + public void testGet() { + long[] rows = {0, 1, 4, 5, 7, 9}; + RangeSet initialRange = RangeSet.ofItems(rows); + + for (int i = 0; i < rows.length; i++) { + assertEquals("i=" + i, rows[i], initialRange.get(i)); + } + + initialRange.removeRange(new Range(0, 1)); + } + + @Test + public void testShift() { + RangeSet r = RangeSet.ofRange(0, 2); + r.applyShifts(new ShiftedRange[] { + new ShiftedRange(new Range(0, 2), 2) + }); + assertEquals(RangeSet.ofRange(2, 4), r); + r.applyShifts(new ShiftedRange[] { + new ShiftedRange(new Range(2, 6), -2) + }); + assertEquals(RangeSet.ofRange(0, 2), r); + r.applyShifts(new ShiftedRange[] { + new ShiftedRange(new Range(1, 2), 3) + }); + assertEquals(RangeSet.ofItems(0, 4, 5), r); + r.applyShifts(new ShiftedRange[] { + new ShiftedRange(new Range(4, 4), -1) + }); + assertEquals(RangeSet.ofItems(0, 3, 5), r); + + r = RangeSet.ofItems(0, 3, 4, 5, 6, 10); + r.applyShifts(new ShiftedRange[] { + new ShiftedRange(new Range(4, 4), 2), + new ShiftedRange(new Range(5, 6), 3), + }); + assertEquals(RangeSet.ofItems(0, 3, 6, 8, 9, 10), r); + + + r = RangeSet.fromSortedRanges(new Range[] { + new Range(0, 1), + new Range(3, 5), + new Range(7, 13), + new Range(15, 19), + }); + r.applyShifts(new ShiftedRange[] { + new ShiftedRange(new Range(3, 4), -1), + new ShiftedRange(new Range(7, 13), -1), + new ShiftedRange(new Range(15, 17), -2), + }); + assertEquals(RangeSet.fromSortedRanges(new Range[] { + new Range(0, 3), + new Range(5, 15), + new Range(18, 19), + }), r); + + + r = RangeSet.fromSortedRanges(new Range[] { + new Range(28972, 28987), + new Range(28989, 29003), + new Range(29005, 29011), + new Range(29013, 29013), + new Range(29015, 29018), + new Range(29020, 29020), + new Range(29022, 29024), + new Range(29026, 29039), + }); + r.applyShifts(new ShiftedRange[] { + new ShiftedRange(new Range(28989, 29011), 2), + new ShiftedRange(new Range(29013, 29013), 1), + new ShiftedRange(new Range(29022, 29024), -1), + new ShiftedRange(new Range(29026, 29026), -2), + }); + } }