Pass keyDescriptor to BasicMap using constructor

Original commit: a660562743
This commit is contained in:
Alexey Tsvetkov
2015-09-04 15:57:58 +03:00
parent 55ca868be3
commit 3e9b92bf7f
2 changed files with 9 additions and 13 deletions
@@ -601,10 +601,7 @@ public class IncrementalCacheImpl(
override fun dumpValue(value: Boolean) = ""
}
private inner class SourceToClassesMap(storageFile: File) : BasicStringMap<List<String>>(storageFile, StringListExternalizer) {
override val keyDescriptor: KeyDescriptor<String>
get() = PathStringDescriptor.INSTANCE
private inner class SourceToClassesMap(storageFile: File) : BasicStringMap<List<String>>(storageFile, PathStringDescriptor.INSTANCE, StringListExternalizer) {
public fun clearOutputsForSource(sourceFile: File) {
storage.remove(sourceFile.getAbsolutePath())
}
@@ -676,10 +673,7 @@ public class IncrementalCacheImpl(
* * inlineFunction - jvmSignature of some inline function in source file
* * target files - collection of files inlineFunction has been inlined to
*/
private inner class InlineFunctionsFilesMap(storageFile: File) : BasicMap<PathFunctionPair, Collection<String>>(storageFile, PathCollectionExternalizer) {
override val keyDescriptor: KeyDescriptor<PathFunctionPair>
get() = PathFunctionPairKeyDescriptor
private inner class InlineFunctionsFilesMap(storageFile: File) : BasicMap<PathFunctionPair, Collection<String>>(storageFile, PathFunctionPairKeyDescriptor, PathCollectionExternalizer) {
public fun add(sourcePath: String, jvmSignature: String, targetPath: String) {
val key = PathFunctionPair(sourcePath, jvmSignature)
storage.appendData(key) { out ->
@@ -27,10 +27,9 @@ import java.io.IOException
public abstract class BasicMap<K : Comparable<K>, V>(
private val storageFile: File,
private val keyDescriptor: KeyDescriptor<K>,
private val valueExternalizer: DataExternalizer<V>
) {
protected abstract val keyDescriptor: KeyDescriptor<K>
protected var storage: PersistentHashMap<K, V> = createMap()
public fun contains(key: K): Boolean = storage.containsMapping(key)
@@ -92,10 +91,13 @@ public abstract class BasicMap<K : Comparable<K>, V>(
public abstract class BasicStringMap<V>(
storageFile: File,
keyDescriptor: KeyDescriptor<String>,
valueExternalizer: DataExternalizer<V>
) : BasicMap<String, V>(storageFile, valueExternalizer) {
override val keyDescriptor: KeyDescriptor<String>
get() = EnumeratorStringDescriptor()
) : BasicMap<String, V>(storageFile, keyDescriptor, valueExternalizer) {
public constructor(
storageFile: File,
valueExternalizer: DataExternalizer<V>
) : this(storageFile, EnumeratorStringDescriptor.INSTANCE, valueExternalizer)
override fun dumpKey(key: String): String = key
}