<commit_before>
/*
 * Copyright (C) 2015 <NAME>. All rights reserved.
 */

package org.jsimpledb.jsck.cmd;

import java.io.PrintWriter;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

import org.jsimpledb.Session;
import org.jsimpledb.SessionMode;
import org.jsimpledb.cli.CliSession;
import org.jsimpledb.cli.cmd.AbstractCommand;
import org.jsimpledb.core.FieldTypeRegistry;
import org.jsimpledb.jsck.Jsck;
import org.jsimpledb.jsck.JsckConfig;
import org.jsimpledb.jsck.JsckLogger;
import org.jsimpledb.kv.KVTransaction;
import org.jsimpledb.kv.KeyRanges;
import org.jsimpledb.schema.SchemaModel;
import org.jsimpledb.util.ParseContext;

public class JsckCommand extends AbstractCommand {

    public JsckCommand() {
        super("jsck"
         + " -repair:repair"
         + " -verbose:verbose"
         + " -limit:limit:int"
         + " -gc:garbageCollectSchemas"
         + " -force-schemas:schema-map:expr"
         + " -force-format-version:format-version:int"
         + " -keys:key-range:expr"
         + " -registry:registry:expr");
    }

    @Override
    public String getHelpSummary() {
        return "Check a key/value database for inconsistencies and optionally repair them";
    }

    @Override
    public String getHelpDetail() {
        return "Options:\n"
          + "   -repair\n"
          + "       In addition to detecting issues, attempt to repair them.\n"
          + "   -limit\n"
          + "       Stop after encountering `limit' issues.\n"
          + "   -gc\n"      // TODO
          + "       Garbage collect unused schema versions at the end of inspection.\n"
          + "   -registry\n"
          + "       Specify a custom field type registry. If this flag is not given, in JSimpleDB and Core API modes,\n"
          + "       the configured registry will be used; in key/value database CLI mode, a default instances is used.\n"
          + "       The parameter must be a Java expression returning a FieldTypeRegistry.\n"
          + "   -keys\n"    // TODO
          + "       Restrict (non-schema) checks to keys in the specified range. The parameter must be\n"
          + "       a Java expression returning a KeyRanges object.\n"
          + "   -force-schemas\n"
          + "       Forcibly override schema versions. WARNING: only use this if you know what you are doing.\n"
          + "       The parameter must be a Java expression returning a Map<Integer, SchemaModel>.\n"
          + "       This flag is ignored without `-repair'.\n"
          + "   -force-format-version\n"
          + "       Forcibly override format version. WARNING: only use this if you know what you are doing.\n"
          + "       This flag is ignored without `-repair'.\n"
          + "   -verbose\n"
          + "       Increase logging verbosity to show a high level of detail\n";
    }

    @Override
    public EnumSet<SessionMode> getSessionModes() {
        return EnumSet.allOf(SessionMode.class);
    }

    @Override
    public CliSession.Action getAction(CliSession session, ParseContext ctx, boolean complete, Map<String, Object> params) {

        // Setup config
        final JsckConfig config = new JsckConfig();
        final boolean verbose = params.containsKey("verbose");
        config.setGarbageCollectSchemas(params.containsKey("gc"));
        final FieldTypeRegistry registry = this.getParam(params, "registry", FieldTypeRegistry.class);
        if (registry != null)
            config.setFieldTypeRegistry(registry);
        config.setRepair(params.containsKey("repair"));
        final KeyRanges keys = this.getParam(params, "keys", KeyRanges.class);
        if (keys != null)
            config.setKeysToInspect(keys);<commit_msg>Remove unimplemented `jsck' command flag.<commit_after>
/*
 * Copyright (C) 2015 <NAME>. All rights reserved.
 */

package org.jsimpledb.jsck.cmd;

import java.io.PrintWriter;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;

import org.jsimpledb.Session;
import org.jsimpledb.SessionMode;
import org.jsimpledb.cli.CliSession;
import org.jsimpledb.cli.cmd.AbstractCommand;
import org.jsimpledb.core.FieldTypeRegistry;
import org.jsimpledb.jsck.Jsck;
import org.jsimpledb.jsck.JsckConfig;
import org.jsimpledb.jsck.JsckLogger;
import org.jsimpledb.kv.KVTransaction;
import org.jsimpledb.kv.KeyRanges;
import org.jsimpledb.schema.SchemaModel;
import org.jsimpledb.util.ParseContext;

public class JsckCommand extends AbstractCommand {

    public JsckCommand() {
        super("jsck"
         + " -repair:repair"
         + " -verbose:verbose"
         + " -limit:limit:int"
         + " -gc:garbageCollectSchemas"
         + " -force-schemas:schema-map:expr"
         + " -force-format-version:format-version:int"
         + " -registry:registry:expr");
    }

    @Override
    public String getHelpSummary() {
        return "Check a key/value database for inconsistencies and optionally repair them";
    }

    @Override
    public String getHelpDetail() {
        return "Options:\n"
          + "   -repair\n"
          + "       In addition to detecting issues, attempt to repair them.\n"
          + "   -limit\n"
          + "       Stop after encountering `limit' issues.\n"
          + "   -gc\n"      // TODO
          + "       Garbage collect unused schema versions at the end of inspection.\n"
          + "   -registry\n"
          + "       Specify a custom field type registry. If this flag is not given, in JSimpleDB and Core API modes,\n"
          + "       the configured registry will be used; in key/value database CLI mode, a default instances is used.\n"
          + "       The parameter must be a Java expression returning a FieldTypeRegistry.\n"
          + "   -force-schemas\n"
          + "       Forcibly override schema versions. WARNING: only use this if you know what you are doing.\n"
          + "       The parameter must be a Java expression returning a Map<Integer, SchemaModel>.\n"
          + "       This flag is ignored without `-repair'.\n"
          + "   -force-format-version\n"
          + "       Forcibly override format version. WARNING: only use this if you know what you are doing.\n"
          + "       This flag is ignored without `-repair'.\n"
          + "   -verbose\n"
          + "       Increase logging verbosity to show a high level of detail\n";
    }

    @Override
    public EnumSet<SessionMode> getSessionModes() {
        return EnumSet.allOf(SessionMode.class);
    }

    @Override
    public CliSession.Action getAction(CliSession session, ParseContext ctx, boolean complete, Map<String, Object> params) {

        // Setup config
        final JsckConfig config = new JsckConfig();
        final boolean verbose = params.containsKey("verbose");
        config.setGarbageCollectSchemas(params.containsKey("gc"));
        final FieldTypeRegistry registry = this.getParam(params, "registry", FieldTypeRegistry.class);
        if (registry != null)
            config.setFieldTypeRegistry(registry);
        config.setRepair(params.containsKey("repair"));
{'fraction_non_alphanumeric': 0.10348675034867504, 'fraction_numerical': 0.0011157601115760112, 'mean_word_length': 2.447596153846154, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4045204', 'n_tokens_mistral': 2102, 'n_tokens_neox': 2054, 'n_words': 556}