Skip to content

Commit 8591906

Browse files
committed
Fix code style
1 parent 6336bb2 commit 8591906

File tree

9 files changed

+189
-198
lines changed

9 files changed

+189
-198
lines changed

presto-flight-shim/src/main/java/com/facebook/presto/flightshim/ArrowBatchSource.java

Lines changed: 58 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ public boolean nextBatch()
113113

114114
int i;
115115
for (i = 0; i < maxRowsPerBatch; ++i) {
116-
117116
if (!cursor.advanceNextPosition()) {
118117
closed = true;
119118
break;
@@ -123,7 +122,8 @@ public boolean nextBatch()
123122
ArrowShimWriter writer = writers.get(column);
124123
if (cursor.isNull(column)) {
125124
writer.writeNull(i);
126-
} else {
125+
}
126+
else {
127127
ColumnMetadata columnMetadata = columns.get(column);
128128
Type type = columnMetadata.getType();
129129
Class<?> javaType = type.getJavaType();
@@ -161,7 +161,7 @@ public void close()
161161

162162
private static VectorSchemaRoot createVectorSchemaRoot(BufferAllocator allocator, List<ColumnMetadata> columns)
163163
{
164-
List<Field> fields = columns.stream().map( column -> {
164+
List<Field> fields = columns.stream().map(column -> {
165165
// TODO add ColumnMetadata to Arrow?
166166
ArrowType arrowType = prestoToArrowType(column.getType());
167167
return new Field(column.getName(), new FieldType(column.isNullable(), arrowType, null), ImmutableList.of());
@@ -228,37 +228,37 @@ private static List<ArrowShimWriter> createArrowWriters(VectorSchemaRoot root)
228228
final List<FieldVector> vectors = root.getFieldVectors();
229229
return vectors.stream().map(ArrowBatchSource::createArrowWriter).collect(Collectors.toList());
230230
}
231-
231+
232232
private static ArrowShimWriter createArrowWriter(FieldVector vector)
233233
{
234234
switch (vector.getMinorType()) {
235-
case BIT:
236-
return new ArrowShimBitWriter((BitVector) vector);
237-
case TINYINT:
238-
return new ArrowShimTinyIntWriter((TinyIntVector) vector);
239-
case SMALLINT:
240-
return new ArrowShimSmallIntWriter((SmallIntVector) vector);
241-
case INT:
242-
return new ArrowShimIntWriter((IntVector) vector);
243-
case BIGINT:
244-
return new ArrowShimLongWriter((BigIntVector) vector);
245-
case FLOAT4:
246-
return new ArrowShimRealWriter((Float4Vector) vector);
247-
case FLOAT8:
248-
return new ArrowShimDoubleWriter((Float8Vector) vector);
249-
case DECIMAL:
250-
return new ArrowShimDecimalWriter((DecimalVector) vector);
251-
case VARBINARY:
252-
case VARCHAR:
253-
return new ArrowShimVariableWidthWriter((BaseVariableWidthVector) vector);
254-
case DATEDAY:
255-
return new ArrowShimDateWriter((DateDayVector) vector);
256-
case TIMEMILLI:
257-
return new ArrowShimTimeWriter((TimeMilliVector) vector);
258-
case TIMESTAMPMILLI:
259-
return new ArrowShimTimeStampWriter((TimeStampVector) vector);
260-
default:
261-
throw new UnsupportedOperationException("Unsupported Arrow type: " + vector.getMinorType().name());
235+
case BIT:
236+
return new ArrowShimBitWriter((BitVector) vector);
237+
case TINYINT:
238+
return new ArrowShimTinyIntWriter((TinyIntVector) vector);
239+
case SMALLINT:
240+
return new ArrowShimSmallIntWriter((SmallIntVector) vector);
241+
case INT:
242+
return new ArrowShimIntWriter((IntVector) vector);
243+
case BIGINT:
244+
return new ArrowShimLongWriter((BigIntVector) vector);
245+
case FLOAT4:
246+
return new ArrowShimRealWriter((Float4Vector) vector);
247+
case FLOAT8:
248+
return new ArrowShimDoubleWriter((Float8Vector) vector);
249+
case DECIMAL:
250+
return new ArrowShimDecimalWriter((DecimalVector) vector);
251+
case VARBINARY:
252+
case VARCHAR:
253+
return new ArrowShimVariableWidthWriter((BaseVariableWidthVector) vector);
254+
case DATEDAY:
255+
return new ArrowShimDateWriter((DateDayVector) vector);
256+
case TIMEMILLI:
257+
return new ArrowShimTimeWriter((TimeMilliVector) vector);
258+
case TIMESTAMPMILLI:
259+
return new ArrowShimTimeStampWriter((TimeStampVector) vector);
260+
default:
261+
throw new UnsupportedOperationException("Unsupported Arrow type: " + vector.getMinorType().name());
262262
}
263263
}
264264

@@ -270,7 +270,7 @@ private static void allocateVectorCapacity(VectorSchemaRoot root, int capacity)
270270
}
271271
}
272272

273-
private static abstract class ArrowShimWriter
273+
private abstract static class ArrowShimWriter
274274
{
275275
public abstract void writeNull(int index);
276276

@@ -295,7 +295,8 @@ public void writeSlice(int index, Slice value, int offset, int length)
295295
}
296296
}
297297

298-
private static abstract class ArrowFixedWidthShimWriter extends ArrowShimWriter
298+
private abstract static class ArrowFixedWidthShimWriter
299+
extends ArrowShimWriter
299300
{
300301
public abstract BaseFixedWidthVector getVector();
301302

@@ -306,7 +307,8 @@ public void writeNull(int index)
306307
}
307308
}
308309

309-
private static class ArrowShimBitWriter extends ArrowFixedWidthShimWriter
310+
private static class ArrowShimBitWriter
311+
extends ArrowFixedWidthShimWriter
310312
{
311313
private final BitVector vector;
312314

@@ -328,7 +330,8 @@ public void writeBoolean(int index, boolean value)
328330
}
329331
}
330332

331-
private static class ArrowShimTinyIntWriter extends ArrowFixedWidthShimWriter
333+
private static class ArrowShimTinyIntWriter
334+
extends ArrowFixedWidthShimWriter
332335
{
333336
private final TinyIntVector vector;
334337

@@ -350,7 +353,8 @@ public void writeLong(int index, long value)
350353
}
351354
}
352355

353-
private static class ArrowShimSmallIntWriter extends ArrowFixedWidthShimWriter
356+
private static class ArrowShimSmallIntWriter
357+
extends ArrowFixedWidthShimWriter
354358
{
355359
private final SmallIntVector vector;
356360

@@ -372,7 +376,8 @@ public void writeLong(int index, long value)
372376
}
373377
}
374378

