Ejemplo n.º 1
0
        public IndexPersistDataContainer(ILocator locator, DataType keyType, DataType recordType, bool compressKeys, bool compressRecords)
        {
            Locator = locator;

            KeyType    = keyType;
            RecordType = recordType;

            CompressKeys    = compressKeys;
            CompressRecords = compressRecords;

            if (compressKeys)
            {
                keyIndexerPersist = new DataIndexerPersist(keyType);
            }
            else
            {
                keyIndexerPersist = new DataIndexerPersistRaw(keyType);
            }

            if (compressRecords)
            {
                recordIndexerPersist = new DataIndexerPersist(recordType);
            }
            else
            {
                recordIndexerPersist = new DataIndexerPersistRaw(recordType);
            }
        }
Ejemplo n.º 2
0
 public OrderedSetPersist(IIndexerPersist <IData> keyIndexerPersist, IIndexerPersist <IData> recordIndexerPersist, IOrderedSetFactory orderedSetFactory)
 {
     this.keyIndexerPersist    = keyIndexerPersist;
     this.recordIndexerPersist = recordIndexerPersist;
     this.orderedSetFactory    = orderedSetFactory;
     verticalCompression       = true;
 }
Ejemplo n.º 3
0
 public DataContainerPersist(IIndexerPersist <IData> keyIndexerPersist, IIndexerPersist <IData> recordIndexerPersist, IDataContainerFactory containerFactory)
 {
     this.keyIndexerPersist    = keyIndexerPersist;
     this.recordIndexerPersist = recordIndexerPersist;
     this.containerFactory     = containerFactory;
     verticalCompression       = true;
 }
Ejemplo n.º 4
0
        private Expression GetStorePersistCall(IIndexerPersist persist, int slotIndex, Expression msAccess, ParameterExpression values, ParameterExpression count)
        {
            var castPersist = Expression.Convert(Expression.Constant(Persists[slotIndex]), Persists[slotIndex].GetType());

            var binaryWriter = Expression.New(typeof(BinaryWriter).GetConstructor(new Type[] { typeof(MemoryStream) }), msAccess);

            var idx      = Expression.Variable(typeof(int), "idx");
            var callFunc = Expression.Call(values, values.Type.GetMethod("Invoke"), idx);

            var cast  = Expression.Convert(callFunc, DataTypeUtils.GetDataType(DataType));
            var field = Expression.Field(cast, String.Format("Slot{0}", slotIndex));

            var storeMethod = persist.GetType().GetMethod("Store");

            var func      = Expression.Lambda(field, idx);
            var storeCall = Expression.Call(castPersist, storeMethod, new Expression[] { binaryWriter, func, count });

            //((IIndexerPersist<Int32>)persist[0]).Store(new BinaryWriter(streams[0]), (idx) => { return ((Data<int, string, double>)values(idx)).Slot0; }, count);

            return(storeCall);
        }
Ejemplo n.º 5
0
        private Expression GetStoreActionBody(IIndexerPersist persist, int slotIndex, ParameterExpression values, ParameterExpression count, ParameterExpression ms)
        {
            List <Expression> list = new List <Expression>();

            var msAccess      = Expression.ArrayAccess(ms, Expression.Constant(slotIndex));
            var msConstructor = Expression.New(typeof(MemoryStream).GetConstructor(new Type[] { }));
            var msAssign      = Expression.Assign(msAccess, msConstructor);

            var storeCall = GetStorePersistCall(persist, slotIndex, msAccess, values, count);

            list.Add(msAssign);
            list.Add(storeCall);

            //() =>
            //{
            //    ms[slotIndex] = new MemoryStream();
            //    ((IIndexerPersist<Int32>)persist[0]).Store(new BinaryWriter(streams[0]), (idx) => { return ((Data<int, string, double>)values(idx)).Slot0; }, count);
            //};

            var action = Expression.Lambda(Expression.Block(list));

            return(action);
        }