From 80dc9e52168df68c3aaf3491baf0fc6d3d245a92 Mon Sep 17 00:00:00 2001 From: Tobias Hafner Date: Tue, 19 Sep 2023 10:54:06 +0200 Subject: [PATCH] remove unused fields --- .../relational/RelationalMetaRetriever.java | 27 +++-------- .../StatementProcessor.java | 13 ----- .../PolyValueSerializationTest.java | 48 +++---------------- 3 files changed, 14 insertions(+), 74 deletions(-) diff --git a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/relational/RelationalMetaRetriever.java b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/relational/RelationalMetaRetriever.java index 0cb1b5d423..63da7377b1 100644 --- a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/relational/RelationalMetaRetriever.java +++ b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/relational/RelationalMetaRetriever.java @@ -16,7 +16,6 @@ package org.polypheny.db.protointerface.relational; -import com.google.common.collect.ImmutableBiMap; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -43,29 +42,18 @@ public class RelationalMetaRetriever { - private static final String PROTO_VALUE_TYPE_PREFIX = "PROTO_VALUE_TYPE_"; private static final int ORIGIN_COLUMN_INDEX = 3; private static final int ORIGIN_TABLE_INDEX = 2; private static final int ORIGIN_SCHEMA_INDEX = 1; - private static final int ORIGIN_DATABASE_INDEX = 0; public static List retrieveParameterMetas( AlgDataType parameterRowType ) { - int index = 0; return parameterRowType.getFieldList().stream() .map( p -> retrieveParameterMeta( p, null ) ) .collect( Collectors.toList() ); } - public static List retrieveParameterMetas( AlgDataType parameterRowType, ImmutableBiMap namedIndexes ) { - int index = 0; - return parameterRowType.getFieldList().stream() - .map( p -> retrieveParameterMeta( p, namedIndexes.inverse().get( index ) ) ) - .collect( Collectors.toList() ); - } - - private static ParameterMeta retrieveParameterMeta( AlgDataTypeField algDataTypeField, String parameterName ) { AlgDataType algDataType = algDataTypeField.getType(); ParameterMeta.Builder metaBuilder = ParameterMeta.newBuilder(); @@ -110,19 +98,19 @@ private static ColumnMeta retrieveColumnMeta( return columnMetaBuilder .setColumnIndex( index ) .setColumnName( fieldName ) // designated column name - .setColumnLabel( getColumnLabel( origins, type, fieldName ) ) // alias as specified in sql AS clause + .setColumnLabel( getColumnLabel( origins, fieldName ) ) // alias as specified in sql AS clause .setIsNullable( type.isNullable() ) .setLength( type.getPrecision() ) .setPrecision( QueryProcessorHelpers.getPrecision( type ) ) // <- same as type.getPrecision() but returns 0 if not applicable .setScale( type.getScale() ) .setTypeMeta( typeMeta ) //.setNamespace() - //TODO TH: find out how to get namespace form here + //TODO: find out how to get namespace form here .build(); } - private static String getColumnLabel( List origins, AlgDataType type, String fieldName ) { + private static String getColumnLabel( List origins, String fieldName ) { String columnLabel = QueryProcessorHelpers.origin( origins, ORIGIN_COLUMN_INDEX ); return columnLabel == null ? fieldName : columnLabel; } @@ -180,16 +168,15 @@ private static TypeMeta retrieveTypeMeta( AlgDataType algDataType ) { private static AlgDataType retrieveAlgDataType( PolyImplementation polyImplementation ) { switch ( polyImplementation.getKind() ) { - case INSERT: - case DELETE: - case UPDATE: - case EXPLAIN: + case INSERT, DELETE, UPDATE, EXPLAIN -> { // FIXME: getValidatedNodeType is wrong for DML Kind kind = polyImplementation.getKind(); JavaTypeFactory typeFactory = polyImplementation.getStatement().getTransaction().getTypeFactory(); return AlgOptUtil.createDmlRowType( kind, typeFactory ); - default: + } + default -> { return polyImplementation.getRowType(); + } } } diff --git a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/StatementProcessor.java b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/StatementProcessor.java index 3ef9ae6bac..835f841927 100644 --- a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/StatementProcessor.java +++ b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/StatementProcessor.java @@ -94,19 +94,6 @@ public static Frame fetch( PIStatement piStatement, int fetchSize ) { return executor.fetch( piStatement, fetchSize ); } - - public static Frame fetchGraphFrame( PIStatement piStatement ) { - throw new RuntimeException( "Feature not implemented" ); - /* - Statement statement = piStatement.getStatement(); - PolyImplementation implementation = piStatement.getImplementation(); - //TODO TH: Whats the actual type here? - List data = implementation.getArrayRows( statement, true ); - return ProtoUtils.buildGraphFrame(); - */ - } - - public static void prepare( PIPreparedStatement piStatement ) { Transaction transaction = piStatement.getClient().getCurrentOrCreateNewTransaction(); String query = piStatement.getQuery(); diff --git a/plugins/proto-interface/src/test/java/org/polypheny/db/protointerface/PolyValueSerializationTest.java b/plugins/proto-interface/src/test/java/org/polypheny/db/protointerface/PolyValueSerializationTest.java index 1a43027ece..a618165bf8 100644 --- a/plugins/proto-interface/src/test/java/org/polypheny/db/protointerface/PolyValueSerializationTest.java +++ b/plugins/proto-interface/src/test/java/org/polypheny/db/protointerface/PolyValueSerializationTest.java @@ -16,6 +16,7 @@ package org.polypheny.db.protointerface; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -58,8 +59,8 @@ public class PolyValueSerializationTest { @BeforeClass public static void init() { + // needed to launch polypheny TestHelper.getInstance(); - } private enum TestEnum { @@ -125,7 +126,7 @@ public void polyBigDecimalSeriaizationTest() { public void polyBinarySerializationTest() { PolyBinary expected = PolyBinary.of( new byte[]{ 0x01, 0x02, 0x03 } ); ProtoValue protoValue = PolyValueSerializer.serialize( expected ); - assertEquals( new byte[]{ 0x01, 0x02, 0x03 }, protoValue.getBinary().toByteArray() ); + assertArrayEquals( new byte[]{ 0x01, 0x02, 0x03 }, protoValue.getBinary().toByteArray() ); } @@ -177,13 +178,6 @@ public void polyIntegerSerializationTest() { assertEquals( 1234, protoValue.getInteger().getInteger() ); } - - @Test - public void polyIntervalSerializationTest() { - //TODO TH: create test - } - - @Test public void polyListSerializationTest() { PolyList expected = new PolyList( @@ -193,10 +187,10 @@ public void polyListSerializationTest() { new PolyInteger( 4 ) ); List protoValues = PolyValueSerializer.serialize( expected ).getList().getValuesList(); - assertEquals( 1, protoValues.get( 1 ).getInteger().getInteger() ); - assertEquals( 2, protoValues.get( 2 ).getInteger().getInteger() ); - assertEquals( 3, protoValues.get( 3 ).getInteger().getInteger() ); - assertEquals( 4, protoValues.get( 4 ).getInteger().getInteger() ); + assertEquals( 1, protoValues.get( 0 ).getInteger().getInteger() ); + assertEquals( 2, protoValues.get( 1 ).getInteger().getInteger() ); + assertEquals( 3, protoValues.get( 2 ).getInteger().getInteger() ); + assertEquals( 4, protoValues.get( 3 ).getInteger().getInteger() ); } @@ -208,15 +202,6 @@ public void polyLongSerializationTest() { } - @Test - public void polyStreamSerializationTest() { - ByteArrayInputStream stream = new ByteArrayInputStream( "test data".getBytes() ); - PolyStream expected = new PolyStream( stream ); - ProtoValue protoValue = PolyValueSerializer.serialize( expected ); - //TODO TH: create test - } - - @Test public void polyStringSerializationTest() { PolyString expected = new PolyString( "sample string" ); @@ -224,15 +209,6 @@ public void polyStringSerializationTest() { assertEquals( "sample string", protoValue.getString().getString() ); } - - @Test - public void polySymbolSerializationTest() { - PolySymbol expected = new PolySymbol( TestEnum.UNTESTED ); - ProtoValue protoValue = PolyValueSerializer.serialize( expected ); - //TODO TH: create test - } - - @Test public void polyTimeSerializationTest() { PolyTime expected = PolyTime.of( new Time( 1691879380700L ) ); @@ -248,15 +224,6 @@ public void polyTimeStampSerializationTest() { assertEquals( 1691879380700L, protoValue.getTimeStamp().getTimeStamp() ); } - - @Test - public void polyUserDefinedValueSerializationTest() { - PolyUserDefinedValue expected = buildTestUdt(); - ProtoValue protoValue = PolyValueSerializer.serialize( expected ); - //TODO TH: create test - } - - @Test public void polyBigDecimalSerializationCorrectTypeTest() { PolyBigDecimal expected = new PolyBigDecimal( new BigDecimal( 1691879380700L ) ); @@ -391,7 +358,6 @@ public void polySymbolSerializationCorrectTypeTest() { PolySymbol expected = new PolySymbol( TestEnum.UNTESTED ); ProtoValue protoValue = PolyValueSerializer.serialize( expected ); assertEquals( ProtoValueType.SYMBOL, protoValue.getType() ); - }