public StructRowKey asStructRowKey() { final StructBuilder structBuilder = new StructBuilder(); // add all fields for (IndexFieldDefinition field : fields) { structBuilder.add(field.asRowKey()); } // add identifier structBuilder.add(this.identifierIndexFieldDefinition.asRowKey()); return structBuilder.toRowKey(); }
final RowKey key = fieldDef.asRowKey(); key.setTermination(Termination.MUST); fromKeyStructBuilder.add(key);
private void checkQueryValueType(IndexFieldDefinition fieldDef, Object value) { if (value != null) { final RowKey rowKey = fieldDef.asRowKey(); if (!rowKey.getDeserializedClass().isAssignableFrom(value.getClass())) { throw new MalformedQueryException("query for field " + fieldDef.getName() + " contains" + " a value of an incorrect type. Expected: " + rowKey.getDeserializedClass() + ", found: " + value.getClass().getName()); } } }
/** * Check if the index definition would support storing the given field with the given value. * * @param fieldName name of the field to be stored in the index * @param fieldValue value to be stored under this name * @throws MalformedIndexEntryException if the given field is not supported */ public void checkFieldSupport(String fieldName, Object fieldValue) { final IndexFieldDefinition correspondingIndexFieldDefinition = fieldsByName.get(fieldName); if (correspondingIndexFieldDefinition == null) { throw new MalformedIndexEntryException("Index entry contains a field that is not part of " + "the index definition: " + fieldName); } else if (fieldValue != null) { final RowKey rowKey = correspondingIndexFieldDefinition.asRowKey(); if (!rowKey.getDeserializedClass().isAssignableFrom(fieldValue.getClass())) { throw new MalformedIndexEntryException("Index entry for field " + fieldName + " contains" + " a value of an incorrect type. Expected: " + rowKey.getDeserializedClass() + ", found: " + fieldValue.getClass().getName()); } } }