-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Santhosh Gandhe <[email protected]>
- Loading branch information
Showing
9 changed files
with
74 additions
and
93 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
39 changes: 18 additions & 21 deletions
39
...rc/main/java/org/opensearch/dataprepper/plugins/source/source_crawler/model/ItemInfo.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 |
---|---|---|
@@ -1,49 +1,46 @@ | ||
package org.opensearch.dataprepper.plugins.source.source_crawler.model; | ||
|
||
|
||
import lombok.Getter; | ||
import lombok.NonNull; | ||
|
||
import java.time.Instant; | ||
import java.util.Map; | ||
|
||
|
||
@Getter | ||
public abstract class ItemInfo { | ||
|
||
public interface ItemInfo { | ||
|
||
/** | ||
* Use this field to store primary item of a repository. Primary item of a repository is something | ||
* which can be fetched/queried/obtained from repository just using its item ID. | ||
* which can be fetched/queried/obtained from source service just using its item ID. | ||
*/ | ||
@NonNull | ||
String itemId; | ||
String getItemId(); | ||
|
||
/** | ||
* Use this field to store items metadata. Item metadata can be any information other than item | ||
* contents itself which can be used to apply regex filtering, change data capture etc. general | ||
* assumption here is that fetching metadata should be faster than fetching entire Item | ||
*/ | ||
Map<String, Object> metadata; | ||
Map<String, Object> getMetadata(); | ||
|
||
/** | ||
* Process your change log events serially (preferably in a single thread) and ensure that you are | ||
* applying monotonously increasing timeStamp. If you don't do that, then SDK could miss latest | ||
* updates as it processes events out of order and it relies on this member to decide which change | ||
* log events to keep and which ones to discard. | ||
*/ | ||
Instant eventTime; | ||
Instant getEventTime(); | ||
|
||
public ItemInfo(String itemId) { | ||
this.itemId = itemId; | ||
} | ||
String getPartitionKey(); | ||
|
||
public ItemInfo(@NonNull String itemId, Map<String, Object> metadata, Instant eventTime) { | ||
this.itemId = itemId; | ||
this.metadata = metadata; | ||
this.eventTime = eventTime; | ||
} | ||
/** | ||
* Service specific Unique Id of this Item. | ||
* @return String value indicating unique id of this item. | ||
*/ | ||
String getId(); | ||
|
||
public abstract String getPartitionKey(); | ||
public abstract String getId(); | ||
public abstract Map<String, String> getKeyAttributes(); | ||
/** | ||
* Key attributes related to this Item. | ||
* | ||
* @return A map of key attributes of this Item. | ||
*/ | ||
Map<String, String> getKeyAttributes(); | ||
} |
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
51 changes: 51 additions & 0 deletions
51
...est/java/org/opensearch/dataprepper/plugins/source/source_crawler/model/TestItemInfo.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,51 @@ | ||
package org.opensearch.dataprepper.plugins.source.source_crawler.model; | ||
|
||
import java.time.Instant; | ||
import java.util.Map; | ||
|
||
public class TestItemInfo implements ItemInfo { | ||
|
||
String itemId; | ||
Map<String, Object> metadata; | ||
Instant eventTime; | ||
|
||
public TestItemInfo(String itemId, Map<String, Object> metadata, Instant eventTime) { | ||
this.itemId = itemId; | ||
this.metadata = metadata; | ||
this.eventTime = eventTime; | ||
} | ||
|
||
public TestItemInfo(String itemId) { | ||
this.itemId = itemId; | ||
} | ||
|
||
@Override | ||
public String getItemId() { | ||
return itemId; | ||
} | ||
|
||
@Override | ||
public Map<String, Object> getMetadata() { | ||
return this.metadata; | ||
} | ||
|
||
@Override | ||
public Instant getEventTime() { | ||
return this.eventTime; | ||
} | ||
|
||
@Override | ||
public String getPartitionKey() { | ||
return "partitionKey"; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return "id"; | ||
} | ||
|
||
@Override | ||
public Map<String, String> getKeyAttributes() { | ||
return Map.of(); | ||
} | ||
} |