-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IGNITE-19082] Catalog. Cleanup dead code
- Loading branch information
Showing
7 changed files
with
242 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...atalog/src/main/java/org/apache/ignite/internal/catalog/commands/CreateSchemaCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.ignite.internal.catalog.commands; | ||
|
||
import java.util.List; | ||
import org.apache.ignite.internal.catalog.Catalog; | ||
import org.apache.ignite.internal.catalog.CatalogCommand; | ||
import org.apache.ignite.internal.catalog.CatalogValidationException; | ||
import org.apache.ignite.internal.catalog.descriptors.CatalogIndexDescriptor; | ||
import org.apache.ignite.internal.catalog.descriptors.CatalogSchemaDescriptor; | ||
import org.apache.ignite.internal.catalog.descriptors.CatalogSystemViewDescriptor; | ||
import org.apache.ignite.internal.catalog.descriptors.CatalogTableDescriptor; | ||
import org.apache.ignite.internal.catalog.storage.NewSchemaEntry; | ||
import org.apache.ignite.internal.catalog.storage.ObjectIdGenUpdateEntry; | ||
import org.apache.ignite.internal.catalog.storage.UpdateEntry; | ||
|
||
/** | ||
* Command to create a new schema. | ||
*/ | ||
public class CreateSchemaCommand implements CatalogCommand { | ||
|
||
private final String schemaName; | ||
|
||
private CreateSchemaCommand(String schemaName) { | ||
this.schemaName = schemaName; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public List<UpdateEntry> get(Catalog catalog) { | ||
int id = catalog.objectIdGenState(); | ||
|
||
if (schemaName == null) { | ||
throw new CatalogValidationException("Schema name is null"); | ||
} | ||
|
||
CatalogSchemaDescriptor schema = new CatalogSchemaDescriptor( | ||
id, | ||
schemaName, | ||
new CatalogTableDescriptor[0], | ||
new CatalogIndexDescriptor[0], | ||
new CatalogSystemViewDescriptor[0], | ||
0 | ||
); | ||
|
||
return List.of( | ||
new NewSchemaEntry(schema), | ||
new ObjectIdGenUpdateEntry(1) | ||
); | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static class Builder implements CreateSchemaCommandBuilder { | ||
|
||
private String name; | ||
|
||
Builder() { | ||
|
||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public CreateSchemaCommandBuilder name(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public CatalogCommand build() { | ||
return new CreateSchemaCommand(name); | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...src/main/java/org/apache/ignite/internal/catalog/commands/CreateSchemaCommandBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.ignite.internal.catalog.commands; | ||
|
||
import org.apache.ignite.internal.catalog.CatalogCommand; | ||
|
||
/** | ||
* Builder for a {@link CreateSchemaCommand}. | ||
*/ | ||
public interface CreateSchemaCommandBuilder { | ||
|
||
/** Sets schema name. */ | ||
CreateSchemaCommandBuilder name(String name); | ||
|
||
/** Creates new schema command. */ | ||
CatalogCommand build(); | ||
} |
83 changes: 83 additions & 0 deletions
83
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/storage/NewSchemaEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.ignite.internal.catalog.storage; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.apache.ignite.internal.catalog.Catalog; | ||
import org.apache.ignite.internal.catalog.descriptors.CatalogSchemaDescriptor; | ||
import org.apache.ignite.internal.catalog.storage.serialization.CatalogObjectSerializer; | ||
import org.apache.ignite.internal.catalog.storage.serialization.MarshallableEntryType; | ||
import org.apache.ignite.internal.util.io.IgniteDataInput; | ||
import org.apache.ignite.internal.util.io.IgniteDataOutput; | ||
|
||
/** | ||
* New schema entry. | ||
*/ | ||
public class NewSchemaEntry implements UpdateEntry { | ||
|
||
public static CatalogObjectSerializer<NewSchemaEntry> SERIALIZER = new CatalogObjectSerializer<NewSchemaEntry>() { | ||
@Override | ||
public NewSchemaEntry readFrom(IgniteDataInput input) throws IOException { | ||
CatalogSchemaDescriptor schemaDescriptor = CatalogSchemaDescriptor.SERIALIZER.readFrom(input); | ||
return new NewSchemaEntry(schemaDescriptor); | ||
} | ||
|
||
@Override | ||
public void writeTo(NewSchemaEntry value, IgniteDataOutput output) throws IOException { | ||
CatalogSchemaDescriptor.SERIALIZER.writeTo(value.descriptor, output); | ||
} | ||
}; | ||
|
||
private final CatalogSchemaDescriptor descriptor; | ||
|
||
public NewSchemaEntry(CatalogSchemaDescriptor descriptor) { | ||
this.descriptor = descriptor; | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public Catalog applyUpdate(Catalog catalog, long causalityToken) { | ||
CatalogSchemaDescriptor schema = catalog.schema(descriptor.name()); | ||
if (schema != null) { | ||
return catalog; | ||
} | ||
|
||
descriptor.updateToken(causalityToken); | ||
|
||
List<CatalogSchemaDescriptor> schemas = new ArrayList<>(catalog.schemas().size() + 1); | ||
schemas.addAll(catalog.schemas()); | ||
schemas.add(descriptor); | ||
|
||
return new Catalog( | ||
catalog.version(), | ||
catalog.time(), | ||
catalog.objectIdGenState(), | ||
catalog.zones(), | ||
schemas, | ||
catalog.defaultZone().id() | ||
); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public int typeId() { | ||
return MarshallableEntryType.NEW_SCHEMA.id(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters