当前位置: 首页>>代码示例>>Java>>正文


Java Mutation类代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.thrift.generated.Mutation的典型用法代码示例。如果您正苦于以下问题:Java Mutation类的具体用法?Java Mutation怎么用?Java Mutation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Mutation类属于org.apache.hadoop.hbase.thrift.generated包,在下文中一共展示了Mutation类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doTestCheckAndPut

import org.apache.hadoop.hbase.thrift.generated.Mutation; //导入依赖的package包/类
/**
 * Check that checkAndPut fails if the cell does not exist, then put in the cell, then check that
 * the checkAndPut succeeds.
 *
 * @throws Exception
 */
public static void doTestCheckAndPut() throws Exception {
  ThriftServerRunner.HBaseHandler handler =
    new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration(),
      UserProvider.instantiate(UTIL.getConfiguration()));
  handler.createTable(tableAname, getColumnDescriptors());
  try {
    List<Mutation> mutations = new ArrayList<Mutation>(1);
    mutations.add(new Mutation(false, columnAname, valueAname, true));
    Mutation putB = (new Mutation(false, columnBname, valueBname, true));

    assertFalse(handler.checkAndPut(tableAname, rowAname, columnAname, valueAname, putB, null));

    handler.mutateRow(tableAname, rowAname, mutations, null);

    assertTrue(handler.checkAndPut(tableAname, rowAname, columnAname, valueAname, putB, null));

    TRowResult rowResult = handler.getRow(tableAname, rowAname, null).get(0);
    assertEquals(rowAname, rowResult.row);
    assertEquals(valueBname, rowResult.columns.get(columnBname).value);
  } finally {
    handler.disableTable(tableAname);
    handler.deleteTable(tableAname);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:31,代码来源:TestThriftServer.java

示例2: getBatchMutations

import org.apache.hadoop.hbase.thrift.generated.Mutation; //导入依赖的package包/类
/**
 *
 * @return a List of BatchMutations with the following effects:
 * (rowA, columnA): delete
 * (rowA, columnB): place valueC
 * (rowB, columnA): place valueC
 * (rowB, columnB): place valueD
 */
private static List<BatchMutation> getBatchMutations() {
  List<BatchMutation> batchMutations = new ArrayList<BatchMutation>();

  // Mutations to rowA.  You can't mix delete and put anymore.
  List<Mutation> rowAmutations = new ArrayList<Mutation>();
  rowAmutations.add(new Mutation(true, columnAname, null, true));
  batchMutations.add(new BatchMutation(rowAname, rowAmutations));

  rowAmutations = new ArrayList<Mutation>();
  rowAmutations.add(new Mutation(false, columnBname, valueCname, true));
  batchMutations.add(new BatchMutation(rowAname, rowAmutations));

  // Mutations to rowB
  List<Mutation> rowBmutations = new ArrayList<Mutation>();
  rowBmutations.add(new Mutation(false, columnAname, valueCname, true));
  rowBmutations.add(new Mutation(false, columnBname, valueDname, true));
  batchMutations.add(new BatchMutation(rowBname, rowBmutations));

  return batchMutations;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:TestThriftServer.java

示例3: doTestCheckAndPut

import org.apache.hadoop.hbase.thrift.generated.Mutation; //导入依赖的package包/类
/**
 * Check that checkAndPut fails if the cell does not exist, then put in the cell, then check that
 * the checkAndPut succeeds.
 */
public static void doTestCheckAndPut() throws Exception {
  ThriftServerRunner.HBaseHandler handler =
    new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration(),
      UserProvider.instantiate(UTIL.getConfiguration()));
  handler.createTable(tableAname, getColumnDescriptors());
  try {
    List<Mutation> mutations = new ArrayList<>(1);
    mutations.add(new Mutation(false, columnAname, valueAname, true));
    Mutation putB = (new Mutation(false, columnBname, valueBname, true));

    assertFalse(handler.checkAndPut(tableAname, rowAname, columnAname, valueAname, putB, null));

    handler.mutateRow(tableAname, rowAname, mutations, null);

    assertTrue(handler.checkAndPut(tableAname, rowAname, columnAname, valueAname, putB, null));

    TRowResult rowResult = handler.getRow(tableAname, rowAname, null).get(0);
    assertEquals(rowAname, rowResult.row);
    assertEquals(valueBname, rowResult.columns.get(columnBname).value);
  } finally {
    handler.disableTable(tableAname);
    handler.deleteTable(tableAname);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:29,代码来源:TestThriftServer.java

示例4: getBatchMutations

import org.apache.hadoop.hbase.thrift.generated.Mutation; //导入依赖的package包/类
/**
 * @return a List of BatchMutations with the following effects:
 *         (rowA, columnA): delete
 *         (rowA, columnB): place valueC
 *         (rowB, columnA): place valueC
 *         (rowB, columnB): place valueD
 */
private static List<BatchMutation> getBatchMutations() {
  List<BatchMutation> batchMutations = new ArrayList<>(3);

  // Mutations to rowA.  You can't mix delete and put anymore.
  List<Mutation> rowAmutations = new ArrayList<>(1);
  rowAmutations.add(new Mutation(true, columnAname, null, true));
  batchMutations.add(new BatchMutation(rowAname, rowAmutations));

  rowAmutations = new ArrayList<>(1);
  rowAmutations.add(new Mutation(false, columnBname, valueCname, true));
  batchMutations.add(new BatchMutation(rowAname, rowAmutations));

  // Mutations to rowB
  List<Mutation> rowBmutations = new ArrayList<>(2);
  rowBmutations.add(new Mutation(false, columnAname, valueCname, true));
  rowBmutations.add(new Mutation(false, columnBname, valueDname, true));
  batchMutations.add(new BatchMutation(rowBname, rowBmutations));

  return batchMutations;
}
 
开发者ID:apache,项目名称:hbase,代码行数:28,代码来源:TestThriftServer.java

示例5: doTestCheckAndPut

import org.apache.hadoop.hbase.thrift.generated.Mutation; //导入依赖的package包/类
/**
 * Check that checkAndPut fails if the cell does not exist, then put in the cell, then check that
 * the checkAndPut succeeds.
 *
 * @throws Exception
 */
public static void doTestCheckAndPut() throws Exception {
  ThriftServerRunner.HBaseHandler handler =
      new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration());
  handler.createTable(tableAname, getColumnDescriptors());
  try {
    List<Mutation> mutations = new ArrayList<Mutation>(1);
    mutations.add(new Mutation(false, columnAname, valueAname, true));
    Mutation putB = (new Mutation(false, columnBname, valueBname, true));

    assertFalse(handler.checkAndPut(tableAname, rowAname, columnAname, valueAname, putB, null));

    handler.mutateRow(tableAname, rowAname, mutations, null);

    assertTrue(handler.checkAndPut(tableAname, rowAname, columnAname, valueAname, putB, null));

    TRowResult rowResult = handler.getRow(tableAname, rowAname, null).get(0);
    assertEquals(rowAname, rowResult.row);
    assertEquals(valueBname, rowResult.columns.get(columnBname).value);
  } finally {
    handler.disableTable(tableAname);
    handler.deleteTable(tableAname);
  }
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:30,代码来源:TestThriftServer.java

示例6: mutateRow

import org.apache.hadoop.hbase.thrift.generated.Mutation; //导入依赖的package包/类
@Override
public void mutateRow(ByteBuffer tableName, ByteBuffer row,
    List<Mutation> mutations, Map<ByteBuffer, ByteBuffer> attributes)
    throws IOError, IllegalArgument {
  mutateRowTs(tableName, row, mutations, HConstants.LATEST_TIMESTAMP,
              attributes);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:8,代码来源:ThriftServerRunner.java

示例7: doTestIncrements

import org.apache.hadoop.hbase.thrift.generated.Mutation; //导入依赖的package包/类
public static void doTestIncrements(HBaseHandler handler) throws Exception {
  List<Mutation> mutations = new ArrayList<Mutation>(1);
  mutations.add(new Mutation(false, columnAAname, valueEname, true));
  mutations.add(new Mutation(false, columnAname, valueEname, true));
  handler.mutateRow(tableAname, rowAname, mutations, null);
  handler.mutateRow(tableAname, rowBname, mutations, null);

  List<TIncrement> increments = new ArrayList<TIncrement>();
  increments.add(new TIncrement(tableAname, rowBname, columnAAname, 7));
  increments.add(new TIncrement(tableAname, rowBname, columnAAname, 7));
  increments.add(new TIncrement(tableAname, rowBname, columnAAname, 7));

  int numIncrements = 60000;
  for (int i = 0; i < numIncrements; i++) {
    handler.increment(new TIncrement(tableAname, rowAname, columnAname, 2));
    handler.incrementRows(increments);
  }

  Thread.sleep(1000);
  long lv = handler.get(tableAname, rowAname, columnAname, null).get(0).value.getLong();
  // Wait on all increments being flushed
  while (handler.coalescer.getQueueSize() != 0) Threads.sleep(10);
  assertEquals((100 + (2 * numIncrements)), lv );


  lv = handler.get(tableAname, rowBname, columnAAname, null).get(0).value.getLong();
  assertEquals((100 + (3 * 7 * numIncrements)), lv);

  assertTrue(handler.coalescer.getSuccessfulCoalescings() > 0);

}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:32,代码来源:TestThriftServer.java

示例8: doTestAppend

import org.apache.hadoop.hbase.thrift.generated.Mutation; //导入依赖的package包/类
/**
 * Appends the value to a cell and checks that the cell value is updated properly.
 *
 * @throws Exception
 */
public static void doTestAppend() throws Exception {
  ThriftServerRunner.HBaseHandler handler =
    new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration(),
      UserProvider.instantiate(UTIL.getConfiguration()));
  handler.createTable(tableAname, getColumnDescriptors());
  try {
    List<Mutation> mutations = new ArrayList<Mutation>(1);
    mutations.add(new Mutation(false, columnAname, valueAname, true));
    handler.mutateRow(tableAname, rowAname, mutations, null);

    List<ByteBuffer> columnList = new ArrayList<ByteBuffer>();
    columnList.add(columnAname);
    List<ByteBuffer> valueList = new ArrayList<ByteBuffer>();
    valueList.add(valueBname);

    TAppend append = new TAppend(tableAname, rowAname, columnList, valueList);
    handler.append(append);

    TRowResult rowResult = handler.getRow(tableAname, rowAname, null).get(0);
    assertEquals(rowAname, rowResult.row);
    assertArrayEquals(Bytes.add(valueAname.array(), valueBname.array()),
      rowResult.columns.get(columnAname).value.array());
  } finally {
    handler.disableTable(tableAname);
    handler.deleteTable(tableAname);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:33,代码来源:TestThriftServer.java

示例9: getMutations

import org.apache.hadoop.hbase.thrift.generated.Mutation; //导入依赖的package包/类
/**
 *
 * @return a List of Mutations for a row, with columnA having valueA
 * and columnB having valueB
 */
private static List<Mutation> getMutations() {
  List<Mutation> mutations = new ArrayList<Mutation>();
  mutations.add(new Mutation(false, columnAname, valueAname, true));
  mutations.add(new Mutation(false, columnBname, valueBname, true));
  return mutations;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:TestThriftServer.java

示例10: doTestIncrements

import org.apache.hadoop.hbase.thrift.generated.Mutation; //导入依赖的package包/类
public static void doTestIncrements(HBaseHandler handler) throws Exception {
  List<Mutation> mutations = new ArrayList<Mutation>(1);
  mutations.add(new Mutation(false, columnAAname, valueEname, true));
  mutations.add(new Mutation(false, columnAname, valueEname, true));
  handler.mutateRow(tableAname, rowAname, mutations, null);
  handler.mutateRow(tableAname, rowBname, mutations, null);

  List<TIncrement> increments = new ArrayList<TIncrement>();
  increments.add(new TIncrement(tableAname, rowBname, columnAAname, 7));
  increments.add(new TIncrement(tableAname, rowBname, columnAAname, 7));
  increments.add(new TIncrement(tableAname, rowBname, columnAAname, 7));

  int numIncrements = 60000;
  for (int i = 0; i < numIncrements; i++) {
    handler.increment(new TIncrement(tableAname, rowAname, columnAname, 2));
    handler.incrementRows(increments);
  }

  Thread.sleep(1000);
  long lv = handler.get(tableAname, rowAname, columnAname, null).get(0).value.getLong();
  assertEquals((100 + (2 * numIncrements)), lv );


  lv = handler.get(tableAname, rowBname, columnAAname, null).get(0).value.getLong();
  assertEquals((100 + (3 * 7 * numIncrements)), lv);

  assertTrue(handler.coalescer.getSuccessfulCoalescings() > 0);

}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:30,代码来源:TestThriftServer.java

示例11: doTestIncrements

import org.apache.hadoop.hbase.thrift.generated.Mutation; //导入依赖的package包/类
public static void doTestIncrements(HBaseHandler handler) throws Exception {
  List<Mutation> mutations = new ArrayList<>(1);
  mutations.add(new Mutation(false, columnAAname, valueEname, true));
  mutations.add(new Mutation(false, columnAname, valueEname, true));
  handler.mutateRow(tableAname, rowAname, mutations, null);
  handler.mutateRow(tableAname, rowBname, mutations, null);

  List<TIncrement> increments = new ArrayList<>(3);
  increments.add(new TIncrement(tableAname, rowBname, columnAAname, 7));
  increments.add(new TIncrement(tableAname, rowBname, columnAAname, 7));
  increments.add(new TIncrement(tableAname, rowBname, columnAAname, 7));

  int numIncrements = 60000;
  for (int i = 0; i < numIncrements; i++) {
    handler.increment(new TIncrement(tableAname, rowAname, columnAname, 2));
    handler.incrementRows(increments);
  }

  Thread.sleep(1000);
  long lv = handler.get(tableAname, rowAname, columnAname, null).get(0).value.getLong();
  // Wait on all increments being flushed
  while (handler.coalescer.getQueueSize() != 0) {
    Threads.sleep(10);
  }

  assertEquals((100 + (2 * numIncrements)), lv);

  lv = handler.get(tableAname, rowBname, columnAAname, null).get(0).value.getLong();
  assertEquals((100 + (3 * 7 * numIncrements)), lv);

  assertTrue(handler.coalescer.getSuccessfulCoalescings() > 0);

}
 
开发者ID:apache,项目名称:hbase,代码行数:34,代码来源:TestThriftServer.java

示例12: doTestAppend

import org.apache.hadoop.hbase.thrift.generated.Mutation; //导入依赖的package包/类
/**
 * Appends the value to a cell and checks that the cell value is updated properly.
 */
public static void doTestAppend() throws Exception {
  ThriftServerRunner.HBaseHandler handler =
    new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration(),
      UserProvider.instantiate(UTIL.getConfiguration()));
  handler.createTable(tableAname, getColumnDescriptors());
  try {
    List<Mutation> mutations = new ArrayList<>(1);
    mutations.add(new Mutation(false, columnAname, valueAname, true));
    handler.mutateRow(tableAname, rowAname, mutations, null);

    List<ByteBuffer> columnList = new ArrayList<>(1);
    columnList.add(columnAname);
    List<ByteBuffer> valueList = new ArrayList<>(1);
    valueList.add(valueBname);

    TAppend append = new TAppend(tableAname, rowAname, columnList, valueList);
    handler.append(append);

    TRowResult rowResult = handler.getRow(tableAname, rowAname, null).get(0);
    assertEquals(rowAname, rowResult.row);
    assertArrayEquals(Bytes.add(valueAname.array(), valueBname.array()),
      rowResult.columns.get(columnAname).value.array());
  } finally {
    handler.disableTable(tableAname);
    handler.deleteTable(tableAname);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:31,代码来源:TestThriftServer.java

示例13: getMutations

import org.apache.hadoop.hbase.thrift.generated.Mutation; //导入依赖的package包/类
/**
 * @return a List of Mutations for a row, with columnA having valueA
 *         and columnB having valueB
 */
private static List<Mutation> getMutations() {
  List<Mutation> mutations = new ArrayList<>(2);
  mutations.add(new Mutation(false, columnAname, valueAname, true));
  mutations.add(new Mutation(false, columnBname, valueBname, true));
  return mutations;
}
 
开发者ID:apache,项目名称:hbase,代码行数:11,代码来源:TestThriftServer.java

示例14: doTestAppend

import org.apache.hadoop.hbase.thrift.generated.Mutation; //导入依赖的package包/类
/**
 * Appends the value to a cell and checks that the cell value is updated properly.
 *
 * @throws Exception
 */
public static void doTestAppend() throws Exception {
  ThriftServerRunner.HBaseHandler handler =
      new ThriftServerRunner.HBaseHandler(UTIL.getConfiguration());
  handler.createTable(tableAname, getColumnDescriptors());
  try {
    List<Mutation> mutations = new ArrayList<Mutation>(1);
    mutations.add(new Mutation(false, columnAname, valueAname, true));
    handler.mutateRow(tableAname, rowAname, mutations, null);

    List<ByteBuffer> columnList = new ArrayList<ByteBuffer>();
    columnList.add(columnAname);
    List<ByteBuffer> valueList = new ArrayList<ByteBuffer>();
    valueList.add(valueBname);

    TAppend append = new TAppend(tableAname, rowAname, columnList, valueList);
    handler.append(append);

    TRowResult rowResult = handler.getRow(tableAname, rowAname, null).get(0);
    assertEquals(rowAname, rowResult.row);
    assertArrayEquals(Bytes.add(valueAname.array(), valueBname.array()),
      rowResult.columns.get(columnAname).value.array());
  } finally {
    handler.disableTable(tableAname);
    handler.deleteTable(tableAname);
  }
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:32,代码来源:TestThriftServer.java


注:本文中的org.apache.hadoop.hbase.thrift.generated.Mutation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。