/* istanbul ignore file */ // 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. /* eslint-disable unicorn/no-array-callback-reference */ import { Data } from '../data.js'; import { Visitor } from '../visitor.js'; import { TypeToDataType } from '../interfaces.js'; import { Type, TimeUnit, UnionMode } from '../enum.js'; import { DataType, Dictionary, Float, Int, Date_, Interval, Time, Timestamp, Bool, Null, Utf8, Binary, Decimal, FixedSizeBinary, List, FixedSizeList, Map_, Struct, Union, DenseUnion, SparseUnion, } from '../type.js'; /** @ignore */ const sum = (x: number, y: number) => x + y; /** @ignore */ export interface GetByteLengthVisitor extends Visitor { visit(node: Data, index: number): number; visitMany(nodes: Data[], index: number[]): number[]; getVisitFn(node: Data | T): (data: Data, index: number) => number; getVisitFn(node: T): (data: Data>, index: number) => number; visitBinary(data: Data, index: number): number; visitUtf8(data: Data, index: number): number; visitList(data: Data, index: number): number; visitDenseUnion(data: Data, index: number): number; visitSparseUnion(data: Data, index: number): number; visitFixedSizeList(data: Data, index: number): number; } /** @ignore */ export class GetByteLengthVisitor extends Visitor { public visitNull(____: Data, _: number) { return 0; } public visitInt(data: Data, _: number) { return data.type.bitWidth / 8; } public visitFloat(data: Data, _: number) { return data.type.ArrayType.BYTES_PER_ELEMENT; } public visitBool(____: Data, _: number) { return 1 / 8; } public visitDecimal(data: Data, _: number) { return data.type.bitWidth / 8; } public visitDate(data: Data, _: number) { return (data.type.unit + 1) * 4; } public visitTime(data: Data