Package org.apache.accumulo.core.data

Examples of org.apache.accumulo.core.data.Key


    BatchWriter writer = new MockBatchWriter(acc, tableName);
    try {
      Iterator<Entry<Key,Value>> iter = super.iterator();
      while (iter.hasNext()) {
        Entry<Key,Value> next = iter.next();
        Key k = next.getKey();
        Mutation m = new Mutation(k.getRow());
        m.putDelete(k.getColumnFamily(), k.getColumnQualifier(), new ColumnVisibility(k.getColumnVisibility()), k.getTimestamp());
        writer.addMutation(m);
      }
    } finally {
      writer.close();
    }
View Full Code Here


    for (FileStatus importStatus : fs.listStatus(importPath)) {
      try {
        FileSKVIterator importIterator = FileOperations.getInstance().openReader(importStatus.getPath().toString(), true, fs, fs.getConf(),
            AccumuloConfiguration.getDefaultConfiguration());
        while (importIterator.hasTop()) {
          Key key = importIterator.getTopKey();
          Value value = importIterator.getTopValue();
          if (setTime) {
            key.setTimestamp(time);
          }
          Mutation mutation = new Mutation(key.getRow());
          if (!key.isDeleted()) {
            mutation.put(key.getColumnFamily(), key.getColumnQualifier(), new ColumnVisibility(key.getColumnVisibilityData().toArray()), key.getTimestamp(),
                value);
          } else {
            mutation.putDelete(key.getColumnFamily(), key.getColumnQualifier(), new ColumnVisibility(key.getColumnVisibilityData().toArray()),
                key.getTimestamp());
          }
          table.addMutation(mutation);
          importIterator.next();
        }
      } catch (Exception e) {
View Full Code Here

    MockTable t = acu.tables.get(tableName);
    Text startText = start != null ? new Text(start) : new Text();
    Text endText = end != null ? new Text(end) : new Text(t.table.lastKey().getRow().getBytes());
    startText.append(ZERO, 0, 1);
    endText.append(ZERO, 0, 1);
    Set<Key> keep = new TreeSet<Key>(t.table.subMap(new Key(startText), new Key(endText)).keySet());
    t.table.keySet().removeAll(keep);
  }
View Full Code Here

 
  public static Range maximizeStartKeyTimeStamp(Range range) {
    Range seekRange = range;
   
    if (range.getStartKey() != null && range.getStartKey().getTimestamp() != Long.MAX_VALUE) {
      Key seekKey = new Key(seekRange.getStartKey());
      seekKey.setTimestamp(Long.MAX_VALUE);
      seekRange = new Range(seekKey, true, range.getEndKey(), range.isEndKeyInclusive());
    }
   
    return seekRange;
  }
View Full Code Here

 
  public static Range minimizeEndKeyTimeStamp(Range range) {
    Range seekRange = range;
   
    if (range.getEndKey() != null && range.getEndKey().getTimestamp() != Long.MIN_VALUE) {
      Key seekKey = new Key(seekRange.getEndKey());
      seekKey.setTimestamp(Long.MIN_VALUE);
      seekRange = new Range(range.getStartKey(), range.isStartKeyInclusive(), seekKey, true);
    }
   
    return seekRange;
  }
View Full Code Here

     
      private Size fetch() {
        long tabletSize = 0;
        while (iterator.hasNext()) {
          Entry<Key,Value> entry = iterator.next();
          Key key = entry.getKey();
          if (key.getColumnFamily().equals(Constants.METADATA_DATAFILE_COLUMN_FAMILY)) {
            String[] sizeEntries = new String(entry.getValue().get(), Constants.UTF8).split(",");
            if (sizeEntries.length == 2) {
              tabletSize += Long.parseLong(sizeEntries[0]);
            }
          } else if (Constants.METADATA_PREV_ROW_COLUMN.hasColumns(key)) {
            KeyExtent extent = new KeyExtent(key.getRow(), entry.getValue());
            return new Size(extent, tabletSize);
          }
        }
        return null;
      }
View Full Code Here

      this.time = time;
    }
  }
 
  public static Pair<SortedMap<KeyExtent,Text>,List<KeyExtent>> getMetadataLocationEntries(SortedMap<Key,Value> entries) {
    Key key;
    Value val;
    Text location = null;
    Value prevRow = null;
    KeyExtent ke;
   
    SortedMap<KeyExtent,Text> results = new TreeMap<KeyExtent,Text>();
    ArrayList<KeyExtent> locationless = new ArrayList<KeyExtent>();
   
    Text lastRowFromKey = new Text();
   
    // text obj below is meant to be reused in loop for efficiency
    Text colf = new Text();
    Text colq = new Text();
   
    for (Entry<Key,Value> entry : entries.entrySet()) {
      key = entry.getKey();
      val = entry.getValue();
     
      if (key.compareRow(lastRowFromKey) != 0) {
        prevRow = null;
        location = null;
        key.getRow(lastRowFromKey);
      }
     
      colf = key.getColumnFamily(colf);
      colq = key.getColumnQualifier(colq);
     
      // interpret the row id as a key extent
      if (colf.equals(Constants.METADATA_CURRENT_LOCATION_COLUMN_FAMILY) || colf.equals(Constants.METADATA_FUTURE_LOCATION_COLUMN_FAMILY)) {
        if (location != null) {
          throw new IllegalStateException("Tablet has multiple locations : " + lastRowFromKey);
        }
        location = new Text(val.toString());
      } else if (Constants.METADATA_PREV_ROW_COLUMN.equals(colf, colq)) {
        prevRow = new Value(val);
      }
     
      if (prevRow != null) {
        ke = new KeyExtent(key.getRow(), prevRow);
        if (location != null)
          results.put(ke, location);
        else
          locationless.add(ke);
View Full Code Here

    Constants.METADATA_PREV_ROW_COLUMN.fetch(scanner);
    scanner.fetchColumnFamily(Constants.METADATA_CURRENT_LOCATION_COLUMN_FAMILY);
   
    // position at first entry in metadata table for given table
    KeyExtent ke = new KeyExtent(new Text(tableId), new Text(), null);
    Key startKey = new Key(ke.getMetadataEntry());
    ke = new KeyExtent(new Text(tableId), null, null);
    Key endKey = new Key(ke.getMetadataEntry()).followingKey(PartialKey.ROW);
    scanner.setRange(new Range(startKey, endKey));
   
    Text colf = new Text();
    Text colq = new Text();
   
View Full Code Here

  }
 
  @Override
  public org.apache.accumulo.proxy.thrift.Key getFollowing(org.apache.accumulo.proxy.thrift.Key key, org.apache.accumulo.proxy.thrift.PartialKey part)
      throws TException {
    Key key_ = Util.fromThrift(key);
    PartialKey part_ = PartialKey.valueOf(part.toString());
    Key followingKey = key_.followingKey(part_);
    return getProxyKey(followingKey);
  }
View Full Code Here

    if (m.size() == 0)
      throw new IllegalArgumentException("Can not add empty mutations");
    long now = System.currentTimeMillis();
    mutationCount++;
    for (ColumnUpdate u : m.getUpdates()) {
      Key key = new Key(m.getRow(), 0, m.getRow().length, u.getColumnFamily(), 0, u.getColumnFamily().length, u.getColumnQualifier(), 0,
          u.getColumnQualifier().length, u.getColumnVisibility(), 0, u.getColumnVisibility().length, u.getTimestamp());
      if (u.isDeleted())
        key.setDeleted(true);
      if (!u.hasTimestamp())
        if (timeType.equals(TimeType.LOGICAL))
          key.setTimestamp(mutationCount);
        else
          key.setTimestamp(now);
     
      table.put(new MockMemKey(key, mutationCount), new Value(u.getValue()));
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.accumulo.core.data.Key

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.