@@ -57,19 +57,22 @@ public synchronized FlatRecord extract(String type, int ordinal) {
57
57
58
58
HollowTypeReadState typeState = extractFrom .getTypeState (type );
59
59
60
- extractHollowRecord (typeState , ordinal );
60
+ extractHollowRecord (type , typeState , ordinal );
61
61
62
62
return writer .generateFlatRecord ();
63
63
}
64
64
65
- private void extractHollowRecord (HollowTypeReadState typeState , int ordinal ) {
66
- if (ordinal == -1 )
65
+ private void extractHollowRecord (String type , HollowTypeReadState typeState , int ordinal ) {
66
+ if (ordinal == -1 ) {
67
67
return ;
68
+ }
69
+
70
+ if (typeState == null ) {
71
+ throw new IllegalArgumentException ("Type '" + type + "' not found in HollowReadStateEngine" );
72
+ }
68
73
69
74
traverse (typeState , ordinal );
70
75
71
- String type = typeState .getSchema ().getName ();
72
-
73
76
HollowRecordCopier recordCopier = recordCopier (type );
74
77
HollowWriteRecord rec = recordCopier .copy (ordinal );
75
78
@@ -100,9 +103,10 @@ private void traverseObject(HollowObjectTypeReadState typeState, int ordinal) {
100
103
101
104
for (int i =0 ;i <schema .numFields ();i ++) {
102
105
if (schema .getFieldType (i ) == FieldType .REFERENCE ) {
106
+ String refType = schema .getReferencedType (i );;
103
107
HollowTypeReadState refTypeState = schema .getReferencedTypeState (i );
104
108
int refOrdinal = typeState .readOrdinal (ordinal , i );
105
- extractHollowRecord (refTypeState , refOrdinal );
109
+ extractHollowRecord (refType , refTypeState , refOrdinal );
106
110
}
107
111
}
108
112
}
@@ -115,7 +119,7 @@ private void traverseList(HollowListTypeReadState typeState, int ordinal) {
115
119
for (int i =0 ;i <size ;i ++) {
116
120
int refOrdinal = typeState .getElementOrdinal (ordinal , i );
117
121
if (refOrdinal != HollowConstants .ORDINAL_NONE )
118
- extractHollowRecord (schema .getElementTypeState (), refOrdinal );
122
+ extractHollowRecord (schema .getElementType (), schema . getElementTypeState (), refOrdinal );
119
123
}
120
124
}
121
125
@@ -127,7 +131,7 @@ private void traverseSet(HollowSetTypeReadState typeState, int ordinal) {
127
131
int refOrdinal = iter .next ();
128
132
while (refOrdinal != HollowOrdinalIterator .NO_MORE_ORDINALS ) {
129
133
if (refOrdinal != HollowConstants .ORDINAL_NONE )
130
- extractHollowRecord (schema .getElementTypeState (), refOrdinal );
134
+ extractHollowRecord (schema .getElementType (), schema . getElementTypeState (), refOrdinal );
131
135
refOrdinal = iter .next ();
132
136
}
133
137
}
@@ -139,9 +143,9 @@ private void traverseMap(HollowMapTypeReadState typeState, int ordinal) {
139
143
140
144
while (iter .next ()) {
141
145
if (iter .getKey () != HollowConstants .ORDINAL_NONE )
142
- extractHollowRecord (schema .getKeyTypeState (), iter .getKey ());
146
+ extractHollowRecord (schema .getKeyType (), schema . getKeyTypeState (), iter .getKey ());
143
147
if (iter .getValue () != HollowConstants .ORDINAL_NONE )
144
- extractHollowRecord (schema .getValueTypeState (), iter .getValue ());
148
+ extractHollowRecord (schema .getValueType (), schema . getValueTypeState (), iter .getValue ());
145
149
}
146
150
}
147
151
0 commit comments