2021-12-28 09:43:26 +08:00
|
|
|
// Licensed to the LF AI & Data foundation 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
|
2021-04-19 11:32:24 +08:00
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
2021-12-28 09:43:26 +08:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2021-04-19 11:32:24 +08:00
|
|
|
//
|
2021-12-28 09:43:26 +08:00
|
|
|
// 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.
|
2021-04-19 11:32:24 +08:00
|
|
|
|
2020-12-07 15:22:20 +08:00
|
|
|
package storage
|
|
|
|
|
|
|
|
import (
|
2024-02-06 17:04:25 +08:00
|
|
|
"github.com/apache/arrow/go/v12/parquet"
|
|
|
|
"github.com/apache/arrow/go/v12/parquet/file"
|
2024-02-21 17:10:52 +08:00
|
|
|
"github.com/apache/arrow/go/v12/parquet/pqarrow"
|
2024-02-06 17:04:25 +08:00
|
|
|
|
2023-06-09 01:28:37 +08:00
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/schemapb"
|
2020-12-07 15:22:20 +08:00
|
|
|
)
|
|
|
|
|
2021-12-14 20:03:20 +08:00
|
|
|
// PayloadWriterInterface abstracts PayloadWriter
|
2020-12-09 09:55:56 +08:00
|
|
|
type PayloadWriterInterface interface {
|
2023-06-14 18:04:38 +08:00
|
|
|
AddDataToPayload(msgs any, dim ...int) error
|
2020-12-09 09:55:56 +08:00
|
|
|
AddBoolToPayload(msgs []bool) error
|
2021-12-16 16:35:42 +08:00
|
|
|
AddByteToPayload(msgs []byte) error
|
2020-12-09 09:55:56 +08:00
|
|
|
AddInt8ToPayload(msgs []int8) error
|
|
|
|
AddInt16ToPayload(msgs []int16) error
|
|
|
|
AddInt32ToPayload(msgs []int32) error
|
|
|
|
AddInt64ToPayload(msgs []int64) error
|
|
|
|
AddFloatToPayload(msgs []float32) error
|
|
|
|
AddDoubleToPayload(msgs []float64) error
|
|
|
|
AddOneStringToPayload(msgs string) error
|
2023-04-20 11:32:31 +08:00
|
|
|
AddOneArrayToPayload(msg *schemapb.ScalarField) error
|
|
|
|
AddOneJSONToPayload(msg []byte) error
|
2020-12-09 09:55:56 +08:00
|
|
|
AddBinaryVectorToPayload(binVec []byte, dim int) error
|
|
|
|
AddFloatVectorToPayload(binVec []float32, dim int) error
|
2023-09-08 10:03:16 +08:00
|
|
|
AddFloat16VectorToPayload(binVec []byte, dim int) error
|
2024-01-11 15:48:51 +08:00
|
|
|
AddBFloat16VectorToPayload(binVec []byte, dim int) error
|
2024-03-14 05:32:54 +08:00
|
|
|
AddSparseFloatVectorToPayload(data *SparseFloatVectorFieldData) error
|
2020-12-09 09:55:56 +08:00
|
|
|
FinishPayloadWriter() error
|
|
|
|
GetPayloadBufferFromWriter() ([]byte, error)
|
|
|
|
GetPayloadLengthFromWriter() (int, error)
|
2021-12-09 12:37:06 +08:00
|
|
|
ReleasePayloadWriter()
|
2024-06-17 12:06:04 +08:00
|
|
|
Reserve(size int)
|
2021-12-09 12:37:06 +08:00
|
|
|
Close()
|
2020-12-09 09:55:56 +08:00
|
|
|
}
|
|
|
|
|
2021-12-14 20:03:20 +08:00
|
|
|
// PayloadReaderInterface abstracts PayloadReader
|
2020-12-09 09:55:56 +08:00
|
|
|
type PayloadReaderInterface interface {
|
2023-06-14 18:04:38 +08:00
|
|
|
GetDataFromPayload() (any, int, error)
|
2020-12-09 09:55:56 +08:00
|
|
|
GetBoolFromPayload() ([]bool, error)
|
2021-12-16 16:35:42 +08:00
|
|
|
GetByteFromPayload() ([]byte, error)
|
2020-12-09 09:55:56 +08:00
|
|
|
GetInt8FromPayload() ([]int8, error)
|
|
|
|
GetInt16FromPayload() ([]int16, error)
|
|
|
|
GetInt32FromPayload() ([]int32, error)
|
|
|
|
GetInt64FromPayload() ([]int64, error)
|
|
|
|
GetFloatFromPayload() ([]float32, error)
|
|
|
|
GetDoubleFromPayload() ([]float64, error)
|
2022-03-30 15:21:28 +08:00
|
|
|
GetStringFromPayload() ([]string, error)
|
2023-04-20 11:32:31 +08:00
|
|
|
GetArrayFromPayload() ([]*schemapb.ScalarField, error)
|
|
|
|
GetJSONFromPayload() ([][]byte, error)
|
2020-12-09 09:55:56 +08:00
|
|
|
GetBinaryVectorFromPayload() ([]byte, int, error)
|
2023-09-08 10:03:16 +08:00
|
|
|
GetFloat16VectorFromPayload() ([]byte, int, error)
|
2024-01-11 15:48:51 +08:00
|
|
|
GetBFloat16VectorFromPayload() ([]byte, int, error)
|
2020-12-09 09:55:56 +08:00
|
|
|
GetFloatVectorFromPayload() ([]float32, int, error)
|
2024-03-14 05:32:54 +08:00
|
|
|
GetSparseFloatVectorFromPayload() (*SparseFloatVectorFieldData, int, error)
|
2020-12-09 09:55:56 +08:00
|
|
|
GetPayloadLengthFromReader() (int, error)
|
2024-02-06 17:04:25 +08:00
|
|
|
|
|
|
|
GetByteArrayDataSet() (*DataSet[parquet.ByteArray, *file.ByteArrayColumnChunkReader], error)
|
2024-02-21 17:10:52 +08:00
|
|
|
GetArrowRecordReader() (pqarrow.RecordReader, error)
|
2024-02-06 17:04:25 +08:00
|
|
|
|
2023-03-20 10:41:56 +08:00
|
|
|
ReleasePayloadReader() error
|
|
|
|
Close() error
|
2020-12-09 09:55:56 +08:00
|
|
|
}
|