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


Java TRowMutations类代码示例

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


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

示例1: rowMutationsFromThrift

import org.apache.hadoop.hbase.thrift2.generated.TRowMutations; //导入依赖的package包/类
/**
 * Creates a {@link RowMutations} (HBase) from a {@link TRowMutations} (Thrift)
 *
 * @param in the <code>TRowMutations</code> to convert
 *
 * @return converted <code>RowMutations</code>
 */
public static RowMutations rowMutationsFromThrift(TRowMutations in) throws IOException {
  RowMutations out = new RowMutations(in.getRow());
  List<TMutation> mutations = in.getMutations();
  for (TMutation mutation : mutations) {
    if (mutation.isSetPut()) {
      out.add(putFromThrift(mutation.getPut()));
    }
    if (mutation.isSetDeleteSingle()) {
      out.add(deleteFromThrift(mutation.getDeleteSingle()));
    }
  }
  return out;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:ThriftUtilities.java

示例2: mutateRow

import org.apache.hadoop.hbase.thrift2.generated.TRowMutations; //导入依赖的package包/类
@Override
public void mutateRow(ByteBuffer table, TRowMutations rowMutations) throws TIOError, TException {
  Table htable = getTable(table);
  try {
    htable.mutateRow(rowMutationsFromThrift(rowMutations));
  } catch (IOException e) {
    throw getTIOError(e);
  } finally {
    closeTable(htable);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:ThriftHBaseServiceHandler.java

示例3: mutateRow

import org.apache.hadoop.hbase.thrift2.generated.TRowMutations; //导入依赖的package包/类
@Override
public void mutateRow(ByteBuffer table, TRowMutations rowMutations) throws TIOError, TException {
  HTableInterface htable = getTable(table);
  try {
    htable.mutateRow(rowMutationsFromThrift(rowMutations));
  } catch (IOException e) {
    throw getTIOError(e);
  } finally {
    closeTable(htable);
  }
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:12,代码来源:ThriftHBaseServiceHandler.java

示例4: rowMutationsFromThrift

import org.apache.hadoop.hbase.thrift2.generated.TRowMutations; //导入依赖的package包/类
/**
 * Creates a {@link RowMutations} (HBase) from a {@link TRowMutations} (Thrift)
 *
 * @param in the <code>TRowMutations</code> to convert
 *
 * @return converted <code>RowMutations</code>
 */
public static RowMutations rowMutationsFromThrift(TRowMutations in) throws IOException {
  List<TMutation> mutations = in.getMutations();
  RowMutations out = new RowMutations(in.getRow(), mutations.size());
  for (TMutation mutation : mutations) {
    if (mutation.isSetPut()) {
      out.add(putFromThrift(mutation.getPut()));
    }
    if (mutation.isSetDeleteSingle()) {
      out.add(deleteFromThrift(mutation.getDeleteSingle()));
    }
  }
  return out;
}
 
开发者ID:apache,项目名称:hbase,代码行数:21,代码来源:ThriftUtilities.java

示例5: checkAndMutate

import org.apache.hadoop.hbase.thrift2.generated.TRowMutations; //导入依赖的package包/类
@Override
public boolean checkAndMutate(ByteBuffer table, ByteBuffer row, ByteBuffer family,
    ByteBuffer qualifier, TCompareOp compareOp, ByteBuffer value, TRowMutations rowMutations)
        throws TIOError, TException {
  checkReadOnlyMode();
  try (final Table htable = getTable(table)) {
    return htable.checkAndMutate(byteBufferToByteArray(row), byteBufferToByteArray(family))
        .qualifier(byteBufferToByteArray(qualifier))
        .ifMatches(compareOpFromThrift(compareOp), byteBufferToByteArray(value))
        .thenMutate(rowMutationsFromThrift(rowMutations));
  } catch (IOException e) {
    throw getTIOError(e);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:15,代码来源:ThriftHBaseServiceHandler.java

示例6: mutateRow

import org.apache.hadoop.hbase.thrift2.generated.TRowMutations; //导入依赖的package包/类
@Override
public void mutateRow(ByteBuffer table, TRowMutations rowMutations) throws TIOError, TException {
  checkReadOnlyMode();
  Table htable = getTable(table);
  try {
    htable.mutateRow(rowMutationsFromThrift(rowMutations));
  } catch (IOException e) {
    throw getTIOError(e);
  } finally {
    closeTable(htable);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:13,代码来源:ThriftHBaseServiceHandler.java

示例7: testCheckAndMutateWithReadOnly

import org.apache.hadoop.hbase.thrift2.generated.TRowMutations; //导入依赖的package包/类
@Test
public void testCheckAndMutateWithReadOnly() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  ByteBuffer table = wrap(tableAname);
  ByteBuffer row = wrap(Bytes.toBytes("row"));
  ByteBuffer family = wrap(familyAname);
  ByteBuffer qualifier = wrap(qualifierAname);
  ByteBuffer value = wrap(valueAname);

  List<TColumnValue> columnValuesB = new ArrayList<>(1);
  TColumnValue columnValueB = new TColumnValue(family, wrap(qualifierBname), wrap(valueBname));
  columnValuesB.add(columnValueB);
  TPut putB = new TPut(row, columnValuesB);
  putB.setColumnValues(columnValuesB);

  TRowMutations tRowMutations = new TRowMutations(row,
      Arrays.<TMutation> asList(TMutation.put(putB)));

  boolean exceptionCaught = false;
  try {
    handler.checkAndMutate(table, row, family, qualifier, TCompareOp.EQUAL, value,
        tRowMutations);
  } catch (TIOError e) {
    exceptionCaught = true;
    assertTrue(e.getCause() instanceof DoNotRetryIOException);
    assertEquals("Thrift Server is in Read-only mode.", e.getMessage());
  } finally {
    assertTrue(exceptionCaught);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:31,代码来源:TestThriftHBaseServiceHandlerWithReadOnly.java

示例8: testMutateRowWithReadOnly

import org.apache.hadoop.hbase.thrift2.generated.TRowMutations; //导入依赖的package包/类
@Test
public void testMutateRowWithReadOnly() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = Bytes.toBytes("testMutateRow");
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValuesA = new ArrayList<>(1);
  TColumnValue columnValueA = new TColumnValue(wrap(familyAname), wrap(qualifierAname),
      wrap(valueAname));
  columnValuesA.add(columnValueA);
  TPut putA = new TPut(wrap(rowName), columnValuesA);
  putA.setColumnValues(columnValuesA);

  TDelete delete = new TDelete(wrap(rowName));

  List<TMutation> mutations = new ArrayList<>(2);
  TMutation mutationA = TMutation.put(putA);
  mutations.add(mutationA);
  TMutation mutationB = TMutation.deleteSingle(delete);
  mutations.add(mutationB);
  TRowMutations tRowMutations = new TRowMutations(wrap(rowName),mutations);

  boolean exceptionCaught = false;
  try {
    handler.mutateRow(table,tRowMutations);
  } catch (TIOError e) {
    exceptionCaught = true;
    assertTrue(e.getCause() instanceof DoNotRetryIOException);
    assertEquals("Thrift Server is in Read-only mode.", e.getMessage());
  } finally {
    assertTrue(exceptionCaught);
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:34,代码来源:TestThriftHBaseServiceHandlerWithReadOnly.java

示例9: testMutateRow

import org.apache.hadoop.hbase.thrift2.generated.TRowMutations; //导入依赖的package包/类
/**
 * Put valueA to a row, make sure put has happened, then create a mutation object to put valueB
 * and delete ValueA, then check that the row value is only valueB.
 *
 * @throws Exception
 */
@Test
public void testMutateRow() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = "testMutateRow".getBytes();
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValuesA = new ArrayList<TColumnValue>();
  TColumnValue columnValueA = new TColumnValue(wrap(familyAname), wrap(qualifierAname),
      wrap(valueAname));
  columnValuesA.add(columnValueA);
  TPut putA = new TPut(wrap(rowName), columnValuesA);
  putA.setColumnValues(columnValuesA);

  handler.put(table,putA);

  TGet get = new TGet(wrap(rowName));
  TResult result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  List<TColumnValue> returnedColumnValues = result.getColumnValues();

  List<TColumnValue> expectedColumnValues = new ArrayList<TColumnValue>();
  expectedColumnValues.add(columnValueA);
  assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);

  List<TColumnValue> columnValuesB = new ArrayList<TColumnValue>();
  TColumnValue columnValueB = new TColumnValue(wrap(familyAname), wrap(qualifierBname),
      wrap(valueBname));
  columnValuesB.add(columnValueB);
  TPut putB = new TPut(wrap(rowName), columnValuesB);
  putB.setColumnValues(columnValuesB);

  TDelete delete = new TDelete(wrap(rowName));
  List<TColumn> deleteColumns = new ArrayList<TColumn>();
  TColumn deleteColumn = new TColumn(wrap(familyAname));
  deleteColumn.setQualifier(qualifierAname);
  deleteColumns.add(deleteColumn);
  delete.setColumns(deleteColumns);

  List<TMutation> mutations = new ArrayList<TMutation>();
  TMutation mutationA = TMutation.put(putB);
  mutations.add(mutationA);

  TMutation mutationB = TMutation.deleteSingle(delete);
  mutations.add(mutationB);

  TRowMutations tRowMutations = new TRowMutations(wrap(rowName),mutations);
  handler.mutateRow(table,tRowMutations);

  result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  returnedColumnValues = result.getColumnValues();

  expectedColumnValues = new ArrayList<TColumnValue>();
  expectedColumnValues.add(columnValueB);
  assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:63,代码来源:TestThriftHBaseServiceHandler.java

示例10: testMutateRow

import org.apache.hadoop.hbase.thrift2.generated.TRowMutations; //导入依赖的package包/类
/**
 * Put valueA to a row, make sure put has happened, then create a mutation object to put valueB
 * and delete ValueA, then check that the row value is only valueB.
 */
@Test
public void testMutateRow() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  byte[] rowName = Bytes.toBytes("testMutateRow");
  ByteBuffer table = wrap(tableAname);

  List<TColumnValue> columnValuesA = new ArrayList<>(1);
  TColumnValue columnValueA = new TColumnValue(wrap(familyAname), wrap(qualifierAname),
      wrap(valueAname));
  columnValuesA.add(columnValueA);
  TPut putA = new TPut(wrap(rowName), columnValuesA);
  putA.setColumnValues(columnValuesA);

  handler.put(table,putA);

  TGet get = new TGet(wrap(rowName));
  TResult result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  List<TColumnValue> returnedColumnValues = result.getColumnValues();

  List<TColumnValue> expectedColumnValues = new ArrayList<>(1);
  expectedColumnValues.add(columnValueA);
  assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);

  List<TColumnValue> columnValuesB = new ArrayList<>(1);
  TColumnValue columnValueB = new TColumnValue(wrap(familyAname), wrap(qualifierBname),
      wrap(valueBname));
  columnValuesB.add(columnValueB);
  TPut putB = new TPut(wrap(rowName), columnValuesB);
  putB.setColumnValues(columnValuesB);

  TDelete delete = new TDelete(wrap(rowName));
  List<TColumn> deleteColumns = new ArrayList<>(1);
  TColumn deleteColumn = new TColumn(wrap(familyAname));
  deleteColumn.setQualifier(qualifierAname);
  deleteColumns.add(deleteColumn);
  delete.setColumns(deleteColumns);

  List<TMutation> mutations = new ArrayList<>(2);
  TMutation mutationA = TMutation.put(putB);
  mutations.add(mutationA);

  TMutation mutationB = TMutation.deleteSingle(delete);
  mutations.add(mutationB);

  TRowMutations tRowMutations = new TRowMutations(wrap(rowName),mutations);
  handler.mutateRow(table,tRowMutations);

  result = handler.get(table, get);
  assertArrayEquals(rowName, result.getRow());
  returnedColumnValues = result.getColumnValues();

  expectedColumnValues = new ArrayList<>(1);
  expectedColumnValues.add(columnValueB);
  assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);
}
 
开发者ID:apache,项目名称:hbase,代码行数:61,代码来源:TestThriftHBaseServiceHandler.java

示例11: testCheckAndMutate

import org.apache.hadoop.hbase.thrift2.generated.TRowMutations; //导入依赖的package包/类
@Test
public void testCheckAndMutate() throws Exception {
  ThriftHBaseServiceHandler handler = createHandler();
  ByteBuffer table = wrap(tableAname);
  ByteBuffer row = wrap(Bytes.toBytes("row"));
  ByteBuffer family = wrap(familyAname);
  ByteBuffer qualifier = wrap(qualifierAname);
  ByteBuffer value = wrap(valueAname);

  // Create a mutation to write to 'B', our "mutate" of "checkAndMutate"
  List<TColumnValue> columnValuesB = new ArrayList<>(1);
  TColumnValue columnValueB = new TColumnValue(family, wrap(qualifierBname), wrap(valueBname));
  columnValuesB.add(columnValueB);
  TPut putB = new TPut(row, columnValuesB);
  putB.setColumnValues(columnValuesB);

  TRowMutations tRowMutations = new TRowMutations(row,
      Arrays.<TMutation> asList(TMutation.put(putB)));

  // Empty table when we begin
  TResult result = handler.get(table, new TGet(row));
  assertEquals(0, result.getColumnValuesSize());

  // checkAndMutate -- condition should fail because the value doesn't exist.
  assertFalse("Expected condition to not pass",
      handler.checkAndMutate(table, row, family, qualifier, TCompareOp.EQUAL, value,
          tRowMutations));

  List<TColumnValue> columnValuesA = new ArrayList<>(1);
  TColumnValue columnValueA = new TColumnValue(family, qualifier, value);
  columnValuesA.add(columnValueA);

  // Put an update 'A'
  handler.put(table, new TPut(row, columnValuesA));

  // Verify that the update is there
  result = handler.get(table, new TGet(row));
  assertEquals(1, result.getColumnValuesSize());
  assertTColumnValueEqual(columnValueA, result.getColumnValues().get(0));

  // checkAndMutate -- condition should pass since we added the value
  assertTrue("Expected condition to pass",
      handler.checkAndMutate(table, row, family, qualifier, TCompareOp.EQUAL, value,
          tRowMutations));

  result = handler.get(table, new TGet(row));
  assertEquals(2, result.getColumnValuesSize());
  assertTColumnValueEqual(columnValueA, result.getColumnValues().get(0));
  assertTColumnValueEqual(columnValueB, result.getColumnValues().get(1));
}
 
开发者ID:apache,项目名称:hbase,代码行数:51,代码来源:TestThriftHBaseServiceHandler.java


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