如何在Cassandra中刷新键空间所有表中的数据?

问题描述

我目前正在用golang编写测试,并且在完成测试后想摆脱表的所有数据。我想知道是否有可能刷新cassandra中所有表的数据。

仅供参考:我正在使用3.11版的Cassandra。

解决方法

在这种情况下,“冲洗”一词不明确。

在Cassandra中,“刷新”是将数据从内存中“清除”并作为SSTables写入磁盘的操作。刷新可以根据某些触发器自动发生,也可以使用$(document).ready(function() { //Validation $("#theForm").validate({ ignore: [],rules: { 'myRadio[]': { required: { depends: function(el) { return $("#updateNum").is(':checked'); } } },newText: { required: { depends: function(el) { return $("#newRadio").is(':checked'); } } },chgText: { required: { depends: function(el) { return $("#chgRadio").is(':checked'); } } },movText: { required: { depends: function(el) { return $("#movRadio").is(':checked'); } } },},errorPlacement: function(error,element) { if (element.attr("name") === "newText") { $("#newError").html(error); } else if (element.attr("name") === "chgText") { $("#chgError").html(error); } else if (element.attr("name") === "movText") { $("#movError").html(error); } else { $("#updateError").html(error); } },messages: { 'myRadio[]': { required: '* Select One of the Options above' },newText: { required: '* Number Required 1' },chgText: { required: '* Number Required 2' },movText: { required: '* Number Required 3' },submitHandler: function(form) { if (confirm('Form ready to submit')) { form.submit(); } else { alert('not valid form'); return false; } } }); //checkbox change event $("#updateNum").on('change',function() { $("#error").empty(); if ($(this).is(':checked')) { $("#showWrapper").fadeIn(); } else { $("#showWrapper").fadeOut(); //fadeOut Parent $("#showWrapper").find('.newMobileWrapper').fadeOut(); //fadeout childrens //Prop checked false $('input[name="myRadio[]"]').each(function(index,element) { $(element).prop('checked',false); }) //remove all values $('.newMobileTextinput').each(function(index,element) { $(element).val('') }) } }); //Radio button change event $(".newNumGroup").on('change',function() { $("#showWrapper").find('.newMobileWrapper').fadeOut(); //fadeout all //New if ($(this).is(':checked') && $(this).attr('id') == 'newRadio') { $("#showWrapper").find('.newMobileWrapper').eq(0).find('input').val('') //empty input $("#showWrapper").find('.newMobileWrapper').eq(0).fadeIn(); } //Change if ($(this).is(':checked') && $(this).attr('id') == 'chgRadio') { $("#showWrapper").find('.newMobileWrapper').eq(1).fadeIn(); $("#showWrapper").find('.newMobileWrapper').eq(1).find('input').val('') //empty input } //Move if ($(this).is(':checked') && $(this).attr('id') == 'movRadio') { $("#showWrapper").find('.newMobileWrapper').eq(2).fadeIn(); $("#showWrapper").find('.newMobileWrapper').eq(2).find('input').val('') //empty input } //Empty errors $('.newMobileError').empty(); }); });命令手动完成。

但是,根据您的描述,您想要的是“截断”表的内容。您可以使用以下CQL命令执行此操作:

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">

<head>
  <title>Something</title>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
  <meta http-equiv="expires" content="0">
  <meta http-equiv="Pragma" content="no-cache">
  <style type="text/css">

  </style>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js" integrity="sha512-uto9mlQzrs59VwILcLiRYeLKPPbS/bT71da/OEBYEwcdNUk8jYIy+D176RYoop1Da+f9mvkYrmj5MCLZWEtQuA==" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.2/jquery.validate.min.js" integrity="sha512-UdIMMlVx0HEynClOIFSyOrPggomfhBKJE28LKl8yR3ghkgugPnG6iLfRfHwushZl1MOPSY6TsuBDGPK2X4zYKg==" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.2/additional-methods.min.js" integrity="sha512-6Uv+497AWTmj/6V14BsQioPrm3kgwmK9HYIyWP+vClykX52b0zrDGP7lajZoIY1nNlX4oQuh7zsGjmF7D0VZYA==" crossorigin="anonymous"></script>

</head>

<body>
  <form name="theForm" id="theForm" action="#">
    <div>
      <div>
        <label for="updateNum">Change Number: </label>
        <input name="updateNum" type="checkbox" id="updateNum" value="1" tabindex="1">
      </div>
      <br>
      <div id="showWrapper" style="display:none;">
        <div>
          <label for="newRadio"><input name="myRadio[]" id="newRadio" type="radio" class="newNumGroup" value="1"> Enter New Number</label>
          <div id="newWrapper" class="newMobileWrapper" style="display:none;margin-left:25px !important;">
            <label>New Number&nbsp;&nbsp;<input type="text" name="newText"  class="newMobileTextinput" id="newText"></label>
            <div id="newError" class="newMobileError errorContainer"></div>
          </div>
        </div>
        <br>
        <div>
          <label for="chgRadio"><input name="myRadio[]" type="radio" id="chgRadio" class="newNumGroup" value="2"> Change Existing Number</label>
          <div id="chgWrapper" class="newMobileWrapper" style="display:none;margin-left:25px !important;">
            <label>Change Number&nbsp;&nbsp;<input type="text" name="chgText"  class="newMobileTextinput" id="chgText"></label>
            <div id="chgError" class="newMobileError errorContainer"></div>
          </div>
        </div>
        <br>
        <div>
          <label for="movRadio"><input name="myRadio[]" type="radio" id="movRadio" class="newNumGroup" value="3"> Move Existing Number</label>
          <div id="movWrapper" class="newMobileWrapper" style="display:none;margin-left:25px !important;">
            <label>Move Number&nbsp;&nbsp;<input type="text" name="movText" class="newMobileTextinput" id="movText"></label>
            <div id="movError" class="newMobileError errorContainer"></div>
          </div>
        </div>
      </div>
      <br>
      <div id="updateError" class="errorContainer"></div>
    </div>
    <div><br><br><input name="submitForm" type="submit" id="submitForm" value="Submit" tabindex="-99"></div>
  </form>

</body>

</html>

您将需要遍历键空间中的每个表。有关更多信息,请参见CQL TRUNCATE command。干杯!