• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java StringByteIterator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.yahoo.ycsb.StringByteIterator的典型用法代码示例。如果您正苦于以下问题:Java StringByteIterator类的具体用法?Java StringByteIterator怎么用?Java StringByteIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StringByteIterator类属于com.yahoo.ycsb包,在下文中一共展示了StringByteIterator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: readImpl

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
protected int readImpl(TxnHandle txn, String table, String key, Set<String> fields,
        HashMap<String, ByteIterator> result) throws WrongTypeException, NoSuchObjectException,
        VersionNotFoundException, NetworkException {
    @SuppressWarnings("unchecked")
    final LWWStringMapRegisterCRDT register = txn.get(new CRDTIdentifier(table, key), false,
            LWWStringMapRegisterCRDT.class, notificationsSubscriber);
    final HashMap<String, String> value = register.getValue();
    if (value == null) {
        return ERROR_NOT_FOUND;
    }
    if (fields == null) {
        StringByteIterator.putAllAsByteIterators(result, value);
    } else {
        for (final String field : fields) {
            result.put(field, new StringByteIterator(value.get(field)));
        }
    }
    return 0;
}
 
开发者ID:SyncFree,项目名称:SwiftCloud,代码行数:20,代码来源:SwiftRegisterPerKeyClient.java


示例2: updateImpl

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
protected int updateImpl(TxnHandle txn, String table, String key, HashMap<String, ByteIterator> values)
        throws WrongTypeException, NoSuchObjectException, VersionNotFoundException, NetworkException {
    @SuppressWarnings("unchecked")
    final LWWStringMapRegisterCRDT register = txn.get(new CRDTIdentifier(table, key), false,
            LWWStringMapRegisterCRDT.class, notificationsSubscriber);
    final HashMap<String, String> value = register.getValue();
    if (value == null) {
        return ERROR_NOT_FOUND;
    }
    final HashMap<String, String> mutableValue = new HashMap<String, String>(value);
    StringByteIterator.putAllAsStrings(mutableValue, values);
    register.set(mutableValue);

    return 0;
}
 
开发者ID:SyncFree,项目名称:SwiftCloud,代码行数:17,代码来源:SwiftRegisterPerKeyClient.java


示例3: readImpl

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
protected int readImpl(TxnHandle txn, String table, String key, Set<String> fields,
        HashMap<String, ByteIterator> result) throws WrongTypeException, NoSuchObjectException,
        VersionNotFoundException, NetworkException {
    @SuppressWarnings("unchecked")
    final PutOnlyLWWStringMapCRDT map = txn.get(new CRDTIdentifier(table, key), false,
            PutOnlyLWWStringMapCRDT.class, notificationsSubscriber);
    if (fields == null) {
        final HashMap<String, String> value = map.getValue();
        StringByteIterator.putAllAsByteIterators(result, value);
    } else {
        for (final String field : fields) {
            final String keyValue = map.get(field);
            if (keyValue == null) {
                return ERROR_NOT_FOUND;
            }
            result.put(field, new StringByteIterator(keyValue));
        }
    }
    return 0;
}
 
开发者ID:SyncFree,项目名称:SwiftCloud,代码行数:21,代码来源:SwiftMapPerKeyClient.java


示例4: readImpl

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
protected int readImpl(TxnHandle txn, String table, String key, Set<String> fields,
        HashMap<String, ByteIterator> result) throws WrongTypeException, NoSuchObjectException,
        VersionNotFoundException, NetworkException {
    final HashMap<CRDTIdentifier, String> ids = getFieldIds(txn, table, key, fields, false);

    // Just trigger parallel reads.
    txn.bulkGet(notificationsSubscriber != null, ids.keySet(), null);
    // Then do separate reads, to trigger notifications too.
    for (final Entry<CRDTIdentifier, String> entry : ids.entrySet()) {
        @SuppressWarnings("unchecked")
        final LWWStringRegisterCRDT register = txn.get(entry.getKey(), false, LWWStringRegisterCRDT.class,
                notificationsSubscriber);
        final String value = register.getValue();
        if (value == null) {
            return ERROR_NOT_FOUND;
        }
        result.put(entry.getValue(), new StringByteIterator(register.getValue()));
    }
    return 0;
}
 
开发者ID:SyncFree,项目名称:SwiftCloud,代码行数:21,代码来源:SwiftRegisterPerFieldClient.java


