當前位置: 首頁>>代碼示例>>Java>>正文


Java HGRandomAccessResult類代碼示例

本文整理匯總了Java中org.hypergraphdb.HGRandomAccessResult的典型用法代碼示例。如果您正苦於以下問題:Java HGRandomAccessResult類的具體用法?Java HGRandomAccessResult怎麽用?Java HGRandomAccessResult使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


HGRandomAccessResult類屬於org.hypergraphdb包,在下文中一共展示了HGRandomAccessResult類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkBeforeFirstAfterLastNotEmptyRS

import org.hypergraphdb.HGRandomAccessResult; //導入依賴的package包/類
private void checkBeforeFirstAfterLastNotEmptyRS(
        HGRandomAccessResult<HGHandle> res)
{
    // check goTo() for all the elements in the result set
    List<HGHandle> handles = new ArrayList<HGHandle>();
    while (res.hasNext())
        handles.add(res.next());
    int i = 0;
    for (HGHandle h : handles)
    {
        // Assert.assertEquals(GotoResult.found, res.goTo(h, false));
        if (res.goTo(h, !false) != GotoResult.found)
            System.out
                    .println("Problem in: " + i + " of " + handles.size());
        i++;
    }
    res.goAfterLast();
    Assert.assertFalse(res.hasNext());
    Assert.assertNotNull(res.prev());
    res.goBeforeFirst();
    Assert.assertFalse(res.hasPrev());
    Assert.assertNotNull(res.next());
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:24,代碼來源:ResultSets.java

示例2: execute

import org.hypergraphdb.HGRandomAccessResult; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public HGSearchResult<T> execute() 
{
	HGRandomAccessResult<T> baseResult = (HGRandomAccessResult<T>)query.execute();
	try
	{
		while (baseResult.hasNext())
		{
			T next = baseResult.next();
			if (predicate.eval(next))
				return new FilteredRAResultSet<T>(baseResult, predicate, 1);
		}
	}
	catch (Throwable t)
	{
		HGUtils.closeNoException(baseResult);
		HGUtils.wrapAndRethrow(t);			
	}
	baseResult.close();		
	return (HGSearchResult<T>)HGSearchResult.EMPTY;
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:22,代碼來源:PredicateBasedRAFilter.java

示例3: goTo

import org.hypergraphdb.HGRandomAccessResult; //導入依賴的package包/類
public HGRandomAccessResult.GotoResult goTo(T value, boolean exactMatch)
    {
        GotoResult r = rs.goTo(value, exactMatch);
        if (exactMatch)
            return r == GotoResult.found && predicate.eval(value) ? GotoResult.found : GotoResult.nothing;

        if (predicate.eval(value)) { //would happen on result of found
//    			System.out.println("FRARS matched the value, We have a match for:" + value);
          return r;
				}

        if (hasNext()) {  //Replaced AP
//    			System.out.println("FRARS goto checked for next, got it, so moving to next and returning close");
        	next();
        	return GotoResult.close;
        }
        
        //would cause infinite loops
//        while (rs.hasNext())
//          if (predicate.eval(rs.next()))
//              return GotoResult.close;        
//        
        return GotoResult.nothing;
    }
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:25,代碼來源:FilteredRAResultSet.java

示例4: isEmpty

import org.hypergraphdb.HGRandomAccessResult; //導入依賴的package包/類
public boolean isEmpty()
{
    //2012.02.09 hilpold old: return size() == 0;
	// we can conclude false more efficient by looking for a first.
    HGRandomAccessResult<E> rs = delegate.getSearchResult();
    try
    {
        while (rs.hasNext())
            if (predicate.eval(rs.next()))
                return false;
    }
    finally
    {
        rs.close();
    }
    return true;
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:18,代碼來源:FilteredSortedSet.java

示例5: last

import org.hypergraphdb.HGRandomAccessResult; //導入依賴的package包/類
public E last()
{
    HGRandomAccessResult<E> rs = delegate.getSearchResult();
    rs.goAfterLast();
    try
    {
        while (rs.hasPrev())
            if (predicate.eval(rs.prev()))
                return rs.current();
    }
    finally
    {
        rs.close();
    }
    throw new NoSuchElementException();
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:17,代碼來源:FilteredSortedSet.java

示例6: toArray

import org.hypergraphdb.HGRandomAccessResult; //導入依賴的package包/類
public Object[] toArray()
{
    ArrayList<Object> L = new ArrayList<Object>();
    HGRandomAccessResult<E> rs = delegate.getSearchResult();
    try
    {
        while (rs.hasNext())
            if (predicate.eval(rs.next()))
                L.add(rs.current());
    }
    finally
    {
        rs.close();
    }
    return L.toArray();
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:17,代碼來源:FilteredSortedSet.java

示例7: containsAll

import org.hypergraphdb.HGRandomAccessResult; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public boolean containsAll(Collection<?> c)
{
    HGRandomAccessResult<HGHandle> rs = getSearchResult();
    try 
    { 
        for (HGHandle x : (Collection<HGHandle>)c)            
            if (rs.goTo(x, true) != HGRandomAccessResult.GotoResult.found)
                return false;
        return true;
    }
    finally
    {
        rs.close();
    }        
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:17,代碼來源:StorageBasedIncidenceSet.java

示例8: toArray

import org.hypergraphdb.HGRandomAccessResult; //導入依賴的package包/類
public Object[] toArray()
{
    HGRandomAccessResult<HGHandle> rs = getSearchResult();
    try
    {
        int size = size();
        Object [] a = new Object[size];
        for (int i = 0; i < size; i++)
            a[i] = rs.next();
        return a;
    }
    finally
    {
        rs.close();
    }
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:17,代碼來源:StorageBasedIncidenceSet.java

示例9: toArray

import org.hypergraphdb.HGRandomAccessResult; //導入依賴的package包/類
public Object[] toArray()
{
	HGRandomAccessResult<T> rs = getSearchResult();
	try
	{
		int size = size();
        Object [] a = new Object[size];
        for (int i = 0; i < size; i++)
        	a[i] = rs.next();
        return a;
	}
	finally
	{
		rs.close();
	}
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:17,代碼來源:DBKeyedSortedSet.java

示例10: testNumberOrder

import org.hypergraphdb.HGRandomAccessResult; //導入依賴的package包/類
@Test
public void testNumberOrder()
{
    HGHandle typeHandle = graph.getTypeSystem().getTypeHandle(SimpleBean.class);
    ByPartIndexer<Long> byPartIndexer = new ByPartIndexer<Long>("id_indexer", typeHandle, "longProp");
    graph.getIndexManager().register(byPartIndexer);

    for (long i = 1l; i < 2000l; i++)
    {
        graph.add(new Id(i));
    }
    
    HGIndex index = graph.getIndexManager().getIndex(byPartIndexer);
    HGRandomAccessResult result = index.scanValues();
    result.goBeforeFirst();
    try
    {
        ArrayList<Long> numbers = new ArrayList<Long>();
        while (result.hasNext())
        {
            SimpleBean b = graph.get((HGHandle) result.next());
            numbers.add(b.getLongProp());
        }
        for (int i = 0; i < numbers.size() - 1; i++)
            Assert.assertTrue(numbers.get(i) < numbers.get(i+1));
    }
    finally
    {
        result.close();
    }
    
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:33,代碼來源:PropertyIndexingTests.java

示例11: zigzag_or_in_memory_test

import org.hypergraphdb.HGRandomAccessResult; //導入依賴的package包/類
private void zigzag_or_in_memory_test(boolean zigzag_or_in_memory)
    {
        if(!fix_random_acces_result_sets) return;
        HGRandomAccessResult<HGHandle> res = null;
        RSCombiner<HGHandle> combiner = (zigzag_or_in_memory) ? new ZigZagIntersectionResult.Combiner<HGHandle>()
                : new InMemoryIntersectionResult.Combiner<HGHandle>();
        try
        {
            HGSearchResult<HGHandle> left = index.findGTE(9);
            HGSearchResult<HGHandle> right = index.findGTE(8);
            res = (HGRandomAccessResult<HGHandle>)combiner.combine(left, right);
//             List<Integer> left_list = result__list(graph, left);
//             List<Integer> right_list = result__list(graph, right);
            // left.goBeforeFirst(); right.goBeforeFirst();

            List<Integer> list = result__list(graph, res);
            Assert.assertEquals(list.size(), 2);
            if (list.size() != 1)
            {
                res.goBeforeFirst();
                while (left.hasNext())
                    System.out.println("L:" + left.next());
                while (right.hasNext())
                    System.out.println("R:" + right.next());
            }
            // List<Integer> back_list = back_result__list(graph, res);
            // Assert.assertTrue(reverseLists(list, back_list));
            checkBeforeFirstAfterLastNotEmptyRS(res);
        }
        finally
        {
            res.close();
        }
    }
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:35,代碼來源:ResultSets.java

示例12: testSingleValueResultSet

import org.hypergraphdb.HGRandomAccessResult; //導入依賴的package包/類
@Test
    public void testSingleValueResultSet()
    {
        HGBidirectionalIndex<String, HGPersistentHandle> idx = graph.getStore()
                .getBidirectionalIndex(
                /* HGTypeSystem.TYPE_ALIASES_DB_NAME, */
                "hg_typesystem_type_alias", BAtoString.getInstance(),
                        BAtoHandle.getInstance(graph.getHandleFactory()), null, null, false);
        HGRandomAccessResult<String> res = idx.findByValue(graph
                .getPersistentHandle(graph.getTypeSystem().getTypeHandle(
                        TestInt.class)));
        try
        {
//            Assert.assertTrue(expectedType(res, "SingleValueResultSet"));
            List<String> list = new ArrayList<String>();
            while (res.hasNext())
                list.add(res.next());
            Assert.assertEquals(list.size(), ALIAS_COUNT);
            List<String> back_list = new ArrayList<String>();
            back_list.add(res.current());
            while (res.hasPrev())
                back_list.add(res.prev());
            // print(list); print(back_list);
            Assert.assertTrue(reverseLists(list, back_list));
            // checkBeforeFirstAfterLastNotEmptyRS((HGRandomAccessResult) res);
        }
        finally
        {
            res.close();
        }
    }
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:32,代碼來源:ResultSets.java

示例13: shouldIgnore

import org.hypergraphdb.HGRandomAccessResult; //導入依賴的package包/類
boolean shouldIgnore(HGPersistentHandle handle, HGPersistentHandle [] result)
{
    if (wrapped.getRoots().contains(handle) || result == null || result.length <= 1)
        return false;
    HGRandomAccessResult<HGPersistentHandle> rs = indexByValue.find(result[1]);
    try
    {
        return rs.goTo(handle, true) == HGRandomAccessResult.GotoResult.found;
    }
    finally
    {
        rs.close();
    }
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:15,代碼來源:SubgraphManager.java

示例14: keys

import org.hypergraphdb.HGRandomAccessResult; //導入依賴的package包/類
public Count keys(long cost, boolean isEstimateOk)
{
	index.checkOpen();
	if (cost < Long.MAX_VALUE && !isEstimateOk)
		return null;
	else if (cost == Long.MAX_VALUE)
		return new Count(new Ref<Long>() 
		{
			public Long get()
			{
				final long [] value = new long[1];
				try (HGRandomAccessResult<Key> keys = index.scanKeys())
				{
					while (keys.hasNext()) { value[0]++; keys.next(); }
				}
				return value[0];
			}
		}, false);					
	else // isEstimateOk
	{
		return new Count(new Ref<Long>() {
			public Long get()
			{
				MDB_stat stat = index.db.stat();					
				return stat.ms_entries;
			}
		}, true);
	}
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:30,代碼來源:LMDBIndexStats.java

示例15: values

import org.hypergraphdb.HGRandomAccessResult; //導入依賴的package包/類
public Count values(long cost, boolean isEstimateOk)
{
	index.checkOpen();
	if (cost < Long.MAX_VALUE && !isEstimateOk)
		return null;
	else if (cost == Long.MAX_VALUE)
		return new Count(new Ref<Long>() {
			public Long get()
			{
				final long [] cnt = new long[1];
				try (HGRandomAccessResult<Value> values = index.scanValues())
				{
					while (values.hasNext()) { cnt[0]++; values.next(); }
				}
				return cnt[0];	
			}
		}, false);
	else // isEstimateOk
	{
		return new Count(new Ref<Long>() {
			public Long get()
			{
				MDB_stat stat = index.db.stat();					
				return stat.ms_entries;	
			}
		}, true);			
	}		
}
 
開發者ID:hypergraphdb,項目名稱:hypergraphdb,代碼行數:29,代碼來源:LMDBIndexStats.java


注:本文中的org.hypergraphdb.HGRandomAccessResult類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。