Esempio n. 1
0
  private void deleteIndexesContainingArrayValues(
      File storeDir, PageCache pageCache, SchemaIndexProvider schemaIndexProvider)
      throws IOException {
    File indexRoot =
        getRootDirectory(storeDir, schemaIndexProvider.getProviderDescriptor().getKey());
    IndexSamplingConfig samplingConfig = new IndexSamplingConfig(new Config());
    List<File> indexesToBeDeleted = new ArrayList<>();
    try (SchemaStore schema = schemaStoreProvider.provide(storeDir, pageCache)) {
      Iterator<SchemaRule> rules = schema.loadAllSchemaRules();
      while (rules.hasNext()) {
        SchemaRule rule = rules.next();
        IndexConfiguration indexConfig =
            new IndexConfiguration(rule.getKind() == UNIQUENESS_CONSTRAINT);
        try (IndexAccessor accessor =
            schemaIndexProvider.getOnlineAccessor(rule.getId(), indexConfig, samplingConfig)) {
          try (IndexReader reader = accessor.newReader()) {
            if (reader.valueTypesInIndex().contains(Array.class)) {
              indexesToBeDeleted.add(new File(indexRoot, "" + rule.getId()));
            }
          }
        }
      }
    }

    for (File index : indexesToBeDeleted) {
      fileSystem.deleteRecursively(index);
    }
  }
Esempio n. 2
0
 public Collection<DynamicRecord> allocateFrom(SchemaRule rule) {
   RecordSerializer serializer = new RecordSerializer();
   serializer = serializer.append(rule);
   Collection<DynamicRecord> records = new ArrayList<>();
   allocateRecordsFromBytes(
       records, serializer.serialize(), IteratorUtil.iterator(forceGetRecord(rule.getId())), this);
   return records;
 }