コード例 #1
0
        public unsafe ICell LoadGenericCell(IKeyValueStore storage, long cellId)
        {
            var err = storage.LoadCell(cellId, out byte[] buff, out ushort type);

            if (err != Trinity.TrinityErrorCode.E_SUCCESS)
            {
                switch (err)
                {
                case Trinity.TrinityErrorCode.E_CELL_NOT_FOUND:
                    throw new CellNotFoundException("Cannot access the cell.");

                case Trinity.TrinityErrorCode.E_NETWORK_SEND_FAILURE:
                    throw new System.IO.IOException("Network error while accessing the cell.");

                default:
                    throw new Exception("Cannot access the cell. Error code: " + err.ToString());
                }
            }
            int seg = GetIntervalIndex.ByCellTypeID(type);

            fixed(byte *p = buff)
            {
                return(CompositeStorage.GenericCellOperations[seg].UseGenericCell(cellId, p, -1, type));
            }
        }
コード例 #2
0
        public ushort GetCellType(string cellTypeString)
        {
            if (!CompositeStorage.CellTypeIDs.Keys.Contains(cellTypeString))
            {
                throw new CellTypeNotMatchException("Unrecognized cell type string.");
            }

            int seg = GetIntervalIndex.ByCellTypeName(cellTypeString);

            return(CompositeStorage.StorageSchema[seg].GetCellType(cellTypeString));
        }
コード例 #3
0
        public unsafe ICell LoadGenericCell(LocalMemoryStorage storage, long cellId)
        {
            var err = storage.GetLockedCellInfo(cellId, out int size, out ushort cellType, out byte *cellPtr, out int entryIndex);

            if (err != Trinity.TrinityErrorCode.E_SUCCESS)
            {
                throw new CellNotFoundException("Cannot access the cell.");
            }
            int seg = GetIntervalIndex.ByCellTypeID(cellType);

            return(CompositeStorage.GenericCellOperations[seg].UseGenericCell(cellId, cellPtr, entryIndex, cellType));
        }
コード例 #4
0
        public unsafe ICellAccessor UseGenericCell(LocalMemoryStorage storage, long cellId, CellAccessOptions options)
        {
            var err = storage
                      .GetLockedCellInfo(cellId,
                                         out int size,
                                         out ushort cellType,
                                         out byte *cellPtr,
                                         out int entryIndex);

            switch (err)
            {
            case Trinity.TrinityErrorCode.E_SUCCESS:
                break;

            case Trinity.TrinityErrorCode.E_CELL_NOT_FOUND:
            {
                if ((options & CellAccessOptions.ThrowExceptionOnCellNotFound) != 0)
                {
                    throw new CellNotFoundException("The cell with id = " + cellId + " not found.");
                }
                else if ((options & CellAccessOptions.CreateNewOnCellNotFound) != 0)
                {
                    throw new ArgumentException(
                              "CellAccessOptions.CreateNewOnCellNotFound is not valid for this method. Cannot determine new cell type.", "options");
                }
                else if ((options & CellAccessOptions.ReturnNullOnCellNotFound) != 0)
                {
                    return(null);
                }
                else
                {
                    throw new CellNotFoundException("The cell with id = " + cellId + " not found.");
                }
            }

            default:
                throw new CellNotFoundException("Cannot access the cell.");
            }

            int seg = GetIntervalIndex.ByCellTypeID(cellType);

            return(CompositeStorage.GenericCellOperations[seg].UseGenericCell(cellId, cellPtr, entryIndex, cellType, options));
        }
コード例 #5
0
        public void SaveGenericCell(LocalMemoryStorage storage, CellAccessOptions writeAheadLogOptions, ICell cell)
        {
            int seg = GetIntervalIndex.ByCellTypeID(cell.CellType);

            CompositeStorage.GenericCellOperations[seg].SaveGenericCell(storage, writeAheadLogOptions, cell);
        }
コード例 #6
0
        public void SaveGenericCell(IKeyValueStore storage, long cellId, ICell cell)
        {
            int seg = GetIntervalIndex.ByCellTypeID(cell.CellType);

            CompositeStorage.GenericCellOperations[seg].SaveGenericCell(storage, cellId, cell);
        }
コード例 #7
0
        public ICell NewGenericCell(string cellType, string content)
        {
            int seg = GetIntervalIndex.ByCellTypeName(cellType);

            return(CompositeStorage.GenericCellOperations[seg].NewGenericCell(cellType, content));
        }
コード例 #8
0
        public unsafe ICellAccessor UseGenericCell(long cellId, byte *cellPtr, int entryIndex, ushort cellType, CellAccessOptions options)
        {
            int seg = GetIntervalIndex.ByCellTypeID(cellType);

            return(CompositeStorage.GenericCellOperations[seg].UseGenericCell(cellId, cellPtr, entryIndex, cellType, options));
        }
コード例 #9
0
        public ICellAccessor UseGenericCell(LocalMemoryStorage storage, long cellId, CellAccessOptions options, string cellType)
        {
            int seg = GetIntervalIndex.ByCellTypeName(cellType);

            return(CompositeStorage.GenericCellOperations[seg].UseGenericCell(storage, cellId, options, cellType));
        }