Create a new table on disk.
(self)
| 1030 | return enum_map |
| 1031 | |
| 1032 | def _g_create(self) -> int: |
| 1033 | """Create a new table on disk.""" |
| 1034 | # Warning against assigning too much columns... |
| 1035 | # F. Alted 2005-06-05 |
| 1036 | max_columns = self._v_file.params["MAX_COLUMNS"] |
| 1037 | if len(self.description._v_names) > max_columns: |
| 1038 | warnings.warn( |
| 1039 | "table ``%s`` is exceeding the recommended " |
| 1040 | "maximum number of columns (%d); " |
| 1041 | "be ready to see PyTables asking for *lots* of memory " |
| 1042 | "and possibly slow I/O" % (self._v_pathname, max_columns), |
| 1043 | PerformanceWarning, |
| 1044 | ) |
| 1045 | |
| 1046 | # 1. Create the HDF5 table (some parameters need to be computed). |
| 1047 | |
| 1048 | # Fix the byteorder of the recarray and update the number of |
| 1049 | # expected rows if necessary |
| 1050 | if self._v_recarray is not None: |
| 1051 | self._v_recarray = self._g_fix_byteorder_data( |
| 1052 | self._v_recarray, self._rabyteorder |
| 1053 | ) |
| 1054 | if len(self._v_recarray) > self._v_expectedrows: |
| 1055 | self._v_expectedrows = len(self._v_recarray) |
| 1056 | # Compute a sensible chunkshape |
| 1057 | if self._v_chunkshape is None: |
| 1058 | self._v_chunkshape = self._calc_chunkshape( |
| 1059 | self._v_expectedrows, self.rowsize, self.rowsize |
| 1060 | ) |
| 1061 | # Correct the byteorder, if still needed |
| 1062 | if self.byteorder is None: |
| 1063 | self.byteorder = sys.byteorder |
| 1064 | |
| 1065 | # Cache some data which is already in the description. |
| 1066 | # This is necessary to happen before creation time in order |
| 1067 | # to be able to populate the self._v_wdflts |
| 1068 | self._cache_description_data() |
| 1069 | |
| 1070 | # After creating the table, ``self._v_objectid`` needs to be |
| 1071 | # set because it is needed for setting attributes afterwards. |
| 1072 | self._v_objectid = self._create_table( |
| 1073 | self._v_new_title, self.filters.complib or "", obversion |
| 1074 | ) |
| 1075 | self._v_recarray = None # not useful anymore |
| 1076 | self._rabyteorder = None # not useful anymore |
| 1077 | |
| 1078 | # 2. Compute or get chunk shape and buffer size parameters. |
| 1079 | self.nrowsinbuf = self._calc_nrowsinbuf() |
| 1080 | |
| 1081 | # 3. Get field fill attributes from the table description and |
| 1082 | # set them on disk. |
| 1083 | if self._v_file.params["PYTABLES_SYS_ATTRS"]: |
| 1084 | set_attr = self._v_attrs._g__setattr |
| 1085 | for i, colobj in enumerate(self.description._f_walk(type="Col")): |
| 1086 | fieldname = "FIELD_%d_FILL" % i |
| 1087 | set_attr(fieldname, colobj.dflt) |
| 1088 | |
| 1089 | return self._v_objectid |
nothing calls this directly
no test coverage detected