Skip to content

Commit f80a587

Browse files
committed
Reformat code & optimize imports
1 parent cb625d6 commit f80a587

12 files changed

Lines changed: 167 additions & 87 deletions

File tree

src/main/java/org/polypheny/jdbc/RpcService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,20 +419,21 @@ PreparedStatementSignature prepareIndexedStatement( PrepareStatementRequest msg,
419419
return completeSynchronously( req, timeout ).getPreparedStatementSignature();
420420
}
421421

422+
422423
public PreparedStatementSignature prepareNamedStatement( PrepareStatementRequest msg, int timeout ) throws PrismInterfaceServiceException {
423424
Request.Builder req = newMessage();
424425
req.setPrepareIndexedStatementRequest( msg );
425426
return completeSynchronously( req, timeout ).getPreparedStatementSignature();
426427
}
427428

428429

429-
430430
StatementResult executeIndexedStatement( ExecuteIndexedStatementRequest msg, int timeout ) throws PrismInterfaceServiceException {
431431
Request.Builder req = newMessage();
432432
req.setExecuteIndexedStatementRequest( msg );
433433
return completeSynchronously( req, timeout ).getStatementResult();
434434
}
435435

436+
436437
public StatementResult executeNamedStatement( ExecuteNamedStatementRequest msg, int timeout ) throws PrismInterfaceServiceException {
437438
Request.Builder req = newMessage();
438439
req.setExecuteNamedStatementRequest( msg );
@@ -466,4 +467,5 @@ CloseResultResponse closeResult( CloseResultRequest msg, int timeout ) throws Pr
466467
req.setCloseResultRequest( msg );
467468
return completeSynchronously( req, timeout ).getCloseResultResponse();
468469
}
470+
469471
}

src/main/java/org/polypheny/jdbc/multimodel/GraphResult.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.polypheny.jdbc.multimodel;
1818

