From 37689486ed44d274e318e7fb2d6a90a6a42f8712 Mon Sep 17 00:00:00 2001 From: datomo Date: Mon, 9 Oct 2023 01:05:30 +0200 Subject: [PATCH] added missing dependincies from merge --- core/build.gradle | 25 +- .../org/polypheny/db/PolyImplementation.java | 7 +- dbms/build.gradle | 3 +- .../db/processing/DataMigratorImpl.java | 4 +- .../db/protointerface/DbMetaRetriever.java | 312 ++++++++++-------- .../PIClientInfoProperties.java | 7 +- .../relational/RelationalMetaRetriever.java | 3 +- .../statementProcessing/DocumentExecutor.java | 17 +- .../statementProcessing/MongoImplementer.java | 13 +- .../RelationalExecutor.java | 8 +- .../statementProcessing/SqlImplementer.java | 3 +- .../PIPreparedIndexedStatement.java | 7 +- .../statements/PIPreparedNamedStatement.java | 2 +- .../statements/PIStatement.java | 16 +- .../PIUnparameterizedStatement.java | 37 +-- .../utils/PolyValueSerializer.java | 20 +- .../polypheny/db/webui/crud/LanguageCrud.java | 6 +- .../polypheny/db/webui/models/DbColumn.java | 1 + .../models/requests/BatchUpdateRequest.java | 4 +- 19 files changed, 240 insertions(+), 255 deletions(-) diff --git a/core/build.gradle b/core/build.gradle index 13fc157f4b..1158dbc990 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -54,14 +54,8 @@ dependencies { implementation group: "org.codehaus.janino", name: "commons-compiler", version: commons_compiler_version // BSD implementation group: 'com.j256.simplemagic', name: 'simplemagic', version: simplemagic_version // ISC - api(group: "org.apache.calcite", name: "calcite-linq4j", version: calcite_linq4j_version) { - exclude(module: 'guava') - exclude(module: 'avatica-core') - } // Apache 2.0 - api(group: "org.polypheny.avatica", name: "avatica-core", version: avatica_core_version) { - exclude(module: "protobuf-java") - exclude group: 'org.apache.calcite', module: 'avatica-core' - } // Apache 2.0 + api group: "org.apache.calcite", name: "calcite-linq4j", version: calcite_linq4j_version // Apache 2.0 + api group: "org.polypheny.avatica", name: "avatica-core", version: avatica_core_version // Apache 2.0 implementation group: "com.drewnoakes", name: "metadata-extractor", version: metadata_extractor_version // Apache 2.0 @@ -88,13 +82,19 @@ dependencies { testImplementation group: "junit", name: "junit", version: junit_version testImplementation group: "org.hamcrest", name: "hamcrest-core", version: hamcrest_core_version +} +protobuf { + protoc { + artifact = "com.google.protobuf:protoc:$protobuf_version" + } +} sourceSets { main { java { - srcDirs = ["src/main/java","build/generated-sources"] + srcDirs = ["src/main/java", "build/generated-sources", "build/generated/source/proto/main/java"] outputDir = file(project.buildDir.absolutePath + "/classes") } resources { @@ -126,11 +126,18 @@ compileJava { dependsOn("generateJdbcVersionProperties") dependsOn(":config:processResources") dependsOn(":information:processResources") + dependsOn("generateProto") } delombok { dependsOn(":config:processResources") dependsOn(":information:processResources") + dependsOn("generateProto") +} + +extractIncludeProto { + dependsOn(":config:compileJava") + dependsOn(":information:compileJava") } diff --git a/core/src/main/java/org/polypheny/db/PolyImplementation.java b/core/src/main/java/org/polypheny/db/PolyImplementation.java index 0a7de9296b..f38d26b07e 100644 --- a/core/src/main/java/org/polypheny/db/PolyImplementation.java +++ b/core/src/main/java/org/polypheny/db/PolyImplementation.java @@ -230,14 +230,11 @@ public ResultIterator execute( Statement statement, int batch, boolean isAnalyze } - - - - private Iterator createIterator( Bindable bindable, Statement statement, boolean isAnalyzed ) { + private Iterator createIterator( Bindable bindable, Statement statement, boolean isAnalyzed ) { if ( isAnalyzed ) { statement.getOverviewDuration().start( "Execution" ); } - final Enumerable enumerable = enumerable( bindable, statement.getDataContext() ); + final Enumerable enumerable = enumerable( bindable, statement.getDataContext() ); if ( isAnalyzed ) { statement.getOverviewDuration().stop( "Execution" ); diff --git a/dbms/build.gradle b/dbms/build.gradle index cf47a191b2..3d2e03d916 100644 --- a/dbms/build.gradle +++ b/dbms/build.gradle @@ -44,7 +44,8 @@ dependencies { implementation group: "org.apache.logging.log4j", name: "log4j-slf4j-impl", version: log4j_slf4j_impl_version // Apache 2.0 ////// SLF4J - implementation group: 'org.pf4j', name: 'pf4j', version: pf4jVersion // Apache 2.0 + implementation group: 'org.pf4j', name: 'pf4j', version: pf4j_version // Apache 2.0 + implementation(group: "io.javalin", name: "javalin", version: javalin_version)// Apache 2.0 implementation group: "com.github.rvesse", name: "airline", version: airline_version // Apache 2.0 implementation group: "com.github.oshi", name: "oshi-core", version: oshi_core_version // MIT diff --git a/dbms/src/main/java/org/polypheny/db/processing/DataMigratorImpl.java b/dbms/src/main/java/org/polypheny/db/processing/DataMigratorImpl.java index f32d4f513d..960a8eee34 100644 --- a/dbms/src/main/java/org/polypheny/db/processing/DataMigratorImpl.java +++ b/dbms/src/main/java/org/polypheny/db/processing/DataMigratorImpl.java @@ -357,7 +357,7 @@ public void executeQuery( List selectedColumns, AlgRoot source int batchSize = RuntimeConfig.DATA_MIGRATOR_BATCH_SIZE.getInteger(); int i = 0; - ResultIterator iter = result.execute( sourceStatement, batchSize ); + ResultIterator iter = implementation.execute( sourceStatement, batchSize ); do { List> rows = iter.getRows(); if ( rows.isEmpty() ) { @@ -752,7 +752,7 @@ public void copyAllocationData( Transaction transaction, CatalogAdapter store, L }*/ int batchSize = RuntimeConfig.DATA_MIGRATOR_BATCH_SIZE.getInteger(); - ResultIterator iter = result.execute( source.sourceStatement, batchSize ); + ResultIterator iter = result.execute( source.sourceStatement, batchSize ); do { List> rows = iter.getRows();//MetaImpl.collect( result.getCursorFactory(), LimitIterator.of( sourceIterator, batchSize ), new ArrayList<>() ).stream().map( r -> r.stream().map( e -> (PolyValue) e ).collect( Collectors.toList() ) ).collect( Collectors.toList() ); diff --git a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/DbMetaRetriever.java b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/DbMetaRetriever.java index c41a03e957..9ff376a34b 100644 --- a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/DbMetaRetriever.java +++ b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/DbMetaRetriever.java @@ -65,241 +65,256 @@ public class DbMetaRetriever { // Namespace search by name and type - public static NamespacesResponse searchNamespaces(String namespacePattern, String namespaceType) { - List namespaces = getLogicalNamespaces(namespacePattern, namespaceType); + public static NamespacesResponse searchNamespaces( String namespacePattern, String namespaceType ) { + List namespaces = getLogicalNamespaces( namespacePattern, namespaceType ); NamespacesResponse.Builder responseBuilder = NamespacesResponse.newBuilder(); - namespaces.forEach(namespace -> responseBuilder.addNamespaces(getNamespaceMeta(namespace))); + namespaces.forEach( namespace -> responseBuilder.addNamespaces( getNamespaceMeta( namespace ) ) ); return responseBuilder.build(); } - private static List getLogicalNamespaces(String namespacePattern, String namespaceType) { - Pattern catalogNamespacePattern = getPatternOrNull(namespacePattern); - List logicalNamespaces = Catalog.getInstance().getSnapshot().getNamespaces(catalogNamespacePattern); - if (namespaceType == null) { + private static List getLogicalNamespaces( String namespacePattern, String namespaceType ) { + Pattern catalogNamespacePattern = getPatternOrNull( namespacePattern ); + List logicalNamespaces = Catalog.getInstance().getSnapshot().getNamespaces( catalogNamespacePattern ); + if ( namespaceType == null ) { return logicalNamespaces; } - NamespaceType catalogNamespaceType = NamespaceType.valueOf(namespaceType); - return logicalNamespaces.stream().filter(n -> n.getNamespaceType() == catalogNamespaceType).collect(Collectors.toList()); + NamespaceType catalogNamespaceType = NamespaceType.valueOf( namespaceType ); + return logicalNamespaces.stream().filter( n -> n.getNamespaceType() == catalogNamespaceType ).collect( Collectors.toList() ); } - private static Namespace getNamespaceMeta(LogicalNamespace logicalNamespace) { + + private static Namespace getNamespaceMeta( LogicalNamespace logicalNamespace ) { Namespace.Builder namespaceBuilder = Namespace.newBuilder(); - namespaceBuilder.setNamespaceName(logicalNamespace.getName()); - namespaceBuilder.setDatabaseName(logicalNamespace.getDatabaseName()); - namespaceBuilder.setOwnerName(logicalNamespace.getOwnerName()); - Optional.ofNullable(logicalNamespace.getNamespaceType()).ifPresent(p -> namespaceBuilder.setNamespaceType(p.name())); + namespaceBuilder.setNamespaceName( logicalNamespace.getName() ); + namespaceBuilder.setDatabaseName( logicalNamespace.getDatabaseName() ); + namespaceBuilder.setOwnerName( logicalNamespace.getOwnerName() ); + Optional.ofNullable( logicalNamespace.getNamespaceType() ).ifPresent( p -> namespaceBuilder.setNamespaceType( p.name() ) ); return namespaceBuilder.build(); } - private static Pattern getPatternOrNull(String pattern) { - return pattern == null ? null : new Pattern(pattern); + private static Pattern getPatternOrNull( String pattern ) { + return pattern == null ? null : new Pattern( pattern ); } - public static Namespace getNamespace(String namespaceName) { + + public static Namespace getNamespace( String namespaceName ) { return getNamespaceMeta( Catalog.getInstance().getSnapshot().getNamespace( namespaceName ).orElseThrow() ); } + // Entity search by namespace - public static EntitiesResponse searchEntities(String namespaceName, String entityPattern) { + public static EntitiesResponse searchEntities( String namespaceName, String entityPattern ) { EntitiesResponse.Builder responseBuilder = EntitiesResponse.newBuilder(); LogicalNamespace namespace = Catalog.getInstance().getSnapshot().getNamespace( namespaceName ).orElseThrow(); - switch (namespace.getNamespaceType()) { + switch ( namespace.getNamespaceType() ) { case RELATIONAL: - responseBuilder.addAllEntities(getRelationalEntities(namespace.getId(), entityPattern)); + responseBuilder.addAllEntities( getRelationalEntities( namespace.getId(), entityPattern ) ); break; case GRAPH: - responseBuilder.addAllEntities(getGraphEntities(namespace.getId(), entityPattern)); + responseBuilder.addAllEntities( getGraphEntities( namespace.getId(), entityPattern ) ); break; case DOCUMENT: - responseBuilder.addAllEntities(getDocumentEntities(namespace.getId(), entityPattern)); + responseBuilder.addAllEntities( getDocumentEntities( namespace.getId(), entityPattern ) ); break; } return responseBuilder.build(); } + // Relational entities - private static List getRelationalEntities(long namespaceId, String entityPattern) { - Pattern catalogEntityPattern = getPatternOrNull(entityPattern); - final List tables = Catalog.getInstance().getSnapshot().rel().getTables(namespaceId, catalogEntityPattern); - return tables.stream().map(logicalTable -> buildEntityFromTable(getTableMeta(logicalTable))).collect(Collectors.toList()); + private static List getRelationalEntities( long namespaceId, String entityPattern ) { + Pattern catalogEntityPattern = getPatternOrNull( entityPattern ); + final List tables = Catalog.getInstance().getSnapshot().rel().getTables( namespaceId, catalogEntityPattern ); + return tables.stream().map( logicalTable -> buildEntityFromTable( getTableMeta( logicalTable ) ) ).collect( Collectors.toList() ); } - private static Entity buildEntityFromTable(Table table) { + + private static Entity buildEntityFromTable( Table table ) { return Entity.newBuilder() - .setTable(table) + .setTable( table ) .build(); } - private static Table getTableMeta(LogicalTable logicalTable) { + + private static Table getTableMeta( LogicalTable logicalTable ) { Table.Builder tableBuilder = Table.newBuilder(); - tableBuilder.setSourceDatabaseName(logicalTable.getDatabaseName()); - tableBuilder.setNamespaceName(logicalTable.getNamespaceName()); - tableBuilder.setTableName(logicalTable.getName()); - tableBuilder.setTableType(logicalTable.getEntityType().name()); - tableBuilder.setOwnerName(logicalTable.getOwnerName()); - tableBuilder.addAllColumns(getColumns(logicalTable)); - if (hasPrimaryKey(logicalTable)) { - tableBuilder.setPrimaryKey(getPrimaryKeyMeta(logicalTable)); + tableBuilder.setSourceDatabaseName( logicalTable.getDatabaseName() ); + tableBuilder.setNamespaceName( logicalTable.getNamespaceName() ); + tableBuilder.setTableName( logicalTable.getName() ); + tableBuilder.setTableType( logicalTable.getEntityType().name() ); + tableBuilder.setOwnerName( logicalTable.getOwnerName() ); + tableBuilder.addAllColumns( getColumns( logicalTable ) ); + if ( hasPrimaryKey( logicalTable ) ) { + tableBuilder.setPrimaryKey( getPrimaryKeyMeta( logicalTable ) ); } - tableBuilder.addAllForeignKeys(getForeignKeys(logicalTable)); - tableBuilder.addAllExportedKeys(getExportedKeys(logicalTable)); - tableBuilder.addAllIndexes(getIndexes(logicalTable, true)); + tableBuilder.addAllForeignKeys( getForeignKeys( logicalTable ) ); + tableBuilder.addAllExportedKeys( getExportedKeys( logicalTable ) ); + tableBuilder.addAllIndexes( getIndexes( logicalTable, true ) ); return tableBuilder.build(); } - private static List getColumns(LogicalTable logicalTable) { - return logicalTable.getColumns().stream().map(DbMetaRetriever::getColumnMeta).collect(Collectors.toList()); + + private static List getColumns( LogicalTable logicalTable ) { + return logicalTable.getColumns().stream().map( DbMetaRetriever::getColumnMeta ).collect( Collectors.toList() ); } - private static boolean hasPrimaryKey(LogicalTable logicalTable) { - if (logicalTable.primaryKey == null) { + + private static boolean hasPrimaryKey( LogicalTable logicalTable ) { + if ( logicalTable.primaryKey == null ) { return false; } - return Catalog.getInstance().getSnapshot().rel().getPrimaryKey(logicalTable.primaryKey).isPresent(); + return Catalog.getInstance().getSnapshot().rel().getPrimaryKey( logicalTable.primaryKey ).isPresent(); } - private static PrimaryKey getPrimaryKeyMeta(LogicalTable logicalTable) { - LogicalPrimaryKey logicalPrimaryKey = Catalog.getInstance().getSnapshot().rel().getPrimaryKey(logicalTable.primaryKey).orElseThrow(); + private static PrimaryKey getPrimaryKeyMeta( LogicalTable logicalTable ) { + LogicalPrimaryKey logicalPrimaryKey = Catalog.getInstance().getSnapshot().rel().getPrimaryKey( logicalTable.primaryKey ).orElseThrow(); return PrimaryKey.newBuilder() - .setDatabaseName(logicalPrimaryKey.getDatabaseName()) - .setNamespaceName(logicalPrimaryKey.getSchemaName()) - .setTableName(logicalPrimaryKey.getTableName()) - .addAllColumns(getColumns(logicalPrimaryKey)) + .setDatabaseName( logicalPrimaryKey.getSchemaName() ) + .setNamespaceName( logicalPrimaryKey.getSchemaName() ) + .setTableName( logicalPrimaryKey.getTableName() ) + .addAllColumns( getColumns( logicalPrimaryKey ) ) .build(); } - private static List getColumns(LogicalKey logicalKey) { - return logicalKey.getColumns().stream().map(DbMetaRetriever::getColumnMeta).collect(Collectors.toList()); + + private static List getColumns( LogicalKey logicalKey ) { + return logicalKey.getColumns().stream().map( DbMetaRetriever::getColumnMeta ).collect( Collectors.toList() ); } - private static Column getColumnMeta(LogicalColumn logicalColumn) { + + private static Column getColumnMeta( LogicalColumn logicalColumn ) { Column.Builder columnBuilder = Column.newBuilder(); - columnBuilder.setDatabaseName(logicalColumn.getDatabaseName()); - columnBuilder.setNamespaceName(logicalColumn.getNamespaceName()); - columnBuilder.setTableName(logicalColumn.getTableName()); - columnBuilder.setColumnName(logicalColumn.getName()); - columnBuilder.setTypeName(logicalColumn.getType().getTypeName()); - Optional.ofNullable(logicalColumn.getLength()).ifPresent(columnBuilder::setTypeLength); - Optional.ofNullable(logicalColumn.getScale()).ifPresent(columnBuilder::setTypeScale); - columnBuilder.setIsNullable(logicalColumn.isNullable()); - Optional.ofNullable(logicalColumn.getDefaultValue()).ifPresent(p -> columnBuilder.setDefaultValueAsString(p.getValue())); - columnBuilder.setColumnIndex(logicalColumn.getPosition()); - Optional.ofNullable(CatalogObject.getEnumNameOrNull(logicalColumn.getCollation())).ifPresent(columnBuilder::setCollation); + columnBuilder.setDatabaseName( logicalColumn.getDatabaseName() ); + columnBuilder.setNamespaceName( logicalColumn.getNamespaceName() ); + columnBuilder.setTableName( logicalColumn.getTableName() ); + columnBuilder.setColumnName( logicalColumn.getName() ); + columnBuilder.setTypeName( logicalColumn.getType().getTypeName() ); + Optional.ofNullable( logicalColumn.getLength() ).ifPresent( columnBuilder::setTypeLength ); + Optional.ofNullable( logicalColumn.getScale() ).ifPresent( columnBuilder::setTypeScale ); + columnBuilder.setIsNullable( logicalColumn.isNullable() ); + Optional.ofNullable( logicalColumn.getDefaultValue() ).ifPresent( p -> columnBuilder.setDefaultValueAsString( p.getValue() ) ); + columnBuilder.setColumnIndex( logicalColumn.getPosition() ); + Optional.ofNullable( CatalogObject.getEnumNameOrNull( logicalColumn.getCollation() ) ).ifPresent( columnBuilder::setCollation ); columnBuilder.setIsHidden( logicalColumn.getVisibility() == Visibility.INTERNAL ); - columnBuilder.setColumnType(Column.ColumnType.UNSPECIFIED); //TODO: reserved for future use + columnBuilder.setColumnType( Column.ColumnType.UNSPECIFIED ); //TODO: reserved for future use return columnBuilder.build(); } - private static List getForeignKeys(LogicalTable logicalTable) { - return Catalog.getInstance().getSnapshot().rel().getForeignKeys(logicalTable.getId()) - .stream().map(DbMetaRetriever::getForeignKeyMeta).collect(Collectors.toList()); + private static List getForeignKeys( LogicalTable logicalTable ) { + return Catalog.getInstance().getSnapshot().rel().getForeignKeys( logicalTable.getId() ) + .stream().map( DbMetaRetriever::getForeignKeyMeta ).collect( Collectors.toList() ); } - private static ForeignKey getForeignKeyMeta(LogicalForeignKey logicalForeignKey) { + + private static ForeignKey getForeignKeyMeta( LogicalForeignKey logicalForeignKey ) { ForeignKey.Builder foreignKeyBuilder = ForeignKey.newBuilder(); - foreignKeyBuilder.setReferencedNamespaceName(logicalForeignKey.getReferencedKeySchemaName()); - foreignKeyBuilder.setReferencedDatabaseName(logicalForeignKey.getReferencedKeyDatabaseName()); - foreignKeyBuilder.setReferencedTableName(logicalForeignKey.getReferencedKeyTableName()); - foreignKeyBuilder.setUpdateRule(logicalForeignKey.getUpdateRule().getId()); - foreignKeyBuilder.setDeleteRule(logicalForeignKey.getDeleteRule().getId()); - Optional.ofNullable(logicalForeignKey.getName()).ifPresent(foreignKeyBuilder::setKeyName); - foreignKeyBuilder.addAllReferencedColumns(getReferencedColumns(logicalForeignKey)); - foreignKeyBuilder.addAllForeignColumns(getColumns(logicalForeignKey)); + foreignKeyBuilder.setReferencedNamespaceName( logicalForeignKey.getReferencedKeySchemaName() ); + foreignKeyBuilder.setReferencedDatabaseName( logicalForeignKey.getReferencedKeySchemaName() ); + foreignKeyBuilder.setReferencedTableName( logicalForeignKey.getReferencedKeyTableName() ); + foreignKeyBuilder.setUpdateRule( logicalForeignKey.getUpdateRule().getId() ); + foreignKeyBuilder.setDeleteRule( logicalForeignKey.getDeleteRule().getId() ); + Optional.ofNullable( logicalForeignKey.getName() ).ifPresent( foreignKeyBuilder::setKeyName ); + foreignKeyBuilder.addAllReferencedColumns( getReferencedColumns( logicalForeignKey ) ); + foreignKeyBuilder.addAllForeignColumns( getColumns( logicalForeignKey ) ); return foreignKeyBuilder.build(); } - private static List getReferencedColumns(LogicalForeignKey logicalForeignKey) { - return logicalForeignKey.getReferencedColumns().stream().map(DbMetaRetriever::getColumnMeta).collect(Collectors.toList()); + + private static List getReferencedColumns( LogicalForeignKey logicalForeignKey ) { + return logicalForeignKey.getReferencedKeyColumnIds().stream().map( id -> Catalog.snapshot().rel().getColumn( id ).orElseThrow() ).map( DbMetaRetriever::getColumnMeta ).collect( Collectors.toList() ); } - private static List getExportedKeys(LogicalTable logicalTable) { - return Catalog.getInstance().getSnapshot().rel().getExportedKeys(logicalTable.getId()) - .stream().map(DbMetaRetriever::getForeignKeyMeta).collect(Collectors.toList()); + + private static List getExportedKeys( LogicalTable logicalTable ) { + return Catalog.getInstance().getSnapshot().rel().getExportedKeys( logicalTable.getId() ) + .stream().map( DbMetaRetriever::getForeignKeyMeta ).collect( Collectors.toList() ); } - private static List getIndexes(LogicalTable logicalTable, boolean unique) { - return Catalog.getInstance().getSnapshot().rel().getIndexes(logicalTable.getId(), unique) - .stream().map(DbMetaRetriever::getIndexMeta).collect(Collectors.toList()); + + private static List getIndexes( LogicalTable logicalTable, boolean unique ) { + return Catalog.getInstance().getSnapshot().rel().getIndexes( logicalTable.getId(), unique ) + .stream().map( DbMetaRetriever::getIndexMeta ).collect( Collectors.toList() ); } - private static Index getIndexMeta(LogicalIndex logicalIndex) { + private static Index getIndexMeta( LogicalIndex logicalIndex ) { Index.Builder importedKeyBuilder = Index.newBuilder(); - importedKeyBuilder.setDatabaseName(logicalIndex.getDatabaseName()); - importedKeyBuilder.setNamespaceName(logicalIndex.getKey().getSchemaName()); - importedKeyBuilder.setTableName(logicalIndex.getKey().getTableName()); - importedKeyBuilder.setUnique(logicalIndex.isUnique()); - importedKeyBuilder.setIndexName(logicalIndex.getName()); - importedKeyBuilder.addAllColumns(getColumns(logicalIndex.getKey())); - importedKeyBuilder.setLocation(logicalIndex.getLocation()); - importedKeyBuilder.setIndexType(logicalIndex.getType().getId()); + importedKeyBuilder.setDatabaseName( logicalIndex.getDatabaseName() ); + importedKeyBuilder.setNamespaceName( logicalIndex.getKey().getSchemaName() ); + importedKeyBuilder.setTableName( logicalIndex.getKey().getTableName() ); + importedKeyBuilder.setUnique( logicalIndex.isUnique() ); + importedKeyBuilder.setIndexName( logicalIndex.getName() ); + importedKeyBuilder.addAllColumns( getColumns( logicalIndex.getKey() ) ); + importedKeyBuilder.setLocation( logicalIndex.getLocation() ); + importedKeyBuilder.setIndexType( logicalIndex.getType().getId() ); return importedKeyBuilder.build(); } - public static List getDocumentEntities(long namespaceId, String entityPattern) { + public static List getDocumentEntities( long namespaceId, String entityPattern ) { return null; } - public static List getGraphEntities(long namespaceId, String entityPattern) { + + public static List getGraphEntities( long namespaceId, String entityPattern ) { return null; } - private static List getLogicalIndexesOf(long entityId, boolean unique) { - return Catalog.getInstance().getSnapshot().rel().getIndexes(entityId, unique); + private static List getLogicalIndexesOf( long entityId, boolean unique ) { + return Catalog.getInstance().getSnapshot().rel().getIndexes( entityId, unique ); } public static synchronized DatabasesResponse getDatabases() { Database database = Database.newBuilder() - .setDatabaseName(Catalog.DATABASE_NAME) - .setOwnerName("system") - .setDefaultNamespaceName(Catalog.defaultNamespaceName) + .setDatabaseName( Catalog.DATABASE_NAME ) + .setOwnerName( "system" ) + .setDefaultNamespaceName( Catalog.defaultNamespaceName ) .build(); return DatabasesResponse.newBuilder() - .addDatabases(database) + .addDatabases( database ) .build(); } public static synchronized TableTypesResponse getTableTypes() { - List tableTypes = Arrays.stream(EntityType.values()).map(EntityType::name).collect(Collectors.toList()); + List tableTypes = Arrays.stream( EntityType.values() ).map( EntityType::name ).collect( Collectors.toList() ); TableTypesResponse.Builder responseBuilder = TableTypesResponse.newBuilder(); - tableTypes.forEach(tableType -> responseBuilder.addTableTypes(getTableTypeMeta(tableType))); + tableTypes.forEach( tableType -> responseBuilder.addTableTypes( getTableTypeMeta( tableType ) ) ); return responseBuilder.build(); } - private static TableType getTableTypeMeta(String tableType) { - return TableType.newBuilder().setTableType(tableType).build(); + private static TableType getTableTypeMeta( String tableType ) { + return TableType.newBuilder().setTableType( tableType ).build(); } public static synchronized TypesResponse getTypes() { TypesResponse.Builder responseBuilder = TypesResponse.newBuilder(); - Arrays.stream(PolyType.values()).forEach(polyType -> responseBuilder.addTypes(getTypeMeta(polyType))); + Arrays.stream( PolyType.values() ).forEach( polyType -> responseBuilder.addTypes( getTypeMeta( polyType ) ) ); return responseBuilder.build(); } - private static Type getTypeMeta(PolyType polyType) { + private static Type getTypeMeta( PolyType polyType ) { AlgDataTypeSystem typeSystem = AlgDataTypeSystem.DEFAULT; Type.Builder typeBuilder = Type.newBuilder(); - typeBuilder.setTypeName(polyType.getName()); - typeBuilder.setPrecision(typeSystem.getMaxPrecision(polyType)); - Optional.ofNullable(typeSystem.getLiteral(polyType, true)).ifPresent(typeBuilder::setLiteralPrefix); - Optional.ofNullable(typeSystem.getLiteral(polyType, false)).ifPresent(typeBuilder::setLiteralSuffix); - typeBuilder.setIsCaseSensitive(typeSystem.isCaseSensitive(polyType)); - typeBuilder.setIsSearchable(DatabaseMetaData.typeSearchable); - typeBuilder.setIsAutoIncrement(typeSystem.isAutoincrement(polyType)); - typeBuilder.setMinScale(polyType.getMinScale()); - typeBuilder.setMaxScale(typeSystem.getMaxScale(polyType) ); - typeBuilder.setRadix(typeSystem.getNumTypeRadix(polyType)); + typeBuilder.setTypeName( polyType.getName() ); + typeBuilder.setPrecision( typeSystem.getMaxPrecision( polyType ) ); + Optional.ofNullable( typeSystem.getLiteral( polyType, true ) ).ifPresent( typeBuilder::setLiteralPrefix ); + Optional.ofNullable( typeSystem.getLiteral( polyType, false ) ).ifPresent( typeBuilder::setLiteralSuffix ); + typeBuilder.setIsCaseSensitive( typeSystem.isCaseSensitive( polyType ) ); + typeBuilder.setIsSearchable( DatabaseMetaData.typeSearchable ); + typeBuilder.setIsAutoIncrement( typeSystem.isAutoincrement( polyType ) ); + typeBuilder.setMinScale( polyType.getMinScale() ); + typeBuilder.setMaxScale( typeSystem.getMaxScale( polyType ) ); + typeBuilder.setRadix( typeSystem.getNumTypeRadix( polyType ) ); return typeBuilder.build(); } @@ -309,47 +324,53 @@ public static String getSqlKeywords() { return ""; } - public static ProceduresResponse getProcedures(String languageName, String procedureNamePattern) { + + public static ProceduresResponse getProcedures( String languageName, String procedureNamePattern ) { // TODO: get data after functionality is implemented return ProceduresResponse.newBuilder().build(); } + public static ClientInfoPropertyMetaResponse getClientInfoProperties() { List propertyInfoMetas = PIClientInfoProperties.DEFAULTS.stream() - .map(DbMetaRetriever::getClientInfoPropertyMeta).collect(Collectors.toList()); + .map( DbMetaRetriever::getClientInfoPropertyMeta ).collect( Collectors.toList() ); return ClientInfoPropertyMetaResponse.newBuilder() - .addAllClientInfoPropertyMetas(propertyInfoMetas) + .addAllClientInfoPropertyMetas( propertyInfoMetas ) .build(); } - private static ClientInfoPropertyMeta getClientInfoPropertyMeta(PIClientInfoProperties.ClientInfoPropertiesDefault clientInfoPropertiesDefault) { + + private static ClientInfoPropertyMeta getClientInfoPropertyMeta( PIClientInfoProperties.ClientInfoPropertiesDefault clientInfoPropertiesDefault ) { return ClientInfoPropertyMeta.newBuilder() - .setKey(clientInfoPropertiesDefault.key) - .setDefaultValue(clientInfoPropertiesDefault.default_value) - .setMaxlength(clientInfoPropertiesDefault.maxlength) - .setDescription(clientInfoPropertiesDefault.description) + .setKey( clientInfoPropertiesDefault.key ) + .setDefaultValue( clientInfoPropertiesDefault.default_value ) + .setMaxlength( clientInfoPropertiesDefault.maxlength ) + .setDescription( clientInfoPropertiesDefault.description ) .build(); } - public static FunctionsResponse getFunctions(QueryLanguage language, FunctionCategory functionCategory) { - List functions = OperatorRegistry.getMatchingOperators(language).values().stream() - .filter(o -> o instanceof org.polypheny.db.nodes.Function) - .map(org.polypheny.db.nodes.Function.class::cast) - .filter(f -> f.getFunctionCategory() == functionCategory || functionCategory == null) - .map(DbMetaRetriever::getFunctionMeta) - .collect(Collectors.toList()); - return FunctionsResponse.newBuilder().addAllFunctions(functions).build(); + + public static FunctionsResponse getFunctions( QueryLanguage language, FunctionCategory functionCategory ) { + List functions = OperatorRegistry.getMatchingOperators( language ).values().stream() + .filter( o -> o instanceof org.polypheny.db.nodes.Function ) + .map( org.polypheny.db.nodes.Function.class::cast ) + .filter( f -> f.getFunctionCategory() == functionCategory || functionCategory == null ) + .map( DbMetaRetriever::getFunctionMeta ) + .collect( Collectors.toList() ); + return FunctionsResponse.newBuilder().addAllFunctions( functions ).build(); } - private static Function getFunctionMeta(org.polypheny.db.nodes.Function function) { + + private static Function getFunctionMeta( org.polypheny.db.nodes.Function function ) { Function.Builder functionBuilder = Function.newBuilder(); - functionBuilder.setName(function.getName()); - functionBuilder.setSyntax(function.getAllowedSignatures()); - functionBuilder.setFunctionCategory(function.getFunctionCategory().name()); - functionBuilder.setIsTableFunction(function.getFunctionCategory().isTableFunction()); + functionBuilder.setName( function.getName() ); + functionBuilder.setSyntax( function.getAllowedSignatures() ); + functionBuilder.setFunctionCategory( function.getFunctionCategory().name() ); + functionBuilder.setIsTableFunction( function.getFunctionCategory().isTableFunction() ); return functionBuilder.build(); } + public static DbmsVersionResponse getDbmsVersion() { try { String versionName = PolyphenyDb.class.getPackage().getImplementationVersion(); @@ -376,14 +397,15 @@ public static DbmsVersionResponse getDbmsVersion() { .setMinorVersion( minorVersion ) .build(); return dbmsVersionResponse; - } catch (Exception e) { + } catch ( Exception e ) { DbmsVersionResponse dbmsVersionResponse = DbmsVersionResponse.newBuilder() - .setDbmsName("Polypheny-DB") - .setVersionName("DEVELOPMENT VERSION") - .setMajorVersion(-1) - .setMinorVersion(-1) + .setDbmsName( "Polypheny-DB" ) + .setVersionName( "DEVELOPMENT VERSION" ) + .setMajorVersion( -1 ) + .setMinorVersion( -1 ) .build(); return dbmsVersionResponse; } } + } \ No newline at end of file diff --git a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/PIClientInfoProperties.java b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/PIClientInfoProperties.java index 9debca3bed..0bbfb2fd98 100644 --- a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/PIClientInfoProperties.java +++ b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/PIClientInfoProperties.java @@ -16,10 +16,11 @@ package org.polypheny.db.protointerface; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; import lombok.AllArgsConstructor; -import java.util.*; - public class PIClientInfoProperties extends Properties { private static final int MAX_STRING_LENGTH = 2147483647; public static final List DEFAULTS = Arrays.asList( @@ -56,7 +57,7 @@ public PIClientInfoProperties() { @AllArgsConstructor - static class ClientInfoPropertiesDefault { + public static class ClientInfoPropertiesDefault { String key; String default_value; int maxlength; 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 2cfcc5ad4e..b8c4b08cd9 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 @@ -38,7 +38,6 @@ import org.polypheny.db.protointerface.proto.StructMeta; import org.polypheny.db.protointerface.proto.TypeMeta; import org.polypheny.db.type.PolyType; -import org.polypheny.db.type.entity.PolyValue; public class RelationalMetaRetriever { @@ -66,7 +65,7 @@ private static ParameterMeta retrieveParameterMeta( AlgDataTypeField algDataType } - public static List retrieveColumnMetas( PolyImplementation polyImplementation ) { + public static List retrieveColumnMetas( PolyImplementation polyImplementation ) { AlgDataType algDataType = retrieveAlgDataType( polyImplementation ); AlgDataType whatever = QueryProcessorHelpers.makeStruct( polyImplementation.getStatement().getTransaction().getTypeFactory(), algDataType ); List> origins = polyImplementation.getPreparedResult().getFieldOrigins(); diff --git a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/DocumentExecutor.java b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/DocumentExecutor.java index deae220e4f..4460ebf64d 100644 --- a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/DocumentExecutor.java +++ b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/DocumentExecutor.java @@ -40,8 +40,9 @@ NamespaceType getNamespaceType() { return namespaceType; } + @Override - StatementResult executeAndGetResult(PIStatement piStatement) throws Exception { + StatementResult executeAndGetResult( PIStatement piStatement ) { if ( hasInvalidNamespaceType( piStatement ) ) { throw new PIServiceException( "The results of type " + piStatement.getLanguage().getNamespaceType() @@ -50,7 +51,7 @@ StatementResult executeAndGetResult(PIStatement piStatement) throws Exception { 9000 ); } - PolyImplementation implementation = piStatement.getImplementation(); + PolyImplementation implementation = piStatement.getImplementation(); if ( implementation == null ) { throw new PIServiceException( "Can't retrieve results form an unexecuted statement.", "I9002", @@ -71,7 +72,7 @@ StatementResult executeAndGetResult(PIStatement piStatement) throws Exception { @Override - StatementResult executeAndGetResult(PIStatement piStatement, int fetchSize ) throws Exception { + StatementResult executeAndGetResult( PIStatement piStatement, int fetchSize ) throws Exception { if ( hasInvalidNamespaceType( piStatement ) ) { throw new PIServiceException( "The results of type " + piStatement.getLanguage().getNamespaceType() @@ -80,7 +81,7 @@ StatementResult executeAndGetResult(PIStatement piStatement, int fetchSize ) thr 9000 ); } - PolyImplementation implementation = piStatement.getImplementation(); + PolyImplementation implementation = piStatement.getImplementation(); if ( implementation == null ) { throw new PIServiceException( "Can't retrieve results form an unexecuted statement.", "I9002", @@ -93,7 +94,7 @@ StatementResult executeAndGetResult(PIStatement piStatement, int fetchSize ) thr resultBuilder.setScalar( 1 ); return resultBuilder.build(); } - piStatement.setIterator(implementation.execute(piStatement.getStatement(), fetchSize )); + piStatement.setIterator( implementation.execute( piStatement.getStatement(), fetchSize ) ); Frame frame = fetch( piStatement, fetchSize ); resultBuilder.setFrame( frame ); if ( frame.getIsLast() ) { @@ -122,15 +123,15 @@ Frame fetch( PIStatement piStatement, int fetchSize ) { 9001 ); } - PolyImplementation implementation = piStatement.getImplementation(); + PolyImplementation implementation = piStatement.getImplementation(); if ( implementation == null ) { throw new PIServiceException( "Can't fetch form an unexecuted statement.", "I9002", 9002 ); } - ResultIterator iterator = piStatement.getIterator(); - if (iterator == null) { + ResultIterator iterator = piStatement.getIterator(); + if ( iterator == null ) { throw new PIServiceException( "Can't fetch form an unexecuted statement.", "I9002", 9002 diff --git a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/MongoImplementer.java b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/MongoImplementer.java index 1f80dc6881..6d0d5e1e43 100644 --- a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/MongoImplementer.java +++ b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/MongoImplementer.java @@ -18,21 +18,16 @@ import org.polypheny.db.PolyImplementation; import org.polypheny.db.algebra.AlgRoot; -import org.polypheny.db.algebra.constant.Kind; import org.polypheny.db.catalog.Catalog; -import org.polypheny.db.catalog.logistic.NamespaceType; import org.polypheny.db.languages.QueryLanguage; import org.polypheny.db.languages.QueryParameters; import org.polypheny.db.languages.mql.Mql.Family; import org.polypheny.db.languages.mql.MqlNode; import org.polypheny.db.languages.mql.MqlQueryParameters; -import org.polypheny.db.nodes.Node; import org.polypheny.db.processing.AutomaticDdlProcessor; -import org.polypheny.db.processing.Processor; import org.polypheny.db.protointerface.PIServiceException; import org.polypheny.db.protointerface.statements.PIStatement; import org.polypheny.db.transaction.Statement; -import org.polypheny.db.type.entity.PolyValue; public class MongoImplementer extends StatementImplementer { @@ -46,7 +41,7 @@ public QueryLanguage getLanguage() { @Override - public void implement(PIStatement piStatement ) throws PIServiceException { + public void implement( PIStatement piStatement ) throws PIServiceException { if ( hasInvalidLanguage( piStatement ) ) { throw new PIServiceException( "The statement in the language " + piStatement.getLanguage() @@ -63,9 +58,9 @@ public void implement(PIStatement piStatement ) throws PIServiceException { ); } String query = piStatement.getQuery(); - PolyImplementation implementation; - AutomaticDdlProcessor mqlProcessor = (AutomaticDdlProcessor)statement.getTransaction().getProcessor( language ); - QueryParameters parameters = new MqlQueryParameters( query, piStatement.getNamespace().getName(), piStatement.getNamespace().getNamespaceType() ); + PolyImplementation implementation; + AutomaticDdlProcessor mqlProcessor = (AutomaticDdlProcessor) statement.getTransaction().getProcessor( language ); + QueryParameters parameters = new MqlQueryParameters( query, Catalog.snapshot().getNamespace( piStatement.getNamespace().getName() ).orElseThrow().id, piStatement.getNamespace().getNamespaceType() ); MqlNode parsed = (MqlNode) mqlProcessor.parse( query ).get( 0 ); if ( parsed.getFamily() == Family.DML && mqlProcessor.needsDdlGeneration( parsed, parameters ) ) { mqlProcessor.autoGenerateDDL( statement, parsed, parameters ); diff --git a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/RelationalExecutor.java b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/RelationalExecutor.java index 65a82219bd..d387def56b 100644 --- a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/RelationalExecutor.java +++ b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/RelationalExecutor.java @@ -61,7 +61,7 @@ StatementResult executeAndGetResult(PIStatement piStatement) throws Exception { 9001 ); } - PolyImplementation implementation = piStatement.getImplementation(); + PolyImplementation implementation = piStatement.getImplementation(); if (implementation == null) { throw new PIServiceException( "Can't retrieve results form an unexecuted statement.", "I9002", @@ -98,7 +98,7 @@ public StatementResult executeAndGetResult(PIStatement piStatement, int fetchSiz 9001 ); } - PolyImplementation implementation = piStatement.getImplementation(); + PolyImplementation implementation = piStatement.getImplementation(); if (implementation == null) { throw new PIServiceException( "Can't retrieve results form an unprepared statement.", "I9002", @@ -138,14 +138,14 @@ public Frame fetch( PIStatement piStatement, int fetchSize ) { ); } StopWatch executionStopWatch = piStatement.getExecutionStopWatch(); - PolyImplementation implementation = piStatement.getImplementation(); + PolyImplementation implementation = piStatement.getImplementation(); if (implementation == null) { throw new PIServiceException( "Can't fetch form an unprepared statement.", "I9002", 9002 ); } - ResultIterator iterator = piStatement.getIterator(); + ResultIterator iterator = piStatement.getIterator(); if (iterator == null) { throw new PIServiceException( "Can't fetch form an unexecuted statement.", "I9002", diff --git a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/SqlImplementer.java b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/SqlImplementer.java index b22a37ffc5..1d0bcc64e7 100644 --- a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/SqlImplementer.java +++ b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statementProcessing/SqlImplementer.java @@ -28,7 +28,6 @@ import org.polypheny.db.protointerface.PIServiceException; import org.polypheny.db.protointerface.statements.PIStatement; import org.polypheny.db.transaction.Statement; -import org.polypheny.db.type.entity.PolyValue; import org.polypheny.db.util.Pair; public class SqlImplementer extends StatementImplementer { @@ -58,7 +57,7 @@ public void implement(PIStatement piStatement ) throws PIServiceException{ ); } String query = piStatement.getQuery(); - PolyImplementation implementation; + PolyImplementation implementation; Processor queryProcessor = statement.getTransaction().getProcessor( language ); Node parsedStatement = queryProcessor.parse( query ).get( 0 ); if ( parsedStatement.isA( Kind.DDL ) ) { diff --git a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statements/PIPreparedIndexedStatement.java b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statements/PIPreparedIndexedStatement.java index d4147eb01b..a266447597 100644 --- a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statements/PIPreparedIndexedStatement.java +++ b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statements/PIPreparedIndexedStatement.java @@ -19,7 +19,6 @@ import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; - import lombok.Getter; import lombok.Setter; import org.polypheny.db.PolyImplementation; @@ -33,15 +32,13 @@ import org.polypheny.db.transaction.Transaction; import org.polypheny.db.type.entity.PolyValue; +@Getter public class PIPreparedIndexedStatement extends PIPreparedStatement { - @Getter protected String query; - @Getter protected Statement statement; - @Getter @Setter - protected PolyImplementation implementation; + protected PolyImplementation implementation; public PIPreparedIndexedStatement( diff --git a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statements/PIPreparedNamedStatement.java b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statements/PIPreparedNamedStatement.java index eb91811882..174353641a 100644 --- a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statements/PIPreparedNamedStatement.java +++ b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statements/PIPreparedNamedStatement.java @@ -37,7 +37,7 @@ public class PIPreparedNamedStatement extends PIPreparedStatement { protected String query; @Getter @Setter - protected PolyImplementation implementation; + protected PolyImplementation implementation; @Getter protected Statement statement; private final NamedValueProcessor namedValueProcessor; diff --git a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statements/PIStatement.java b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statements/PIStatement.java index 5e216a8d3d..ead610238a 100644 --- a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statements/PIStatement.java +++ b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statements/PIStatement.java @@ -16,7 +16,6 @@ package org.polypheny.db.protointerface.statements; -import java.util.Iterator; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -28,23 +27,17 @@ import org.polypheny.db.protointerface.PIClient; import org.polypheny.db.transaction.Statement; import org.polypheny.db.transaction.Transaction; -import org.polypheny.db.type.entity.PolyValue; +@Getter @Slf4j public abstract class PIStatement { - @Getter protected final int id; - @Getter protected final PIClient client; - @Getter protected final StopWatch executionStopWatch; - @Getter protected final QueryLanguage language; - @Getter @Setter - private PolyImplementation.ResultIterator iterator; - @Getter + private PolyImplementation.ResultIterator iterator; protected LogicalNamespace namespace; @@ -70,9 +63,10 @@ public void closeResults() { } } - public abstract PolyImplementation getImplementation(); - public abstract void setImplementation( PolyImplementation implementation ); + public abstract PolyImplementation getImplementation(); + + public abstract void setImplementation( PolyImplementation implementation ); public abstract Statement getStatement(); diff --git a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statements/PIUnparameterizedStatement.java b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statements/PIUnparameterizedStatement.java index 63944669a0..264632d870 100644 --- a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statements/PIUnparameterizedStatement.java +++ b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/statements/PIUnparameterizedStatement.java @@ -16,6 +16,8 @@ package org.polypheny.db.protointerface.statements; +import lombok.Getter; +import lombok.Setter; import lombok.extern.slf4j.Slf4j; import org.polypheny.db.PolyImplementation; import org.polypheny.db.catalog.entity.logical.LogicalNamespace; @@ -25,14 +27,17 @@ import org.polypheny.db.protointerface.statementProcessing.StatementProcessor; import org.polypheny.db.transaction.Statement; import org.polypheny.db.transaction.Transaction; -import org.polypheny.db.type.entity.PolyValue; @Slf4j public class PIUnparameterizedStatement extends PIStatement { + @Getter String query; + @Getter Statement statement; - PolyImplementation implementation; + @Setter + @Getter + PolyImplementation implementation; public PIUnparameterizedStatement( int id, PIClient client, QueryLanguage language, LogicalNamespace namespace, String query ) { @@ -46,38 +51,14 @@ public PIUnparameterizedStatement( int id, PIClient client, QueryLanguage langua } - public StatementResult execute(int fetchSize) throws Exception { + public StatementResult execute( int fetchSize ) throws Exception { statement = client.getCurrentOrCreateNewTransaction().createStatement(); synchronized ( client ) { StatementProcessor.implement( this ); - return StatementProcessor.executeAndGetResult( this, fetchSize); + return StatementProcessor.executeAndGetResult( this, fetchSize ); } } - @Override - public PolyImplementation getImplementation() { - return implementation; - } - - - @Override - public void setImplementation( PolyImplementation implementation ) { - this.implementation = implementation; - } - - - @Override - public Statement getStatement() { - return statement; - } - - - @Override - public String getQuery() { - return query; - } - - @Override public Transaction getTransaction() { return statement.getTransaction(); diff --git a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/utils/PolyValueSerializer.java b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/utils/PolyValueSerializer.java index 9914703d5a..8950ad3a4f 100644 --- a/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/utils/PolyValueSerializer.java +++ b/plugins/proto-interface/src/main/java/org/polypheny/db/protointerface/utils/PolyValueSerializer.java @@ -54,19 +54,18 @@ import org.polypheny.db.type.entity.PolyBoolean; import org.polypheny.db.type.entity.PolyDate; import org.polypheny.db.type.entity.PolyDouble; -import org.polypheny.db.type.entity.PolyFile; import org.polypheny.db.type.entity.PolyFloat; import org.polypheny.db.type.entity.PolyInteger; import org.polypheny.db.type.entity.PolyInterval; import org.polypheny.db.type.entity.PolyList; import org.polypheny.db.type.entity.PolyLong; import org.polypheny.db.type.entity.PolyNull; -import org.polypheny.db.type.entity.PolyStream; import org.polypheny.db.type.entity.PolyString; import org.polypheny.db.type.entity.PolyTime; import org.polypheny.db.type.entity.PolyTimeStamp; import org.polypheny.db.type.entity.PolyUserDefinedValue; import org.polypheny.db.type.entity.PolyValue; +import org.polypheny.db.type.entity.category.PolyBlob; import org.polypheny.db.type.entity.document.PolyDocument; import org.polypheny.db.type.entity.graph.GraphPropertyHolder; import org.polypheny.db.type.entity.graph.PolyEdge; @@ -208,16 +207,7 @@ public static ProtoValue serialize( PolyValue polyValue ) { case AUDIO: case FILE: // used by PolyFile - if ( polyValue instanceof PolyFile ) { - throw new NotImplementedException( "Serialization of PolyFile not implemented" ); - //return serializeAsProtoFile( polyValue.asFile() ); - } - if ( polyValue instanceof PolyStream ) { - throw new NotImplementedException( "Serialization of PolyStream not implemented" ); - //return serializeAsProtoStream( polyValue.asStream() ); - } - throw new IllegalArgumentException( "Illegal poly value for poly type FILE." ); - // used by PolyStream + return serializeAsProtoFile( polyValue.asBlob() ); case DISTINCT: case STRUCTURED: case ROW: @@ -385,13 +375,13 @@ private static ProtoList serializeToProtoList( PolyList polyList ) { } - private static ProtoValue serializeAsProtoFile( PolyFile polyFile ) { + private static ProtoValue serializeAsProtoFile( PolyBlob polyBlob ) { ProtoBinary protoBinary = ProtoBinary.newBuilder() - .setBinary( ByteString.copyFrom( polyFile.getValue() ) ) + .setBinary( ByteString.copyFrom( polyBlob.getValue() ) ) .build(); return ProtoValue.newBuilder() .setBinary( protoBinary ) - .setType( getType( polyFile ) ) + .setType( getType( polyBlob ) ) .build(); } diff --git a/webui/src/main/java/org/polypheny/db/webui/crud/LanguageCrud.java b/webui/src/main/java/org/polypheny/db/webui/crud/LanguageCrud.java index f8fda51b40..ccd1001abb 100644 --- a/webui/src/main/java/org/polypheny/db/webui/crud/LanguageCrud.java +++ b/webui/src/main/java/org/polypheny/db/webui/crud/LanguageCrud.java @@ -208,7 +208,7 @@ public static void attachError( Transaction transaction, List> resu throw new GenericRuntimeException( e ); } - LogicalTable catalogTable = null; + LogicalTable table = null; if ( request.entityId != null ) { table = Catalog.snapshot().rel().getTable( request.entityId ).orElseThrow(); } @@ -258,8 +258,8 @@ public static void attachError( Transaction transaction, List> resu } - private static GraphResult getGraphResult( Statement statement,QueryLanguage language, QueryRequest request, String query, PolyImplementation implementation, Transaction transaction, boolean noLimit ) { - ResultIterator iterator = implementation.execute( statement, noLimit ? -1 : RuntimeConfig.UI_PAGE_SIZE.getInteger() ); + private static GraphResult getGraphResult( Statement statement, QueryLanguage language, QueryRequest request, String query, PolyImplementation implementation, Transaction transaction, boolean noLimit ) { + ResultIterator iterator = implementation.execute( statement, noLimit ? -1 : RuntimeConfig.UI_PAGE_SIZE.getInteger() ); List data = iterator.getArrayRows(); try { iterator.close(); diff --git a/webui/src/main/java/org/polypheny/db/webui/models/DbColumn.java b/webui/src/main/java/org/polypheny/db/webui/models/DbColumn.java index d9222f8639..94c97555d3 100644 --- a/webui/src/main/java/org/polypheny/db/webui/models/DbColumn.java +++ b/webui/src/main/java/org/polypheny/db/webui/models/DbColumn.java @@ -25,6 +25,7 @@ import lombok.Setter; import lombok.experimental.Accessors; import lombok.experimental.SuperBuilder; +import org.polypheny.db.webui.models.catalog.FieldDefinition; /** diff --git a/webui/src/main/java/org/polypheny/db/webui/models/requests/BatchUpdateRequest.java b/webui/src/main/java/org/polypheny/db/webui/models/requests/BatchUpdateRequest.java index 0eb6a92435..036893e82e 100644 --- a/webui/src/main/java/org/polypheny/db/webui/models/requests/BatchUpdateRequest.java +++ b/webui/src/main/java/org/polypheny/db/webui/models/requests/BatchUpdateRequest.java @@ -81,12 +81,12 @@ public String getQuery( String tableId, Statement statement, HttpServletRequest log.warn( "This should not happen" ); } } - sBuilder.append( setClauses.toString() ); + sBuilder.append( setClauses ); StringJoiner whereClauses = new StringJoiner( " AND " ); for ( Entry entry : oldPkValues.entrySet() ) { whereClauses.add( String.format( "\"%s\"='%s'", entry.getKey(), entry.getValue() ) ); } - sBuilder.append( " WHERE " ).append( whereClauses.toString() ); + sBuilder.append( " WHERE " ).append( whereClauses ); return sBuilder.toString(); }