public SSTableTombstoneWriter build()

in cassandra-four-zero-bridge/src/main/java/org/apache/cassandra/io/sstable/SSTableTombstoneWriter.java [399:456]


        public SSTableTombstoneWriter build()
        {
            if (directory == null)
            {
                throw new IllegalStateException("No ouptut directory specified, you should provide a directory with inDirectory()");
            }
            if (schemaStatement == null)
            {
                throw new IllegalStateException("Missing schema, you should provide the schema for the SSTable to create with forTable()");
            }
            if (deleteStatement == null)
            {
                throw new IllegalStateException("No delete statement specified, you should provide a delete statement through using()");
            }

            TableMetadata tableMetadata = CassandraSchema.apply(schema -> {
                if (schema.getKeyspaceMetadata(SchemaConstants.SYSTEM_KEYSPACE_NAME) == null)
                {
                    schema.load(SystemKeyspace.metadata());
                }

                String keyspaceName = schemaStatement.keyspace();

                if (schema.getKeyspaceMetadata(keyspaceName) == null)
                {
                    schema.load(KeyspaceMetadata.create(keyspaceName,
                                                        KeyspaceParams.simple(1),
                                                        Tables.none(),
                                                        Views.none(),
                                                        Types.none(),
                                                        Functions.none()));
                }

                KeyspaceMetadata ksm = schema.getKeyspaceMetadata(keyspaceName);

                TableMetadata table = ksm.tables.getNullable(schemaStatement.table());
                if (table == null)
                {
                    Types types = createTypes(keyspaceName);
                    table = createTable(types);
                    schema.load(ksm.withSwapped(ksm.tables.with(table)).withSwapped(types));
                }
                return table;
            });

            DeleteStatement preparedDelete = prepareDelete();
            TableMetadataRef ref = TableMetadataRef.forOfflineTools(tableMetadata);
            AbstractSSTableSimpleWriter writer = new SSTableSimpleUnsortedWriter(directory, ref,
                                                                                 preparedDelete.updatedColumns(),
                                                                                 bufferSizeInMB);

            if (formatType != null)
            {
                writer.setSSTableFormatType(formatType);
            }

            return new SSTableTombstoneWriter(writer, preparedDelete, preparedDelete.getBindVariables(), tableMetadata.comparator);
        }