Batch_mutate 在 Cassandra 中默默失败

发布于 2024-09-17 22:54:59 字数 2362 浏览 8 评论 0原文

我正在使用 thrift 接口使用 Cassandra 0.6.5。我正在尝试使用batch_mutate方法调用,但是,当我执行它时,我没有收到错误消息。这让我相信它有效。当我使用 CLI 检查时,什么也没有。我的代码或任何人都可以看到的mutation_map 格式是否有问题?有什么想法吗?

预先感谢

LN

public void Update(string keyspace, Common.NetworkPackage.MetaAsset ma)
{
  Dictionary<string, Dictionary<string, List<Mutation>>> package;
  Dictionary<string, List<Mutation>> packageEntry;
  Dictionary<string, object>.Enumerator en;
  List<Mutation> mutList;
  Mutation mut;
  DateTime now = DateTime.Now;

  if(!ma.Fields.ContainsKey("$guid")) 
    throw new ArgumentException("The field $guid is not present");

  mutList = new List<Mutation>();
  en = ma.Fields.GetEnumerator();

  while(en.MoveNext())
  {
    if (en.Current.Value == null)
      continue;
    mut = new Mutation();
    mut.Column_or_supercolumn = new ColumnOrSuperColumn();
    mut.Column_or_supercolumn.Column = new Column();
    mut.Column_or_supercolumn.Column.Name = _utf8.GetBytes(en.Current.Key);

    if (en.Current.Value == null)
      mut.Column_or_supercolumn.Column.Value = null;
    else
      mut.Column_or_supercolumn.Column.Value = ToBytes(en.Current.Value);

    mut.Column_or_supercolumn.Column.Timestamp = Utilities.Timestamp(now);          
    mutList.Add(mut);
  }

  packageEntry = new Dictionary<string, List<Mutation>>();
  packageEntry.Add("MetaAsset", mutList);

  package = new Dictionary<string, Dictionary<string, List<Mutation>>>();
  package.Add((string)ma.Fields["$guid"], packageEntry);

  Console.WriteLine(Utilities.ExportBulkMutate("LawOffice", package));

  _client.batch_mutate(keyspace, package, ConsistencyLevel.QUORUM);
}

上面的代码生成(列是名称:值@时间戳,值由类型组成:和实际值的表示):

LawOffice : {
 Row=08469fba50f448be8943614abd059d10 : {
   CF=MetaAsset : {
    $guid : String:08469fba50f448be8943614abd059d10 @ 93
    $creator : String:Lucas @ 93
    $previousversion : String:00000000000000000000000000000000 @ 93
    $nextversion : String:00000000000000000000000000000000 @ 93
    $etag : String:0 @ 93
    $length : Int32:123456789 @ 93
    $extension : String:.odt @ 93
    $created : DateTime:90 @ 93
    $modified : DateTime:90 @ 93
    $lastaccess : DateTime:90 @ 93
    $title : String:Title @ 93
    $tags : List`1:tag1,tag2,tag3 @ 93
   }
 }
}

I am working with Cassandra 0.6.5 using the thrift interface. I am trying to use the batch_mutate method call, however, when I execute it, I receive no error message. This leads me to believe it worked. When I check using the CLI, there is nothing there. Is there something wrong with my code or format of the mutation_map that anyone can see? Any ideas?

Thanks in advance,

LN

public void Update(string keyspace, Common.NetworkPackage.MetaAsset ma)
{
  Dictionary<string, Dictionary<string, List<Mutation>>> package;
  Dictionary<string, List<Mutation>> packageEntry;
  Dictionary<string, object>.Enumerator en;
  List<Mutation> mutList;
  Mutation mut;
  DateTime now = DateTime.Now;

  if(!ma.Fields.ContainsKey("$guid")) 
    throw new ArgumentException("The field $guid is not present");

  mutList = new List<Mutation>();
  en = ma.Fields.GetEnumerator();

  while(en.MoveNext())
  {
    if (en.Current.Value == null)
      continue;
    mut = new Mutation();
    mut.Column_or_supercolumn = new ColumnOrSuperColumn();
    mut.Column_or_supercolumn.Column = new Column();
    mut.Column_or_supercolumn.Column.Name = _utf8.GetBytes(en.Current.Key);

    if (en.Current.Value == null)
      mut.Column_or_supercolumn.Column.Value = null;
    else
      mut.Column_or_supercolumn.Column.Value = ToBytes(en.Current.Value);

    mut.Column_or_supercolumn.Column.Timestamp = Utilities.Timestamp(now);          
    mutList.Add(mut);
  }

  packageEntry = new Dictionary<string, List<Mutation>>();
  packageEntry.Add("MetaAsset", mutList);

  package = new Dictionary<string, Dictionary<string, List<Mutation>>>();
  package.Add((string)ma.Fields["$guid"], packageEntry);

  Console.WriteLine(Utilities.ExportBulkMutate("LawOffice", package));

  _client.batch_mutate(keyspace, package, ConsistencyLevel.QUORUM);
}

The above code produces (columns are name:value @ timestamp, value consists of a type:and a representation of the actual value):

LawOffice : {
 Row=08469fba50f448be8943614abd059d10 : {
   CF=MetaAsset : {
    $guid : String:08469fba50f448be8943614abd059d10 @ 93
    $creator : String:Lucas @ 93
    $previousversion : String:00000000000000000000000000000000 @ 93
    $nextversion : String:00000000000000000000000000000000 @ 93
    $etag : String:0 @ 93
    $length : Int32:123456789 @ 93
    $extension : String:.odt @ 93
    $created : DateTime:90 @ 93
    $modified : DateTime:90 @ 93
    $lastaccess : DateTime:90 @ 93
    $title : String:Title @ 93
    $tags : List`1:tag1,tag2,tag3 @ 93
   }
 }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难以启齿的温柔 2024-09-24 22:54:59

This has been marked as a bug and can be followed at https://issues.apache.org/jira/browse/CASSANDRA-1482

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文