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 time-related types to the storage and transactional interfaces. #2437

Merged
merged 17 commits into from
Jan 8, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove deprecated Key constructor for time-related types
  • Loading branch information
Torch3333 committed Dec 26, 2024
commit 0b774d21af6fa787e4fd841d42ed03d484d40b99
60 changes: 4 additions & 56 deletions core/src/main/java/com/scalar/db/io/Key.java
Original file line number Diff line number Diff line change
@@ -172,58 +172,6 @@ public Key(String columnName, ByteBuffer blobValue) {
columns = Collections.singletonList(BlobColumn.of(columnName, blobValue));
}

/**
* Constructs a {@code Key} with a single column with a DATE type
*
* @param columnName a column name
* @param dateValue a DATE value of the column as LocalDate type
* @deprecated As of release 3.6.0. Will be removed in release 5.0.0. Use {@link #ofDate(String,
* LocalDate)} instead
*/
@Deprecated
public Key(String columnName, LocalDate dateValue) {
columns = Collections.singletonList(DateColumn.of(columnName, dateValue));
}

/**
* Constructs a {@code Key} with a single column with a TIME type
*
* @param columnName a column name
* @param timeValue a TIME value of the column as LocalTime type
* @deprecated As of release 3.6.0. Will be removed in release 5.0.0. Use {@link #ofTime(String,
* LocalTime)} instead
*/
@Deprecated
public Key(String columnName, LocalTime timeValue) {
columns = Collections.singletonList(TimeColumn.of(columnName, timeValue));
}

/**
* Constructs a {@code Key} with a single column with a TIMESTAMP type
*
* @param columnName a column name
* @param timestampValue a TIMESTAMP value of the column as LocalDateTime type
* @deprecated As of release 3.6.0. Will be removed in release 5.0.0. Use {@link
* #ofTimestamp(String, LocalDateTime)} instead
*/
@Deprecated
public Key(String columnName, LocalDateTime timestampValue) {
columns = Collections.singletonList(TimestampColumn.of(columnName, timestampValue));
}

/**
* Constructs a {@code Key} with a single column with a TIMESTAMPTZ type
*
* @param columnName a column name
* @param timestampTZValue a TIMESTAMPTZ value of the column as Instant type
* @deprecated As of release 3.6.0. Will be removed in release 5.0.0. Use {@link
* #ofTimestampTZ(String, Instant)} instead
*/
@Deprecated
public Key(String columnName, Instant timestampTZValue) {
columns = Collections.singletonList(TimestampTZColumn.of(columnName, timestampTZValue));
}

/**
* Constructs a {@code Key} with two columns
*
@@ -701,7 +649,7 @@ public static Key ofBlob(String columnName, ByteBuffer value) {
* @return a {@code Key} object
*/
public static Key ofDate(String columnName, LocalDate value) {
return new Key(columnName, value);
return new Key(Collections.singletonList(DateColumn.of(columnName, value)));
}

/**
@@ -712,7 +660,7 @@ public static Key ofDate(String columnName, LocalDate value) {
* @return a {@code Key} object
*/
public static Key ofTime(String columnName, LocalTime value) {
return new Key(columnName, value);
return new Key(Collections.singletonList(TimeColumn.of(columnName, value)));
}

/**
@@ -723,7 +671,7 @@ public static Key ofTime(String columnName, LocalTime value) {
* @return a {@code Key} object
*/
public static Key ofTimestamp(String columnName, LocalDateTime value) {
return new Key(columnName, value);
return new Key(Collections.singletonList(TimestampColumn.of(columnName, value)));
}

/**
@@ -734,7 +682,7 @@ public static Key ofTimestamp(String columnName, LocalDateTime value) {
* @return a {@code Key} object
*/
public static Key ofTimestampTZ(String columnName, Instant value) {
return new Key(columnName, value);
return new Key(Collections.singletonList(TimestampTZColumn.of(columnName, value)));
}

/**
68 changes: 0 additions & 68 deletions core/src/test/java/com/scalar/db/io/KeyTest.java
Original file line number Diff line number Diff line change
@@ -177,74 +177,6 @@ public void constructor_WithSingleByteBufferValue_ShouldReturnWhatsSet() {
assertThat(key.getBlobValueAsBytes(0)).isEqualTo(value);
}

@Test
public void constructor_WithSingleDateValue_ShouldReturnWhatsSet() {
// Arrange
String name = ANY_NAME_1;
Key key = new Key(name, ANY_DATE);

// Act Assert
List<Column<?>> columns = key.getColumns();
assertThat(columns.size()).isEqualTo(1);
assertThat(columns.get(0).getName()).isEqualTo(name);
assertThat(columns.get(0).getDateValue()).isEqualTo(ANY_DATE);

assertThat(key.size()).isEqualTo(1);
assertThat(key.getColumnName(0)).isEqualTo(name);
assertThat(key.getDateValue(0)).isEqualTo(ANY_DATE);
}

@Test
public void constructor_WithSingleTimeValue_ShouldReturnWhatsSet() {
// Arrange
String name = ANY_NAME_1;
Key key = new Key(name, ANY_TIME);

// Act Assert
List<Column<?>> columns = key.getColumns();
assertThat(columns.size()).isEqualTo(1);
assertThat(columns.get(0).getName()).isEqualTo(name);
assertThat(columns.get(0).getTimeValue()).isEqualTo(ANY_TIME);

assertThat(key.size()).isEqualTo(1);
assertThat(key.getColumnName(0)).isEqualTo(name);
assertThat(key.getTimeValue(0)).isEqualTo(ANY_TIME);
}

@Test
public void constructor_WithSingleTimestampValue_ShouldReturnWhatsSet() {
// Arrange
String name = ANY_NAME_1;
Key key = new Key(name, ANY_TIMESTAMP);

// Act Assert
List<Column<?>> columns = key.getColumns();
assertThat(columns.size()).isEqualTo(1);
assertThat(columns.get(0).getName()).isEqualTo(name);
assertThat(columns.get(0).getTimestampValue()).isEqualTo(ANY_TIMESTAMP);

assertThat(key.size()).isEqualTo(1);
assertThat(key.getColumnName(0)).isEqualTo(name);
assertThat(key.getTimestampValue(0)).isEqualTo(ANY_TIMESTAMP);
}

@Test
public void constructor_WithSingleTimestampTZValue_ShouldReturnWhatsSet() {
// Arrange
String name = ANY_NAME_1;
Key key = new Key(name, ANY_TIMESTAMPTZ);

// Act Assert
List<Column<?>> columns = key.getColumns();
assertThat(columns.size()).isEqualTo(1);
assertThat(columns.get(0).getName()).isEqualTo(name);
assertThat(columns.get(0).getTimestampTZValue()).isEqualTo(ANY_TIMESTAMPTZ);

assertThat(key.size()).isEqualTo(1);
assertThat(key.getColumnName(0)).isEqualTo(name);
assertThat(key.getTimestampTZValue(0)).isEqualTo(ANY_TIMESTAMPTZ);
}

@Test
public void constructor_WithMultipleNamesAndValues_ShouldReturnWhatsSet() {
// Arrange