-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make new View array type for BinaryView/Utf8View
- Loading branch information
Showing
6 changed files
with
131 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,3 @@ | ||
# 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. | ||
|
||
name = "Arrow" | ||
uuid = "69666777-d1a9-59fb-9406-91d4454c9d45" | ||
authors = ["quinnj <[email protected]>"] | ||
|
@@ -32,6 +16,7 @@ LoggingExtras = "e6f89c97-d47a-5376-807f-9c37f3926c36" | |
Mmap = "a63ad114-7e13-5084-954f-fe012c677804" | ||
PooledArrays = "2dfb63ee-cc39-5dd5-95bd-886bf059d720" | ||
SentinelArrays = "91c51154-3ec4-41a3-a24f-3f23e20d615c" | ||
StringViews = "354b36f9-a18e-4713-926e-db85100087ba" | ||
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" | ||
TimeZones = "f269a46b-ccf7-5d73-abea-4c690281aa53" | ||
TranscodingStreams = "3bb67fe8-82b1-5028-8e26-92a6c54297fa" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -271,3 +271,4 @@ include("map.jl") | |
include("struct.jl") | ||
include("unions.jl") | ||
include("dictencoding.jl") | ||
include("views.jl") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# 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. | ||
|
||
struct ViewElement | ||
length::Int32 | ||
prefix::Int32 | ||
bufindex::Int32 | ||
offset::Int32 | ||
end | ||
|
||
""" | ||
Arrow.View | ||
An `ArrowVector` where each element is a variable sized list of some kind, like an `AbstractVector` or `AbstractString`. | ||
""" | ||
struct View{T} <: ArrowVector{T} | ||
arrow::Vector{UInt8} # need to hold a reference to arrow memory blob | ||
validity::ValidityBitmap | ||
data::Vector{ViewElement} | ||
inline::Vector{UInt8} # `data` field reinterpreted as a byte array | ||
buffers::Vector{Vector{UInt8}} # holds non-inlined data | ||
ℓ::Int | ||
metadata::Union{Nothing,Base.ImmutableDict{String,String}} | ||
end | ||
|
||
Base.size(l::View) = (l.ℓ,) | ||
|
||
@propagate_inbounds function Base.getindex(l::View{T}, i::Integer) where {T} | ||
@boundscheck checkbounds(l, i) | ||
@inbounds v = l.data[i] | ||
S = Base.nonmissingtype(T) | ||
if S <: Base.CodeUnits | ||
# BinaryView | ||
return !l.validity[i] ? missing : | ||
v.length < 13 ? | ||
Base.CodeUnits(StringView(@view l.inline[(((i - 1) * 16) + 5):(((i - 1) * 16) + 5 + v.length - 1)])) : | ||
Base.CodeUnits(StringView(@view l.buffers[v.bufindex + 1][(v.offset + 1):(v.offset + v.length)])) | ||
else | ||
# Utf8View | ||
return !l.validity[i] ? missing : | ||
v.length < 13 ? | ||
ArrowTypes.fromarrow(T, StringView(@view l.inline[(((i - 1) * 16) + 5):(((i - 1) * 16) + 5 + v.length - 1)])) : | ||
ArrowTypes.fromarrow(T, StringView(@view l.buffers[v.bufindex + 1][(v.offset + 1):(v.offset + v.length)])) | ||
end | ||
end | ||
|
||
# @propagate_inbounds function Base.setindex!(l::List{T}, v, i::Integer) where {T} | ||
|
||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters