http://git-wip-us.apache.org/repos/asf/ignite/blob/4f80f866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheIdAwareDataInnerIO.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheIdAwareDataInnerIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheIdAwareDataInnerIO.java new file mode 100644 index 0000000..8740147 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheIdAwareDataInnerIO.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.tree; + +import org.apache.ignite.internal.pagemem.PageUtils; +import org.apache.ignite.internal.processors.cache.persistence.tree.io.IOVersions; + +/** + * + */ +public final class CacheIdAwareDataInnerIO extends AbstractDataInnerIO { + /** */ + public static final IOVersions<CacheIdAwareDataInnerIO> VERSIONS = new IOVersions<>( + new CacheIdAwareDataInnerIO(1) + ); + + /** + * @param ver Page format version. + */ + CacheIdAwareDataInnerIO(int ver) { + super(T_CACHE_ID_AWARE_DATA_REF_INNER, ver, true, 16); + } + + + @Override public int getCacheId(long pageAddr, int idx) { + return PageUtils.getInt(pageAddr, offset(idx) + 12); + } + + /** {@inheritDoc} */ + @Override protected boolean storeCacheId() { + return true; + } +}
http://git-wip-us.apache.org/repos/asf/ignite/blob/4f80f866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheIdAwareDataLeafIO.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheIdAwareDataLeafIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheIdAwareDataLeafIO.java new file mode 100644 index 0000000..1f82cbb --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheIdAwareDataLeafIO.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.tree; + +import org.apache.ignite.internal.pagemem.PageUtils; +import org.apache.ignite.internal.processors.cache.persistence.tree.io.IOVersions; + +/** + * + */ +public final class CacheIdAwareDataLeafIO extends AbstractDataLeafIO { + /** */ + public static final IOVersions<CacheIdAwareDataLeafIO> VERSIONS = new IOVersions<>( + new CacheIdAwareDataLeafIO(1) + ); + + /** + * @param ver Page format version. + */ + CacheIdAwareDataLeafIO(int ver) { + super(T_CACHE_ID_AWARE_DATA_REF_LEAF, ver, 16); + } + + + @Override public int getCacheId(long pageAddr, int idx) { + return PageUtils.getInt(pageAddr, offset(idx) + 12); + } + + /** {@inheritDoc} */ + @Override protected boolean storeCacheId() { + return true; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/4f80f866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheIdAwarePendingEntryInnerIO.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheIdAwarePendingEntryInnerIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheIdAwarePendingEntryInnerIO.java new file mode 100644 index 0000000..f166841 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheIdAwarePendingEntryInnerIO.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.tree; + +import org.apache.ignite.internal.pagemem.PageUtils; +import org.apache.ignite.internal.processors.cache.persistence.tree.io.IOVersions; + +/** + * + */ +public final class CacheIdAwarePendingEntryInnerIO extends AbstractPendingEntryInnerIO { + /** */ + public static final IOVersions<CacheIdAwarePendingEntryInnerIO> VERSIONS = new IOVersions<>( + new CacheIdAwarePendingEntryInnerIO(1) + ); + + /** + * @param ver Page format version. + */ + CacheIdAwarePendingEntryInnerIO(int ver) { + super(T_CACHE_ID_AWARE_PENDING_REF_INNER, ver, true, 20); + } + + + @Override public int getCacheId(long pageAddr, int idx) { + return PageUtils.getInt(pageAddr, offset(idx) + 16); + } + + /** {@inheritDoc} */ + @Override protected boolean storeCacheId() { + return true; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/4f80f866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheIdAwarePendingEntryLeafIO.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheIdAwarePendingEntryLeafIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheIdAwarePendingEntryLeafIO.java new file mode 100644 index 0000000..3fee2b6 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/CacheIdAwarePendingEntryLeafIO.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.tree; + +import org.apache.ignite.internal.pagemem.PageUtils; +import org.apache.ignite.internal.processors.cache.persistence.tree.io.IOVersions; + +/** + * + */ +public final class CacheIdAwarePendingEntryLeafIO extends AbstractPendingEntryLeafIO { + /** */ + public static final IOVersions<CacheIdAwarePendingEntryLeafIO> VERSIONS = new IOVersions<>( + new CacheIdAwarePendingEntryLeafIO(1) + ); + + /** + * @param ver Page format version. + */ + CacheIdAwarePendingEntryLeafIO(int ver) { + super(T_CACHE_ID_AWARE_PENDING_REF_LEAF, ver, 20); + } + + + @Override public int getCacheId(long pageAddr, int idx) { + return PageUtils.getInt(pageAddr, offset(idx) + 16); + } + + /** {@inheritDoc} */ + @Override protected boolean storeCacheId() { + return true; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/4f80f866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataInnerIO.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataInnerIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataInnerIO.java new file mode 100644 index 0000000..15cc3a0 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataInnerIO.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.tree; + +import org.apache.ignite.internal.processors.cache.GridCacheUtils; +import org.apache.ignite.internal.processors.cache.persistence.tree.io.IOVersions; + +/** + * + */ +public final class DataInnerIO extends AbstractDataInnerIO { + /** */ + public static final IOVersions<DataInnerIO> VERSIONS = new IOVersions<>( + new DataInnerIO(1) + ); + + /** + * @param ver Page format version. + */ + DataInnerIO(int ver) { + super(T_DATA_REF_INNER, ver, true, 12); + } + + + @Override public int getCacheId(long pageAddr, int idx) { + return GridCacheUtils.UNDEFINED_CACHE_ID; + } + + /** {@inheritDoc} */ + @Override protected boolean storeCacheId() { + return false; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/4f80f866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataLeafIO.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataLeafIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataLeafIO.java new file mode 100644 index 0000000..66cbaa4 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataLeafIO.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.tree; + +import org.apache.ignite.internal.processors.cache.GridCacheUtils; +import org.apache.ignite.internal.processors.cache.persistence.tree.io.IOVersions; + +/** + * + */ +public final class DataLeafIO extends AbstractDataLeafIO { + /** */ + public static final IOVersions<DataLeafIO> VERSIONS = new IOVersions<>( + new DataLeafIO(1) + ); + + /** + * @param ver Page format version. + */ + DataLeafIO(int ver) { + super(T_DATA_REF_LEAF, ver, 12); + } + + + @Override public int getCacheId(long pageAddr, int idx) { + return GridCacheUtils.UNDEFINED_CACHE_ID; + } + + /** {@inheritDoc} */ + @Override protected boolean storeCacheId() { + return false; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/4f80f866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java new file mode 100644 index 0000000..00ad95c --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/DataRow.java @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.tree; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.IgniteException; +import org.apache.ignite.internal.processors.cache.CacheGroupContext; +import org.apache.ignite.internal.processors.cache.CacheObject; +import org.apache.ignite.internal.processors.cache.KeyCacheObject; +import org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter; +import org.apache.ignite.internal.processors.cache.version.GridCacheVersion; + +/** + * + */ +public class DataRow extends CacheDataRowAdapter { + /** */ + protected int part; + + /** */ + protected int hash; + + /** + * @param hash Hash code. + * @param link Link. + * @param part Partition. + * @param rowData Required row data. + */ + DataRow(CacheGroupContext grp, int hash, long link, int part, RowData rowData) { + super(link); + + this.hash = hash; + + this.part = part; + + try { + // We can not init data row lazily because underlying buffer can be concurrently cleared. + initFromLink(grp, rowData); + } + catch (IgniteCheckedException e) { + throw new IgniteException(e); + } + + if (key != null) + key.partition(part); + } + + /** + * @param key Key. + * @param val Value. + * @param ver Version. + * @param part Partition. + * @param expireTime Expire time. + * @param cacheId Cache ID. + */ + public DataRow(KeyCacheObject key, CacheObject val, GridCacheVersion ver, int part, long expireTime, int cacheId) { + super(0); + + this.hash = key.hashCode(); + this.key = key; + this.val = val; + this.ver = ver; + this.part = part; + this.expireTime = expireTime; + this.cacheId = cacheId; + } + + /** {@inheritDoc} */ + @Override public int partition() { + return part; + } + + /** {@inheritDoc} */ + @Override public int hash() { + return hash; + } + + /** {@inheritDoc} */ + @Override public void link(long link) { + this.link = link; + } + + /** + * @param cacheId Cache ID. + */ + public void cacheId(int cacheId) { + this.cacheId = cacheId; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/4f80f866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingEntriesTree.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingEntriesTree.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingEntriesTree.java new file mode 100644 index 0000000..6b6090a --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingEntriesTree.java @@ -0,0 +1,118 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.tree; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.pagemem.PageMemory; +import org.apache.ignite.internal.processors.cache.CacheGroupContext; +import org.apache.ignite.internal.processors.cache.GridCacheUtils; +import org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree; +import org.apache.ignite.internal.processors.cache.persistence.tree.io.BPlusIO; +import org.apache.ignite.internal.processors.cache.persistence.tree.reuse.ReuseList; + +/** + * + */ +public class PendingEntriesTree extends BPlusTree<PendingRow, PendingRow> { + /** */ + public final static Object WITHOUT_KEY = new Object(); + + /** */ + private final CacheGroupContext grp; + + /** + * @param grp Cache group. + * @param name Tree name. + * @param pageMem Page memory. + * @param metaPageId Meta page ID. + * @param reuseList Reuse list. + * @param initNew Initialize new index. + * @throws IgniteCheckedException If failed. + */ + public PendingEntriesTree( + CacheGroupContext grp, + String name, + PageMemory pageMem, + long metaPageId, + ReuseList reuseList, + boolean initNew) + throws IgniteCheckedException { + super(name, + grp.groupId(), + pageMem, + grp.shared().wal(), + grp.offheap().globalRemoveId(), + metaPageId, + reuseList, + grp.sharedGroup() ? CacheIdAwarePendingEntryInnerIO.VERSIONS : PendingEntryInnerIO.VERSIONS, + grp.sharedGroup() ? CacheIdAwarePendingEntryLeafIO.VERSIONS : PendingEntryLeafIO.VERSIONS); + + this.grp = grp; + + initTree(initNew); + } + + /** {@inheritDoc} */ + @Override protected int compare(BPlusIO<PendingRow> iox, long pageAddr, int idx, PendingRow row) + throws IgniteCheckedException { + PendingRowIO io = (PendingRowIO)iox; + + int cmp; + + if (grp.sharedGroup()) { + assert row.cacheId != GridCacheUtils.UNDEFINED_CACHE_ID : "Cache ID is not provided!"; + assert io.getCacheId(pageAddr, idx) != GridCacheUtils.UNDEFINED_CACHE_ID : "Cache ID is not stored!"; + + cmp = Integer.compare(io.getCacheId(pageAddr, idx), row.cacheId); + + if (cmp != 0) + return cmp; + + if (row.expireTime == 0 && row.link == 0) { + // A search row with a cach ID only is used as a cache bound. + // The found position will be shifted until the exact cache bound is found; + // See for details: + // o.a.i.i.p.c.database.tree.BPlusTree.ForwardCursor.findLowerBound() + // o.a.i.i.p.c.database.tree.BPlusTree.ForwardCursor.findUpperBound() + return cmp; + } + } + + long expireTime = io.getExpireTime(pageAddr, idx); + + cmp = Long.compare(expireTime, row.expireTime); + + if (cmp != 0) + return cmp; + + if (row.link == 0L) + return 0; + + long link = io.getLink(pageAddr, idx); + + return Long.compare(link, row.link); + } + + /** {@inheritDoc} */ + @Override protected PendingRow getRow(BPlusIO<PendingRow> io, long pageAddr, int idx, Object flag) + throws IgniteCheckedException { + PendingRow row = io.getLookupRow(this, pageAddr, idx); + + return flag == WITHOUT_KEY ? row : row.initKey(grp); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/4f80f866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingEntryInnerIO.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingEntryInnerIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingEntryInnerIO.java new file mode 100644 index 0000000..2cfd6a3 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingEntryInnerIO.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.tree; + +import org.apache.ignite.internal.processors.cache.GridCacheUtils; +import org.apache.ignite.internal.processors.cache.persistence.tree.io.IOVersions; + +/** + * + */ +public final class PendingEntryInnerIO extends AbstractPendingEntryInnerIO { + /** */ + public static final IOVersions<PendingEntryInnerIO> VERSIONS = new IOVersions<>( + new PendingEntryInnerIO(1) + ); + + /** + * @param ver Page format version. + */ + PendingEntryInnerIO(int ver) { + super(T_PENDING_REF_INNER, ver, true, 16); + } + + + @Override public int getCacheId(long pageAddr, int idx) { + return GridCacheUtils.UNDEFINED_CACHE_ID; + } + + /** {@inheritDoc} */ + @Override protected boolean storeCacheId() { + return false; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/4f80f866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingEntryLeafIO.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingEntryLeafIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingEntryLeafIO.java new file mode 100644 index 0000000..653f3dc --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingEntryLeafIO.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.tree; + +import org.apache.ignite.internal.processors.cache.GridCacheUtils; +import org.apache.ignite.internal.processors.cache.persistence.tree.io.IOVersions; + +/** + * + */ +public final class PendingEntryLeafIO extends AbstractPendingEntryLeafIO { + /** */ + public static final IOVersions<PendingEntryLeafIO> VERSIONS = new IOVersions<>( + new PendingEntryLeafIO(1) + ); + + /** + * @param ver Page format version. + */ + PendingEntryLeafIO(int ver) { + super(T_PENDING_REF_LEAF, ver, 16); + } + + + @Override public int getCacheId(long pageAddr, int idx) { + return GridCacheUtils.UNDEFINED_CACHE_ID; + } + + /** {@inheritDoc} */ + @Override protected boolean storeCacheId() { + return false; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/4f80f866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingRow.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingRow.java new file mode 100644 index 0000000..1a6a183 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingRow.java @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.tree; + +import org.apache.ignite.IgniteCheckedException; +import org.apache.ignite.internal.processors.cache.CacheGroupContext; +import org.apache.ignite.internal.processors.cache.KeyCacheObject; +import org.apache.ignite.internal.processors.cache.persistence.CacheDataRowAdapter; +import org.apache.ignite.internal.util.typedef.internal.S; + +/** + * + */ +public class PendingRow { + /** Expire time. */ + public long expireTime; + + /** Link. */ + public long link; + + /** Cache ID. */ + public int cacheId; + + /** */ + public KeyCacheObject key; + + /** + * Creates a new instance which represents an upper or lower bound + * inside a logical cache. + * + * @param cacheId Cache ID. + */ + public PendingRow(int cacheId) { + this.cacheId = cacheId; + } + + /** + * @param cacheId Cache ID. + * @param expireTime Expire time. + * @param link Link + */ + public PendingRow(int cacheId, long expireTime, long link) { + assert expireTime != 0; + + this.cacheId = cacheId; + this.expireTime = expireTime; + this.link = link; + } + + /** + * @param grp Cache group. + * @return Row. + * @throws IgniteCheckedException If failed. + */ + PendingRow initKey(CacheGroupContext grp) throws IgniteCheckedException { + CacheDataRowAdapter rowData = new CacheDataRowAdapter(link); + rowData.initFromLink(grp, CacheDataRowAdapter.RowData.KEY_ONLY); + + key = rowData.key(); + + return this; + } + + /** {@inheritDoc} */ + @Override public String toString() { + return S.toString(PendingRow.class, this); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/4f80f866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingRowIO.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingRowIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingRowIO.java new file mode 100644 index 0000000..50c8d26 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/PendingRowIO.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.tree; + +/** + * + */ +public interface PendingRowIO { + /** + * @param pageAddr Page address. + * @param idx Index. + * @return Expire time. + */ + long getExpireTime(long pageAddr, int idx); + + /** + * @param pageAddr Page address. + * @param idx Index. + * @return Link. + */ + long getLink(long pageAddr, int idx); + + /** + * @param pageAddr Page address. + * @param idx Index. + * @return Cache ID or {@code 0} if Cache ID is not defined. + */ + int getCacheId(long pageAddr, int idx); +} http://git-wip-us.apache.org/repos/asf/ignite/blob/4f80f866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/RowLinkIO.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/RowLinkIO.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/RowLinkIO.java new file mode 100644 index 0000000..55f880c --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/RowLinkIO.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.tree; + +/** + * + */ +public interface RowLinkIO { + /** + * @param pageAddr Page address. + * @param idx Index. + * @return Row link. + */ + public long getLink(long pageAddr, int idx); + + /** + * @param pageAddr Page address. + * @param idx Index. + * @return Key hash code. + */ + public int getHash(long pageAddr, int idx); + + /** + * @param pageAddr Page address. + * @param idx Index. + * @return Cache ID or {@code 0} if cache ID is not defined. + */ + public int getCacheId(long pageAddr, int idx); +} http://git-wip-us.apache.org/repos/asf/ignite/blob/4f80f866/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/SearchRow.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/SearchRow.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/SearchRow.java new file mode 100644 index 0000000..6257013 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/tree/SearchRow.java @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.tree; + +import org.apache.ignite.internal.processors.cache.KeyCacheObject; +import org.apache.ignite.internal.processors.cache.persistence.CacheSearchRow; + +/** + * + */ +public class SearchRow implements CacheSearchRow { + /** */ + private final KeyCacheObject key; + + /** */ + private final int hash; + + /** */ + private final int cacheId; + + /** + * @param cacheId Cache ID. + * @param key Key. + */ + public SearchRow(int cacheId, KeyCacheObject key) { + this.key = key; + this.hash = key.hashCode(); + this.cacheId = cacheId; + } + + /** + * Instantiates a new fake search row as a logic cache based bound. + * + * @param cacheId Cache ID. + */ + public SearchRow(int cacheId) { + this.key = null; + this.hash = 0; + this.cacheId = cacheId; + } + + /** {@inheritDoc} */ + @Override public KeyCacheObject key() { + return key; + } + + /** {@inheritDoc} */ + @Override public long link() { + throw new UnsupportedOperationException(); + } + + /** {@inheritDoc} */ + @Override public int hash() { + return hash; + } + + /** {@inheritDoc} */ + @Override public int cacheId() { + return cacheId; + } +}
