Skip to content

Commit

Permalink
Google Java Format
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Sep 16, 2023
1 parent 36d0c37 commit bebe4b4
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class PostgresEndpoint extends Endpoint {

private PostgresLanguage postgresLanguage;

//Join Table
// Join Table
private List<String> idList;

public PostgresEndpoint() {}
Expand Down Expand Up @@ -280,6 +280,7 @@ public StringResponse insertIntoJoinTable(
this.metadataTableNames = List.of(metadataTableName);
return this.postgresService.insertIntoJoinTable(this).blockingGet();
}

public StringResponse batchInsertIntoJoinTable(
String metadataTableName, List<String> idList, String metadataId) {
this.idList = idList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,27 +198,26 @@ public EdgeChain<StringResponse> insertIntoJoinTable(PostgresEndpoint postgresEn
postgresEndpoint);
}

public EdgeChain<StringResponse> batchInsertIntoJoinTable(PostgresEndpoint postgresEndpoint) {
return new EdgeChain<>(
Observable.create(
emitter -> {
try {
this.metadataRepository.batchInsertIntoJoinTable(
postgresEndpoint.getTableName(),
postgresEndpoint.getMetadataTableNames().get(0),
postgresEndpoint.getIdList(),
postgresEndpoint.getMetadataId()
);

emitter.onNext(new StringResponse("Inserted"));
emitter.onComplete();

} catch (final Exception e) {
emitter.onError(e);
}
}),
postgresEndpoint);
}
public EdgeChain<StringResponse> batchInsertIntoJoinTable(PostgresEndpoint postgresEndpoint) {
return new EdgeChain<>(
Observable.create(
emitter -> {
try {
this.metadataRepository.batchInsertIntoJoinTable(
postgresEndpoint.getTableName(),
postgresEndpoint.getMetadataTableNames().get(0),
postgresEndpoint.getIdList(),
postgresEndpoint.getMetadataId());

emitter.onNext(new StringResponse("Inserted"));
emitter.onComplete();

} catch (final Exception e) {
emitter.onError(e);
}
}),
postgresEndpoint);
}

public EdgeChain<List<PostgresWordEmbeddings>> query(PostgresEndpoint postgresEndpoint) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,19 @@ public void insertIntoJoinTable(PostgresEndpoint postgresEndpoint) {

@Transactional
public void batchInsertIntoJoinTable(
String tableName, String metadataTableName, List<String> idList, String metadataId) {
String tableName, String metadataTableName, List<String> idList, String metadataId) {
String joinTableName = tableName + "_join_" + metadataTableName;
List<String> sqlStatements = new ArrayList<>();
for(String id: idList) {
for (String id : idList) {
sqlStatements.add(
String.format(
"INSERT INTO %s (id, metadata_id) VALUES ('%s', '%s') ON CONFLICT (id) DO UPDATE SET"
+ " metadata_id = EXCLUDED.metadata_id;",
joinTableName,
UUID.fromString(id),
UUID.fromString(metadataId)
)
);
String.format(
"INSERT INTO %s (id, metadata_id) VALUES ('%s', '%s') ON CONFLICT (id) DO UPDATE SET"
+ " metadata_id = EXCLUDED.metadata_id;",
joinTableName, UUID.fromString(id), UUID.fromString(metadataId)));
}
jdbcTemplate.batchUpdate(sqlStatements.toArray(new String[0]));
}


@Transactional(readOnly = true, propagation = Propagation.REQUIRED)
public List<Map<String, Object>> queryWithMetadata(
String tableName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ public Single<StringResponse> insertIntoJoinTable(

@PostMapping("/join/batch-insert")
public Single<StringResponse> batchInsertIntoJoinTable(
@RequestBody PostgresEndpoint postgresEndpoint) {
EdgeChain<StringResponse> edgeChain = this.postgresClient.batchInsertIntoJoinTable(postgresEndpoint);
@RequestBody PostgresEndpoint postgresEndpoint) {
EdgeChain<StringResponse> edgeChain =
this.postgresClient.batchInsertIntoJoinTable(postgresEndpoint);
return edgeChain.toSingle();
}

Expand Down

0 comments on commit bebe4b4

Please sign in to comment.