Package com.dbxml.db.common.btree

Source Code of com.dbxml.db.common.btree.CompoundEQ

package com.dbxml.db.common.btree;

/*
* dbXML - Native XML Database
* Copyright (c) 1999-2006 The dbXML Group, L.L.C.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* $Id: CompoundEQ.java,v 1.3 2006/02/02 18:53:52 bradford Exp $
*/

import com.dbxml.db.core.data.Value;
import com.dbxml.db.core.indexer.IndexPattern;
import com.dbxml.db.core.indexer.IndexQuery;

/**
* CompoundEQ is a specialized IndexQuery implementation for use by the
* BTree class' query method.
*/

final class CompoundEQ extends IndexQuery {
   public CompoundEQ(IndexPattern pattern, Value v) {
      this.pattern = pattern;
      this.op = EQ;

      // Must morph it into a null terminated starts-with
      byte[] r = v.getRawData();
      int pos = v.getOffset();
      int len = v.getLength();

      byte[] b = new byte[len+2];
      System.arraycopy(r, pos, b, 0, len);
      b[b.length-1] = (byte)0xFF; // Was 127
      b[b.length-2] = 0;

      Value v1 = new Value(b, 0, b.length-1);
      Value v2 = new Value(b, 0, b.length-2);
      Value v3 = new Value(b, 0, b.length);

      vals = new Value[]{v1, v2, v3};
   }

   public int getOperator() {
      return EQ;
   }

   public boolean testValue(Value v) {
      return v.equals(vals[1]);
   }
}
TOP

Related Classes of com.dbxml.db.common.btree.CompoundEQ

TOP
Copyright © 2018 www.massapi.com. 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.