Beispiel #1
0
 private ImmutableList<ColumnIdent> getPrimaryKey() {
   Map<String, Object> metaMap = getNested(defaultMappingMap, "_meta");
   if (metaMap != null) {
     ImmutableList.Builder<ColumnIdent> builder = ImmutableList.builder();
     Object pKeys = metaMap.get("primary_keys");
     if (pKeys != null) {
       if (pKeys instanceof String) {
         builder.add(ColumnIdent.fromPath((String) pKeys));
         return builder.build();
       } else if (pKeys instanceof Collection) {
         Collection keys = (Collection) pKeys;
         if (!keys.isEmpty()) {
           for (Object pkey : keys) {
             builder.add(ColumnIdent.fromPath(pkey.toString()));
           }
           return builder.build();
         }
       }
     }
   }
   if (getCustomRoutingCol() == null && partitionedByList.isEmpty()) {
     hasAutoGeneratedPrimaryKey = true;
     return ImmutableList.of(ID_IDENT);
   }
   return ImmutableList.of();
 }
Beispiel #2
0
 private ColumnIdent childIdent(ColumnIdent ident, String name) {
   if (ident == null) {
     return new ColumnIdent(name);
   }
   if (ident.isColumn()) {
     return new ColumnIdent(ident.name(), name);
   } else {
     ImmutableList.Builder<String> builder = ImmutableList.builder();
     for (String s : ident.path()) {
       builder.add(s);
     }
     builder.add(name);
     return new ColumnIdent(ident.name(), builder.build());
   }
 }
Beispiel #3
0
 private ImmutableList<ColumnIdent> getPartitionedBy() {
   ImmutableList.Builder<ColumnIdent> builder = ImmutableList.builder();
   for (List<String> partitionedByInfo : partitionedByList) {
     builder.add(ColumnIdent.fromPath(partitionedByInfo.get(0)));
   }
   return builder.build();
 }
Beispiel #4
0
 private void add(
     ColumnIdent column,
     DataType type,
     ColumnPolicy columnPolicy,
     ReferenceInfo.IndexType indexType,
     boolean partitioned) {
   ReferenceInfo info = newInfo(column, type, columnPolicy, indexType);
   // don't add it if there is a partitioned equivalent of this column
   if (partitioned || !(partitionedBy != null && partitionedBy.contains(column))) {
     if (info.ident().isColumn()) {
       columnsBuilder.add(info);
     }
     referencesBuilder.put(info.ident().columnIdent(), info);
   }
   if (partitioned) {
     partitionedByColumnsBuilder.add(info);
   }
 }