Package org.apache.phoenix.hbase.index.util

Examples of org.apache.phoenix.hbase.index.util.ImmutableBytesPtr


      if(!durable){
        durable = m.getDurability() != Durability.SKIP_WAL;
      }

      // add the mutation to the batch set
      ImmutableBytesPtr row = new ImmutableBytesPtr(m.getRow());
      MultiMutation stored = mutations.get(row);
      // we haven't seen this row before, so add it
      if (stored == null) {
        stored = new MultiMutation(row, m.getWriteToWAL());
        mutations.put(row, stored);
View Full Code Here


    // simple map to make lookups easy while we build the map of tables to create
    Map<ImmutableBytesPtr, HTableInterfaceReference> tables =
        new HashMap<ImmutableBytesPtr, HTableInterfaceReference>(updates.size());
    for (Pair<Mutation, byte[]> entry : indexUpdates) {
      byte[] tableName = entry.getSecond();
      ImmutableBytesPtr ptr = new ImmutableBytesPtr(tableName);
      HTableInterfaceReference table = tables.get(ptr);
      if (table == null) {
        table = new HTableInterfaceReference(ptr);
        tables.put(ptr, table);
      }
View Full Code Here

  }

  @Override
  @SuppressWarnings("unchecked")
  public HTableInterface getTable(ImmutableBytesPtr tablename) throws IOException {
    ImmutableBytesPtr tableBytes = new ImmutableBytesPtr(tablename);
    synchronized (openTables) {
      HTableInterface table = (HTableInterface) openTables.get(tableBytes);
      if (table == null) {
        table = delegate.getTable(tablename);
        openTables.put(tableBytes, table);
View Full Code Here

    private int hashCode;

    public IndexedKeyValue() {}

    public IndexedKeyValue(byte[] bs, Mutation mutation) {
        this.indexTableName = new ImmutableBytesPtr(bs);
        this.mutation = mutation;
        this.hashCode = calcHashCode(indexTableName, mutation);
    }
View Full Code Here

     * complement to {@link #writeData(DataOutput)}.
     */
    @SuppressWarnings("javadoc")
    @Override
    public void readFields(DataInput in) throws IOException {
        this.indexTableName = new ImmutableBytesPtr(Bytes.readByteArray(in));
        Class<? extends Mutation> clazz;
        try {
            clazz = Class.forName(in.readUTF()).asSubclass(Mutation.class);
            this.mutation = clazz.newInstance();
            this.mutation.readFields(in);
View Full Code Here

                boolean isNullable = true;
                boolean isDataColumnInverted = false;
                SortOrder dataSortOrder = SortOrder.getDefault();
                if (dataPkPosition[i] == -1) {
                    dataColumnType = indexedColumnTypes.get(j);
                    ImmutableBytesPtr value = valueGetter.getLatestValue(iterator.next());
                    if (value == null) {
                        ptr.set(ByteUtil.EMPTY_BYTE_ARRAY);
                    } else {
                        ptr.set(value.copyBytesIfNecessary());
                    }
                    j++;
               } else {
                    Field field = dataRowKeySchema.getField(dataPkPosition[i]);
                    dataColumnType = field.getDataType();
View Full Code Here

        // New row being inserted: add the empty key value
        if (valueGetter.getLatestValue(dataEmptyKeyValueRef) == null) {
            byte[] indexRowKey = this.buildRowKey(valueGetter, dataRowKeyPtr);
            put = new Put(indexRowKey);
            // add the keyvalue for the empty row
            put.add(kvBuilder.buildPut(new ImmutableBytesPtr(indexRowKey),
                this.getEmptyKeyValueFamily(), QueryConstants.EMPTY_COLUMN_BYTES_PTR, ts,
                ByteUtil.EMPTY_BYTE_ARRAY_PTR));
            put.setWriteToWAL(!indexWALDisabled);
        }
        int i = 0;
        for (ColumnReference ref : this.getCoverededColumns()) {
            ImmutableBytesPtr cq = this.indexQualifiers.get(i++);
            ImmutableBytesPtr value = valueGetter.getLatestValue(ref);
            byte[] indexRowKey = this.buildRowKey(valueGetter, dataRowKeyPtr);
            ImmutableBytesPtr rowKey = new ImmutableBytesPtr(indexRowKey);
            if (value != null) {
                if (put == null) {
                    put = new Put(indexRowKey);
                    put.setWriteToWAL(!indexWALDisabled);
                }
View Full Code Here

            newState.put(new ColumnReference(kv.getFamily(), kv.getQualifier()), kv);
        }
        for (ColumnReference ref : indexedColumns) {
            KeyValue newValue = newState.get(ref);
            if (newValue != null) { // Indexed column was potentially changed
                ImmutableBytesPtr oldValue = oldState.getLatestValue(ref);
                boolean  newValueSetAsNull = newValue.getType() == Type.DeleteColumn.getCode();
                //If the new column value has to be set as null and the older value is null too,
                //then just skip to the next indexed column.
                if (newValueSetAsNull && oldValue == null) {
                    continue;
                }
                if ((oldValue == null && !newValueSetAsNull) || (oldValue != null && newValueSetAsNull)) {
                    return true;
                }
                // If there was no old value or the old value is different than the new value, the index row needs to be deleted
                if (oldValue == null ||
                        Bytes.compareTo(oldValue.get(), oldValue.getOffset(), oldValue.getLength(),
                                newValue.getBuffer(), newValue.getValueOffset(), newValue.getValueLength()) != 0){
                    return true;
                }
            }
        }
View Full Code Here

            byte[] cq = Bytes.readByteArray(input);
            coveredColumns.add(new ColumnReference(cf,cq));
        }
        indexTableName = Bytes.readByteArray(input);
        dataEmptyKeyValueCF = Bytes.readByteArray(input);
        emptyKeyValueCFPtr = new ImmutableBytesPtr(Bytes.readByteArray(input));
       
        rowKeyMetaData = newRowKeyMetaData();
        rowKeyMetaData.readFields(input);
        int nDataCFs = WritableUtils.readVInt(input);
        // Encode indexWALDisabled in nDataCFs
View Full Code Here

                new ColumnReference(emptyKeyValueCFPtr.copyBytesIfNecessary(),
                        QueryConstants.EMPTY_COLUMN_BYTES);

        indexQualifiers = Lists.newArrayListWithExpectedSize(this.coveredColumns.size());
        for (ColumnReference ref : coveredColumns) {
            indexQualifiers.add(new ImmutableBytesPtr(IndexUtil.getIndexColumnName(
                ref.getFamily(), ref.getQualifier())));
        }

        this.allColumns = Sets.newLinkedHashSetWithExpectedSize(indexedColumns.size() + coveredColumns.size());
        allColumns.addAll(indexedColumns);
View Full Code Here

TOP

Related Classes of org.apache.phoenix.hbase.index.util.ImmutableBytesPtr

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.