<commit_before>package com.nhn.pinpoint.web.mapper;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.nhn.pinpoint.common.buffer.Buffer;
import com.nhn.pinpoint.common.buffer.FixedBuffer;
import com.nhn.pinpoint.common.hbase.HBaseTables;
import com.nhn.pinpoint.common.util.TimeUtils;
import com.nhn.pinpoint.web.vo.TransactionId;
import com.nhn.pinpoint.web.vo.scatter.Dot;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Result;
import org.springframework.data.hadoop.hbase.RowMapper;
import org.springframework.stereotype.Component;

import com.nhn.pinpoint.common.util.BytesUtils;

/**
 * @author emeroad
 */
@Component
public class TraceIndexScatterMapper implements RowMapper<List<Dot>> {

	@Override
	public List<Dot> mapRow(Result result, int rowNum) throws Exception {
        if (result.isEmpty()) {
            return Collections.emptyList();
        }

		KeyValue[] raw = result.raw();
		List<Dot> list = new ArrayList<Dot>(raw.length);
		for (KeyValue kv : raw) {
            final Dot dot = readPoint(kv);
            list.add(dot);
		}

		return list;
	}

    private Dot readPoint(KeyValue kv) {
        final byte[] buffer = kv.getBuffer();

        final int valueOffset = kv.getValueOffset();
        final Buffer valueBuffer = new FixedBuffer(buffer, valueOffset);
        int elapsed = valueBuffer.readVarInt();
        int exceptionCode = valueBuffer.readSVarInt();
        String agentId = valueBuffer.readPrefixedString();

        long reverseAcceptedTime = BytesUtils.bytesToLong(buffer, kv.getRowOffset() + HBaseTables.APPLICATION_NAME_MAX_LEN + HBaseTables.APPLICATION_TRACE_INDEX_ROW_DISTRIBUTE_SIZE);
        long acceptedTime = TimeUtils.recoveryCurrentTimeMillis(reverseAcceptedTime);

        final int qualifierOffset = kv.getQualifierOffset();

        TransactionId transactionId = new TransactionId(buffer, qualifierOffset);
        return new Dot(transactionId, acceptedTime, elapsed, exceptionCode, agentId);
    }
}<commit_msg>[강운덕] [LUCYSUS-1744] api명 변경.<commit_after>package com.nhn.pinpoint.web.mapper;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.nhn.pinpoint.common.buffer.Buffer;
import com.nhn.pinpoint.common.buffer.FixedBuffer;
import com.nhn.pinpoint.common.hbase.HBaseTables;
import com.nhn.pinpoint.common.util.TimeUtils;
import com.nhn.pinpoint.web.vo.TransactionId;
import com.nhn.pinpoint.web.vo.scatter.Dot;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.client.Result;
import org.springframework.data.hadoop.hbase.RowMapper;
import org.springframework.stereotype.Component;

import com.nhn.pinpoint.common.util.BytesUtils;

/**
 * @author emeroad
 */
@Component
public class TraceIndexScatterMapper implements RowMapper<List<Dot>> {

	@Override
	public List<Dot> mapRow(Result result, int rowNum) throws Exception {
        if (result.isEmpty()) {
            return Collections.emptyList();
        }

		KeyValue[] raw = result.raw();
		List<Dot> list = new ArrayList<Dot>(raw.length);
		for (KeyValue kv : raw) {
            final Dot dot = createDot(kv);
            list.add(dot);
		}

		return list;
	}

    private Dot createDot(KeyValue kv) {
        final byte[] buffer = kv.getBuffer();

        final int valueOffset = kv.getValueOffset();
        final Buffer valueBuffer = new FixedBuffer(buffer, valueOffset);
        int elapsed = valueBuffer.readVarInt();
        int exceptionCode = valueBuffer.readSVarInt();
        String agentId = valueBuffer.readPrefixedString();

        long reverseAcceptedTime = BytesUtils.bytesToLong(buffer, kv.getRowOffset() + HBaseTables.APPLICATION_NAME_MAX_LEN + HBaseTables.APPLICATION_TRACE_INDEX_ROW_DISTRIBUTE_SIZE);
        long acceptedTime = TimeUtils.recoveryCurrentTimeMillis(reverseAcceptedTime);

        final int qualifierOffset = kv.getQualifierOffset();

        TransactionId transactionId = new TransactionId(buffer, qualifierOffset);
        return new Dot(transactionId, acceptedTime, elapsed, exceptionCode, agentId);
    }
}
{'fraction_non_alphanumeric': 0.10634146341463414, 'fraction_numerical': 0.000975609756097561, 'mean_word_length': 4.025735294117647, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3021651', 'n_tokens_mistral': 1264, 'n_tokens_neox': 1226, 'n_words': 245}