tkalkirill commented on code in PR #773:
URL: https://github.com/apache/ignite-3/pull/773#discussion_r851074880
##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/DataStorageManager.java:
##########
@@ -118,6 +96,73 @@ public Consumer<DataStorageChange>
defaultTableDataStorageConsumer(String defaul
};
}
+ /**
+ * Returns the default data storage.
+ *
+ * @param defaultDataStorageView View of {@link
TablesConfigurationSchema#defaultDataStorage}. For the case {@link
+ * UnknownDataStorageConfigurationSchema#UNKNOWN_DATA_STORAGE} and there
is only one engine, then it will be the default.
+ */
+ public String defaultDataStorage(String defaultDataStorageView) {
+ return !defaultDataStorageView.equals(UNKNOWN_DATA_STORAGE) ||
engines.size() > 1
+ ? defaultDataStorageView : first(engines.keySet());
+ }
+
+ /**
+ * Creates a consumer that will change the {@link
DataStorageConfigurationSchema data storage} for the {@link
+ * TableConfigurationSchema#dataStorage}.
+ *
+ * @param dataStorage Data storage, {@link
UnknownDataStorageConfigurationSchema#UNKNOWN_DATA_STORAGE} is invalid.
+ * @param values {@link Value Values} for the data storage. Mapping: field
name -> field value.
+ */
+ public Consumer<DataStorageChange> tableDataStorageConsumer(String
dataStorage, Map<String, Object> values) {
+ assert !dataStorage.equals(UNKNOWN_DATA_STORAGE);
+
+ ConfigurationSource configurationSource = new ConfigurationSource() {
+ /** {@inheritDoc} */
+ @Override
+ public String polymorphicTypeId(String fieldName) {
+ throw new UnsupportedOperationException("polymorphicTypeId");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void descend(ConstructableTreeNode node) {
+ for (Entry<String, Object> e : values.entrySet()) {
+ assert e.getKey() != null;
+ assert e.getValue() != null : e.getKey();
+
+ ConfigurationSource leafSource = new ConfigurationSource()
{
+ /** {@inheritDoc} */
+ @Override
+ public <T> T unwrap(Class<T> clazz) {
+ return clazz.cast(e.getValue());
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void descend(ConstructableTreeNode node) {
+ throw new UnsupportedOperationException("descend");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String polymorphicTypeId(String fieldName) {
+ throw new
UnsupportedOperationException("polymorphicTypeId");
+ }
+ };
+
+ node.construct(e.getKey(), leafSource, true);
+ }
+ }
+ };
+
+ return tableDataStorageChange -> {
+ tableDataStorageChange.convert(dataStorage);
+
+ configurationSource.descend(((ConstructableTreeNode)
tableDataStorageChange));
Review Comment:
Fix it
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]