Skip to content

Commit e346077

Browse files
committed
addressed comments
1 parent e91f431 commit e346077

8 files changed

Lines changed: 25 additions & 23 deletions

File tree

document-store/src/main/java/org/hypertrace/core/documentstore/model/config/ConnectionConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static class ConnectionConfigBuilder {
7171
String replicaSet;
7272
Map<String, String> customParameters = new HashMap<>();
7373

74-
public ConnectionConfigBuilder customParameters(String key, String value) {
74+
public ConnectionConfigBuilder customParameter(String key, String value) {
7575
this.customParameters.put(key, value);
7676
return this;
7777
}

document-store/src/main/java/org/hypertrace/core/documentstore/model/config/TypesafeConfigDatastoreConfigExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public TypesafeConfigDatastoreConfigExtractor customParametersKey(@NonNull final
184184
.entrySet()
185185
.forEach(
186186
entry -> {
187-
connectionConfigBuilder.customParameters(
187+
connectionConfigBuilder.customParameter(
188188
entry.getKey(), paramConfig.getString(entry.getKey()));
189189
});
190190
} catch (Exception e) {

document-store/src/main/java/org/hypertrace/core/documentstore/postgres/PostgresCollection.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,7 +1295,7 @@ protected Document prepareDocument() throws SQLException, IOException {
12951295
}
12961296

12971297
// Remove document ID if needed
1298-
if (removeDocumentId) {
1298+
if (shouldRemoveDocumentId()) {
12991299
jsonNode.remove(DOCUMENT_ID);
13001300
}
13011301

@@ -1386,7 +1386,7 @@ static class PostgresResultIterator implements CloseableIterator<Document> {
13861386

13871387
protected final ObjectMapper MAPPER = new ObjectMapper();
13881388
protected ResultSet resultSet;
1389-
final boolean removeDocumentId;
1389+
private final boolean removeDocumentId;
13901390
protected boolean cursorMovedForward = false;
13911391
protected boolean hasNext = false;
13921392

@@ -1438,7 +1438,7 @@ protected Document prepareDocument() throws SQLException, IOException {
14381438
String documentString = resultSet.getString(DOCUMENT);
14391439
ObjectNode jsonNode = (ObjectNode) MAPPER.readTree(documentString);
14401440
// internal iterators may need document id
1441-
if (removeDocumentId) {
1441+
if (shouldRemoveDocumentId()) {
14421442
jsonNode.remove(DOCUMENT_ID);
14431443
}
14441444
// Add Timestamps to Document
@@ -1464,6 +1464,10 @@ protected void closeResultSet() {
14641464
public void close() {
14651465
closeResultSet();
14661466
}
1467+
1468+
protected boolean shouldRemoveDocumentId() {
1469+
return removeDocumentId;
1470+
}
14671471
}
14681472

14691473
static class PostgresResultIteratorWithMetaData extends PostgresResultIterator {

document-store/src/main/java/org/hypertrace/core/documentstore/postgres/query/v1/PostgresQueryParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class PostgresQueryParser {
2828

2929
@Getter private final PostgresTableIdentifier tableIdentifier;
3030
@Getter private final Query query;
31-
@Getter private final Optional<String> flatStructureCollectionName;
31+
@Getter private final String flatStructureCollectionName;
3232

3333
@Setter String finalTableName;
3434
@Getter private final Builder paramsBuilder = Params.newBuilder();
@@ -49,7 +49,7 @@ public PostgresQueryParser(
4949
PostgresTableIdentifier tableIdentifier, Query query, String flatStructureCollectionName) {
5050
this.tableIdentifier = tableIdentifier;
5151
this.query = query;
52-
this.flatStructureCollectionName = Optional.ofNullable(flatStructureCollectionName);
52+
this.flatStructureCollectionName = flatStructureCollectionName;
5353
this.finalTableName = tableIdentifier.toString();
5454
toPgColumnTransformer = new FieldToPgColumnTransformer(this);
5555
}

document-store/src/main/java/org/hypertrace/core/documentstore/postgres/query/v1/parser/filter/PostgresNotContainsRelationalFilterParser.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ public String parse(
1414
final RelationalExpression expression, final PostgresRelationalFilterContext context) {
1515
final String parsedLhs = expression.getLhs().accept(context.lhsParser());
1616

17+
String flatStructureCollection = context.getFlatStructureCollectionName();
1718
boolean isFirstClassField =
18-
context
19-
.getFlatStructureCollectionName()
20-
.map(name -> name.equals(context.getTableIdentifier().getTableName()))
21-
.orElse(false);
19+
flatStructureCollection != null
20+
&& flatStructureCollection.equals(context.getTableIdentifier().getTableName());
2221

2322
if (isFirstClassField) {
2423
// Use the non-JSON logic for first-class fields

document-store/src/main/java/org/hypertrace/core/documentstore/postgres/query/v1/parser/filter/PostgresNotInRelationalFilterParser.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ public String parse(
2222

2323
private PostgresInRelationalFilterParserInterface getInFilterParser(
2424
PostgresRelationalFilterContext context) {
25+
String flatStructureCollection = context.getFlatStructureCollectionName();
2526
boolean isFirstClassField =
26-
context
27-
.getFlatStructureCollectionName()
28-
.map(name -> name.equals(context.getTableIdentifier().getTableName()))
29-
.orElse(false);
27+
flatStructureCollection != null
28+
&& flatStructureCollection.equals(context.getTableIdentifier().getTableName());
3029

3130
return isFirstClassField ? nonJsonFieldInFilterParser : jsonFieldInFilterParser;
3231
}

document-store/src/main/java/org/hypertrace/core/documentstore/postgres/query/v1/parser/filter/PostgresRelationalFilterParserFactoryImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ public class PostgresRelationalFilterParserFactoryImpl
5151
public PostgresRelationalFilterParser parser(
5252
final RelationalExpression expression, final PostgresQueryParser postgresQueryParser) {
5353

54+
String flatStructureCollection = postgresQueryParser.getFlatStructureCollectionName();
5455
boolean isFirstClassField =
55-
postgresQueryParser
56-
.getFlatStructureCollectionName()
57-
.map(name -> name.equals(postgresQueryParser.getTableIdentifier().getTableName()))
58-
.orElse(false);
56+
flatStructureCollection != null
57+
&& flatStructureCollection.equals(
58+
postgresQueryParser.getTableIdentifier().getTableName());
5959

6060
if (expression.getOperator() == CONTAINS) {
6161
return isFirstClassField ? nonJsonFieldContainsParser : jsonFieldContainsParser;

document-store/src/main/java/org/hypertrace/core/documentstore/postgres/query/v1/transformer/FieldToPgColumnTransformer.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ public FieldToPgColumnTransformer(PostgresQueryParser postgresQueryParser) {
1717

1818
public FieldToPgColumn transform(String orgFieldName) {
1919
// TODO: Forcing to map to the first class fields
20-
if (postgresQueryParser
21-
.getFlatStructureCollectionName()
22-
.map(name -> name.equals(postgresQueryParser.getTableIdentifier().getTableName()))
23-
.orElse(false)) {
20+
String flatStructureCollection = postgresQueryParser.getFlatStructureCollectionName();
21+
if (flatStructureCollection != null
22+
&& flatStructureCollection.equals(
23+
postgresQueryParser.getTableIdentifier().getTableName())) {
2424
return new FieldToPgColumn(null, PostgresUtils.wrapFieldNamesWithDoubleQuotes(orgFieldName));
2525
}
2626
Optional<String> parentField =

0 commit comments

Comments
 (0)