private System.Collections.Generic.IDictionary <AbstractObjectInfo, AbstractObjectInfo> IntrospectGenericMap(
     System.Collections.Generic.IDictionary <object, object> map,
     bool introspect,
     IDictionary <object, NonNativeObjectInfo> alreadyReadObjects, IIntrospectionCallback callback)
 {
     System.Collections.Generic.IDictionary <AbstractObjectInfo, AbstractObjectInfo> mapCopy = new OdbHashMap <AbstractObjectInfo, AbstractObjectInfo>();
     System.Collections.Generic.ICollection <object> keySet = map.Keys;
     System.Collections.IEnumerator keys = keySet.GetEnumerator();
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo          ciKey       = null;
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo          ciValue     = null;
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoiForKey   = null;
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoiForValue = null;
     while (keys.MoveNext())
     {
         object key   = keys.Current;
         object value = map[key];
         if (key != null)
         {
             ciKey = GetClassInfo(OdbClassUtil.GetFullName(key.GetType()));
             if (value != null)
             {
                 ciValue = GetClassInfo(OdbClassUtil.GetFullName(value.GetType()));
             }
             aoiForKey   = GetObjectInfo(key, ciKey, introspect, alreadyReadObjects, callback);
             aoiForValue = GetObjectInfo(value, ciValue, introspect, alreadyReadObjects, callback);
             mapCopy.Add(aoiForKey, aoiForValue);
         }
     }
     return(mapCopy);
 }
예제 #2
0
 /// <summary>Reconnect an object to the current session.</summary>
 /// <remarks>
 /// Reconnect an object to the current session. It connects the object and
 /// all the dependent objects (Objects accessible from the object graph of the
 /// root object
 /// </remarks>
 public override void Reconnect(object @object)
 {
     if (@object == null)
     {
         throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.ReconnectCanReconnectNullObject
                                                    );
     }
     NeoDatis.Odb.Core.Transaction.ICrossSessionCache crossSessionCache = NeoDatis.Odb.Impl.Core.Transaction.CacheFactory
                                                                          .GetCrossSessionCache(GetBaseIdentification().GetIdentification());
     NeoDatis.Odb.OID oid = crossSessionCache.GetOid(@object);
     //in some situation the user can control the disconnect and reconnect
     //so before throws an exception test if in the current session
     //there is the object on the cache
     if (oid == null)
     {
         throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.CrossSessionCacheNullOidForObject
                                                    .AddParameter(@object));
     }
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ObjectInfoHeader oih = objectReader.ReadObjectInfoHeaderFromOid
                                                                     (oid, false);
     GetSession(true).AddObjectToCache(oid, @object, oih);
     // Retrieve Dependent Objects
     NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.GetDependentObjectIntrospectingCallback
         getObjectsCallback = new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.GetDependentObjectIntrospectingCallback
                                  ();
     NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = GetSession(true).GetMetaModel
                                                             ().GetClassInfoFromId(oih.GetClassInfoId());
     objectIntrospector.GetMetaRepresentation(@object, ci, true, null, getObjectsCallback
                                              );
     System.Collections.Generic.ICollection <object> dependentObjects = getObjectsCallback
                                                                        .GetObjects();
     System.Collections.Generic.IEnumerator <object> iterator = dependentObjects.GetEnumerator
                                                                    ();
     while (iterator.MoveNext())
     {
         object o = iterator.Current;
         if (o != null)
         {
             oid = crossSessionCache.GetOid(o);
             if (oid == null)
             {
                 throw new NeoDatis.Odb.ODBRuntimeException(NeoDatis.Odb.Core.NeoDatisError.CrossSessionCacheNullOidForObject
                                                            .AddParameter(o));
             }
             oih = objectReader.ReadObjectInfoHeaderFromOid(oid, false);
             GetSession(true).AddObjectToCache(oid, o, oih);
         }
     }
 }