1919
import java.util.ArrayList;
20-
2120
import java.util.Iterator;
2221
import java.util.List;
2322
import java.util.NoSuchElementException;
@@ -41,29 +40,30 @@ public class GraphResult extends Result implements Iterable<PolyGraphElement> {
4140
private final List<PolyGraphElement> elements;
4241

4342

44-
4543
public GraphResult( Frame frame, PolyStatement polyStatement ) {
4644
super( ResultType.GRAPH );
47-
this.polyStatement= polyStatement;
45+
this.polyStatement = polyStatement;
4846
this.isFullyFetched = frame.getIsLast();
4947
this.elements = new ArrayList<>();
50-
addGraphElements(frame.getGraphFrame());
48+
addGraphElements( frame.getGraphFrame() );
5149
}
5250

51+
5352
private void addGraphElements( GraphFrame graphFrame ) {
54-
if (graphFrame.getNodesCount() > 0) {
55-
graphFrame.getNodesList().forEach( n -> elements.add( new PolyNode(n) ) );
53+
if ( graphFrame.getNodesCount() > 0 ) {
54+
graphFrame.getNodesList().forEach( n -> elements.add( new PolyNode( n ) ) );
5655
return;
5756
}
58-
if (graphFrame.getEdgesCount() > 0) {
59-
graphFrame.getEdgesList().forEach( n -> elements.add( new PolyEdge(n) ) );
57+
if ( graphFrame.getEdgesCount() > 0 ) {
58+
graphFrame.getEdgesList().forEach( n -> elements.add( new PolyEdge( n ) ) );
6059
return;
6160
}
62-
if (graphFrame.getPathsCount() > 0) {
63-
graphFrame.getPathsList().forEach( n -> elements.add( new PolyPath(n) ) );
61+
if ( graphFrame.getPathsCount() > 0 ) {
62+
graphFrame.getPathsList().forEach( n -> elements.add( new PolyPath( n ) ) );
6463
}
6564
}
6665

66+
6767
private void fetchMore() throws PrismInterfaceServiceException {
6868
int id = polyStatement.getStatementId();
6969
int timeout = getPolyphenyConnection().getTimeout();
@@ -78,6 +78,7 @@ private void fetchMore() throws PrismInterfaceServiceException {
7878
addGraphElements( frame.getGraphFrame() );
7979
}
8080

81+
8182
private PolyConnection getPolyphenyConnection() {
8283
return polyStatement.getConnection();
8384
}
@@ -87,12 +88,18 @@ private PrismInterfaceClient getPrismInterfaceClient() {
8788
return getPolyphenyConnection().getPrismInterfaceClient();
8889
}
8990

91+
9092
@Override
91-
public Iterator<PolyGraphElement> iterator() {return new GraphElementIterator();}
93+
public Iterator<PolyGraphElement> iterator() {
94+
return new GraphElementIterator();
95+
}
96+
9297

9398
class GraphElementIterator implements Iterator<PolyGraphElement> {
99+
94100
int index = -1;
95101

102+
96103
@Override
97104
public boolean hasNext() {
98105
if ( index + 1 >= elements.size() ) {
@@ -108,15 +115,16 @@ public boolean hasNext() {
108115
return index + 1 < elements.size();
109116
}
110117

118+
111119
@Override
112120
public PolyGraphElement next() {
113121
if ( !hasNext() ) {
114122
throw new NoSuchElementException( "There are no more graph elements" );
115123
}
116124
return elements.get( ++index );
117125
}
118-
}
119126

127+
}
120128

121129

122130
}

src/main/java/org/polypheny/jdbc/multimodel/RelationalColumnMetadata.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
@Getter
2323
public class RelationalColumnMetadata {
24+
2425
private final int columnIndex;
2526
private final boolean isNullable;
2627
private final int length;
@@ -31,6 +32,7 @@ public class RelationalColumnMetadata {
3132
private final String protocolTypeName;
3233
private final int scale;
3334

35+
3436
public RelationalColumnMetadata( ColumnMeta columnMeta ) {
3537
this.columnIndex = columnMeta.getColumnIndex();
3638
this.isNullable = columnMeta.getIsNullable();
@@ -41,4 +43,5 @@ public RelationalColumnMetadata( ColumnMeta columnMeta ) {
4143
this.protocolTypeName = columnMeta.getTypeMeta().getProtoValueType().name();
4244
this.scale = columnMeta.getScale();
4345
}
46+
4447
}

src/main/java/org/polypheny/jdbc/multimodel/RelationalMetadata.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
import java.util.List;
2020
import java.util.Map;
2121
import java.util.stream.Collectors;
22-
import lombok.Getter;
2322
import org.polypheny.jdbc.PrismInterfaceErrors;
2423
import org.polypheny.jdbc.PrismInterfaceServiceException;
2524
import org.polypheny.prism.ColumnMeta;
2625

2726
public class RelationalMetadata {
27+
2828
private List<RelationalColumnMetadata> columnMetas;
2929
private Map<String, Integer> columnIndexes;
3030

@@ -35,6 +35,7 @@ public RelationalMetadata( List<ColumnMeta> columnMetadata ) {
3535

3636
}
3737

38+
3839
public RelationalColumnMetadata getColumnMeta( int columnIndex ) throws PrismInterfaceServiceException {
3940
try {
4041
return columnMetas.get( columnIndex );

src/main/java/org/polypheny/jdbc/types/PolyEdge.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class PolyEdge extends PolyGraphElement {
2727
private final String target;
2828
private final EdgeDirection direction;
2929

30+
3031
public PolyEdge( ProtoEdge protoEdge ) {
3132
super();
3233
this.id = protoEdge.getId();
@@ -43,6 +44,7 @@ public PolyEdge( ProtoEdge protoEdge ) {
4344
this.direction = EdgeDirection.valueOf( protoEdge.getDirection().name() );
4445
}
4546

47+
4648
enum EdgeDirection {
4749
LEFT_TO_RIGHT,
4850
RIGHT_TO_LEFT,

src/main/java/org/polypheny/jdbc/types/PolyGraphElement.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public class PolyGraphElement extends HashMap<String, TypedValue> {
3030
protected String name;
3131
protected List<String> labels;
3232

33+
3334
public <T> T unwrap( Class<T> aClass ) throws PrismInterfaceServiceException {
3435
if ( aClass.isInstance( this ) ) {
3536
return aClass.cast( this );

src/main/java/org/polypheny/jdbc/types/TypedValue.java

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,47 +1428,4 @@ private static PolyInterval getInterval( ProtoInterval interval ) {
14281428
return new PolyInterval( interval.getMonths(), interval.getMilliseconds() );
14291429
}
14301430

1431-
1432-
@Override
1433-
public String toString() {
1434-
if ( isSerialized ) {
1435-
deserialize();
1436-
}
1437-
switch ( valueCase ) {
1438-
case BOOLEAN:
1439-
return "" + booleanValue;
1440-
case INTEGER:
1441-
return "" + integerValue;
1442-
case LONG:
1443-
return "" + bigintValue;
1444-
case BIG_DECIMAL:
1445-
return "" + bigDecimalValue;
1446-
case FLOAT:
1447-
return "" + floatValue;
1448-
case DOUBLE:
1449-
return "" + doubleValue;
1450-
case DATE:
1451-
return "" + dateValue;
1452-
case TIME:
1453-
return "" + timeValue;
1454-
case TIMESTAMP:
1455-
return "" + timestampValue;
1456-
case INTERVAL:
1457-
return "" + otherValue;
1458-
case STRING:
1459-
return varcharValue;
1460-
case BINARY:
1461-
return "BINARY";
1462-
case NULL:
1463-
return "NULL";
1464-
case LIST:
1465-
return "LIST";
1466-
case FILE:
1467-
return "FILE";
1468-
case DOCUMENT:
1469-
return "DOCUMENT";
1470-
}
1471-
return "";
1472-
}
1473-
14741431
}

src/main/java/org/polypheny/jdbc/utils/ProtoUtils.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@ public static List<ProtoValue> serializeParameterList( List<TypedValue> values )
4848
}
4949

5050

51-
public static Map<String, ProtoValue> serializeParameterMap(Map<String, TypedValue> values) {
52-
return values.entrySet().stream().collect(Collectors.toMap(
51+
public static Map<String, ProtoValue> serializeParameterMap( Map<String, TypedValue> values ) {
52+
return values.entrySet().stream().collect( Collectors.toMap(
5353
Entry::getKey,
5454
value -> {
5555
try {
5656
return value.getValue().serialize();
57-
} catch (Exception e) {
58-
throw new RuntimeException("Serialization failed", e);
57+
} catch ( Exception e ) {
58+
throw new RuntimeException( "Serialization failed", e );
5959
}
6060
}
61-
));
61+
) );
6262
}
6363

6464
}

src/test/java/org/polypheny/jdbc/ConnectionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ void testMetaDataGetProceduresNotStrict() throws SQLException {
194194

195195
@Test
196196
@Disabled
197-
// This test fails due to syntax definitions missing for some of the functions on the server side (operator registry).
197+
// This test fails due to syntax definitions missing for some of the functions on the server side (operator registry).
198198
void testMetaDataGetFunctionsNotStrict() throws SQLException {
199199
try ( Connection con = DriverManager.getConnection( "jdbc:polypheny://127.0.0.1:20590?strict=false", "pa", "" ) ) {
200200
DatabaseMetaData meta = con.getMetaData();

src/test/java/org/polypheny/jdbc/Demo.java

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,46 +40,47 @@ public class Demo {
4040
private static String namespace = "public";
4141
private static Connection con;
4242

43-
public static void main(String[] args) {
43+
44+
public static void main( String[] args ) {
4445
try {
45-
con = DriverManager.getConnection("jdbc:polypheny://127.0.0.1:20590?strict=false", "pa", "");
46-
if (!con.isWrapperFor(PolyConnection.class)) {
47-
System.out.println("Driver must support unwrapping to PolyConnection");
46+
con = DriverManager.getConnection( "jdbc:polypheny://127.0.0.1:20590?strict=false", "pa", "" );
47+
if ( !con.isWrapperFor( PolyConnection.class ) ) {
48+
System.out.println( "Driver must support unwrapping to PolyConnection" );
4849
return;
4950
}
50-
Scanner scanner = new Scanner(System.in);
51+
Scanner scanner = new Scanner( System.in );
5152

52-
while (true) {
53+
while ( true ) {
5354
printPrompt();
5455
String input = scanner.nextLine();
5556

56-
if (input.startsWith("lng ")) {
57-
language = input.substring(4).trim();
58-
System.out.println("Language set to " + language);
59-
} else if (input.startsWith("ns ")) {
60-
namespace = input.substring(3).trim();
61-
System.out.println("Namespace set to " + namespace);
62-
} else if (input.equals("exit")) {
57+
if ( input.startsWith( "lng " ) ) {
58+
language = input.substring( 4 ).trim();
59+
System.out.println( "Language set to " + language );
60+
} else if ( input.startsWith( "ns " ) ) {
61+
namespace = input.substring( 3 ).trim();
62+
System.out.println( "Namespace set to " + namespace );
63+
} else if ( input.equals( "exit" ) ) {
6364
break;
6465
} else {
65-
if (language == null || namespace == null) {
66-
System.out.println("Please set both language and namespace before executing a statement.");
66+
if ( language == null || namespace == null ) {
67+
System.out.println( "Please set both language and namespace before executing a statement." );
6768
continue;
6869
}
6970
String statement = input.trim();
70-
executeStatement(namespace, language, statement);
71+
executeStatement( namespace, language, statement );
7172
}
7273
}
7374

7475
scanner.close();
75-
} catch (Exception e) {
76+
} catch ( Exception e ) {
7677
e.printStackTrace();
7778
} finally {
7879
try {
79-
if (con != null && !con.isClosed()) {
80+
if ( con != null && !con.isClosed() ) {
8081
con.close();
8182
}
82-
} catch (Exception e) {
83+
} catch ( Exception e ) {
8384
e.printStackTrace();
8485
}
8586
}

0 commit comments

Comments
 (0)