Skip to content

Commit 7eb353d

Browse files
authored
Get rid of Symbols synchronization on Usages, Builders feaures (#190)
* Indexing is broken in case of turned on Foreign keys #184 * Indexing is broken in case of turned on Foreign keys #184 * fix tests
1 parent 099fc26 commit 7eb353d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+900
-886
lines changed

build.gradle.kts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ val semVer: String? by project
55
val includeDokka: String? by project
66

77
group = "org.jacodb"
8-
version = semVer ?: "1.3-SNAPSHOT"
8+
version = semVer ?: "1.4-SNAPSHOT"
99

1010
plugins {
1111
kotlin("jvm") version Versions.kotlin
1212
kotlin("plugin.allopen") version Versions.kotlin
1313
kotlin("plugin.serialization") version Versions.kotlin apply false
14-
with(Plugins.Dokka) { id(id) version (version) }
15-
with(Plugins.Licenser) { id(id) version (version) }
14+
id(Plugins.Dokka)
15+
id(Plugins.Licenser)
1616
`java-library`
1717
`java-test-fixtures`
1818
`maven-publish`
@@ -96,6 +96,13 @@ allprojects {
9696
setup(jacocoTestReport)
9797
}
9898

99+
jar {
100+
manifest {
101+
attributes["Implementation-Title"] = project.name
102+
attributes["Implementation-Version"] = archiveVersion
103+
}
104+
}
105+
99106
val lifecycleTest by creating(Test::class) {
100107
useJUnitPlatform {
101108
includeTags(Tests.lifecycleTag)

buildSrc/src/main/kotlin/Dependencies.kt

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
@file:Suppress("PublicApiImplicitType", "MemberVisibilityCanBePrivate", "unused", "ConstPropertyName")
22

3+
import org.gradle.plugin.use.PluginDependenciesSpec
4+
5+
36
object Versions {
47
const val asm = "9.5"
58
const val dokka = "1.7.20"
69
const val gradle_download = "5.3.0"
710
const val gradle_versions = "0.47.0"
8-
const val guava = "31.1-jre"
911
const val hikaricp = "5.0.1"
12+
const val guava = "31.1-jre"
1013
const val javax_activation = "1.1"
1114
const val javax_mail = "1.4.7"
1215
const val javax_servlet_api = "2.5"
@@ -27,7 +30,6 @@ object Versions {
2730
const val kotlinx_serialization = "1.4.1"
2831
const val licenser = "0.6.1"
2932
const val mockito = "4.8.0"
30-
const val postgresql = "42.5.1"
3133
const val shadow = "8.1.1"
3234
const val slf4j = "1.7.36"
3335
const val soot_utbot_fork = "4.4.0-FORK-2"
@@ -157,13 +159,6 @@ object Libs {
157159
version = Versions.kotlinx_cli
158160
)
159161

160-
// https://github.com/pgjdbc/pgjdbc
161-
val postgresql = dep(
162-
group = "org.postgresql",
163-
name = "postgresql",
164-
version = Versions.postgresql
165-
)
166-
167162
// https://github.com/brettwooldridge/HikariCP
168163
val hikaricp = dep(
169164
group = "com.zaxxer",
@@ -283,39 +278,46 @@ object Libs {
283278
}
284279

285280
object Plugins {
281+
282+
abstract class ProjectPlugin(val version: String, val id: String)
283+
286284
// https://github.com/Kotlin/dokka
287-
object Dokka {
288-
const val version = Versions.dokka
289-
const val id = "org.jetbrains.dokka"
290-
}
285+
object Dokka: ProjectPlugin(
286+
version = Versions.dokka,
287+
id = "org.jetbrains.dokka"
288+
)
291289

292290
// https://github.com/michel-kraemer/gradle-download-task
293-
object GradleDownload {
294-
const val version = Versions.gradle_download
295-
const val id = "de.undercouch.download"
296-
}
291+
object GradleDownload: ProjectPlugin(
292+
version = Versions.gradle_download,
293+
id = "de.undercouch.download"
294+
)
297295

298296
// https://github.com/ben-manes/gradle-versions-plugin
299-
object GradleVersions {
300-
const val version = Versions.gradle_versions
301-
const val id = "com.github.ben-manes.versions"
302-
}
297+
object GradleVersions: ProjectPlugin(
298+
version = Versions.gradle_versions,
299+
id = "com.github.ben-manes.versions"
300+
)
303301

304302
// https://github.com/Kotlin/kotlinx-benchmark
305-
object KotlinxBenchmark {
306-
const val version = Versions.kotlinx_benchmark
307-
const val id = "org.jetbrains.kotlinx.benchmark"
308-
}
303+
object KotlinxBenchmark : ProjectPlugin(
304+
version = Versions.kotlinx_benchmark,
305+
id = "org.jetbrains.kotlinx.benchmark"
306+
)
309307

310308
// https://github.com/CadixDev/licenser
311-
object Licenser {
312-
const val version = Versions.licenser
313-
const val id = "org.cadixdev.licenser"
314-
}
309+
object Licenser : ProjectPlugin(
310+
version = Versions.licenser,
311+
id = "org.cadixdev.licenser"
312+
)
315313

316314
// https://github.com/johnrengelman/shadow
317-
object Shadow {
318-
const val version = Versions.shadow
319-
const val id = "com.github.johnrengelman.shadow"
320-
}
315+
object Shadow : ProjectPlugin(
316+
version = Versions.shadow,
317+
id = "com.github.johnrengelman.shadow"
318+
)
321319
}
320+
321+
fun PluginDependenciesSpec.id(plugin: Plugins.ProjectPlugin) {
322+
id(plugin.id).version(plugin.version)
323+
}

jacodb-api/src/main/kotlin/org/jacodb/api/Api.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ interface JcDatabasePersistence : Closeable {
158158
fun findClassSources(cp: JcClasspath, fullName: String): List<ClassSource>
159159

160160
fun createIndexes() {}
161-
162-
fun getScript(name: String): String
163161
}
164162

165163
interface RegisteredLocation {

jacodb-benchmarks/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import kotlinx.benchmark.gradle.JvmBenchmarkTarget
33

44
plugins {
55
`java-test-fixtures`
6-
with(Plugins.GradleDownload) { id(id) version (version) }
7-
with(Plugins.KotlinxBenchmark) { id(id) version (version) }
6+
id(Plugins.GradleDownload)
7+
id(Plugins.KotlinxBenchmark)
88
}
99

1010
dependencies {

jacodb-benchmarks/src/test/kotlin/org/jacodb/testing/performance/TakeMemoryDump.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ fun main() {
2929
runBlocking {
3030
val db = jacodb {
3131
loadByteCode(allClasspath)
32-
persistent(
33-
"d:\\work\\jacodb\\jacodb-classpath.db",
34-
)
32+
// persistent(
33+
// "d:\\work\\jacodb\\jacodb-classpath.db",
34+
// )
3535
installFeatures(InMemoryHierarchy, Usages, Builders)
3636
}.also {
3737
println("AWAITING db took ${System.currentTimeMillis() - start}ms")

jacodb-core/build.gradle.kts

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import org.jooq.codegen.GenerationTool
2+
import org.jooq.meta.jaxb.*
23
import org.jooq.meta.jaxb.Configuration
3-
import org.jooq.meta.jaxb.Database
4-
import org.jooq.meta.jaxb.Generate
5-
import org.jooq.meta.jaxb.Generator
6-
import org.jooq.meta.jaxb.Jdbc
74
import org.jooq.meta.jaxb.Target
85
import java.nio.file.Paths
96

@@ -18,7 +15,7 @@ buildscript {
1815
classpath(Libs.jooq_kotlin)
1916
// classpath(Libs.postgresql)
2017
// classpath(Libs.hikaricp)
21-
// classpath(Libs.sqlite)
18+
classpath(Libs.sqlite)
2219
}
2320
}
2421

@@ -38,15 +35,13 @@ dependencies {
3835
implementation(Libs.kotlinx_serialization_cbor)
3936
implementation(Libs.jdot)
4037
implementation(Libs.guava)
41-
implementation(Libs.postgresql)
42-
implementation(Libs.hikaricp)
4338
implementation(Libs.sqlite)
4439

4540
testImplementation(Libs.javax_activation)
4641
testImplementation(Libs.javax_mail)
4742
testImplementation(Libs.joda_time)
4843
testImplementation(Libs.slf4j_simple)
49-
// testImplementation(files("src/test/resources/samples"))
44+
testImplementation(Libs.hikaricp)
5045

5146
testFixturesImplementation(project(":jacodb-api"))
5247
testFixturesImplementation(kotlin("reflect"))
@@ -58,10 +53,10 @@ dependencies {
5853
testFixturesImplementation(Libs.kotlinx_coroutines_core)
5954
}
6055

61-
tasks.register("generateSqlScheme") {
62-
val databaseLocation = project.properties["database_location"]
63-
if (databaseLocation != null) {
64-
val url = "jdbc:sqlite:file:$databaseLocation"
56+
tasks {
57+
register("generateSqlScheme") {
58+
val location = "src/main/resources/sqlite/empty.db"
59+
val url = "jdbc:sqlite:file:$location"
6560
val driver = "org.sqlite.JDBC"
6661
GenerationTool.generate(
6762
Configuration()
@@ -86,12 +81,18 @@ tasks.register("generateSqlScheme") {
8681
)
8782
)
8883
}
89-
}
9084

91-
tasks.register<JavaExec>("generateDocSvgs") {
92-
dependsOn("testClasses")
93-
mainClass.set("org.utbot.jcdb.impl.cfg.IRSvgGeneratorKt")
94-
classpath = sourceSets.test.get().runtimeClasspath
95-
val svgDocs = Paths.get(rootDir.absolutePath, "docs", "svg").toFile()
96-
args = listOf(svgDocs.absolutePath)
85+
register<JavaExec>("generateDocSvgs") {
86+
dependsOn("testClasses")
87+
mainClass.set("org.utbot.jcdb.impl.cfg.IRSvgGeneratorKt")
88+
classpath = sourceSets.test.get().runtimeClasspath
89+
val svgDocs = Paths.get(rootDir.absolutePath, "docs", "svg").toFile()
90+
args = listOf(svgDocs.absolutePath)
91+
}
92+
93+
processResources {
94+
filesMatching("**/*.properties") {
95+
expand("version" to project.version)
96+
}
97+
}
9798
}

jacodb-core/src/main/jooq/org/jacodb/impl/storage/jooq/DefaultSchema.kt

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,10 @@
2020
package org.jacodb.impl.storage.jooq
2121

2222

23-
import kotlin.collections.List
24-
23+
import org.jacodb.impl.storage.jooq.tables.*
2524
import org.jooq.Catalog
2625
import org.jooq.Table
2726
import org.jooq.impl.SchemaImpl
28-
import org.jacodb.impl.storage.jooq.tables.Annotations
29-
import org.jacodb.impl.storage.jooq.tables.Annotationvalues
30-
import org.jacodb.impl.storage.jooq.tables.Builders
31-
import org.jacodb.impl.storage.jooq.tables.Bytecodelocations
32-
import org.jacodb.impl.storage.jooq.tables.Calls
33-
import org.jacodb.impl.storage.jooq.tables.Classes
34-
import org.jacodb.impl.storage.jooq.tables.Classhierarchies
35-
import org.jacodb.impl.storage.jooq.tables.Classinnerclasses
36-
import org.jacodb.impl.storage.jooq.tables.Fields
37-
import org.jacodb.impl.storage.jooq.tables.Methodparameters
38-
import org.jacodb.impl.storage.jooq.tables.Methods
39-
import org.jacodb.impl.storage.jooq.tables.Outerclasses
40-
import org.jacodb.impl.storage.jooq.tables.Symbols
4127

4228

4329
/**
@@ -63,6 +49,11 @@ open class DefaultSchema : SchemaImpl("", DefaultCatalog.DEFAULT_CATALOG) {
6349
*/
6450
val ANNOTATIONVALUES get() = Annotationvalues.ANNOTATIONVALUES
6551

52+
/**
53+
* The table <code>ApplicationMetadata</code>.
54+
*/
55+
val APPLICATIONMETADATA get() = Applicationmetadata.APPLICATIONMETADATA
56+
6657
/**
6758
* The table <code>Builders</code>.
6859
*/
@@ -113,6 +104,11 @@ open class DefaultSchema : SchemaImpl("", DefaultCatalog.DEFAULT_CATALOG) {
113104
*/
114105
val OUTERCLASSES get() = Outerclasses.OUTERCLASSES
115106

107+
/**
108+
* The table <code>Refactorings</code>.
109+
*/
110+
val REFACTORINGS get() = Refactorings.REFACTORINGS
111+
116112
/**
117113
* The table <code>Symbols</code>.
118114
*/
@@ -123,6 +119,7 @@ open class DefaultSchema : SchemaImpl("", DefaultCatalog.DEFAULT_CATALOG) {
123119
override fun getTables(): List<Table<*>> = listOf(
124120
Annotations.ANNOTATIONS,
125121
Annotationvalues.ANNOTATIONVALUES,
122+
Applicationmetadata.APPLICATIONMETADATA,
126123
Builders.BUILDERS,
127124
Bytecodelocations.BYTECODELOCATIONS,
128125
Calls.CALLS,
@@ -133,6 +130,7 @@ open class DefaultSchema : SchemaImpl("", DefaultCatalog.DEFAULT_CATALOG) {
133130
Methodparameters.METHODPARAMETERS,
134131
Methods.METHODS,
135132
Outerclasses.OUTERCLASSES,
133+
Refactorings.REFACTORINGS,
136134
Symbols.SYMBOLS
137135
)
138136
}

jacodb-core/src/main/jooq/org/jacodb/impl/storage/jooq/indexes/Indexes.kt

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,36 @@
2020
package org.jacodb.impl.storage.jooq.indexes
2121

2222

23+
import org.jacodb.impl.storage.jooq.tables.*
2324
import org.jooq.Index
2425
import org.jooq.impl.DSL
2526
import org.jooq.impl.Internal
26-
import org.jacodb.impl.storage.jooq.tables.Builders
27-
import org.jacodb.impl.storage.jooq.tables.Calls
28-
2927

3028

3129
// -------------------------------------------------------------------------
3230
// INDEX definitions
3331
// -------------------------------------------------------------------------
3432

35-
val BUILDERSJOIN: Index = Internal.createIndex(DSL.name("BuildersJoin"), Builders.BUILDERS, arrayOf(Builders.BUILDERS.BUILDER_CLASS_SYMBOL_ID), false)
36-
val BUILDERSSEARCH: Index = Internal.createIndex(DSL.name("BuildersSearch"), Builders.BUILDERS, arrayOf(Builders.BUILDERS.LOCATION_ID, Builders.BUILDERS.CLASS_SYMBOL_ID, Builders.BUILDERS.PRIORITY), false)
33+
val ANNOTATIONS_CLASSID: Index = Internal.createIndex(DSL.name("Annotations_classId"), Annotations.ANNOTATIONS, arrayOf(Annotations.ANNOTATIONS.CLASS_ID), false)
34+
val ANNOTATIONS_FIELDID: Index = Internal.createIndex(DSL.name("Annotations_fieldId"), Annotations.ANNOTATIONS, arrayOf(Annotations.ANNOTATIONS.FIELD_ID), false)
35+
val ANNOTATIONS_METHODID: Index = Internal.createIndex(DSL.name("Annotations_methodId"), Annotations.ANNOTATIONS, arrayOf(Annotations.ANNOTATIONS.METHOD_ID), false)
36+
val ANNOTATIONS_PARAMSID: Index = Internal.createIndex(DSL.name("Annotations_paramsId"), Annotations.ANNOTATIONS, arrayOf(Annotations.ANNOTATIONS.PARAM_ID), false)
37+
val BUILDERSJOIN: Index = Internal.createIndex(DSL.name("BuildersJoin"), Builders.BUILDERS, arrayOf(Builders.BUILDERS.BUILDER_CLASS_NAME), false)
38+
val BUILDERSSEARCH: Index = Internal.createIndex(DSL.name("BuildersSearch"), Builders.BUILDERS, arrayOf(Builders.BUILDERS.LOCATION_ID, Builders.BUILDERS.CLASS_NAME, Builders.BUILDERS.PRIORITY), false)
3739
val BUILDERSSORTING: Index = Internal.createIndex(DSL.name("BuildersSorting"), Builders.BUILDERS, arrayOf(Builders.BUILDERS.PRIORITY), false)
38-
val CALLSSEARCH: Index = Internal.createIndex(DSL.name("CallsSearch"), Calls.CALLS, arrayOf(Calls.CALLS.OPCODE, Calls.CALLS.LOCATION_ID, Calls.CALLS.CALLEE_CLASS_SYMBOL_ID, Calls.CALLS.CALLEE_NAME_SYMBOL_ID, Calls.CALLS.CALLEE_DESC_HASH), false)
40+
val BYTECODELOCATIONS_HASH: Index = Internal.createIndex(DSL.name("Bytecodelocations_hash"), Bytecodelocations.BYTECODELOCATIONS, arrayOf(Bytecodelocations.BYTECODELOCATIONS.UNIQUEID), true)
41+
val CALLSSEARCH: Index = Internal.createIndex(DSL.name("CallsSearch"), Calls.CALLS, arrayOf(Calls.CALLS.OPCODE, Calls.CALLS.LOCATION_ID, Calls.CALLS.CALLEE_CLASS_NAME, Calls.CALLS.CALLEE_NAME, Calls.CALLS.CALLEE_DESC_HASH), false)
42+
val `CLASS HIERARCHIES`: Index = Internal.createIndex(DSL.name("Class Hierarchies"), Classhierarchies.CLASSHIERARCHIES, arrayOf(Classhierarchies.CLASSHIERARCHIES.SUPER_ID), false)
43+
val CLASSES_LOCATION: Index = Internal.createIndex(DSL.name("Classes_location"), Classes.CLASSES, arrayOf(Classes.CLASSES.LOCATION_ID), false)
44+
val CLASSES_NAME: Index = Internal.createIndex(DSL.name("Classes_name"), Classes.CLASSES, arrayOf(Classes.CLASSES.NAME), false)
45+
val CLASSES_OUTERMETHODID: Index = Internal.createIndex(DSL.name("Classes_outerMethodId"), Classes.CLASSES, arrayOf(Classes.CLASSES.OUTER_METHOD), false)
46+
val CLASSHIERARCHIES_CLASSID: Index = Internal.createIndex(DSL.name("ClassHierarchies_classId"), Classhierarchies.CLASSHIERARCHIES, arrayOf(Classhierarchies.CLASSHIERARCHIES.CLASS_ID), false)
47+
val CLASSHIERARCHIES_SUPERID: Index = Internal.createIndex(DSL.name("ClassHierarchies_superId"), Classhierarchies.CLASSHIERARCHIES, arrayOf(Classhierarchies.CLASSHIERARCHIES.SUPER_ID), false)
48+
val CLASSINNERCLASSES_CLASSID: Index = Internal.createIndex(DSL.name("ClassInnerClasses_classId"), Classinnerclasses.CLASSINNERCLASSES, arrayOf(Classinnerclasses.CLASSINNERCLASSES.CLASS_ID), false)
49+
val CLASSINNERCLASSES_INNERCLASSID: Index = Internal.createIndex(DSL.name("ClassInnerClasses_innerClassId"), Classinnerclasses.CLASSINNERCLASSES, arrayOf(Classinnerclasses.CLASSINNERCLASSES.INNER_CLASS_ID), false)
50+
val FIELDS_CLASS_ID_NAME: Index = Internal.createIndex(DSL.name("Fields_class_id_name"), Fields.FIELDS, arrayOf(Fields.FIELDS.CLASS_ID, Fields.FIELDS.NAME), true)
51+
val FIELDS_CLASSID: Index = Internal.createIndex(DSL.name("Fields_classId"), Fields.FIELDS, arrayOf(Fields.FIELDS.CLASS_ID), false)
52+
val METHODPARAMETERS_METHODID: Index = Internal.createIndex(DSL.name("MethodParameters_methodId"), Methodparameters.METHODPARAMETERS, arrayOf(Methodparameters.METHODPARAMETERS.METHOD_ID), false)
53+
val METHODS_CLASS_ID_NAME_DESC: Index = Internal.createIndex(DSL.name("Methods_class_id_name_desc"), Methods.METHODS, arrayOf(Methods.METHODS.CLASS_ID, Methods.METHODS.NAME, Methods.METHODS.DESC), true)
54+
val METHODS_CLASSID: Index = Internal.createIndex(DSL.name("Methods_classId"), Methods.METHODS, arrayOf(Methods.METHODS.CLASS_ID), false)
55+
val SYMBOLS_NAME: Index = Internal.createIndex(DSL.name("Symbols_name"), Symbols.SYMBOLS, arrayOf(Symbols.SYMBOLS.NAME), true)

0 commit comments

Comments
 (0)