/* * Copyright 2014-2015 the original author or authors * * Licensed 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 com.wplatform.ddal.result; import com.wplatform.ddal.engine.Constants; import com.wplatform.ddal.value.Value; /** * A simple row that contains data for only one column. */ public class SimpleRowValue implements SearchRow { private final int virtualColumnCount; private long key; private int version; private int index; private Value data; public SimpleRowValue(int columnCount) { this.virtualColumnCount = columnCount; } @Override public void setKeyAndVersion(SearchRow row) { key = row.getKey(); version = row.getVersion(); } @Override public int getVersion() { return version; } @Override public int getColumnCount() { return virtualColumnCount; } @Override public long getKey() { return key; } @Override public void setKey(long key) { this.key = key; } @Override public Value getValue(int idx) { return idx == index ? data : null; } @Override public void setValue(int idx, Value v) { index = idx; data = v; } @Override public String toString() { return "( /* " + key + " */ " + (data == null ? "null" : data.getTraceSQL()) + " )"; } @Override public int getMemory() { return Constants.MEMORY_OBJECT + (data == null ? 0 : data.getMemory()); } }