-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Keysets to to table dto / info (#452)
* wip * wip2 * wip3 * extend serializable * implement serializable
- Loading branch information
Showing
13 changed files
with
409 additions
and
63 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
...mmon-server/src/main/java/com/netflix/metacat/common/server/connectors/model/KeyInfo.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,25 @@ | ||
package com.netflix.metacat.common.server.connectors.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
/** | ||
* Key Info. | ||
*/ | ||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@EqualsAndHashCode(callSuper = false) | ||
public class KeyInfo implements Serializable { | ||
private static final long serialVersionUID = 7254898853779135216L; | ||
|
||
private String name; | ||
private List<String> fields; | ||
} |
88 changes: 88 additions & 0 deletions
88
...n-server/src/main/java/com/netflix/metacat/common/server/connectors/model/KeySetInfo.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,88 @@ | ||
package com.netflix.metacat.common.server.connectors.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.io.Serializable; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
/** | ||
* KeySet Info. | ||
*/ | ||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@EqualsAndHashCode(callSuper = false) | ||
public class KeySetInfo implements Serializable { | ||
private static final long serialVersionUID = 3659843901964058788L; | ||
|
||
private static final String PARTITION_KEY_DEFAULT_NAME = "partition"; | ||
private static final String PRIMARY_KEY_DEFAULT_NAME = "primary"; | ||
private static final String SORT_KEY_DEFAULT_NAME = "sort"; | ||
private static final String INDEX_KEY_DEFAULT_NAME = "index"; | ||
|
||
private List<KeyInfo> partition; | ||
private List<KeyInfo> primary; | ||
private List<KeyInfo> sort; | ||
private List<KeyInfo> index; | ||
|
||
/** | ||
* builds a keyset from fieldInfo list. | ||
* | ||
* @param fields list of fieldInfo | ||
* @return keyset | ||
*/ | ||
public static KeySetInfo buildKeySet(final List<FieldInfo> fields) { | ||
return buildKeySet(fields, null); | ||
} | ||
|
||
/** | ||
* builds a keyset from fieldInfo list and primary key list. | ||
* | ||
* @param fields list of fieldInfo | ||
* @param primary list of primary keys | ||
* @return keyset | ||
*/ | ||
public static KeySetInfo buildKeySet(final List<FieldInfo> fields, final List<KeyInfo> primary) { | ||
if (fields == null) { | ||
return null; | ||
} else if (fields.isEmpty()) { | ||
return new KeySetInfo(); | ||
} | ||
|
||
final List<String> partitionKeys = new LinkedList<>(); | ||
final List<String> sortKeys = new LinkedList<>(); | ||
final List<String> indexKeys = new LinkedList<>(); | ||
for (FieldInfo field : fields) { | ||
if (field.isPartitionKey()) { | ||
partitionKeys.add(field.getName()); | ||
} | ||
if (field.getIsSortKey() != null && field.getIsSortKey()) { | ||
sortKeys.add(field.getName()); | ||
} | ||
if (field.getIsIndexKey() != null && field.getIsIndexKey()) { | ||
indexKeys.add(field.getName()); | ||
} | ||
} | ||
|
||
final KeySetInfo keySetInfo = new KeySetInfo(); | ||
keySetInfo.partition = partitionKeys.isEmpty() ? Collections.emptyList() | ||
: Arrays.asList( | ||
KeyInfo.builder().name(PARTITION_KEY_DEFAULT_NAME).fields(partitionKeys).build()); | ||
keySetInfo.sort = sortKeys.isEmpty() ? Collections.emptyList() | ||
: Arrays.asList(KeyInfo.builder().name(SORT_KEY_DEFAULT_NAME).fields(sortKeys).build()); | ||
keySetInfo.index = indexKeys.isEmpty() ? Collections.emptyList() | ||
: Arrays.asList(KeyInfo.builder().name(INDEX_KEY_DEFAULT_NAME).fields(indexKeys).build()); | ||
keySetInfo.primary = (primary == null || primary.isEmpty()) ? Collections.emptyList() | ||
: primary; | ||
|
||
return keySetInfo; | ||
} | ||
} |
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
17 changes: 17 additions & 0 deletions
17
metacat-common/src/main/java/com/netflix/metacat/common/dto/ClusterDto.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
41 changes: 41 additions & 0 deletions
41
metacat-common/src/main/java/com/netflix/metacat/common/dto/KeyDto.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,41 @@ | ||
/* | ||
* | ||
* Copyright 2016 Netflix, Inc. | ||
* | ||
* Licensed 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 com.netflix.metacat.common.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Key DTO. | ||
*/ | ||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@EqualsAndHashCode(callSuper = false) | ||
public class KeyDto extends BaseDto { | ||
private static final long serialVersionUID = 5511551575484406779L; | ||
|
||
private String name; | ||
private List<String> fields; | ||
} |
43 changes: 43 additions & 0 deletions
43
metacat-common/src/main/java/com/netflix/metacat/common/dto/KeySetDto.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,43 @@ | ||
/* | ||
* | ||
* Copyright 2016 Netflix, Inc. | ||
* | ||
* Licensed 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 com.netflix.metacat.common.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* KeySet DTO. | ||
*/ | ||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@EqualsAndHashCode(callSuper = false) | ||
public class KeySetDto extends BaseDto { | ||
private static final long serialVersionUID = 6250093794701822334L; | ||
|
||
private List<KeyDto> partition; | ||
private List<KeyDto> primary; | ||
private List<KeyDto> sort; | ||
private List<KeyDto> index; | ||
} |
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
Oops, something went wrong.