示例5: insert

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
@SuppressWarnings({ "rawtypes" })
public Status insert(final String table, final String key, final HashMap<String, ByteIterator> values) {
	HashMap fields;
	if (byteFormat) {
		fields = convertContent(values);
	} else {
		fields = StringByteIterator.getStringMap(values);
	}
	try {
		if (xRepo.getDocumentManagement().storeDocument(key, fields, insertProps) == null) {
			logger.debug("insert; document was not created for some reason; key: {}", key);
			return Status.UNEXPECTED_STATE;
		}
		return Status.OK;
	} catch (Exception ex) {
		logger.error("insert.error", ex);
		return Status.ERROR;
	}
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:21,代码来源:BagriDocClient.java


示例6: update

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
@SuppressWarnings({ "rawtypes" })
public Status update(final String table, final String key, final HashMap<String, ByteIterator> values) {
	HashMap fields;
	if (byteFormat) {
		fields = convertContent(values);
	} else {
		fields = StringByteIterator.getStringMap(values);
	}
	try {
		if (xRepo.getDocumentManagement().storeDocument(key, fields, updateProps) == null) {
			logger.debug("update; document was not updated for some reason; key: {}", key);
			return Status.UNEXPECTED_STATE;
		}
		return Status.OK;
	} catch (Exception ex) {
		logger.error("update.error", ex);
		return Status.ERROR;
	}
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:21,代码来源:BagriDocClient.java


示例7: insert

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Status insert(final String table, final String key, final HashMap<String, ByteIterator> values) {
	HashMap<String, Object> params = new HashMap<>();
	params.put("uri", URI.create(key));
	HashMap content = StringByteIterator.getStringMap(values);
	content.put("key", key);
	params.put("content", content);
	params.put("props", insertProps);
	try (ResultCursor cursor = xRepo.getQueryManagement().executeQuery(qStore, params, queryProps)) {
		if (cursor.isEmpty()) {
			logger.debug("insert; document was not created for some reason; key: {}", key);
			return Status.UNEXPECTED_STATE;
		} else {
			return Status.OK;
		}
	} catch (Exception ex) {
		logger.error("insert.error; key: {}", key, ex);
		return Status.ERROR;
	}
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:22,代码来源:BagriQueryClient.java


示例8: update

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public Status update(final String table, final String key, final HashMap<String, ByteIterator> values) {
	HashMap<String, Object> params = new HashMap<>();
	params.put("uri", URI.create(key));
	HashMap content = StringByteIterator.getStringMap(values);
	content.put("key", key);
	params.put("content", content);
	params.put("props", updateProps);
	try (ResultCursor cursor = xRepo.getQueryManagement().executeQuery(qStore, params, queryProps)) {
		if (cursor.isEmpty()) {
			logger.debug("update; document was not updated for some reason; key: {}", key);
			return Status.UNEXPECTED_STATE;
		} else {
			return Status.OK;
		}
	} catch (Exception ex) {
		logger.error("update.error; key: {}", key, ex);
		return Status.ERROR;
	}
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:22,代码来源:BagriQueryClient.java


示例9: populateStringResult

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
protected void populateStringResult(final Map<String, Object> document, final Set<String> fields, 
		final HashMap<String, ByteIterator> result) {
	// fill results
	if (fields == null) {
		for (Map.Entry<String, Object> entry: document.entrySet()) {
			result.put(entry.getKey(), new StringByteIterator(entry.getValue().toString()));
		}
	} else {
		for (String field: fields) {
			Object value = document.get(field);
			if (value != null) {
				result.put(field, new StringByteIterator(value.toString()));
			}
		}
	}
}
 
开发者ID:dsukhoroslov,项目名称:bagri,代码行数:17,代码来源:BagriClientBase.java


示例10: read

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
public int read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) {
    try {
       Map<String, String> row;
       if (clustered) {
          row = AtomicMapLookup.getAtomicMap(infinispanManager.getCache(table), key, false);
       } else {
          Cache<String, Map<String, String>> cache = infinispanManager.getCache(table);
          row = cache.get(key);
       }
       if (row != null) {
          result.clear();
          if (fields == null || fields.isEmpty()) {
StringByteIterator.putAllAsByteIterators(result, row);
          } else {
      for (String field : fields) result.put(field, new StringByteIterator(row.get(field)));
          }
       }
       return OK;
    } catch (Exception e) {
       return ERROR;
    }
 }
 
开发者ID:pbailis,项目名称:hat-vldb2014-code,代码行数:23,代码来源:InfinispanClient.java


示例11: scan

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
public int scan(String table, String startkey, int recordcount,
        Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
    try {
        //XXX what to pass in for nulls / zeros?
        RecordListResponse res = c.scan(table, ScanOrder.Ascending, bufStr(startkey), true, null, false, recordcount, 0);
        int ret = ycsbThriftRet(res.responseCode, ResponseCode.Success, ResponseCode.ScanEnded);
        if(ret == 0) {
            for(Record r : res.records) {
                HashMap<String, ByteIterator> tuple = new HashMap<String, ByteIterator>();
                // Note: r.getKey() and r.getValue() call special helper methods that trim the buffer
                // to an appropriate length, and memcpy it to a byte[].  Trying to manipulate the ByteBuffer
                // directly leads to trouble.
                tuple.put("key", new StringByteIterator(new String(r.getKey())));
                decode(fields, new String(r.getValue())/*strBuf(r.bufferForValue())*/, tuple);
                result.add(tuple);
            }
        }
        return ret;
    } catch(TException e) {
        e.printStackTrace();
        return 2;
    }
}
 
开发者ID:pbailis,项目名称:hat-vldb2014-code,代码行数:25,代码来源:MapKeeperClient.java


示例12: read

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
public int read(String table, String key, Set<String> fields,
		HashMap<String, ByteIterator> result) {
	if ( checkStore(table) == ERROR ) {
		return ERROR;
	}
	
	Versioned<HashMap<String, String>> versionedValue = storeClient.get(key);
	
	if ( versionedValue == null )
		return NOT_FOUND;
	
	if ( fields != null ) {
		for (String field : fields) {
			String val = versionedValue.getValue().get(field);
			if ( val != null )
			    result.put(field, new StringByteIterator(val));
		}
	} else {
		StringByteIterator.putAllAsByteIterators(result, versionedValue.getValue());
	}
	return OK;
}
 
开发者ID:pbailis,项目名称:hat-vldb2014-code,代码行数:24,代码来源:VoldemortClient.java


示例13: read

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
public Status read(String table, String key, Set<String> fields, HashMap<String, ByteIterator> result) {
	HashMap<String, String> r = dmap.get(key);
	if(r == null){
		return Status.NOT_FOUND;
	}else{
		if(fields != null){
			for(Entry<String, ByteIterator> e : StringByteIterator.getByteIteratorMap(r).entrySet()){
				if(fields.contains(e.getKey())){
					result.put(e.getKey(),e.getValue());
				}
			}
		}else{
			result.putAll(StringByteIterator.getByteIteratorMap(r));
		}
		return Status.OK;
	}
}
 
开发者ID:sambenz,项目名称:URingPaxos,代码行数:19,代码来源:YCSB.java


示例14: scan

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
public Status scan(String table, String startkey, int recordcount,	Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
   	Command cmd = new Command(cmd_id.incrementAndGet(),CommandType.GETRANGE,startkey,("").getBytes(),recordcount);
	try {
		Response r = client.send(cmd);
		if(r != null){
			List<Command> lc = r.getResponse(10000);
			if(lc.isEmpty()){ return Status.ERROR; }
   			for(Command c : lc){
    			if(c.getType() == CommandType.RESPONSE){
    				HashMap<String, ByteIterator> tuple = new HashMap<String, ByteIterator>();
    				tuple.put("key", new StringByteIterator(c.getKey()));
    				if(c.getValue() != null && c.getValue().length > 0){
    					decode(fields, new String(c.getValue()), tuple);
    					result.add(tuple);
    				}
    			}			    				
   			}
			return Status.OK;
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
	return Status.ERROR;
}
 
开发者ID:sambenz,项目名称:URingPaxos,代码行数:26,代码来源:YCSB.java


示例15: insert

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
/**
 * Insert a record in the database. Any field/value pairs in the specified values HashMap will be written into the record with the specified
 * record key.
 *
 * @param table The name of the table
 * @param key The record key of the record to insert.
 * @param values A HashMap of field/value pairs to insert in the record
 * @return Zero on success, a non-zero error code on error. See this class's description for a discussion of error codes.
 */
public int insert(String table, String key, HashMap<String, ByteIterator> values) {
  try {
    final ODocument document = new ODocument(CLASS);
    for (Entry<String, String> entry : StringByteIterator.getStringMap(values).entrySet())
      document.field(entry.getKey(), entry.getValue());
    document.save();
    dictionary.put(key, document);

    return 0;
  } catch (Exception e) {
    e.printStackTrace();
  }
  return 1;
}
 
开发者ID:pbailis,项目名称:bolton-sigmod2013-code,代码行数:25,代码来源:OrientDBClient.java


示例16: update

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
/**
 * Update a record in the database. Any field/value pairs in the specified values HashMap will be written into the record with the specified
 * record key, overwriting any existing values with the same field name.
 *
 * @param table The name of the table
 * @param key The record key of the record to write.
 * @param values A HashMap of field/value pairs to update in the record
 * @return Zero on success, a non-zero error code on error. See this class's description for a discussion of error codes.
 */
public int update(String table, String key, HashMap<String, ByteIterator> values) {
  try {
    final ODocument document = dictionary.get(key);
    if (document != null) {
      for (Entry<String, String> entry : StringByteIterator.getStringMap(values).entrySet())
        document.field(entry.getKey(), entry.getValue());
      document.save();
      return 0;
    }
  } catch (Exception e) {
    e.printStackTrace();
  }
  return 1;
}
 
开发者ID:pbailis,项目名称:bolton-sigmod2013-code,代码行数:25,代码来源:OrientDBClient.java


示例17: insert

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
/**
 * Insert a record in the database. Any field/value pairs in the specified
 * values HashMap will be written into the record with the specified record
 * key.
 *
 * @param table The name of the table
 * @param key The record key of the record to insert.
 * @param values A HashMap of field/value pairs to insert in the record
 * @return Zero on success, a non-zero error code on error. See this class's
 * description for a discussion of error codes.
 */
@Override
public int insert(String table, String key, HashMap<String, ByteIterator> values) {
    try {
        final XContentBuilder doc = jsonBuilder().startObject();

        for (Entry<String, String> entry : StringByteIterator.getStringMap(values).entrySet()) {
            doc.field(entry.getKey(), entry.getValue());
        }

        doc.endObject();

        client.prepareIndex(indexKey, table, key)
                .setSource(doc)
                .execute()
                .actionGet();

        return 0;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return 1;
}
 
开发者ID:pbailis,项目名称:bolton-sigmod2013-code,代码行数:34,代码来源:ElasticSearchClient.java


示例18: update

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
/**
 * Update a record in the database. Any field/value pairs in the specified
 * values HashMap will be written into the record with the specified record
 * key, overwriting any existing values with the same field name.
 *
 * @param table The name of the table
 * @param key The record key of the record to write.
 * @param values A HashMap of field/value pairs to update in the record
 * @return Zero on success, a non-zero error code on error. See this class's
 * description for a discussion of error codes.
 */
@Override
public int update(String table, String key, HashMap<String, ByteIterator> values) {
    try {
        final GetResponse response = client.prepareGet(indexKey, table, key)
                .execute()
                .actionGet();

        if (response.isExists()) {
            for (Entry<String, String> entry : StringByteIterator.getStringMap(values).entrySet()) {
                response.getSource().put(entry.getKey(), entry.getValue());
            }

            client.prepareIndex(indexKey, table, key)
                    .setSource(response.getSource())
                    .execute()
                    .actionGet();

            return 0;
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    return 1;
}
 
开发者ID:pbailis,项目名称:bolton-sigmod2013-code,代码行数:37,代码来源:ElasticSearchClient.java


示例19: testUpdate

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
/**
 * Test of update method, of class ElasticSearchClient.
 */
@Test
public void testUpdate() {
    System.out.println("update");
    int i;
    HashMap<String, ByteIterator> newValues = new HashMap<String, ByteIterator>(10);

    for (i = 1; i <= 10; i++) {
        newValues.put("field" + i, new StringByteIterator("newvalue" + i));
    }

    int expResult = 0;
    int result = instance.update(MOCK_TABLE, MOCK_KEY1, newValues);
    assertEquals(expResult, result);

    //validate that the values changed
    HashMap<String, ByteIterator> resultParam = new HashMap<String, ByteIterator>(10);
    instance.read(MOCK_TABLE, MOCK_KEY1, MOCK_DATA.keySet(), resultParam);

    for (i = 1; i <= 10; i++) {
        assertEquals("newvalue" + i, resultParam.get("field" + i).toString());
    }

}
 
开发者ID:pbailis,项目名称:bolton-sigmod2013-code,代码行数:27,代码来源:ElasticSearchClientTest.java


示例20: insertImpl

import com.yahoo.ycsb.StringByteIterator; //导入依赖的package包/类
@Override
protected int insertImpl(TxnHandle txn, String table, String key, HashMap<String, ByteIterator> values)
        throws WrongTypeException, NoSuchObjectException, VersionNotFoundException, NetworkException {
    @SuppressWarnings("unchecked")
    final LWWStringMapRegisterCRDT register = txn.get(new CRDTIdentifier(table, key), true,
            LWWStringMapRegisterCRDT.class, notificationsSubscriber);
    final HashMap<String, String> value = StringByteIterator.getStringMap(values);
    register.set(value);

    return 0;
}
 
开发者ID:SyncFree,项目名称:SwiftCloud,代码行数:12,代码来源:SwiftRegisterPerKeyClient.java



注:本文中的com.yahoo.ycsb.StringByteIterator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JavaPluginLoader类代码示例发布时间:2022-05-22
下一篇:
Java JimpleLocal类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap