Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ public static Datum createFromInt4(DataType type, int val) {
return new Int4Datum(val);
case DATE:
return new DateDatum(val);
case INET4:
return new Inet4Datum(val);
default:
throw new UnsupportedOperationException("Cannot create " + type.getType().name() + " datum from INT4");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package org.apache.tajo.storage;

import org.apache.tajo.common.TajoDataTypes;
import org.apache.tajo.datum.Datum;
import org.apache.tajo.datum.NullDatum;
import org.apache.tajo.datum.ProtobufDatum;
Expand Down Expand Up @@ -50,6 +51,11 @@ public boolean contains(int fieldId) {
return false;
}

@Override
public TajoDataTypes.Type type(int fieldId) {
return TajoDataTypes.Type.NULL_TYPE;
}

@Override
public boolean isNull(int fieldid) {
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* 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.tajo.storage;

import org.apache.tajo.common.TajoDataTypes;
import org.apache.tajo.datum.Datum;

public interface ReadableTuple {

TajoDataTypes.Type type(int fieldId);

boolean isNull(int fieldId);

boolean getBool(int fieldId);

byte getByte(int fieldId);

char getChar(int fieldId);

byte[] getBytes(int fieldId);

short getInt2(int fieldId);

int getInt4(int fieldId);

long getInt8(int fieldId);

float getFloat4(int fieldId);

double getFloat8(int fieldId);

String getText(int fieldId);

Datum getProtobufDatum(int fieldId);

Datum getInterval(int fieldId);

char[] getUnicodeChars(int fieldId);

Datum get(int fieldId);
}
34 changes: 2 additions & 32 deletions tajo-common/src/main/java/org/apache/tajo/storage/Tuple.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@

import org.apache.tajo.datum.Datum;

public interface Tuple extends Cloneable {
public interface Tuple extends Cloneable, ReadableTuple {

int size();

boolean contains(int fieldid);

boolean isNull(int fieldid);

@SuppressWarnings("unused")
boolean isNotNull(int fieldid);

Expand All @@ -41,37 +39,9 @@ public interface Tuple extends Cloneable {

void put(Datum[] values);

Datum get(int fieldId);

void setOffset(long offset);

long getOffset();

boolean getBool(int fieldId);

byte getByte(int fieldId);

char getChar(int fieldId);

byte [] getBytes(int fieldId);

short getInt2(int fieldId);

int getInt4(int fieldId);

long getInt8(int fieldId);

float getFloat4(int fieldId);

double getFloat8(int fieldId);

String getText(int fieldId);

Datum getProtobufDatum(int fieldId);

Datum getInterval(int fieldId);

char [] getUnicodeChars(int fieldId);
long getOffset();

Tuple clone() throws CloneNotSupportedException;

Expand Down
6 changes: 6 additions & 0 deletions tajo-common/src/main/java/org/apache/tajo/storage/VTuple.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.tajo.storage;

import com.google.gson.annotations.Expose;
import org.apache.tajo.common.TajoDataTypes;
import org.apache.tajo.datum.Datum;
import org.apache.tajo.datum.Inet4Datum;
import org.apache.tajo.datum.IntervalDatum;
Expand Down Expand Up @@ -54,6 +55,11 @@ public boolean contains(int fieldId) {
return values[fieldId] != null;
}

@Override
public TajoDataTypes.Type type(int fieldId) {
return values[fieldId] == null ? TajoDataTypes.Type.NULL_TYPE : values[fieldId].type();
}

@Override
public boolean isNull(int fieldid) {
return values[fieldid] == null || values[fieldid].isNull();
Expand Down
5 changes: 5 additions & 0 deletions tajo-common/src/main/java/org/apache/tajo/util/ClassSize.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ public class ClassSize {
/** Overhead for KeyValueSkipListSet */
public static final int KEYVALUE_SKIPLIST_SET;

/** Overhead for BitSet */
public static final int BITSET;

/* Are we running on jdk7? */
private static final boolean JDK7;
static {
Expand Down Expand Up @@ -212,6 +215,8 @@ public class ClassSize {
TIMERANGE_TRACKER = align(ClassSize.OBJECT + Bytes.SIZEOF_LONG * 2);

KEYVALUE_SKIPLIST_SET = align(OBJECT + REFERENCE);

BITSET = align(ARRAY + Bytes.SIZEOF_INT + Bytes.SIZEOF_BOOLEAN);
}

/**
Expand Down
Loading