Package org.apache.hadoop.hbase.io

Examples of org.apache.hadoop.hbase.io.ImmutableBytesWritable


    // verify that entries from ImmutableConfigMap's are merged in the iterator's view
    assertEquals(baseConfSize + 1, cnt);
  }

  private ImmutableBytesWritable strToIbw(String s) {
    return new ImmutableBytesWritable(Bytes.toBytes(s));
  }
View Full Code Here


    this.configs.add(0, new ImmutableConfigMap() {
      Map<ImmutableBytesWritable, ImmutableBytesWritable> m = map;

      @Override
      public String get(String key) {
        ImmutableBytesWritable ibw = new ImmutableBytesWritable(Bytes
            .toBytes(key));
        if (!m.containsKey(ibw))
          return null;
        ImmutableBytesWritable value = m.get(ibw);
        if (value == null || value.get() == null)
          return null;
        return Bytes.toString(value.get());
      }

      @Override
      public String getRaw(String key) {
        return get(key);
      }

      @Override
      public Class<?> getClassByName(String name)
      throws ClassNotFoundException {
        return null;
      }

      @Override
      public int size() {
        // TODO Auto-generated method stub
        return m.size();
      }

      @Override
      public String toString() {
        return m.toString();
      }

      @Override
      public Iterator<Entry<String, String>> iterator() {
        final Iterator<Entry<ImmutableBytesWritable, ImmutableBytesWritable>> entries = m
            .entrySet().iterator();
        return new Iterator<Entry<String, String>>() {

          @Override
          public boolean hasNext() {
            return entries.hasNext();
          }

          @Override
          public Entry<String, String> next() {
            final Entry<ImmutableBytesWritable, ImmutableBytesWritable> e = entries.next();
            return new Entry<String, String>() {

              @Override
              public String setValue(String value) {
                throw new UnsupportedOperationException(
                    "Cannot set value on entry from a CompoundConfiguration!");
              }

              @Override
              public String getValue() {
                ImmutableBytesWritable bytes = e.getValue();
                // unlike regular configuration, ImmutableBytesWritableMaps can take a null value
                if (bytes != null) {
                  return Bytes.toString(bytes.get(), bytes.getOffset(), bytes.getLength());
                }
                return null;
              }

              @Override
              public String getKey() {
                ImmutableBytesWritable bytes = e.getKey();
                return Bytes.toString(bytes.get(), bytes.getOffset(), bytes.getLength());
              }
            };
          }

          @Override
View Full Code Here

      RowResult value, OutputCollector<ImmutableBytesWritable,RowResult> output,
      @SuppressWarnings("unused") Reporter reporter) throws IOException {
   
    byte[][] keyVals = extractKeyValues(value);
    if(keyVals != null) {
      ImmutableBytesWritable tKey = createGroupKey(keyVals);
      output.collect(tKey, value);
    }
  }
View Full Code Here

        sb.append(new String(vals[i], HConstants.UTF8_ENCODING));
      } catch (UnsupportedEncodingException e) {
        throw new RuntimeException(e);
      }
    }
    return new ImmutableBytesWritable(Bytes.toBytes(sb.toString()));
  }
View Full Code Here

  /**
   * @param key The key.
   * @return The value.
   */
  public byte[] getValue(byte[] key) {
    ImmutableBytesWritable ibw = values.get(new ImmutableBytesWritable(key));
    if (ibw == null)
      return null;
    return ibw.get();
  }
View Full Code Here

  /**
   * @param key The key.
   * @param value The value.
   */
  public void setValue(byte[] key, byte[] value) {
    values.put(new ImmutableBytesWritable(key),
      new ImmutableBytesWritable(value));
  }
View Full Code Here

      // version 6+
      this.name = Bytes.readByteArray(in);
      this.values.clear();
      int numValues = in.readInt();
      for (int i = 0; i < numValues; i++) {
        ImmutableBytesWritable key = new ImmutableBytesWritable();
        ImmutableBytesWritable value = new ImmutableBytesWritable();
        key.readFields(in);
        value.readFields(in);
        values.put(key, value);
      }
    }
  }
View Full Code Here

   * @param i which iterator to advance
   * @param firstRow seek to this row
   * @return true if this is the first row or if the row was not found
   */
  private boolean findFirstRow(int i, final byte [] firstRow) throws IOException {
    ImmutableBytesWritable ibw = new ImmutableBytesWritable();
    HStoreKey firstKey
      = (HStoreKey)readers[i].getClosest(new HStoreKey(firstRow, this.store.getHRegionInfo()), ibw);
    if (firstKey == null) {
      // Didn't find it. Close the scanner and return TRUE
      closeSubScanner(i);
      return true;
    }
    long now = System.currentTimeMillis();
    long ttl = store.ttl;
    if (ttl != HConstants.FOREVER && now >= firstKey.getTimestamp() + ttl) {
      // Didn't find it. Close the scanner and return TRUE
      closeSubScanner(i);
      return true;
    }
    this.vals[i] = ibw.get();
    keys[i].setRow(firstKey.getRow());
    keys[i].setColumn(firstKey.getColumn());
    keys[i].setVersion(firstKey.getTimestamp());
    return columnMatch(i);
  }
View Full Code Here

   * @param i which reader to fetch next value from
   * @return true if there is more data available
   */
  private boolean getNext(int i) throws IOException {
    boolean result = false;
    ImmutableBytesWritable ibw = new ImmutableBytesWritable();
    long now = System.currentTimeMillis();
    long ttl = store.ttl;
    while (true) {
      if (!readers[i].next(keys[i], ibw)) {
        closeSubScanner(i);
        break;
      }
      if (keys[i].getTimestamp() <= this.timestamp) {
        if (ttl == HConstants.FOREVER || now < keys[i].getTimestamp() + ttl) {
          vals[i] = ibw.get();
          result = true;
          break;
        }
        if (LOG.isDebugEnabled()) {
          LOG.debug("getNext: " + keys[i] + ": expired, skipped");
View Full Code Here

     * @return ImmutableBytesWritable
     *
     * @see org.apache.hadoop.mapred.RecordReader#createKey()
     */
    public ImmutableBytesWritable createKey() {
      return new ImmutableBytesWritable();
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.io.ImmutableBytesWritable

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.