Github user anoopsjohn commented on a diff in the pull request:

    https://github.com/apache/incubator-phoenix/pull/30#discussion_r12986572
  
    --- Diff: 
phoenix-core/src/main/java/org/apache/phoenix/util/FirstLastValueOffsetDataContainer.java
 ---
    @@ -0,0 +1,111 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + * http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +package org.apache.phoenix.util;
    +
    +import java.io.ByteArrayInputStream;
    +import java.io.ByteArrayOutputStream;
    +import java.io.IOException;
    +import java.io.ObjectInput;
    +import java.io.ObjectInputStream;
    +import java.io.ObjectOutput;
    +import java.io.ObjectOutputStream;
    +import java.nio.ByteBuffer;
    +import java.util.TreeMap;
    +import org.apache.hadoop.hbase.util.Bytes;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +/**
    + * Offset implementation for data container for transfer data between 
server and client aggregation
    + * (FIRST|LAST|NTH)_VALUE functions
    + *
    + */
    +public class FirstLastValueOffsetDataContainer extends 
FirstLastValueDataContainer {
    +
    +   private static final Logger logger = 
LoggerFactory.getLogger(FirstLastValueOffsetDataContainer.class);
    +   protected int offset;
    +   private TreeMap<byte[], byte[]> data;
    +
    +   public void setOffset(int offset) {
    +           this.offset = offset;
    +   }
    +
    +   public int getOffset() {
    +           return offset;
    +   }
    +
    +   public void setData(TreeMap<byte[], byte[]> data) {
    +           this.data = data;
    +   }
    +
    +   public byte[] getPayload() throws IOException {
    +           ByteArrayOutputStream bos = new ByteArrayOutputStream();
    +
    +           bos.write(useCompression ? (byte) 1 : (byte) 0);
    +           bos.write(isAscending ? (byte) 1 : (byte) 0);
    +           bos.write(Bytes.toBytes(offset)); //bos.write(int) writes only 
last byte
    +
    +           ObjectOutput out = null;
    +           try {
    +                   out = new ObjectOutputStream(bos);
    --- End diff --
    
    Writing 'data' as OOS#writeObject() might result in more bytes size getting 
transferred from server to client. What we need is the keys and values right? 
Can you write a custom logic?
    Write the size of the Map
    Write the length of the 1st key
    Write the 1st key
    Write length of the 1st value
    Write 1st value
    ..... (for all the key values)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to