phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anoopsjohn <...@git.apache.org>
Subject [GitHub] incubator-phoenix pull request: Add functions FIRST_VALUE and LAST...
Date Fri, 23 May 2014 06:47:37 GMT
Github user anoopsjohn commented on a diff in the pull request:

    https://github.com/apache/incubator-phoenix/pull/30#discussion_r12987422
  
    --- Diff: phoenix-core/src/main/java/org/apache/phoenix/expression/aggregator/FirstLastValueServerAggregator.java
---
    @@ -0,0 +1,214 @@
    +/*
    + * 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.expression.aggregator;
    +
    +import org.apache.phoenix.expression.Expression;
    +import org.apache.phoenix.schema.PDataType;
    +import org.apache.phoenix.schema.tuple.Tuple;
    +import org.apache.phoenix.util.BinarySerializableComparator;
    +import org.apache.phoenix.util.ByteUtil;
    +import org.apache.phoenix.util.FirstLastValueDataContainer;
    +import org.apache.phoenix.util.FirstLastValueOffsetDataContainer;
    +import org.apache.phoenix.util.SizedUtil;
    +import java.io.IOException;
    +import java.util.List;
    +import java.util.TreeMap;
    +import org.apache.hadoop.hbase.filter.BinaryComparator;
    +import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
    +import org.apache.hadoop.hbase.util.Bytes;
    +import org.apache.phoenix.schema.SortOrder;
    +import org.slf4j.Logger;
    +import org.slf4j.LoggerFactory;
    +
    +/**
    + * Base server aggregator for (FIRST|LAST|NTH)_VALUE functions
    + *
    + */
    +public class FirstLastValueServerAggregator extends BaseAggregator {
    +
    +	private static final Logger logger = LoggerFactory.getLogger(FirstLastValueServerAggregator.class);
    +	protected List<Expression> children;
    +	protected BinaryComparator topOrder = new BinaryComparator(ByteUtil.EMPTY_BYTE_ARRAY);
    +	protected byte[] topValue;
    +	protected boolean useOffset = false;
    +	protected int offset = -1;
    +	protected TreeMap<byte[], byte[]> topValues = new TreeMap<byte[], byte[]>(new
BinarySerializableComparator());
    +	protected boolean isAscending;
    +	protected boolean hasValueDescSortOrder = false;
    +
    +	public FirstLastValueServerAggregator() {
    +		super(SortOrder.getDefault());
    +	}
    +
    +	@Override
    +	public void reset() {
    +		topOrder = new BinaryComparator(ByteUtil.EMPTY_BYTE_ARRAY);
    +		topValue = null;
    +		topValues.clear();
    +		offset = -1;
    +		useOffset = false;
    +	}
    +
    +	@Override
    +	public int getSize() {
    +		return super.getSize() + SizedUtil.IMMUTABLE_BYTES_WRITABLE_SIZE;
    +	}
    +
    +	private Expression getOrderByColumnChild() {
    --- End diff --
    
    Consider having member variables for orderByColumn  and dataColumn (?)
    protected Expression orderByColumn =children.get(0) ;
    protected Expression dataColumn =children.get(2) ;
    
    We might not need to have the member List children.  I can not see it is used in other
places other than getting these 2.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message