MCPcopy Create free account
hub / github.com/TileDB-Inc/TileDB / create_array

Method create_array

test/src/unit-cppapi-query-condition-enumerations.cc:748–794  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

746}
747
748void CPPQueryConditionEnumerationFx::create_array(
749 tiledb_array_type_t type, bool serialize, uint32_t num_rows) {
750 type_ = type;
751 serialize_ = serialize;
752 num_rows_ = num_rows;
753 data_ = generate_data(num_rows_);
754
755 // Create our array schema
756 ArraySchema schema(ctx_, type_);
757
758 if (type_ == TILEDB_SPARSE) {
759 schema.set_capacity(num_rows_);
760 }
761
762 // Create a single dimension row_id as uint32_t
763 auto dim = Dimension::create<uint32_t>(ctx_, "row_id", {{1, num_rows_}});
764 auto dom = Domain(ctx_);
765 dom.add_dimension(dim);
766 schema.set_domain(dom);
767
768 // Create our enumerations
769 create_enumeration(schema, "cell_types", cell_type_index_, false);
770 create_enumeration(schema, "cycle_phases", cycle_phase_index_, true);
771 create_enumeration(schema, "wavelengths", wavelength_index_, true);
772
773 // Create our attributes
774 auto sample_name = Attribute::create<std::string>(ctx_, "sample_name");
775
776 auto cell_type = Attribute::create<uint8_t>(ctx_, "cell_type");
777 AttributeExperimental::set_enumeration_name(ctx_, cell_type, "cell_types");
778
779 auto cell_phase = Attribute::create<uint8_t>(ctx_, "cycle_phase");
780 AttributeExperimental::set_enumeration_name(ctx_, cell_phase, "cycle_phases");
781 cell_phase.set_nullable(true);
782
783 auto wavelength = Attribute::create<uint8_t>(ctx_, "wavelength");
784 AttributeExperimental::set_enumeration_name(ctx_, wavelength, "wavelengths");
785
786 auto luminosity = Attribute::create<float>(ctx_, "luminosity");
787
788 schema.add_attributes(
789 sample_name, cell_type, cell_phase, wavelength, luminosity);
790
791 // Create and write the array.
792 Array::create(uri_, schema);
793 write_array();
794}
795
796void CPPQueryConditionEnumerationFx::write_array() {
797 Array array(ctx_, uri_, TILEDB_WRITE);

Callers

nothing calls this directly

Calls 6

write_arrayFunction · 0.70
DomainClass · 0.50
set_capacityMethod · 0.45
add_dimensionMethod · 0.45
set_domainMethod · 0.45
set_nullableMethod · 0.45

Tested by

no test coverage detected