예제 #3
0
 public override System.Collections.Generic.ICollection <string> GetFieldNames(IndexReader.FieldOption fieldNames)
 {
     EnsureOpen();
     System.Collections.Generic.Dictionary <string, string> fieldSet = new System.Collections.Generic.Dictionary <string, string>();
     for (int i = 0; i < readers.Count; i++)
     {
         IndexReader reader = readers[i];
         System.Collections.Generic.ICollection <string> names = reader.GetFieldNames(fieldNames);
         for (System.Collections.Generic.IEnumerator <string> iterator = names.GetEnumerator(); iterator.MoveNext();)
         {
             string s = iterator.Current;
             fieldSet[s] = s;
         }
     }
     return(fieldSet.Keys);
 }
        public virtual void TestPayloadsPos0()
        {
            Directory   dir    = new MockRAMDirectory();
            IndexWriter writer = new IndexWriter(dir, new TestPayloadAnalyzer(), true,
                                                 IndexWriter.MaxFieldLength.LIMITED);
            Document doc = new Document();

            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            System.IO.StreamWriter sw = new System.IO.StreamWriter(ms);
            sw.Write("a a b c d e a f g h i j a b k k");
            // flush to stream & reset it's position so it can be read
            sw.Flush();
            ms.Position = 0;
            doc.Add(new Field("content", new System.IO.StreamReader(ms)));
            writer.AddDocument(doc);

            IndexReader r = writer.GetReader();

            TermPositions tp    = r.TermPositions(new Term("content", "a"));
            int           count = 0;

            Assert.IsTrue(tp.Next());
            // "a" occurs 4 times
            Assert.AreEqual(4, tp.Freq);
            int expected = 0;

            Assert.AreEqual(expected, tp.NextPosition());
            Assert.AreEqual(1, tp.NextPosition());
            Assert.AreEqual(3, tp.NextPosition());
            Assert.AreEqual(6, tp.NextPosition());

            // only one doc has "a"
            Assert.IsFalse(tp.Next());

            IndexSearcher is_Renamed = new IndexSearcher(r);

            SpanTermQuery stq1 = new SpanTermQuery(new Term("content", "a"));
            SpanTermQuery stq2 = new SpanTermQuery(new Term("content", "k"));

            SpanQuery[]   sqs = new SpanQuery[] { stq1, stq2 };
            SpanNearQuery snq = new SpanNearQuery(sqs, 30, false);

            count = 0;
            bool sawZero = false;

            //System.out.println("\ngetPayloadSpans test");
            Lucene.Net.Search.Spans.Spans pspans = snq.GetSpans(is_Renamed.IndexReader);
            while (pspans.Next())
            {
                //System.out.println(pspans.doc() + " - " + pspans.start() + " - "+ pspans.end());
                System.Collections.Generic.ICollection <byte[]> payloads = pspans.GetPayload();
                sawZero |= pspans.Start() == 0;
                for (System.Collections.IEnumerator it = payloads.GetEnumerator(); it.MoveNext();)
                {
                    count++;
                    System.Object generatedAux2 = it.Current;
                    //System.out.println(new String((byte[]) it.next()));
                }
            }
            Assert.AreEqual(5, count);
            Assert.IsTrue(sawZero);

            //System.out.println("\ngetSpans test");
            Lucene.Net.Search.Spans.Spans spans = snq.GetSpans(is_Renamed.IndexReader);
            count   = 0;
            sawZero = false;
            while (spans.Next())
            {
                count++;
                sawZero |= spans.Start() == 0;
                //System.out.println(spans.doc() + " - " + spans.start() + " - " + spans.end());
            }
            Assert.AreEqual(4, count);
            Assert.IsTrue(sawZero);

            //System.out.println("\nPayloadSpanUtil test");

            sawZero = false;
            PayloadSpanUtil psu = new PayloadSpanUtil(is_Renamed.IndexReader);

            System.Collections.Generic.ICollection <byte[]> pls = psu.GetPayloadsForQuery(snq);
            count = pls.Count;
            for (System.Collections.IEnumerator it = pls.GetEnumerator(); it.MoveNext();)
            {
                System.String s = new System.String(System.Text.UTF8Encoding.UTF8.GetChars((byte[])it.Current));
                //System.out.println(s);
                sawZero |= s.Equals("pos: 0");
            }
            Assert.AreEqual(5, count);
            Assert.IsTrue(sawZero);
            writer.Close();
            is_Renamed.IndexReader.Close();
            dir.Close();
        }
예제 #5
0
    public static void SetListContent <P, D>(P prefab, Transform parent, List <P> itemList, System.Collections.Generic.ICollection <D> dataList, IsItemEnabledFunc <P, D> isItemEnabledFunc, SetDataContentFunc <P, D> setContentFunc,
                                             int start = 0,
                                             int count = 0)
        where P : MonoBehaviour
    {
        if (itemList == null)
        {
            return;
        }
        if (dataList == null)
        {
            foreach (var item in itemList)
            {
                item.gameObject.SetActive(false);
            }
        }
        else
        {
            if (count == 0 || (start + count) > dataList.Count)
            {
                count = dataList.Count - start;
            }
            while (itemList.Count < count)
            {
                itemList.Add(AddChild(parent, prefab));
            }

            var emu = dataList.GetEnumerator();

            for (int i = 0; i < start && emu.MoveNext(); ++i)
            {
            }

            for (int i = 0; i < itemList.Count; ++i)
            {
                if (emu.MoveNext())
                {
                    int index = start + i;
                    var item  = itemList[i];
                    var data  = emu.Current;
                    if (isItemEnabledFunc != null)
                    {
                        if (!isItemEnabledFunc(index, data))
                        {
                            item.gameObject.SetActive(false);
                            continue;
                        }
                    }
                    itemList[i].gameObject.SetActive(true);
                    if (setContentFunc != null)
                    {
                        setContentFunc(index, item, data);
                    }
                }
                else
                {
                    itemList[i].gameObject.SetActive(false);
                }
            }
        }
    }