38
38
public class InternalRecord extends InternalRecordAccessor implements Record
39
39
{
40
40
private final List <String > keys ;
41
- private final Map <String , Integer > keyIndexLookup ;
42
41
private final Value [] values ;
43
42
private int hashcode = 0 ;
44
43
45
44
public InternalRecord ( List <String > keys , Value [] values )
46
45
{
47
46
this .keys = keys ;
48
47
this .values = values ;
49
-
50
- int numFields = keys .size ();
51
- Map <String , Integer > fieldLookup = new HashMap <>( numFields );
52
- for ( int i = 0 ; i < numFields ; i ++ )
53
- {
54
- String name = keys .get (i );
55
- fieldLookup .put ( name , i );
56
- }
57
- this .keyIndexLookup = fieldLookup ;
58
48
}
59
49
60
50
@ Override
@@ -66,8 +56,8 @@ public List<String> keys()
66
56
@ Override
67
57
public int index ( String key )
68
58
{
69
- Integer result = keyIndexLookup . get ( key );
70
- if ( result == null )
59
+ int result = keys . indexOf ( key );
60
+ if ( result == - 1 )
71
61
{
72
62
throw new NoSuchElementException ( "Unknown key: " + key );
73
63
}
@@ -80,15 +70,15 @@ public int index( String key )
80
70
@ Override
81
71
public boolean containsKey ( String key )
82
72
{
83
- return keyIndexLookup . containsKey ( key );
73
+ return keys . contains ( key );
84
74
}
85
75
86
76
@ Override
87
77
public Value get ( String key )
88
78
{
89
- Integer fieldIndex = keyIndexLookup . get ( key );
79
+ int fieldIndex = keys . indexOf ( key );
90
80
91
- if ( fieldIndex == null )
81
+ if ( fieldIndex == - 1 )
92
82
{
93
83
return Values .NULL ;
94
84
}
0 commit comments