-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
211 additions
and
188 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
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
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,110 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Copyright 2018-2020 The Feast Authors | ||
* | ||
* 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 | ||
* | ||
* https://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 feast.core.model; | ||
|
||
import com.google.common.base.Objects; | ||
import com.google.protobuf.InvalidProtocolBufferException; | ||
import feast.proto.core.StoreProto; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.Serializable; | ||
import javax.persistence.*; | ||
import javax.persistence.Entity; | ||
import lombok.AllArgsConstructor; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Entity | ||
@Table( | ||
name = "jobs_stores", | ||
indexes = { | ||
@Index(name = "idx_jobs_stores_job_id", columnList = "job_id"), | ||
@Index(name = "idx_jobs_stores_store_name", columnList = "store_name") | ||
}) | ||
@Getter | ||
@Setter | ||
public class JobStore { | ||
@Embeddable | ||
@EqualsAndHashCode | ||
@AllArgsConstructor | ||
public static class JobStoreKey implements Serializable { | ||
public JobStoreKey() {} | ||
|
||
@Column(name = "job_id") | ||
String jobId; | ||
|
||
@Column(name = "store_name") | ||
String storeName; | ||
} | ||
|
||
@EmbeddedId private JobStoreKey id = new JobStoreKey(); | ||
|
||
@ManyToOne | ||
@MapsId("jobId") | ||
@JoinColumn(name = "job_id") | ||
private Job job; | ||
|
||
@Column(name = "store_proto", nullable = false) | ||
@Lob | ||
private byte[] storeProto; | ||
|
||
public JobStore() {} | ||
|
||
public JobStore(Job job, Store store) { | ||
this.job = job; | ||
this.id.storeName = store.getName(); | ||
try { | ||
setStoreProto(store.toProto()); | ||
} catch (InvalidProtocolBufferException e) { | ||
throw new RuntimeException("Couldn't convert Store to proto. Reason: %s", e.getCause()); | ||
} | ||
} | ||
|
||
public StoreProto.Store getStoreProto() { | ||
try { | ||
return StoreProto.Store.parseFrom(storeProto); | ||
} catch (InvalidProtocolBufferException e) { | ||
return StoreProto.Store.newBuilder().build(); | ||
} | ||
} | ||
|
||
public void setStoreProto(StoreProto.Store storeProto) { | ||
ByteArrayOutputStream output = new ByteArrayOutputStream(); | ||
try { | ||
storeProto.writeTo(output); | ||
} catch (IOException e) { | ||
throw new RuntimeException( | ||
String.format("Couldn't write StoreProto to byteArray: %s", e.getCause())); | ||
} | ||
|
||
this.storeProto = output.toByteArray(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
JobStore jobStore = (JobStore) o; | ||
return Objects.equal(id, jobStore.id) && Objects.equal(storeProto, jobStore.storeProto); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hashCode(id, storeProto); | ||
} | ||
} |
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
2 changes: 0 additions & 2 deletions
2
core/src/main/resources/db/migration/V2.4__Store_Timestamps.sql
This file was deleted.
Oops, something went wrong.
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 @@ | ||
ALTER TABLE jobs_stores ADD COLUMN store_proto oid not null; |
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
Oops, something went wrong.