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


Java ColumnUpdate类代码示例

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


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

示例1: check

import org.apache.accumulo.core.data.ColumnUpdate; //导入依赖的package包/类
@Override
public List<Short> check(Environment env, Mutation mutation) {
  Set<Short> violations = null;

  if (!isAlphaNum(mutation.getRow()))
    violations = addViolation(violations, NON_ALPHA_NUM_ROW);

  Collection<ColumnUpdate> updates = mutation.getUpdates();
  for (ColumnUpdate columnUpdate : updates) {
    if (!isAlphaNum(columnUpdate.getColumnFamily()))
      violations = addViolation(violations, NON_ALPHA_NUM_COLF);

    if (!isAlphaNum(columnUpdate.getColumnQualifier()))
      violations = addViolation(violations, NON_ALPHA_NUM_COLQ);
  }

  return null == violations ? null : new ArrayList<>(violations);
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:19,代码来源:AlphaNumKeyConstraint.java

示例2: write

import org.apache.accumulo.core.data.ColumnUpdate; //导入依赖的package包/类
@Override
public void write(Text table, Mutation mutation) throws IOException, InterruptedException {
  TreeMap<Key,Value> buffer = getBuffer(table);
  int mutationSize = 0;
  for (ColumnUpdate update : mutation.getUpdates()) {
    Key k = new Key(mutation.getRow(), update.getColumnFamily(), update.getColumnQualifier(), update.getColumnVisibility(), update.getTimestamp(),
        update.isDeleted());
    Value v = new Value(update.getValue());
    // TODO account for object overhead
    mutationSize += k.getSize();
    mutationSize += v.getSize();
    buffer.put(k, v);
  }
  size += mutationSize;
  long bufferSize = bufferSizes.get(table);
  
  // TODO use a MutableLong instead
  bufferSize += mutationSize;
  bufferSizes.put(table, bufferSize);
  
  while (size >= maxSize) {
    flushLargestTable();
  }
}
 
开发者ID:apache,项目名称:accumulo-wikisearch,代码行数:25,代码来源:BufferingRFileRecordWriter.java

示例3: toThrift

import org.apache.accumulo.core.data.ColumnUpdate; //导入依赖的package包/类
public static org.apache.accumulo.proxy.thrift.ColumnUpdate toThrift(ColumnUpdate update) {
  if (update == null) {
    return null;
  }

  org.apache.accumulo.proxy.thrift.ColumnUpdate tcu = new org.apache.accumulo.proxy.thrift.ColumnUpdate();
  tcu.setColFamily(update.getColumnFamily());
  tcu.setColQualifier(update.getColumnQualifier());
  tcu.setColVisibility(update.getColumnVisibility());
  tcu.setTimestamp(update.getTimestamp());
  tcu.setValue(update.getValue());
  // Work around for ACCUMULO-3474
  if (update.isDeleted()) {
    tcu.setDeleteCell(update.isDeleted());
  }
  return tcu;
}
 
开发者ID:JHUAPL,项目名称:accumulo-proxy-instance,代码行数:18,代码来源:ThriftHelper.java

示例4: check

import org.apache.accumulo.core.data.ColumnUpdate; //导入依赖的package包/类
/**
 * Ensure mutations pass constraints
 */
public List<Short> check(Environment env, Mutation mutation) {

	// Create a list to hold violation codes
	ArrayList<Short> violations = new ArrayList<Short>();

	// Get the updates from the mutation object
	Collection<ColumnUpdate> updates = mutation.getUpdates();

	// Iterate through each record determining if a record passes
	// constraints
	for (ColumnUpdate columnUpdate : updates) {
		// Ignore any record that contains a delete
		if (!columnUpdate.isDeleted()) {
			// If the record is greater than the maximum value, add a
			// violation code to the list of violations
			if (Long.parseLong(new String(columnUpdate.getValue())) >= maxValue) {
				violations.add(MAX_VALUE_EXCEEDED);
			}
		}
	}

	// Return the list of violation codes
	return violations;
}
 
开发者ID:adamjshook,项目名称:accumulo-training,代码行数:28,代码来源:CustomConstraint.java

示例5: addMutation

import org.apache.accumulo.core.data.ColumnUpdate; //导入依赖的package包/类
/**
 * Signs the given mutation and then write it to Accumulo.
 *
 * @param mutation
 *          The mutation to sign.
 */
@Override
public void addMutation(Mutation mutation) throws MutationsRejectedException {
  Mutation signedMutation = new Mutation(mutation.getRow());

  // Sign the entries.
  for (ColumnUpdate update : mutation.getUpdates()) {
    if (update.isDeleted()) {
      if (signatureConfig.destination == Destination.COLUMN_VISIBILITY) {
        throw new IllegalArgumentException("cannot delete entries when the signature is stored in the column visibility");
      }

      if (update.hasTimestamp()) {
        signedMutation.putDelete(update.getColumnFamily(), update.getColumnQualifier(), new ColumnVisibility(update.getColumnVisibility()),
            update.getTimestamp());
      } else {
        signedMutation.putDelete(update.getColumnFamily(), update.getColumnQualifier(), new ColumnVisibility(update.getColumnVisibility()));
      }
    } else {
      Entry<Key,Value> signedEntry = signer.sign(new MutableEntry(mutation.getRow(), update).toEntry(), update.hasTimestamp());
      Key signedKey = signedEntry.getKey();

      if (update.hasTimestamp()) {
        signedMutation.put(signedKey.getColumnFamily(), signedKey.getColumnQualifier(), signedKey.getColumnVisibilityParsed(), signedKey.getTimestamp(),
            signedEntry.getValue());
      } else {
        signedMutation.put(signedKey.getColumnFamily(), signedKey.getColumnQualifier(), signedKey.getColumnVisibilityParsed(), signedEntry.getValue());
      }
    }
  }

  // Write the signed mutations.
  if (signatureTableWriter != null) {
    tableWriter.addMutation(mutation);
    signatureTableWriter.addMutation(signedMutation);
  } else {
    tableWriter.addMutation(signedMutation);
  }
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:45,代码来源:SignedBatchWriter.java

示例6: MutableEntry

import org.apache.accumulo.core.data.ColumnUpdate; //导入依赖的package包/类
/**
 * Creates a mutable entry for the given update.
 *
 * @param row
 *          The row that is being updated.
 * @param update
 *          Update to wrap.
 */
public MutableEntry(byte[] row, ColumnUpdate update) {
  this.row = row;
  this.colF = update.getColumnFamily();
  this.colQ = update.getColumnQualifier();
  this.colVis = update.getColumnVisibility();
  this.timestamp = update.getTimestamp();
  this.delete = update.isDeleted();
  this.value = update.getValue();
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:18,代码来源:MutableEntry.java

示例7: deleteTest

import org.apache.accumulo.core.data.ColumnUpdate; //导入依赖的package包/类
@Test
public void deleteTest() throws Exception {
  when(mockConnector.createBatchWriter(TEST_TABLE, null)).thenReturn(mockWriter);
  BatchWriter writer = new SignedBatchWriter(mockConnector, TEST_TABLE, null, getConfig("config1.ini"), aliceKeyContainers.get(ValueSigner.RSA_PSS));

  Mutation mutation = new Mutation("row".getBytes());
  mutation.putDelete("colF".getBytes(), "colQ".getBytes());
  mutation.putDelete("colF".getBytes(), "colQ".getBytes(), 0L);
  writer.addMutation(mutation);

  verify(mockWriter).addMutation(captor.capture());
  verify(mockSignatureWriter, never()).addMutation(any());

  List<Mutation> mutations = captor.getAllValues();
  assertThat("only a single mutation", mutations, iterableWithSize(1));

  Mutation signed = mutations.get(0);
  assertThat("row is unchanged", signed.getRow(), equalTo("row".getBytes()));

  List<ColumnUpdate> updates = signed.getUpdates();
  assertThat("has 2 updates", updates, hasSize(2));

  ColumnUpdate update = updates.get(0);
  assertThat("is delete operation", update.isDeleted(), is(true));
  assertThat("column family is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("column qualifier is unchanged", update.getColumnQualifier(), equalTo("colQ".getBytes()));
  assertThat("timestamp is not set", update.hasTimestamp(), is(false));

  update = updates.get(1);
  assertThat("is delete operation", update.isDeleted(), is(true));
  assertThat("column family is unchanged", update.getColumnFamily(), equalTo("colF".getBytes()));
  assertThat("column qualifier is unchanged", update.getColumnQualifier(), equalTo("colQ".getBytes()));
  assertThat("timestamp is set", update.hasTimestamp(), is(true));
  assertThat("timestamp is correct", update.getTimestamp(), is(0L));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:36,代码来源:SignedBatchWriterTest.java

示例8: constructorWithUpdateTest

import org.apache.accumulo.core.data.ColumnUpdate; //导入依赖的package包/类
@Test
public void constructorWithUpdateTest() {
  ColumnUpdate update = new ColumnUpdate(colF, colQ, colVis, true, timestamp, delete, value);
  MutableEntry mutableEntry = new MutableEntry(row, update);

  assertThat("row should be unmodified", mutableEntry.row, is(equalTo(row)));
  assertThat("colF should be unmodified", mutableEntry.colF, is(equalTo(colF)));
  assertThat("colQ should be unmodified", mutableEntry.colQ, is(equalTo(colQ)));
  assertThat("colVis should be unmodified", mutableEntry.colVis, is(equalTo(colVis)));
  assertThat("timestamp should be unmodified", mutableEntry.timestamp, is(equalTo(timestamp)));
  assertThat("delete should be unmodified", mutableEntry.delete, is(equalTo(delete)));
  assertThat("value should be unmodified", mutableEntry.value, is(equalTo(value)));
}
 
开发者ID:mit-ll,项目名称:PACE,代码行数:14,代码来源:MutableEntryTest.java

示例9: createTestData1

import org.apache.accumulo.core.data.ColumnUpdate; //导入依赖的package包/类
private void createTestData1() {
    List<Tag> tags = Collections.singletonList(new Tag("host", "host1"));

    for (long i = 0; i < 1000; i += 100) {
        Metric m = new Metric("sys.loadAvg", i, .2, tags);
        Mutation mutation = MetricAdapter.toMutation(m);
        for (ColumnUpdate cu : mutation.getUpdates()) {
            Key key = new Key(mutation.getRow(), cu.getColumnFamily(), cu.getColumnQualifier(),
                    cu.getColumnVisibility(), cu.getTimestamp());
            testData1.put(key, new Value(cu.getValue()));
        }
    }
}
 
开发者ID:NationalSecurityAgency,项目名称:timely,代码行数:14,代码来源:DownsampleIteratorTest.java

示例10: put

import org.apache.accumulo.core.data.ColumnUpdate; //导入依赖的package包/类
void put(Map<Key, Value> testData, Metric m) {
    Mutation mutation = MetricAdapter.toMutation(m);
    for (ColumnUpdate cu : mutation.getUpdates()) {
        Key key = new Key(mutation.getRow(), cu.getColumnFamily(), cu.getColumnQualifier(),
                cu.getColumnVisibility(), cu.getTimestamp());
        testData.put(key, new Value(cu.getValue()));
    }
}
 
开发者ID:NationalSecurityAgency,项目名称:timely,代码行数:9,代码来源:DownsampleIteratorTest.java

示例11: check

import org.apache.accumulo.core.data.ColumnUpdate; //导入依赖的package包/类
@Override
public List<Short> check(Environment env, Mutation mutation) {
  Collection<ColumnUpdate> updates = mutation.getUpdates();

  for (ColumnUpdate columnUpdate : updates) {
    if (!isNumeric(columnUpdate.getValue()))
      return VIOLATION_LIST;
  }

  return null;
}
 
开发者ID:apache,项目名称:accumulo-examples,代码行数:12,代码来源:NumericValueConstraint.java

示例12: writeMutation

import org.apache.accumulo.core.data.ColumnUpdate; //导入依赖的package包/类
/**
 * Writes a mutation to the specified table.  If the mutation is meant to delete then the mutation will
 * be transformed to a delete mutation.
 * @param table the table to write to.
 * @param mutation the {@link mutation}.
 * @param context the {@link Context}.
 * @param isDelete {@code true} if the mutation should be a delete mutation.  {@code false} otherwise.
 * @throws IOException
 * @throws InterruptedException
 */
private static void writeMutation(final Text table, final Mutation mutation, final Context context, final boolean isDelete) throws IOException, InterruptedException {
    if (isDelete) {
        final List<ColumnUpdate> updates = mutation.getUpdates();
        final ColumnUpdate columnUpdate = updates.get(0);
        final ColumnVisibility cv = columnUpdate.getColumnVisibility() != null ? new ColumnVisibility(columnUpdate.getColumnVisibility()) : null;
        final Mutation deleteMutation = new Mutation(new Text(mutation.getRow()));
        deleteMutation.putDelete(columnUpdate.getColumnFamily(), columnUpdate.getColumnQualifier(), cv, columnUpdate.getTimestamp());
        context.write(table, deleteMutation);
    } else {
        context.write(table, mutation);
    }
}
 
开发者ID:apache,项目名称:incubator-rya,代码行数:23,代码来源:MergeToolMapper.java

示例13: addThriftColumnUpdates

import org.apache.accumulo.core.data.ColumnUpdate; //导入依赖的package包/类
/**
 * Converts each non-thrift ColumnUpdate in {@code list} to a Thrift ColumnUpdate (see {@link #toThrift(ColumnUpdate)}) and adds it to the provided
 * {@code thriftUpdates} list. If {@code updates} is null or empty, {@code thriftUpdates} will not be changed.
 * 
 * @param thriftUpdates
 *          the list where the newly created Thrift ColumnUpdates will be added.
 * @param updates
 *          the list of ColumnUpdates to be converted to Thrift ColumnUpdates
 */
public static void addThriftColumnUpdates(List<org.apache.accumulo.proxy.thrift.ColumnUpdate> thriftUpdates, List<ColumnUpdate> updates) {
  if (updates == null) {
    return;
  }

  for (ColumnUpdate cu : updates) {
    thriftUpdates.add(toThrift(cu));
  }
}
 
开发者ID:JHUAPL,项目名称:accumulo-proxy-instance,代码行数:19,代码来源:ThriftHelper.java

示例14: testWrite2TupleWithColumn

import org.apache.accumulo.core.data.ColumnUpdate; //导入依赖的package包/类
@Test
public void testWrite2TupleWithColumn() throws IOException, ParseException {
    AccumuloStorage storage = new AccumuloStorage("col");

    Tuple t = TupleFactory.getInstance().newTuple(2);
    t.set(0, "row");
    t.set(1, "value");

    Collection<Mutation> mutations = storage.getMutations(t);

    Assert.assertEquals(1, mutations.size());

    Mutation m = mutations.iterator().next();

    Assert.assertTrue("Rows not equal",
            Arrays.equals(m.getRow(), ((String) t.get(0)).getBytes()));

    List<ColumnUpdate> colUpdates = m.getUpdates();
    Assert.assertEquals(1, colUpdates.size());

    ColumnUpdate colUpdate = colUpdates.get(0);
    Assert.assertTrue("CF not equal",
            Arrays.equals(colUpdate.getColumnFamily(), "col".getBytes()));
    Assert.assertTrue("CQ not equal",
            Arrays.equals(colUpdate.getColumnQualifier(), new byte[0]));
    Assert.assertTrue("Values not equal",
            Arrays.equals(colUpdate.getValue(), "value".getBytes()));
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:29,代码来源:TestAccumuloStorage.java

示例15: testWrite2TupleWithColumnQual

import org.apache.accumulo.core.data.ColumnUpdate; //导入依赖的package包/类
@Test
public void testWrite2TupleWithColumnQual() throws IOException,
        ParseException {
    AccumuloStorage storage = new AccumuloStorage("col:qual");

    Tuple t = TupleFactory.getInstance().newTuple(2);
    t.set(0, "row");
    t.set(1, "value");

    Collection<Mutation> mutations = storage.getMutations(t);

    Assert.assertEquals(1, mutations.size());

    Mutation m = mutations.iterator().next();

    Assert.assertTrue("Rows not equal",
            Arrays.equals(m.getRow(), ((String) t.get(0)).getBytes()));

    List<ColumnUpdate> colUpdates = m.getUpdates();
    Assert.assertEquals(1, colUpdates.size());

    ColumnUpdate colUpdate = colUpdates.get(0);
    Assert.assertTrue("CF not equal",
            Arrays.equals(colUpdate.getColumnFamily(), "col".getBytes()));
    Assert.assertTrue("CQ not equal", Arrays.equals(
            colUpdate.getColumnQualifier(), "qual".getBytes()));
    Assert.assertTrue("Values not equal",
            Arrays.equals(colUpdate.getValue(), "value".getBytes()));
}
 
开发者ID:sigmoidanalytics,项目名称:spork,代码行数:30,代码来源:TestAccumuloStorage.java


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