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

Commit 831db2b

Browse files
committed
TAJO-1511 Minimize memory usage of inMemoryTable in ExternalSortExec
1 parent 1971d85 commit 831db2b

31 files changed

Lines changed: 1315 additions & 641 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
@@ -163,6 +163,8 @@ public static Datum createFromInt4(DataType type, int val) {
163163
return new Int4Datum(val);
164164
case DATE:
165165
return new DateDatum(val);
166+
case INET4:
167+
return new Inet4Datum(val);
166168
default:
167169
throw new UnsupportedOperationException("Cannot create " + type.getType().name() + " datum from INT4");
168170
}

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: 2 additions & 32 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
int size();
2626

2727
boolean contains(int fieldid);
2828

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

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

4240
void put(Datum[] values);
4341

44-
Datum get(int fieldId);
45-
4642
void setOffset(long offset);
47-
48-
long getOffset();
49-
50-
boolean getBool(int fieldId);
5143

52-
byte getByte(int fieldId);
53-
54-
char getChar(int fieldId);
55-
56-
byte [] getBytes(int fieldId);
57-
58-
short getInt2(int fieldId);
59-
60-
int getInt4(int fieldId);
61-
62-
long getInt8(int fieldId);
63-
64-
float getFloat4(int fieldId);
65-
66-
double getFloat8(int fieldId);
67-
68-
String getText(int fieldId);
69-
70-
Datum getProtobufDatum(int fieldId);
71-
72-
Datum getInterval(int fieldId);
73-
74-
char [] getUnicodeChars(int fieldId);
44+
long getOffset();
7545

7646
Tuple clone() throws CloneNotSupportedException;
7747

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();

tajo-common/src/main/java/org/apache/tajo/util/ClassSize.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ public class ClassSize {
121121
/** Overhead for KeyValueSkipListSet */
122122
public static final int KEYVALUE_SKIPLIST_SET;
123123

124+
/** Overhead for BitSet */
125+
public static final int BITSET;
126+
124127
/* Are we running on jdk7? */
125128
private static final boolean JDK7;
126129
static {
@@ -212,6 +215,8 @@ public class ClassSize {
212215
TIMERANGE_TRACKER = align(ClassSize.OBJECT + Bytes.SIZEOF_LONG * 2);
213216

214217
KEYVALUE_SKIPLIST_SET = align(OBJECT + REFERENCE);
218+
219+
BITSET = align(ARRAY + Bytes.SIZEOF_INT + Bytes.SIZEOF_BOOLEAN);
215220
}
216221

217222
/**

0 commit comments

Comments
 (0)