public int getMatchingOrdinal(Object key) {
        if (hashTableVolatile == null) {
            throw new IllegalStateException("Index " + primaryKey.toString()  + " wasn't initialized");
        }

        PrimaryKeyIndexHashTable hashTable = hashTableVolatile;
        if(fieldPathIndexes.length != 1 || hashTable.bitsPerElement == 0)
            return -1;

        int hashCode = keyHashCode(key, 0);

        int ordinal = -1;

        do {
            hashTable = this.hashTableVolatile;
            int bucket = hashCode & hashTable.hashMask;
            ordinal = readOrdinal(hashTable, bucket);
            while(ordinal != -1) {
                if(keyDeriver.keyMatches(key, ordinal, 0))
                    break;

                bucket++;
                bucket &= hashTable.hashMask;
                ordinal = readOrdinal(hashTable, bucket);
            }
        } while(hashTableVolatile != hashTable);

        return ordinal;
    }
@Test
    public void testNotBindable() throws IOException {
        HollowWriteStateEngine writeEngine = new HollowWriteStateEngine();
        HollowObjectSchema movieSchema = new HollowObjectSchema("Movie", 3);
        movieSchema.addField("id", HollowObjectSchema.FieldType.LONG);
        movieSchema.addField("title", HollowObjectSchema.FieldType.REFERENCE, "String");
        movieSchema.addField("releaseYear", HollowObjectSchema.FieldType.INT);
        HollowObjectTypeWriteState movieState = new HollowObjectTypeWriteState(movieSchema);
        writeEngine.addTypeState(movieState);

        HollowObjectWriteRecord movieRec = new HollowObjectWriteRecord(movieSchema);
        movieRec.setLong("id", 1);
        movieRec.setReference("title", 0);  // NOTE that String type wasn't added
        movieRec.setInt("releaseYear", 1999);
        writeEngine.add("Movie", movieRec);

        HollowReadStateEngine readEngine = new HollowReadStateEngine();
        StateEngineRoundTripper.roundTripSnapshot(writeEngine, readEngine);

        // invalid because root type doesn't exist
        HollowPrimaryKeyIndex invalidPki1 = new HollowPrimaryKeyIndex(readEngine, "String", "value");
        try {
            invalidPki1.getMatchingOrdinal("test");
            fail("Index on root type not bound is expected to fail hard at query time");
        } catch (IllegalStateException e) {}

        // invalid because a type in the field paths doesn't exist
        HollowPrimaryKeyIndex invalidPki2 = new HollowPrimaryKeyIndex(readEngine, "Movie", "title.value");
        try {
            invalidPki2.getMatchingOrdinal(1L);
            fail("Index on field path not bound is expected to fail hard at query time");
        } catch (IllegalStateException e) {}

        // valid index despite a non-indexed field (title) not bindable to a type (String)
        HollowPrimaryKeyIndex validPki = new HollowPrimaryKeyIndex(readEngine, "Movie", "id");
        Assert.assertEquals(0, validPki.getMatchingOrdinal(1L));
    }