本文整理汇总了Java中org.ojai.store.DocumentMutation类的典型用法代码示例。如果您正苦于以下问题:Java DocumentMutation类的具体用法?Java DocumentMutation怎么用?Java DocumentMutation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentMutation类属于org.ojai.store包,在下文中一共展示了DocumentMutation类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: update
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @param id identifier of document, which will be updated.
* @param artistRate artist rate.
* @return updated artist rate.
*/
@Override
public ArtistRate update(String id, ArtistRate artistRate) {
return processStore((connection, store) -> {
Stopwatch stopwatch = Stopwatch.createStarted();
// Create a DocumentMutation to update non-null fields
DocumentMutation mutation = connection.newMutation();
// Update only non-null fields
if (artistRate.getRating() != null) {
mutation.set("rating", artistRate.getRating());
}
// Update the OJAI Document with specified identifier
store.update(id, mutation);
Document updatedOjaiDoc = store.findById(id);
log.debug("Update document from table '{}' with id: '{}'. Elapsed time: {}", tablePath, id, stopwatch);
// Map Ojai document to the actual instance of model class
return mapOjaiDocument(updatedOjaiDoc);
});
}
开发者ID:mapr-demos,项目名称:mapr-music,代码行数:33,代码来源:ArtistRateDao.java
示例2: update
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @param id identifier of document, which will be updated.
* @param id identifier of document, which will be updated.
* @param statistic statistic.
* @return updated statistic.
*/
@Override
public Statistic update(String id, Statistic statistic) {
return processStore((connection, store) -> {
Stopwatch stopwatch = Stopwatch.createStarted();
// Create a DocumentMutation to update non-null fields
DocumentMutation mutation = connection.newMutation();
// Update only non-null fields
if (statistic.getDocumentNumber() != null) {
mutation.set("document_number", statistic.getDocumentNumber());
}
// Update the OJAI Document with specified identifier
store.update(id, mutation);
Document updatedOjaiDoc = store.findById(id);
log.debug("Update document from table '{}' with id: '{}'. Elapsed time: {}", tablePath, id, stopwatch);
// Map Ojai document to the actual instance of model class
return mapOjaiDocument(updatedOjaiDoc);
});
}
开发者ID:mapr-demos,项目名称:mapr-music,代码行数:34,代码来源:StatisticDao.java
示例3: update
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @param id identifier of document, which will be updated.
* @param albumRate album rate.
* @return updated album rate.
*/
@Override
public AlbumRate update(String id, AlbumRate albumRate) {
return processStore((connection, store) -> {
Stopwatch stopwatch = Stopwatch.createStarted();
// Create a DocumentMutation to update non-null fields
DocumentMutation mutation = connection.newMutation();
// Update only non-null fields
if (albumRate.getRating() != null) {
mutation.set("rating", albumRate.getRating());
}
// Update the OJAI Document with specified identifier
store.update(id, mutation);
Document updatedOjaiDoc = store.findById(id);
log.debug("Update document from table '{}' with id: '{}'. Elapsed time: {}", tablePath, id, stopwatch);
// Map Ojai document to the actual instance of model class
return mapOjaiDocument(updatedOjaiDoc);
});
}
开发者ID:mapr-demos,项目名称:mapr-music,代码行数:33,代码来源:AlbumRateDao.java
示例4: update
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @param id identifier of album, which will be updated.
* @param album contains album info that will be updated.
* @return updated album.
*/
@Override
@SuppressWarnings("unchecked")
public Album update(String id, Album album) {
return processStore((connection, store) -> {
Stopwatch stopwatch = Stopwatch.createStarted();
// Update basic fields
DocumentMutation albumMutation = AlbumMutationBuilder.forConnection(connection)
.setName(album.getName())
.setBarcode(album.getBarcode())
.setCountry(album.getCountry())
.setLanguage(album.getLanguage())
.setPackaging(album.getPackaging())
.setTrackList(album.getTrackList())
.setArtists(album.getArtists())
.setFormat(album.getFormat())
.setDateDay(album.getReleasedDate())
.setRating(album.getRating())
.build();
// Set update info if available
getUpdateInfo().ifPresent(updateInfo -> albumMutation.set("update_info", updateInfo));
// Update the OJAI Document with specified identifier
store.update(id, albumMutation);
Document updatedOjaiDoc = store.findById(id);
log.debug("Update document from table '{}' with id: '{}'. Elapsed time: {}", tablePath, id, stopwatch);
// Map Ojai document to the actual instance of model class
return mapOjaiDocument(updatedOjaiDoc);
});
}
开发者ID:mapr-demos,项目名称:mapr-music,代码行数:44,代码来源:AlbumDao.java
示例5: deleteTrack
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
/**
* Deletes single track according to the specified album identifier and track identifier.
*
* @param albumId identifier of album, for which track will be deleted.
* @param trackId identifier of track, which will be deleted.
* @return <code>true</code> if track is successfully deleted, <code>false</code> otherwise.
*/
public boolean deleteTrack(String albumId, String trackId) {
List<Track> existingAlbumTracks = getTracksList(albumId);
if (existingAlbumTracks == null) {
return false;
}
int trackIndex = getTrackIndexById(existingAlbumTracks, trackId);
if (trackIndex < 0) {
return false;
}
return processStore((connection, store) -> {
Stopwatch stopwatch = Stopwatch.createStarted();
// Delete single track
DocumentMutation mutation = AlbumMutationBuilder.forConnection(connection)
.deleteTrack(trackIndex).build();
// Set update info if available
getUpdateInfo().ifPresent(updateInfo -> mutation.set("update_info", updateInfo));
// Update the OJAI Document with specified identifier
store.update(albumId, mutation);
log.debug("Deleting album's track with id: '{}' for albumId: '{}' took {}", trackId, albumId, stopwatch);
return true;
});
}
开发者ID:mapr-demos,项目名称:mapr-music,代码行数:40,代码来源:AlbumDao.java
示例6: update
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
@Override
public User update(String id, User user) {
return processStore((connection, store) -> {
Stopwatch stopwatch = Stopwatch.createStarted();
// Create a DocumentMutation to update non-null fields
DocumentMutation mutation = connection.newMutation();
// Update only non-null fields
if (user.getFirstName() != null) {
mutation.set("first_name", user.getFirstName());
}
if (user.getLastName() != null) {
mutation.set("last_name", user.getLastName());
}
// Update the OJAI Document with specified identifier
store.update(id, mutation);
Document updatedOjaiDoc = store.findById(id);
log.debug("Update document from table '{}' with id: '{}'. Elapsed time: {}", tablePath, id, stopwatch);
// Map Ojai document to the actual instance of model class
return mapOjaiDocument(updatedOjaiDoc);
});
}
开发者ID:mapr-demos,项目名称:mapr-music,代码行数:30,代码来源:UserDao.java
示例7: newSimulation
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
public void newSimulation(){
DocumentMutation mutation = MapRDB.newMutation().
setOrReplace("time", new Date().getTime()).
increment("simulationId", 1);
simulationTable.update(SIMULATION_KEY, mutation);
addInitialStats();
}
开发者ID:mapr-demos,项目名称:telco-anomaly-detection-spark,代码行数:8,代码来源:DAO.java
示例8: addNewClickToPage
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
private void addNewClickToPage(String s) {
// add clicks to the document
Document clickDetail = Json.newDocument()
.set("ip", "54.54.54.54")
.set("at", new OTimestamp(new java.util.Date()));
DocumentMutation mutation = MapRDB.newMutation()
.increment("nb_of_clicks", 1)
.append("X", "X")
.append("clicks", Arrays.asList(clickDetail));
table.update("index.html", mutation);
}
开发者ID:mapr-demos,项目名称:maprdb-ojai-101,代码行数:14,代码来源:Ex02MapRdbAdmin.java
示例9: createDocumentMutationInternal
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
@Override
protected DocumentMutation createDocumentMutationInternal() {
if(connection == null) {
startConnection();
}
return connection.newMutation();
}
开发者ID:streamsets,项目名称:datacollector,代码行数:9,代码来源:MapRJson6_0DocumentLoader.java
示例10: createDocumentMutation
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
public static DocumentMutation createDocumentMutation() {
if(isTest) {
Preconditions.checkNotNull(testDelegate);
return testDelegate.createDocumentMutationInternal();
} else {
Preconditions.checkNotNull(delegate);
return delegate.createDocumentMutationInternal();
}
}
开发者ID:streamsets,项目名称:datacollector,代码行数:10,代码来源:MapRJsonDocumentLoader.java
示例11: commitMutation
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
public static void commitMutation(String tableName, String fieldPath, DocumentMutation documentMutation) throws MapRJsonDocumentLoaderException {
if(isTest) {
Preconditions.checkNotNull(testDelegate);
testDelegate.commitMutationInternal(tableName, fieldPath, documentMutation);
} else {
Preconditions.checkNotNull(delegate);
delegate.commitMutationInternal(tableName, fieldPath, documentMutation);
}
}
开发者ID:streamsets,项目名称:datacollector,代码行数:10,代码来源:MapRJsonDocumentLoader.java
示例12: performUpdateOperation
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
private void performUpdateOperation(Record rec) throws StageException {
ByteArrayOutputStream os = new ByteArrayOutputStream(1024 * 1024);
createJson(os, rec);
DocumentMutation document = populateDocumentMutation(rec);
doUpdate(document, rec);
flush();
}
开发者ID:streamsets,项目名称:datacollector,代码行数:8,代码来源:MapRJsonTarget.java
示例13: update
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @param id identifier of document, which will be updated.
* @param artist contains artist info that will be updated.
* @return updated artist.
*/
@Override
public Artist update(String id, Artist artist) {
return processStore((connection, store) -> {
Stopwatch stopwatch = Stopwatch.createStarted();
// Create a DocumentMutation to update non-null fields
DocumentMutation mutation = connection.newMutation();
// Update only non-null fields
if (artist.getName() != null) {
mutation.set("name", artist.getName());
}
if (artist.getGender() != null) {
mutation.set("gender", artist.getGender());
}
if (artist.getBeginDate() != null) {
mutation.set("begin_date", artist.getBeginDate());
}
if (artist.getEndDate() != null) {
mutation.set("end_date", artist.getEndDate());
}
if (artist.getIpi() != null) {
mutation.set("IPI", artist.getIpi());
}
if (artist.getIsni() != null) {
mutation.set("ISNI", artist.getIsni());
}
if (artist.getArea() != null) {
mutation.set("area", artist.getArea());
}
if (artist.getAlbums() != null) {
List<Map> albumsMapList = artist.getAlbums().stream()
.map(album -> mapper.convertValue(album, Map.class))
.collect(Collectors.toList());
mutation.set("albums", albumsMapList);
}
if (artist.getProfileImageUrl() != null) {
mutation.set("profile_image_url", artist.getProfileImageUrl());
}
if (artist.getDeleted() != null) {
mutation.set("deleted", artist.getDeleted());
}
if (artist.getRating() != null) {
mutation.set("rating", artist.getRating());
}
// Set update info if available
getUpdateInfo().ifPresent(updateInfo -> mutation.set("update_info", updateInfo));
// Update the OJAI Document with specified identifier
store.update(id, mutation);
Document updatedOjaiDoc = store.findById(id);
log.debug("Update document from table '{}' with id: '{}'. Elapsed time: {}", tablePath, id, stopwatch);
// Map Ojai document to the actual instance of model class
return mapOjaiDocument(updatedOjaiDoc);
});
}
开发者ID:mapr-demos,项目名称:mapr-music,代码行数:81,代码来源:ArtistDao.java
示例14: build
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
public DocumentMutation build() {
return this.mutation;
}
开发者ID:mapr-demos,项目名称:mapr-music,代码行数:4,代码来源:AlbumMutationBuilder.java
示例15: newMutation
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
@Override
public DocumentMutation newMutation() {
throw new UnsupportedOperationException();
}
开发者ID:ojai,项目名称:ojai,代码行数:5,代码来源:DummyJsonDriver.java
示例16: newMutation
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
@Override
public DocumentMutation newMutation() {
return driver.newMutation();
}
开发者ID:ojai,项目名称:ojai,代码行数:5,代码来源:DummyJsonConnection.java
示例17: createDocumentMutationInternal
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
@Override
protected DocumentMutation createDocumentMutationInternal() {
return MapRDB.newMutation();
}
开发者ID:streamsets,项目名称:datacollector,代码行数:5,代码来源:MapRJson5_2DocumentLoader.java
示例18: commitMutationInternal
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
@Override
protected void commitMutationInternal(String tableName, String fieldPath, DocumentMutation documentMutation) throws MapRJsonDocumentLoaderException {
initTable(tableName, false);
theTables.get(tableName).update(fieldPath, documentMutation);
}
开发者ID:streamsets,项目名称:datacollector,代码行数:6,代码来源:MapRJson5_2DocumentLoader.java
示例19: commitMutationInternal
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
@Override
protected void commitMutationInternal(String tableName, String fieldPath, DocumentMutation documentMutation) throws MapRJsonDocumentLoaderException {
initTable(tableName, false);
theStores.get(tableName).update(fieldPath, documentMutation);
}
开发者ID:streamsets,项目名称:datacollector,代码行数:6,代码来源:MapRJson6_0DocumentLoader.java
示例20: populateDocumentMutation
import org.ojai.store.DocumentMutation; //导入依赖的package包/类
private DocumentMutation populateDocumentMutation(Record rec) throws OnRecordErrorException {
DocumentMutation documentMutation = MapRJsonDocumentLoader.createDocumentMutation();
boolean replace = mapRJsonConfigBean.setOrReplace == SetOrReplace.REPLACE;
if(rec != null && (rec.get().getType() == Field.Type.LIST_MAP || rec.get().getType() == Field.Type.MAP)) {
Map<String, Field> fields = rec.get().getValueAsMap();
for(Map.Entry<String, Field> entry : fields.entrySet()) {
String path = entry.getKey();
Field field = entry.getValue();
//don't add the keyField to the document mutation set. that gets added later
if(entry.getKey().equals(mapRJsonConfigBean.keyField)) {
continue;
}
switch(field.getType()) {
case DOUBLE:
double d = field.getValueAsDouble();
documentMutation = (replace ? documentMutation.setOrReplace(path, d) : documentMutation.set(path, d));
break;
case FLOAT:
float f = field.getValueAsFloat();
documentMutation = (replace ? documentMutation.setOrReplace(path, f) : documentMutation.set(path, f));
break;
case INTEGER:
int i = field.getValueAsInteger();
documentMutation = (replace ? documentMutation.setOrReplace(path, i) : documentMutation.set(path, i));
break;
case SHORT:
short s = field.getValueAsShort();
documentMutation = (replace ? documentMutation.setOrReplace(path, s) : documentMutation.set(path, s));
break;
case LONG:
case DATE:
case TIME:
case DATETIME:
long l = field.getValueAsLong();
documentMutation = (replace ? documentMutation.setOrReplace(path, l) : documentMutation.set(path, l));
break;
case STRING:
String st = field.getValueAsString();
documentMutation = (replace ? documentMutation.setOrReplace(path, st) : documentMutation.set(path, st));
break;
case BYTE_ARRAY:
byte[] ba = field.getValueAsByteArray();
documentMutation = (replace ? documentMutation.setOrReplace(path, ByteBuffer.wrap(ba)) : documentMutation.set(path, ByteBuffer.wrap(ba)));
break;
case BOOLEAN:
case MAP:
case LIST:
case LIST_MAP:
case CHAR:
case BYTE:
default:
throw new OnRecordErrorException(rec, Errors.MAPR_JSON_14, field.getType().name());
}
}
}
return documentMutation;
}
开发者ID:streamsets,项目名称:datacollector,代码行数:61,代码来源:MapRJsonTarget.java
注:本文中的org.ojai.store.DocumentMutation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论