Sha256: 1f9a0ebb70526b57b9b0bf2c6cb4c89e28753b57a24f67626c015d5bd23eaceb

Contents?: true

Size: 999 Bytes

Versions: 1

Compression:

Stored size: 999 Bytes

Contents

use std::any::Any;
use std::sync::Arc;

use magnus::IntoValue;
use polars_core::chunked_array::object::builder::ObjectChunkedBuilder;
use polars_core::chunked_array::object::registry;
use polars_core::chunked_array::object::registry::AnonymousObjectBuilder;
use polars_core::prelude::AnyValue;

use crate::prelude::ObjectValue;
use crate::Wrap;

pub(crate) const OBJECT_NAME: &str = "object";

pub(crate) fn register_object_builder() {
    if !registry::is_object_builder_registered() {
        let object_builder = Box::new(|name: &str, capacity: usize| {
            Box::new(ObjectChunkedBuilder::<ObjectValue>::new(name, capacity))
                as Box<dyn AnonymousObjectBuilder>
        });

        let object_converter = Arc::new(|av: AnyValue| {
            let object = ObjectValue {
                inner: Wrap(av).into_value(),
            };
            Box::new(object) as Box<dyn Any>
        });

        registry::register_object_builder(object_builder, object_converter)
    }
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
polars-df-0.6.0 ext/polars/src/object.rs