Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add storageType field to HouseTable Entity #81

Merged
merged 7 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.linkedin.openhouse.internal.catalog.model;

import com.linkedin.openhouse.cluster.storage.StorageType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.IdClass;
Expand Down Expand Up @@ -39,4 +40,12 @@ public class HouseTable {
private long lastModifiedTime;

private long creationTime;

/**
* This column indicates the storage type used by this table. See {@link
* com.linkedin.openhouse.cluster.storage.StorageType}. A storage type indicates the {@link
* com.linkedin.openhouse.cluster.storage.StorageClient} implementation that is used to interact
* with this table.
*/
@Builder.Default private String storageType = StorageType.HDFS.getValue();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package com.linkedin.openhouse.internal.catalog.model;

import com.linkedin.openhouse.cluster.storage.StorageType;
import com.linkedin.openhouse.internal.catalog.mapper.HouseTableSerdeUtils;
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class HouseTableTest {

@Test
public void testHouseTableDefaultValues() {
HouseTable ht = HouseTable.builder().build();

try {
BeanInfo beanInfo = Introspector.getBeanInfo(HouseTable.class);

PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();

for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {

if (propertyDescriptor.getReadMethod() != null) {
Method getter = propertyDescriptor.getReadMethod();
Object value = getter.invoke(ht);

String fieldName =
getter.getName().substring(3, 4).toLowerCase() + getter.getName().substring(4);
if (!HouseTableSerdeUtils.HTS_FIELD_NAMES.contains(fieldName)) {
// not a field getter
continue;
}

if (fieldName.equals("storageType")) {
HotSushi marked this conversation as resolved.
Show resolved Hide resolved
Assertions.assertEquals(StorageType.HDFS.getValue(), value);
} else if (fieldName.equals("creationTime")) {
Assertions.assertEquals(0L, value);
} else if (fieldName.equals("lastModifiedTime")) {
Assertions.assertEquals(0L, value);
} else {
Assertions.assertNull(value, getter.getName() + " is not null: " + value);
}
}
}
} catch (Exception e) {
Assertions.fail(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public void testRepoSave() {
Assertions.assertEquals(result.getDatabaseId(), HOUSE_TABLE.getDatabaseId());
Assertions.assertEquals(result.getTableLocation(), HOUSE_TABLE.getTableLocation());
Assertions.assertEquals(result.getTableVersion(), HOUSE_TABLE.getTableVersion());
Assertions.assertEquals(result.getStorageType(), HOUSE_TABLE.getStorageType());
}

@Test
Expand Down