375-
private static class ArrowShimIntWriter extends ArrowFixedWidthShimWriter
379+
private static class ArrowShimIntWriter
380+
extends ArrowFixedWidthShimWriter
376381
{
377382
private final IntVector vector;
378383

@@ -394,7 +399,8 @@ public void writeLong(int index, long value)
394399
}
395400
}
396401

397-
private static class ArrowShimLongWriter extends ArrowFixedWidthShimWriter
402+
private static class ArrowShimLongWriter
403+
extends ArrowFixedWidthShimWriter
398404
{
399405
private final BigIntVector vector;
400406

@@ -416,7 +422,8 @@ public void writeLong(int index, long value)
416422
}
417423
}
418424

419-
private static class ArrowShimRealWriter extends ArrowFixedWidthShimWriter
425+
private static class ArrowShimRealWriter
426+
extends ArrowFixedWidthShimWriter
420427
{
421428
private final Float4Vector vector;
422429

@@ -438,7 +445,8 @@ public void writeLong(int index, long value)
438445
}
439446
}
440447

441-
private static class ArrowShimDoubleWriter extends ArrowFixedWidthShimWriter
448+
private static class ArrowShimDoubleWriter
449+
extends ArrowFixedWidthShimWriter
442450
{
443451
private final Float8Vector vector;
444452

@@ -460,7 +468,8 @@ public void writeDouble(int index, double value)
460468
}
461469
}
462470

463-
private static class ArrowShimDecimalWriter extends ArrowFixedWidthShimWriter
471+
private static class ArrowShimDecimalWriter
472+
extends ArrowFixedWidthShimWriter
464473
{
465474
private final DecimalVector vector;
466475

@@ -495,7 +504,8 @@ public void writeSlice(int index, Slice value, int offset, int length)
495504
}
496505
}
497506

498-
private static class ArrowShimVariableWidthWriter extends ArrowShimWriter
507+
private static class ArrowShimVariableWidthWriter
508+
extends ArrowShimWriter
499509
{
500510
private final BaseVariableWidthVector vector;
501511

@@ -517,7 +527,8 @@ public void writeSlice(int index, Slice value, int offset, int length)
517527
}
518528
}
519529

520-
private static class ArrowShimDateWriter extends ArrowFixedWidthShimWriter
530+
private static class ArrowShimDateWriter
531+
extends ArrowFixedWidthShimWriter
521532
{
522533
private final DateDayVector vector;
523534

@@ -540,7 +551,8 @@ public void writeLong(int index, long value)
540551
}
541552
}
542553

543-
private static class ArrowShimTimeWriter extends ArrowFixedWidthShimWriter
554+
private static class ArrowShimTimeWriter
555+
extends ArrowFixedWidthShimWriter
544556
{
545557
private final TimeMilliVector vector;
546558

@@ -562,7 +574,8 @@ public void writeLong(int index, long value)
562574
}
563575
}
564576

565-
private static class ArrowShimTimeStampWriter extends ArrowFixedWidthShimWriter
577+
private static class ArrowShimTimeStampWriter
578+
extends ArrowFixedWidthShimWriter
566579
{
567580
private final TimeStampVector vector;
568581

presto-flight-shim/src/main/java/com/facebook/presto/flightshim/FlightShimPluginManager.java

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public void loadCatalogs()
193193

194194
catalogsLoaded.set(true);
195195
}
196-
196+
197197
private void loadCatalog(File file)
198198
throws Exception
199199
{
@@ -258,7 +258,8 @@ private void registerPlugin(Plugin plugin)
258258
}
259259
}
260260

