Registers a new vector function. When overwrite = true, previous functions with the given name will be replaced. Returns true iff an insertion actually happened
| 116 | /// with the given name will be replaced. |
| 117 | /// Returns true iff an insertion actually happened |
| 118 | bool registerStatefulVectorFunction( |
| 119 | const std::string& name, |
| 120 | std::vector<FunctionSignaturePtr> signatures, |
| 121 | VectorFunctionFactory factory, |
| 122 | VectorFunctionMetadata metadata, |
| 123 | bool overwrite) { |
| 124 | auto sanitizedName = sanitizeName(name); |
| 125 | |
| 126 | if (overwrite) { |
| 127 | vectorFunctionFactories().withWLock([&](auto& functionMap) { |
| 128 | // Insert/overwrite. |
| 129 | functionMap[sanitizedName] = { |
| 130 | std::move(signatures), std::move(factory), std::move(metadata)}; |
| 131 | }); |
| 132 | return true; |
| 133 | } |
| 134 | |
| 135 | return vectorFunctionFactories().withWLock([&](auto& functionMap) { |
| 136 | auto [iterator, inserted] = functionMap.insert( |
| 137 | {sanitizedName, |
| 138 | {std::move(signatures), std::move(factory), std::move(metadata)}}); |
| 139 | return inserted; |
| 140 | }); |
| 141 | } |
| 142 | |
| 143 | // Returns true iff an insertion actually happened |
| 144 | bool registerVectorFunction( |