Qualify index names with their table name.
This commit is contained in:
parent
af4156079d
commit
ca6afc326c
3 changed files with 48 additions and 2 deletions
|
@ -337,7 +337,7 @@ public final class SchemaUtil {
|
|||
|
||||
public static SchemaStatement createIndex(HelenusProperty prop) {
|
||||
if (prop.caseSensitiveIndex()) {
|
||||
return SchemaBuilder.createIndex(prop.getIndexName().get().toCql())
|
||||
return SchemaBuilder.createIndex(indexName(prop))
|
||||
.ifNotExists()
|
||||
.onTable(prop.getEntity().getName().toCql())
|
||||
.andColumn(prop.getColumnName().toCql());
|
||||
|
@ -406,7 +406,7 @@ public final class SchemaUtil {
|
|||
}
|
||||
|
||||
public static SchemaStatement dropIndex(HelenusProperty prop) {
|
||||
return SchemaBuilder.dropIndex(prop.getIndexName().get().toCql()).ifExists();
|
||||
return SchemaBuilder.dropIndex(indexName(prop)).ifExists();
|
||||
}
|
||||
|
||||
private static SchemaBuilder.Direction mapDirection(OrderingDirection o) {
|
||||
|
@ -465,4 +465,9 @@ public final class SchemaUtil {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String indexName(HelenusProperty prop) {
|
||||
return prop.getEntity().getName().toCql() + "_" + prop.getIndexName().get().toCql();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,20 +20,53 @@ import net.helenus.core.Getter;
|
|||
public interface Entity {
|
||||
String WRITTEN_AT_METHOD = "writtenAt";
|
||||
String TTL_OF_METHOD = "ttlOf";
|
||||
String TOKEN_OF_METHOD = "tokenOf";
|
||||
|
||||
/**
|
||||
* The write time for the property in question referenced by the getter.
|
||||
*
|
||||
* @param getter the property getter
|
||||
* @return the timestamp associated with the property identified by the getter
|
||||
*/
|
||||
default Long writtenAt(Getter getter) {
|
||||
return 0L;
|
||||
}
|
||||
|
||||
/**
|
||||
* The write time for the property in question referenced by the property name.
|
||||
*
|
||||
* @param prop the name of a property in this entity
|
||||
* @return the timestamp associated with the property identified by the property name if it exists
|
||||
*/
|
||||
default Long writtenAt(String prop) {
|
||||
return 0L;
|
||||
};
|
||||
|
||||
/**
|
||||
* The time-to-live for the property in question referenced by the getter.
|
||||
*
|
||||
* @param getter the property getter
|
||||
* @return the time-to-live in seconds associated with the property identified by the getter
|
||||
*/
|
||||
default Integer ttlOf(Getter getter) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* The time-to-live for the property in question referenced by the property name.
|
||||
*
|
||||
* @param prop the name of a property in this entity
|
||||
* @return the time-to-live in seconds associated with the property identified by the property name if it exists
|
||||
*/
|
||||
default Integer ttlOf(String prop) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* The token (partition identifier) for this entity which can change over time if
|
||||
* the cluster grows or shrinks but should be stable otherwise.
|
||||
*
|
||||
* @return the token for the entity
|
||||
*/
|
||||
default Long tokenOf() { return 0L; }
|
||||
}
|
||||
|
|
|
@ -147,6 +147,14 @@ public class MapperInvocationHandler<E> implements InvocationHandler, Serializab
|
|||
return 0L;
|
||||
}
|
||||
|
||||
if (Entity.TOKEN_OF_METHOD.equals(methodName) && method.getParameterCount() == 0) {
|
||||
Long v = (Long) src.get("");
|
||||
if (v != null) {
|
||||
return v;
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
if (Entity.TTL_OF_METHOD.equals(methodName) && method.getParameterCount() == 1) {
|
||||
final String key;
|
||||
if (args[0] instanceof String) {
|
||||
|
|
Loading…
Reference in a new issue