I just started working with dynamodb, and I couldnt figure out how to retrieve values from SdkPublisher.
My code is using dynamoDBAsyncClient, and I want migrate to dynamodbEnhancedAsyncClient.
I tried to use this example on https://github.com/aws/aws-sdk-java-v2/blob/master/services-custom/dynamodb-enhanced/README.md#non-blocking-asynchronous-operations
List<String> tables = Flowable.fromPublisher(publisher)
.flatMapIterable(ListTablesResponse::tableNames)
.toList()
.blockingGet();
But this example retrieves table names and when I adapted for my situation it blocks on "blockingGet()".
Related
I have a Spring application that runs a cron on it. The cron every few minutes gets new data from external API. The data should be stored in a database (MySQL), in place of old data (Old data should be overwritten by new data). The data requires to be overwritten instead of updated. The application itself provides REST API so the client is able to get the data from the database. So there should not be situation that client sees an empty or just a part of data from database because there is an data update.
Currently I've tried deleting whole old data and insert new data but there is a place that a client gets just a part of the data. I've tried it via Spring Data deleteAll and saveAll methods.
#Override
#Transactional
public List<Country> overrideAll(#NonNull Iterable<Country> countries) {
removeAllAndFlush();
List<CountryEntity> countriesToCreate = stream(countries.spliterator(), false)
.map(CountryEntity::from)
.collect(toList());
List<CountryEntity> createdCountries = repository.saveAll(countriesToCreate);
return createdCountries.stream()
.map(CountryEntity::toCountry)
.collect(toList());
}
private void removeAllAndFlush() {
repository.deleteAll();
repository.flush();
}
I also thought about having a temporary table that gets new data and when the data is complete just replace main table with temporary table. Is it a good idea? Any other ideas?
It's a good idea. You can minimize the downtime by working on another table until it's ready and then switch tables quickly by renaming. This will also improve perceived performance by the users because no record needs to be locked like what happens when using UPDATE/DELETE.
In MySQL, you can use RENAME TABLE if you don't have triggers on the table. It allows multiple table renaming at once and it works atomically (i.e. transaction - if any error happens, no change is made). You can use the following for example
RENAME TABLE countries TO countries_old, countries_new TO countries;
DROP TABLE countries_old;
Refer here for more details
https://dev.mysql.com/doc/refman/5.7/en/rename-table.html
I have to save data in 6 tables in dynamoDB AWS, can I put a 'for' loop and save one by one as shown below :-
DynamoDBMapper mapper = new DynamoDBMapper(dynamoDB);
for(i=0;i<6;i++)
{
mapper.save(<TABLE 1 DATA>)
// and loop and save data in every table
}
Does it looks fine or it can create some problem as I am doing data base operation in loop?
My tables are very small(5 columns)
Thanks
Kailash
Running in the for loop is a bad idea and you can use the batch write item api. dynamoDB.batchWriteItem(TableWriteItems... yourMultipleTableWriteItems)
If you only need to download the data from the table into a local file, like CSV, for example, you can use this CLI tool https://github.com/zshamrock/dynocsv to export data from your table into the CSV file.
I have a list of status enum values which I am currently iterating over and using a basic counter to store how many in my list have the specific value that I am looking for. I want to improve greatly on this however and think that there may be a way to use some kind of JPA query on a paging and sorting repository to accomplish the same thing.
My current version which isn't as optimized as I would like is as follows.
public enum MailStatus {
SENT("SENT"),
DELETED("DELETED"),
SENDING("SENDING"),
}
val mails = mailService.getAllMailForUser(userId).toMutableList()
mails.forEach { mail ->
if (mail.status === MailStatus.SENT) {
mailCounter++
}
}
With a paging and sorting JPA repository is there some way to query this instead and get a count of all mail that has a status of sent only?
I tried the following but seem to be getting everything rather than just the 'SENT' status.
fun countByUserIdAndMailStatusIn(userId: UUID, mailStatus: List<MailStatus>): Long
I am using latest version of GreenDAO... I am missing something on using the data from the DB.
I need to prevent the creation of records that have the same PROFILE_NUMBER. Currently during testing I have inserted 1 record with the PROFILE_NUMBER of 1.
I need someone to show me an example of how to obtain the actual value of the field from the db.
I am using this
SvecPoleDao svecPoleDao = daoSession.getSvecPoleDao();
List poles = svecPoleDao.queryBuilder().where(SvecPoleDao.Properties.Profile_number.eq(1)).list();
and it obtains something... this.
[com.example.bobby.poleattachmenttest2_workingdatabase.db.SvecPole#bfe830c3.2]
Is this serialized? The actual value I am looking for here is 1.
Here is the solution.You'll need to use listlazy() instead of list().
List<SvecPole> poles = svecPoleDao.queryBuilder().where(SvecPoleDao.Properties.Profile_number.eq(1)).listLazy();
I'm trying to get the contents of a Fusion Table Location column
This column contains a Polygon with "outerBoundaryIs" and "innerBoundaryIs"
I'm querying the column with Fusion Tables API Query:sql, but the response don't get the "innerBoundaryIs" elements
I'm using the Fusion Tables Java Library v1r33lv1.15.0-rc
Any direction is appreciated
LluĂs
Set the typed-parameter to false (default is true)
<edit>:
I don't know why(I haven't found anything about this in any documentation), but for me it works when I add a linebreak after the closing </outerBoundaryIs>
Demo: http://jsfiddle.net/doktormolle/LsCLV/ (it's a copy of your table, the only difference is the linebreak)
The query from the Fusion Tables API will not return KML. Look at the documentation for what the 2 types (JSON, CSV) will look like, neither includes the InnerBoundaryIs (or outerBoundaryIs) elements.
If you need the KML, it will be returned if you use the google visualization query, but that is limited to returning 500 rows.
Query using Fusion Tables API v1.0 and parse response to native Google Maps Javascript API v3 objects