Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit 2f53ee3

Browse files
committed
TAJO-1511 Minimize memory usage of inMemoryTable in ExternalSortExec
1 parent 70d5fdf commit 2f53ee3

30 files changed

Lines changed: 1251 additions & 623 deletions

File tree

tajo-common/src/main/java/org/apache/tajo/datum/DatumFactory.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ public static Datum createFromInt4(DataType type, int val) {
162162
return new Int4Datum(val);
163163
case DATE:
164164
return new DateDatum(val);
165+
case INET4:
166+
return new Inet4Datum(val);
165167
default:
166168
throw new UnsupportedOperationException("Cannot create " + type.getType().name() + " datum from INT4");
167169
}

tajo-common/src/main/java/org/apache/tajo/storage/EmptyTuple.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
package org.apache.tajo.storage;
2020

21+
import org.apache.tajo.common.TajoDataTypes;
2122
import org.apache.tajo.datum.Datum;
2223
import org.apache.tajo.datum.NullDatum;
2324
import org.apache.tajo.datum.ProtobufDatum;
@@ -50,6 +51,11 @@ public boolean contains(int fieldId) {
5051
return false;
5152
}
5253

54+
@Override
55+
public TajoDataTypes.Type type(int fieldId) {
56+
return TajoDataTypes.Type.NULL_TYPE;
57+
}
58+
5359
@Override
5460
public boolean isNull(int fieldid) {
5561
return true;
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.tajo.storage;
20+
21+
import org.apache.tajo.common.TajoDataTypes;
22+
import org.apache.tajo.datum.Datum;
23+
24+
public interface ReadableTuple {
25+
26+
TajoDataTypes.Type type(int fieldId);
27+
28+
boolean isNull(int fieldId);
29+
30+
boolean getBool(int fieldId);
31+
32+
byte getByte(int fieldId);
33+
34+
char getChar(int fieldId);
35+
36+
byte [] getBytes(int fieldId);
37+
38+
short getInt2(int fieldId);
39+
40+
int getInt4(int fieldId);
41+
42+
long getInt8(int fieldId);
43+
44+
float getFloat4(int fieldId);
45+
46+
double getFloat8(int fieldId);
47+
48+
String getText(int fieldId);
49+
50+
Datum getProtobufDatum(int fieldId);
51+
52+
Datum getInterval(int fieldId);
53+
54+
char [] getUnicodeChars(int fieldId);
55+
56+
Datum get(int fieldId);
57+
}

tajo-common/src/main/java/org/apache/tajo/storage/Tuple.java

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,12 @@
2020

2121
import org.apache.tajo.datum.Datum;
2222

23-
public interface Tuple extends Cloneable {
23+
public interface Tuple extends Cloneable, ReadableTuple {
2424

2525
public int size();
2626

2727
public boolean contains(int fieldid);
2828

29-
public boolean isNull(int fieldid);
30-
3129
@SuppressWarnings("unused")
3230
public boolean isNotNull(int fieldid);
3331

@@ -41,38 +39,10 @@ public interface Tuple extends Cloneable {
4139

4240
public void put(Datum[] values);
4341

44-
public Datum get(int fieldId);
45-
4642
public void setOffset(long offset);
4743

4844
public long getOffset();
4945

50-
public boolean getBool(int fieldId);
51-
52-
public byte getByte(int fieldId);
53-
54-
public char getChar(int fieldId);
55-
56-
public byte [] getBytes(int fieldId);
57-
58-
public short getInt2(int fieldId);
59-
60-
public int getInt4(int fieldId);
61-
62-
public long getInt8(int fieldId);
63-
64-
public float getFloat4(int fieldId);
65-
66-
public double getFloat8(int fieldId);
67-
68-
public String getText(int fieldId);
69-
70-
public Datum getProtobufDatum(int fieldId);
71-
72-
public Datum getInterval(int fieldId);
73-
74-
public char [] getUnicodeChars(int fieldId);
75-
7646
public Tuple clone() throws CloneNotSupportedException;
7747

7848
public Datum[] getValues();

tajo-common/src/main/java/org/apache/tajo/storage/VTuple.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.tajo.storage;
2020

2121
import com.google.gson.annotations.Expose;
22+
import org.apache.tajo.common.TajoDataTypes;
2223
import org.apache.tajo.datum.Datum;
2324
import org.apache.tajo.datum.Inet4Datum;
2425
import org.apache.tajo.datum.IntervalDatum;
@@ -54,6 +55,11 @@ public boolean contains(int fieldId) {
5455
return values[fieldId] != null;
5556
}
5657

58+
@Override
59+
public TajoDataTypes.Type type(int fieldId) {
60+
return values[fieldId] == null ? TajoDataTypes.Type.NULL_TYPE : values[fieldId].type();
61+
}
62+
5763
@Override
5864
public boolean isNull(int fieldid) {
5965
return values[fieldid] == null || values[fieldid].isNull();

0 commit comments

Comments
 (0)