Skip to content

Commit

Permalink
[apache#5633] remove unnecessary classes from the storage module
Browse files Browse the repository at this point in the history
  • Loading branch information
pithecuse527 committed Nov 26, 2024
1 parent 0421bd2 commit 0751646
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 25 deletions.
8 changes: 0 additions & 8 deletions core/src/main/java/org/apache/gravitino/EntityStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ public interface EntityStore extends Closeable {
*/
void initialize(Config config) throws RuntimeException;

/**
* Set the {@link EntitySerDe} for the entity store. {@link EntitySerDe} will be used to serialize
* and deserialize the entities to the target format, and vice versa.
*
* @param entitySerDe the entity serde to set
*/
void setSerDe(EntitySerDe entitySerDe);

/**
* List all the entities with the specified {@link org.apache.gravitino.Namespace}, and
* deserialize them into the specified {@link Entity} object.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.gravitino.storage;

import java.util.UUID;

/**
* Random id generator. This is used to generate random ids for entities. Please see {@link
* org.apache.gravitino.meta.BaseMetalake#ID} for more details.
*/
public class RandomIdGenerator implements IdGenerator {

public static final RandomIdGenerator INSTANCE = new RandomIdGenerator();

public static final long MAX_ID = 0x7fffffffffffffffL;

@Override
public long nextId() {
// Make sure this is a positive number.
return UUID.randomUUID().getLeastSignificantBits() & MAX_ID;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.apache.gravitino.Configs;
import org.apache.gravitino.Entity;
import org.apache.gravitino.EntityAlreadyExistsException;
import org.apache.gravitino.EntitySerDe;
import org.apache.gravitino.EntityStore;
import org.apache.gravitino.HasIdentifier;
import org.apache.gravitino.MetadataObject;
Expand Down Expand Up @@ -81,11 +80,6 @@ private static RelationalBackend createRelationalEntityBackend(Config config) {
}
}

@Override
public void setSerDe(EntitySerDe entitySerDe) {
throw new UnsupportedOperationException("Unsupported operation in relational entity store.");
}

@Override
public <E extends Entity & HasIdentifier> List<E> list(
Namespace namespace, Class<E> type, Entity.EntityType entityType) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ public static void setUp() throws Exception {

entityStore = new TestMemoryEntityStore.InMemoryEntityStore();
entityStore.initialize(config);
entityStore.setSerDe(null);

entityStore.put(metalakeEntity, true);
entityStore.put(userEntity, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public static void setUp() throws IOException {

entityStore = new TestMemoryEntityStore.InMemoryEntityStore();
entityStore.initialize(config);
entityStore.setSerDe(null);

entityStore.put(metalakeEntity, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ public static void setUp() throws IOException {

entityStore = new TestMemoryEntityStore.InMemoryEntityStore();
entityStore.initialize(config);
entityStore.setSerDe(null);

entityStore.put(metalakeEntity, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public static void setUp() throws IOException {

entityStore = spy(new TestMemoryEntityStore.InMemoryEntityStore());
entityStore.initialize(config);
entityStore.setSerDe(null);

BaseMetalake metalakeEntity =
BaseMetalake.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public static void setUp() {

entityStore = new TestMemoryEntityStore.InMemoryEntityStore();
entityStore.initialize(config);
entityStore.setSerDe(null);

metalakeManager = new MetalakeManager(entityStore, new RandomIdGenerator());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public static void setUp() {

entityStore = new TestMemoryEntityStore.InMemoryEntityStore();
entityStore.initialize(config);
entityStore.setSerDe(null);

MetalakeManager metalakeManager = new MetalakeManager(entityStore, new RandomIdGenerator());
metalakeNormalizeDispatcher = new MetalakeNormalizeDispatcher(metalakeManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.apache.gravitino.Entity;
import org.apache.gravitino.Entity.EntityType;
import org.apache.gravitino.EntityAlreadyExistsException;
import org.apache.gravitino.EntitySerDe;
import org.apache.gravitino.EntityStore;
import org.apache.gravitino.HasIdentifier;
import org.apache.gravitino.Metalake;
Expand Down Expand Up @@ -77,9 +76,6 @@ public void clear() {
@Override
public void initialize(Config config) throws RuntimeException {}

@Override
public void setSerDe(EntitySerDe entitySerDe) {}

@Override
public <E extends Entity & HasIdentifier> List<E> list(
Namespace namespace, Class<E> cl, EntityType entityType) throws IOException {
Expand Down Expand Up @@ -250,7 +246,6 @@ public void testEntityStoreAndRetrieve() throws Exception {

InMemoryEntityStore store = new InMemoryEntityStore();
store.initialize(Mockito.mock(Config.class));
store.setSerDe(Mockito.mock(EntitySerDe.class));

store.put(metalake);
store.put(catalog);
Expand Down

0 comments on commit 0751646

Please sign in to comment.