<commit_before>package perftest.server

import ccf.transport.Request
import ccf.OperationContext
import ccf.session.AbstractRequest
import ccf.tree.operation.TreeOperationDecoder

class ServerEngine {
  def decodeRequest(request: Option[Request]) {
    val operationDecoder = newOperationDecoder

    request match {
      case Some(r: Request) => {
        r.header("type") match {
          case Some(AbstractRequest.joinRequestType) =>
          case Some(AbstractRequest.partRequestType) =>
          case Some(AbstractRequest.contextRequestType) => {
            val encodedContext = r.content.get.asInstanceOf[Map[String, Any]]
            val op = operationDecoder.decode(encodedContext("op"))
            val localMsgSeqNo = encodedContext("localMsgSeqNo").asInstanceOf[Int]
            val remoteMsgSeqNo = encodedContext("remoteMsgSeqNo").asInstanceOf[Int]
            val context = new OperationContext(op, localMsgSeqNo, remoteMsgSeqNo)
          }
          case Some(unknownRequestType) => fatalError("Unknown request type: " + unknownRequestType)
          case None => fatalError("No request type given")
        }
      }
      case None => fatalError("Unable to decode request")
    }
  }

  protected def fatalError(msg: String) {
    error("Unable to decode request")
  }

  protected def newOperationDecoder = new TreeOperationDecoder {
    protected def parseModifier(encodedValue: Any) = null
    protected def parseNode(encodedValue: Any) = null
  }
}<commit_msg>perftest: Split request handling in ServerEngine<commit_after>package perftest.server

import ccf.transport.Request
import ccf.OperationContext
import ccf.tree.operation.TreeOperationDecoder
import ccf.session.{OperationContextRequest, PartRequest, JoinRequest, AbstractRequest}

class ServerEngine {
  def decodeRequest(request: Option[Request]) {
    request match {
      case Some(r: Request) => {
        try {
          handleRequest(AbstractRequest.sessionRequest(r))
        } catch {
          case ex: Exception => fatalError(ex.getMessage)
        }
      }
      case None => fatalError("Unable to decode request")
    }
  }

  private def handleRequest(sessionRequest: AbstractRequest) {
    sessionRequest match {
      case r: JoinRequest =>
      case r: PartRequest =>
      case r: OperationContextRequest => {
        val encodedContext = r.transportRequest.content.get.asInstanceOf[Map[String, Any]]
        val op = newOperationDecoder.decode(encodedContext("op"))
        val localMsgSeqNo = encodedContext("localMsgSeqNo").asInstanceOf[Int]
        val remoteMsgSeqNo = encodedContext("remoteMsgSeqNo").asInstanceOf[Int]
        val context = new OperationContext(op, localMsgSeqNo, remoteMsgSeqNo)
      }
    }
  }

  protected def fatalError(msg: String) {
    error("Unable to decode request")
  }

  protected def newOperationDecoder = new TreeOperationDecoder {
    protected def parseModifier(encodedValue: Any) = null
    protected def parseNode(encodedValue: Any) = null
  }
}
{'fraction_non_alphanumeric': 0.08981636060100166, 'fraction_numerical': 0.0, 'mean_word_length': 3.5052631578947366, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4261890', 'n_tokens_mistral': 788, 'n_tokens_neox': 782, 'n_words': 189}