261-
public ConnectorHolder getConnector(String connectorId) {
261+
public ConnectorHolder getConnector(String connectorId)
262+
{
262263
log.debug("FlightShimPluginManager getting connector: %s", connectorId);
263264
CatalogPropertiesHolder catalogPropertiesHolder = catalogPropertiesMap.get(connectorId);
264265
if (catalogPropertiesHolder == null) {
@@ -313,20 +314,21 @@ public String formatRowExpression(ConnectorSession session, RowExpression expres
313314
final ExpressionOptimizerProvider expressionOptimizerProvider = (ConnectorSession session) -> new RowExpressionOptimizer(metadata);
314315

315316
ConnectorContext context = new ConnectorContextInstance(
316-
new PluginNodeManager(new InMemoryNodeManager(), "flightconnector"),
317-
functionAndTypeManager,
318-
functionAndTypeManager,
319-
new FunctionResolution(functionAndTypeManager.getFunctionAndTypeResolver()),
320-
new PagesIndexPageSorter(new PagesIndex.TestingFactory(false)),
321-
new GroupByHashPageIndexerFactory(new JoinCompiler(metadata)),
322-
rowExpressionService,
323-
new ConnectorFilterStatsCalculatorService(new FilterStatsCalculator(metadata, new ScalarStatsCalculator(metadata, expressionOptimizerProvider), new StatsNormalizer())),
324-
blockEncodingManager,
325-
() -> false);
317+
new PluginNodeManager(new InMemoryNodeManager(), "flightconnector"),
318+
functionAndTypeManager,
319+
functionAndTypeManager,
320+
new FunctionResolution(functionAndTypeManager.getFunctionAndTypeResolver()),
321+
new PagesIndexPageSorter(new PagesIndex.TestingFactory(false)),
322+
new GroupByHashPageIndexerFactory(new JoinCompiler(metadata)),
323+
rowExpressionService,
324+
new ConnectorFilterStatsCalculatorService(new FilterStatsCalculator(metadata, new ScalarStatsCalculator(metadata, expressionOptimizerProvider), new StatsNormalizer())),
325+
blockEncodingManager,
326+
() -> false);
326327

327328
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(factory.getClass().getClassLoader())) {
328329
return new ConnectorHolder(factory.create(name, config, context), factory.getHandleResolver(), typeDeserializer, blockEncodingManager);
329-
} finally {
330+
}
331+
finally {
330332
log.debug("Finished loading connector: %s", connectorId);
331333
}
332334
});
@@ -425,7 +427,8 @@ ColumnMetadata getColumnMetadata(ColumnHandle handle)
425427
}
426428
}
427429

428-
private static Method reflectGetColumnMetadata(ConnectorHandleResolver resolver) {
430+
private static Method reflectGetColumnMetadata(ConnectorHandleResolver resolver)
431+
{
429432
try {
430433
return resolver.getColumnHandleClass().getMethod("getColumnMetadata");
431434
}

presto-flight-shim/src/main/java/com/facebook/presto/flightshim/FlightShimProducer.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ private void runGetStreamAsync(CallContext context, Ticket ticket, ServerStreamL
137137
final String message = "Error getting connector flight stream: " + e.getMessage();
138138
log.error(message, e);
139139
listener.error(CallStatus.INTERNAL.withDescription(message).withCause(e).toRuntimeException());
140-
} finally {
140+
}
141+
finally {
141142
log.debug("Processing GetStream completed");
142143
}
143144
}

presto-flight-shim/src/main/java/com/facebook/presto/flightshim/FlightShimServer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ public static FlightServer start(Injector injector, FlightServer.Builder builder
8484
File clientCertFile = new File(config.getClientSSLCertificateFile());
8585
builder.useMTlsClientVerification(clientCertFile);
8686
}
87-
} else {
87+
}
88+
else {
8889
builder.location(Location.forGrpcInsecure(config.getServerName(), config.getServerPort()));
8990
}
9091

@@ -113,15 +114,16 @@ public static void main(String[] args)
113114
configBuilder.put("flight-shim.server-ssl-certificate-file", "src/test/resources/certs/server.crt");
114115
configBuilder.put("flight-shim.server-ssl-key-file", "src/test/resources/certs/server.key");
115116
config = configBuilder.build();
116-
} else {
117+
}
118+
else {
117119
log.info("FlightShim server using config from: " + System.getProperty("config"));
118120
config = ImmutableMap.of();
119121
}
120122
Injector injector = initialize(config);
121123

122124
log.info("FlightShim server initializing");
123125
try (FlightServer server = start(injector, FlightServer.builder());
124-
FlightShimProducer producer = injector.getInstance(FlightShimProducer.class)) {
126+
FlightShimProducer producer = injector.getInstance(FlightShimProducer.class)) {
125127
log.info(format("======== FlightShim Server started on port: %s ========", server.getPort()));
126128
server.awaitTermination();
127129
}
@@ -131,5 +133,3 @@ public static void main(String[] args)
131133
}
132134
}
133135
}
134-
135-

0 commit comments

Comments
 (0)