Package com.persistit

Examples of com.persistit.Key


            ancestorHKey = keyCreator.newHKey(index.leafMostTable().hKey());
            indexToHKey = ((TableIndex)index).indexToHKey();
        }
       
       
        Key hKey = keyCreator.createKey();
        hKey.clear();
        for (int i = 0; i < indexToHKey.getLength(); i++) {
            if (indexToHKey.isOrdinal(i)) {
                hKey.append(indexToHKey.getOrdinal(i));
            } else {
                int indexField = indexToHKey.getIndexRowPosition(i);
                if (index.isSpatial()) {
                    // A spatial index has a single key column (the z-value), representing the declared spatial key columns.
                    if (indexField > index.firstSpatialArgument())
                        indexField -= index.dimensions() - 1;
                }
                Key keySource = iKey;
                if (indexField < 0 || indexField > keySource.getDepth()) {
                    throw new IllegalStateException(String.format("keySource: %s, indexField: %s",
                                                                  keySource, indexField));
                }
                PersistitKey.appendFieldFromKey(hKey, keySource, indexField, index.getIndexName());
            }
View Full Code Here


    @Override
    public HKey ancestorHKey(Table table)
    {
        HKey ancestorHKey = hKeyCache.hKey(table);
        Key hKey = keyCreator.createKey();
        constructHKeyFromIndexKey(hKey, index.indexToHKey(table.getDepth()));
        ancestorHKey.copyFrom(hKey);
        return ancestorHKey;
    }
View Full Code Here

            return 0;
        }
        // field and byte indexing is as if the pKey and pValue were one contiguous array of bytes. But we switch
        // from pKey to pValue as needed to avoid having to actually copy the bytes into such an array.
        PersistitIndexRowBuffer that = (PersistitIndexRowBuffer) row;
        Key thisKey;
        Key thatKey;
        if (thisStartIndex < this.pKeyFields) {
            thisKey = this.pKey;
        } else {
            checkValueUsage();
            thisKey = this.pValue;
            thisStartIndex -= this.pKeyFields;
        }
        if (thatStartIndex < that.pKeyFields) {
            thatKey = that.pKey;
        } else {
            checkValueUsage();
            thatKey = that.pValue;
            thatStartIndex -= that.pKeyFields;
        }
        int thisPosition = thisKey.indexTo(thisStartIndex).getIndex();
        int thatPosition = thatKey.indexTo(thatStartIndex).getIndex();
        byte[] thisBytes = thisKey.getEncodedBytes();
        byte[] thatBytes = thatKey.getEncodedBytes();
        int c = 0;
        int eqSegments = 0;
        while (eqSegments < fieldCount) {
            byte thisByte = thisBytes[thisPosition++];
            byte thatByte = thatBytes[thatPosition++];
View Full Code Here

                if (index.isSpatial()) {
                    // A spatial index has a single key column (the z-value), representing the declared spatial key columns.
                    if (indexField > index.firstSpatialArgument())
                        indexField -= index.dimensions() - 1;
                }
                Key keySource;
                if (indexField < pKeyFields) {
                    keySource = pKey;
                } else {
                    checkValueUsage();
                    keySource = pValue;
                    indexField -= pKeyFields;
                }
                if (indexField < 0 || indexField > keySource.getDepth()) {
                    throw new IllegalStateException(String.format("keySource: %s, indexField: %s",
                                                                  keySource, indexField));
                }
                PersistitKey.appendFieldFromKey(hKey, keySource, indexField, index.getIndexName());
            }
View Full Code Here

{
    @Override
    public boolean startScan()
    {
        if (subtreeRootKey == null) {
            subtreeRootKey = new Key(cursor.key());
        } else {
            cursor.key().copyTo(subtreeRootKey);
        }
        INDEX_TRAVERSE.hit();
        return cursor.traverse(Key.GT, true);
View Full Code Here

        boolean pastEnd;
        if (endComparison == null) {
            pastEnd = false;
        } else {
            // hiComparisonExpression depends on exchange's key, but we need to compare the correct key segment.
            Key key = cursor.key();
            int keySize = key.getEncodedSize();
            keySource.attach(key, field, fieldTInstance);
            if (sortKeyAdapter.isNull(keySource.asSource())) {
                pastEnd = !ascending;
            } else {
                pastEnd = !sortKeyAdapter.evaluateComparison(endComparison, cursor.context);
                key.setEncodedSize(keySize);
            }
        }
        return pastEnd;
    }
View Full Code Here

        return store.getExchange(getSession(), index);
    }

    public Key newKey()
    {
        return new Key(store.getDb());
    }
View Full Code Here

public class ObjectToKeyIT extends ITBase {
    private final String SCHEMA = "test";
    private final String TABLE = "t";

     private void testObjectToKey(FieldDef field, Object... testValues) throws PersistitException {
        Key key = store().createKey();
        PersistitKeyAppender appender = PersistitKeyAppender.create(key, null);
        for(Object inObj : testValues) {
            key.clear();
            appender.append(inObj, field);

            Object outObj = key.decode();
            if(outObj != null) {
                assertEquals(inObj.toString(), outObj.toString());
            }
            else {
                assertEquals(inObj, outObj);
View Full Code Here

    protected IndexRow readIndexRow(Session session,
                                                   Index parentPKIndex,
                                                   FDBStoreData storeData,
                                                   RowDef childRowDef,
                                                   RowData childRowData) {
        Key parentPkKey = storeData.persistitKey;
        PersistitKeyAppender keyAppender = PersistitKeyAppender.create(parentPkKey, parentPKIndex.getIndexName());
        int[] fields = childRowDef.getParentJoinFields();
        for(int field : fields) {
            FieldDef fieldDef = childRowDef.getFieldDef(field);
            keyAppender.append(fieldDef, childRowData);
View Full Code Here

                              WriteIndexRow indexRow,
                              SpatialColumnHandler spatialColumnHandler,
                              long zValue,
                              boolean doLock) {
        TransactionState txn = txnService.getTransaction(session);
        Key indexKey = createKey();
        constructIndexRow(session, indexKey, rowData, index, hKey, indexRow, spatialColumnHandler, zValue, true);
        checkUniqueness(session, txn, index, rowData, indexKey);

        byte[] packedKey = packedTuple(index, indexKey);
        txn.setBytes(packedKey, EMPTY_BYTE_ARRAY);
View Full Code Here

TOP

Related Classes of com.persistit.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.