Kikkon commented on code in PR #5576:
URL: https://github.com/apache/arrow-rs/pull/5576#discussion_r1554618190


##########
arrow-array/src/array/list_view_array.rs:
##########
@@ -0,0 +1,1227 @@
+// 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.
+
+use crate::array::{get_offsets, get_sizes, make_array, print_long_array};
+use crate::builder::{GenericListViewBuilder, PrimitiveBuilder};
+use crate::iterator::GenericListViewArrayIter;
+use crate::{
+    new_empty_array, Array, ArrayAccessor, ArrayRef, ArrowPrimitiveType, 
FixedSizeListArray,
+    OffsetSizeTrait,
+};
+use arrow_buffer::{NullBuffer, OffsetBuffer, SizeBuffer};
+use arrow_data::{ArrayData, ArrayDataBuilder};
+use arrow_schema::{ArrowError, DataType, FieldRef};
+use std::any::Any;
+use std::ops::Add;
+use std::sync::Arc;
+
+/// A [`GenericListViewArray`] of variable size lists, storing offsets as 
`i32`.
+///
+// See [`ListViewBuilder`](crate::builder::ListViewBuilder) for how to 
construct a [`ListViewArray`]
+pub type ListViewArray = GenericListViewArray<i32>;
+
+/// A [`GenericListViewArray`] of variable size lists, storing offsets as 
`i64`.
+///
+// See [`LargeListViewArray`](crate::builder::LargeListViewBuilder) for how to 
construct a [`LargeListViewArray`]
+pub type LargeListViewArray = GenericListViewArray<i64>;
+
+///
+/// Different than [`crate::GenericListArray`] as it stores both an offset and 
length
+/// meaning that take / filter operations can be implemented without copying 
the underlying data.
+///
+/// [Variable-size List Layout: ListView Layout]: 
https://arrow.apache.org/docs/format/Columnar.html#listview-layout
+pub struct GenericListViewArray<OffsetSize: OffsetSizeTrait> {
+    data_type: DataType,
+    nulls: Option<NullBuffer>,
+    values: ArrayRef,
+    value_offsets: OffsetBuffer<OffsetSize>,
+    value_sizes: SizeBuffer<OffsetSize>,
+    len: usize,
+}
+
+impl<OffsetSize: OffsetSizeTrait> Clone for GenericListViewArray<OffsetSize> {
+    fn clone(&self) -> Self {
+        Self {
+            data_type: self.data_type.clone(),
+            nulls: self.nulls.clone(),
+            values: self.values.clone(),
+            value_offsets: self.value_offsets.clone(),
+            value_sizes: self.value_sizes.clone(),
+            len: self.len,
+        }
+    }
+}
+
+impl<OffsetSize: OffsetSizeTrait> GenericListViewArray<OffsetSize> {
+    /// The data type constructor of listview array.
+    /// The input is the schema of the child array and
+    /// the output is the [`DataType`], ListView or LargeListView.
+    pub const DATA_TYPE_CONSTRUCTOR: fn(FieldRef) -> DataType = if 
OffsetSize::IS_LARGE {
+        DataType::LargeListView
+    } else {
+        DataType::ListView
+    };
+
+    /// Returns the data type of the list view array
+    pub fn try_new(
+        field: FieldRef,
+        offsets: OffsetBuffer<OffsetSize>,

Review Comment:
   Thank you for your suggestion. Previously, I did not fully understand offset 
buffer, now OffsetBuffer has been changed to ScalarBuffer.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to