🚀 Improve performance
This commit is contained in:
parent
c7c285a2c1
commit
b44a2f8809
2
.gitignore
vendored
2
.gitignore
vendored
@ -49,7 +49,7 @@ gradle-app.setting
|
|||||||
## Plugin-specific files:
|
## Plugin-specific files:
|
||||||
|
|
||||||
# IntelliJ
|
# IntelliJ
|
||||||
/out/
|
out/
|
||||||
|
|
||||||
# mpeltonen/sbt-idea plugin
|
# mpeltonen/sbt-idea plugin
|
||||||
.idea_modules/
|
.idea_modules/
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.2.30'
|
ext.kotlin_version = '1.2.41'
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
@ -31,7 +31,7 @@ subprojects {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7"
|
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
|
||||||
compile "org.jetbrains.kotlin:kotlin-reflect"
|
compile "org.jetbrains.kotlin:kotlin-reflect"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ subprojects {
|
|||||||
dependencyManagement {
|
dependencyManagement {
|
||||||
dependencies {
|
dependencies {
|
||||||
dependencySet(group: 'org.jetbrains.kotlin', version: "$kotlin_version") {
|
dependencySet(group: 'org.jetbrains.kotlin', version: "$kotlin_version") {
|
||||||
entry 'kotlin-stdlib-jre7'
|
entry 'kotlin-stdlib-jdk7'
|
||||||
entry 'kotlin-reflect'
|
entry 'kotlin-reflect'
|
||||||
}
|
}
|
||||||
dependencySet(group: 'org.slf4j', version: '1.7.25') {
|
dependencySet(group: 'org.slf4j', version: '1.7.25') {
|
||||||
|
@ -65,7 +65,7 @@ class Plaintext private constructor(
|
|||||||
val message: ByteArray,
|
val message: ByteArray,
|
||||||
val ackData: ByteArray?,
|
val ackData: ByteArray?,
|
||||||
ackMessage: Lazy<ObjectMessage?> = lazy { Factory.createAck(from, ackData, ttl) },
|
ackMessage: Lazy<ObjectMessage?> = lazy { Factory.createAck(from, ackData, ttl) },
|
||||||
val conversationId: UUID = UUID.randomUUID(),
|
var conversationId: UUID = UUID.randomUUID(),
|
||||||
var inventoryVector: InventoryVector? = null,
|
var inventoryVector: InventoryVector? = null,
|
||||||
var signature: ByteArray? = null,
|
var signature: ByteArray? = null,
|
||||||
sent: Long? = null,
|
sent: Long? = null,
|
||||||
|
@ -109,8 +109,8 @@ abstract class AbstractMessageRepository : MessageRepository, InternalContext.Co
|
|||||||
return find("iv IN (SELECT child FROM Message_Parent WHERE parent=X'${Strings.hex(parent.inventoryVector!!.hash)}')")
|
return find("iv IN (SELECT child FROM Message_Parent WHERE parent=X'${Strings.hex(parent.inventoryVector!!.hash)}')")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getConversation(conversationId: UUID): List<Plaintext> {
|
override fun getConversation(conversationId: UUID, offset: Int, limit: Int): List<Plaintext> {
|
||||||
return find("conversation=X'${conversationId.toString().replace("-", "")}'")
|
return find("conversation=X'${conversationId.toString().replace("-", "")}'", offset, limit)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -68,5 +68,5 @@ interface MessageRepository {
|
|||||||
* *
|
* *
|
||||||
* @return all messages with the given conversation ID
|
* @return all messages with the given conversation ID
|
||||||
*/
|
*/
|
||||||
fun getConversation(conversationId: UUID): Collection<Plaintext>
|
fun getConversation(conversationId: UUID, offset: Int = 0, limit: Int = 0): Collection<Plaintext>
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,9 @@ class ConversationService(private val messageRepository: MessageRepository) {
|
|||||||
|
|
||||||
private val SUBJECT_PREFIX = Pattern.compile("^(re|fwd?):\\s*", CASE_INSENSITIVE)
|
private val SUBJECT_PREFIX = Pattern.compile("^(re|fwd?):\\s*", CASE_INSENSITIVE)
|
||||||
|
|
||||||
fun findConversations(label: Label?, offset: Int = 0, limit: Int = 0) = messageRepository.findConversations(label, offset, limit)
|
fun findConversations(label: Label?, offset: Int = 0, limit: Int = 0, conversationLimit: Int = 10) =
|
||||||
.map { getConversation(it) }
|
messageRepository.findConversations(label, offset, limit)
|
||||||
|
.map { getConversation(it, conversationLimit) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the whole conversation from one single message. If the message isn't part
|
* Retrieve the whole conversation from one single message. If the message isn't part
|
||||||
@ -62,8 +63,8 @@ class ConversationService(private val messageRepository: MessageRepository) {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getConversation(conversationId: UUID): Conversation {
|
fun getConversation(conversationId: UUID, limit: Int = 0): Conversation {
|
||||||
val messages = sorted(messageRepository.getConversation(conversationId))
|
val messages = sorted(messageRepository.getConversation(conversationId, 0, limit))
|
||||||
val map = HashMap<InventoryVector, Plaintext>(messages.size)
|
val map = HashMap<InventoryVector, Plaintext>(messages.size)
|
||||||
for (message in messages) {
|
for (message in messages) {
|
||||||
message.inventoryVector?.let {
|
message.inventoryVector?.let {
|
||||||
|
Loading…
Reference in New Issue
Block a user